unipressed


Nameunipressed JSON
Version 1.4.0 PyPI version JSON
download
home_pagehttps://multimeric.github.io/Unipressed
SummaryComprehensive Python client for the Uniprot REST API
upload_time2024-08-16 12:05:21
maintainerNone
docs_urlNone
authorMichael Milton
requires_python<4.0,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Unipressed

**Please visit the [project website](https://multimeric.github.io/Unipressed/) for more comprehensive documentation.**

## Introduction

Unipressed (Uniprot REST) is an API client for the protein database [Uniprot](https://www.uniprot.org/).
It provides thoroughly typed and documented code to ensure your use of the library is easy, fast, and correct!

### Example
Let's say we're interested in very long proteins that are encoded within a chloroplast, in any organism:

```python
from unipressed import UniprotkbClient

for record in UniprotkbClient.search(
    query={
        "and_": [
            {"organelle": "chloroplast"},
            {"length": (5000, "*")}
        ]
    },
    fields=["length", "gene_names"]
).each_record():
    display(record)
```


<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
<span style="font-weight: bold">{</span>
    <span style="color: #008000; text-decoration-color: #008000">'primaryAccession'</span>: <span style="color: #008000; text-decoration-color: #008000">'A0A088CK67'</span>,
    <span style="color: #008000; text-decoration-color: #008000">'genes'</span>: <span style="font-weight: bold">[</span>
        <span style="font-weight: bold">{</span>
            <span style="color: #008000; text-decoration-color: #008000">'geneName'</span>: <span style="font-weight: bold">{</span>
                <span style="color: #008000; text-decoration-color: #008000">'evidences'</span>: <span style="font-weight: bold">[{</span><span style="color: #008000; text-decoration-color: #008000">'evidenceCode'</span>: <span style="color: #008000; text-decoration-color: #008000">'ECO:0000313'</span>, <span style="color: #008000; text-decoration-color: #008000">'source'</span>: <span style="color: #008000; text-decoration-color: #008000">'EMBL'</span>, <span style="color: #008000; text-decoration-color: #008000">'id'</span>: <span style="color: #008000; text-decoration-color: #008000">'AID67672.1'</span><span style="font-weight: bold">}]</span>,
                <span style="color: #008000; text-decoration-color: #008000">'value'</span>: <span style="color: #008000; text-decoration-color: #008000">'ftsH'</span>
            <span style="font-weight: bold">}</span>
        <span style="font-weight: bold">}</span>
    <span style="font-weight: bold">]</span>,
    <span style="color: #008000; text-decoration-color: #008000">'sequence'</span>: <span style="font-weight: bold">{</span><span style="color: #008000; text-decoration-color: #008000">'length'</span>: <span style="color: #008080; text-decoration-color: #008080; font-weight: bold">5242</span><span style="font-weight: bold">}</span>
<span style="font-weight: bold">}</span>
</pre>



### Advantages

* Detailed type hints for autocompleting queries as you type
* Autocompletion for return fields
* Documentation for each field
* Automatic results parsing, for `json`, `tsv`, `list`, and `xml`
* Built-in pagination, so you don't have to handle any of that yourself!
* Most of the API is automatically generated, ensuring very rapid updates whenever the API changes
* Thoroughly tested, with 41 unit tests and counting!

## Usage

### Installation

If you're using poetry:
```bash
poetry add unipressed
```

Otherwise:
```bash
pip install unipressed
```

### Dataset Clients

The `unipressed` module exports a client object for each UniProt dataset:

```python
from unipressed import UniprotkbClient, UniparcClient
```

With one of these clients, you can search the dataset:

```python
records = UniprotkbClient.search({
    "length": (5000, 6000)
}).each_record()

# Show the first record
next(records)
```


<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
<span style="font-weight: bold">{</span>
    <span style="color: #008000; text-decoration-color: #008000">'entryType'</span>: <span style="color: #008000; text-decoration-color: #008000">'UniProtKB reviewed (Swiss-Prot)'</span>,
    <span style="color: #008000; text-decoration-color: #008000">'primaryAccession'</span>: <span style="color: #008000; text-decoration-color: #008000">'Q96RW7'</span>,
    <span style="color: #008000; text-decoration-color: #008000">'secondaryAccessions'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'uniProtkbId'</span>: <span style="color: #008000; text-decoration-color: #008000">'HMCN1_HUMAN'</span>,
    <span style="color: #008000; text-decoration-color: #008000">'entryAudit'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'annotationScore'</span>: <span style="color: #008080; text-decoration-color: #008080; font-weight: bold">5.0</span>,
    <span style="color: #008000; text-decoration-color: #008000">'organism'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'proteinExistence'</span>: <span style="color: #008000; text-decoration-color: #008000">'1: Evidence at protein level'</span>,
    <span style="color: #008000; text-decoration-color: #008000">'proteinDescription'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'genes'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'comments'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'features'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'keywords'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'references'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'uniProtKBCrossReferences'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'sequence'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'extraAttributes'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>
<span style="font-weight: bold">}</span>
</pre>



You can request a single record by ID:

```python
UniprotkbClient.fetch_one("Q96RW7")
```


<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
<span style="font-weight: bold">{</span>
    <span style="color: #008000; text-decoration-color: #008000">'entryType'</span>: <span style="color: #008000; text-decoration-color: #008000">'UniProtKB reviewed (Swiss-Prot)'</span>,
    <span style="color: #008000; text-decoration-color: #008000">'primaryAccession'</span>: <span style="color: #008000; text-decoration-color: #008000">'Q96RW7'</span>,
    <span style="color: #008000; text-decoration-color: #008000">'secondaryAccessions'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'uniProtkbId'</span>: <span style="color: #008000; text-decoration-color: #008000">'HMCN1_HUMAN'</span>,
    <span style="color: #008000; text-decoration-color: #008000">'entryAudit'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'annotationScore'</span>: <span style="color: #008080; text-decoration-color: #008080; font-weight: bold">5.0</span>,
    <span style="color: #008000; text-decoration-color: #008000">'organism'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'proteinExistence'</span>: <span style="color: #008000; text-decoration-color: #008000">'1: Evidence at protein level'</span>,
    <span style="color: #008000; text-decoration-color: #008000">'proteinDescription'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'genes'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'comments'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'features'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'keywords'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'references'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'uniProtKBCrossReferences'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'sequence'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
    <span style="color: #008000; text-decoration-color: #008000">'extraAttributes'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>
<span style="font-weight: bold">}</span>
</pre>



You can also request multiple records:

```python
UniprotkbClient.fetch_many(["A0A0C5B5G6", "A0A1B0GTW7"])
```


<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
<span style="font-weight: bold">[</span>
    <span style="font-weight: bold">{</span>
        <span style="color: #008000; text-decoration-color: #008000">'entryType'</span>: <span style="color: #008000; text-decoration-color: #008000">'UniProtKB reviewed (Swiss-Prot)'</span>,
        <span style="color: #008000; text-decoration-color: #008000">'primaryAccession'</span>: <span style="color: #008000; text-decoration-color: #008000">'A0A0C5B5G6'</span>,
        <span style="color: #008000; text-decoration-color: #008000">'uniProtkbId'</span>: <span style="color: #008000; text-decoration-color: #008000">'MOTSC_HUMAN'</span>,
        <span style="color: #008000; text-decoration-color: #008000">'entryAudit'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'annotationScore'</span>: <span style="color: #008080; text-decoration-color: #008080; font-weight: bold">5.0</span>,
        <span style="color: #008000; text-decoration-color: #008000">'organism'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'proteinExistence'</span>: <span style="color: #008000; text-decoration-color: #008000">'1: Evidence at protein level'</span>,
        <span style="color: #008000; text-decoration-color: #008000">'proteinDescription'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'genes'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'comments'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'features'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'geneLocations'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'keywords'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'references'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'uniProtKBCrossReferences'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'sequence'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'extraAttributes'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>
    <span style="font-weight: bold">}</span>,
    <span style="font-weight: bold">{</span>
        <span style="color: #008000; text-decoration-color: #008000">'entryType'</span>: <span style="color: #008000; text-decoration-color: #008000">'UniProtKB reviewed (Swiss-Prot)'</span>,
        <span style="color: #008000; text-decoration-color: #008000">'primaryAccession'</span>: <span style="color: #008000; text-decoration-color: #008000">'A0A1B0GTW7'</span>,
        <span style="color: #008000; text-decoration-color: #008000">'secondaryAccessions'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'uniProtkbId'</span>: <span style="color: #008000; text-decoration-color: #008000">'CIROP_HUMAN'</span>,
        <span style="color: #008000; text-decoration-color: #008000">'entryAudit'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'annotationScore'</span>: <span style="color: #008080; text-decoration-color: #008080; font-weight: bold">5.0</span>,
        <span style="color: #008000; text-decoration-color: #008000">'organism'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'proteinExistence'</span>: <span style="color: #008000; text-decoration-color: #008000">'1: Evidence at protein level'</span>,
        <span style="color: #008000; text-decoration-color: #008000">'proteinDescription'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'genes'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'comments'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'features'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'keywords'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'references'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'uniProtKBCrossReferences'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'sequence'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>,
        <span style="color: #008000; text-decoration-color: #008000">'extraAttributes'</span>: <span style="color: #808000; text-decoration-color: #808000">...</span>
    <span style="font-weight: bold">}</span>
<span style="font-weight: bold">]</span>
</pre>



### ID Mapping

Unipressed also provides one other unique client, which is designed for mapping identifiers. You provide the source and destination database (both of which will autocomplete in VS Code), and a list of identifiers for the source database.

```python
from unipressed import IdMappingClient
request = IdMappingClient.submit(
    source="UniProtKB_AC-ID", dest="Gene_Name", ids={"A1L190", "A0JP26", "A0PK11"}
)
list(request.each_result())
```


<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">
<span style="font-weight: bold">[</span>
    <span style="font-weight: bold">{</span><span style="color: #008000; text-decoration-color: #008000">'from'</span>: <span style="color: #008000; text-decoration-color: #008000">'A1L190'</span>, <span style="color: #008000; text-decoration-color: #008000">'to'</span>: <span style="color: #008000; text-decoration-color: #008000">'SYCE3'</span><span style="font-weight: bold">}</span>,
    <span style="font-weight: bold">{</span><span style="color: #008000; text-decoration-color: #008000">'from'</span>: <span style="color: #008000; text-decoration-color: #008000">'A0PK11'</span>, <span style="color: #008000; text-decoration-color: #008000">'to'</span>: <span style="color: #008000; text-decoration-color: #008000">'CLRN2'</span><span style="font-weight: bold">}</span>,
    <span style="font-weight: bold">{</span><span style="color: #008000; text-decoration-color: #008000">'from'</span>: <span style="color: #008000; text-decoration-color: #008000">'A0JP26'</span>, <span style="color: #008000; text-decoration-color: #008000">'to'</span>: <span style="color: #008000; text-decoration-color: #008000">'POTEB3'</span><span style="font-weight: bold">}</span>
<span style="font-weight: bold">]</span>
</pre>



Note that, if you submit a large number of IDs, you might need to add a `sleep()` call between submitting the request and retrieving the results.

### Query Syntax

The query syntax refers to the values you pass in to the `query` argument of the `search()` method.

In general, you can't go wrong by following the type hints.
I strongly recommend using something like [`pylance`](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) for [Visual Studio Code](https://code.visualstudio.com/), which will provide automatic completions and warn you when you have used the wrong syntax.

If you already know how to use the Uniprot query language, you can always just input your queries as strings:

```python
UniprotkbClient.search(query="(gene:BRCA*) AND (organism_id:10090)")
```

However, if you want some built-in query validation and code completion using Python's type system, then you can instead use a dictionary.
The simplest query is a dictionary with a single key: 

```python
UniprotkbClient.search(query={"family": "kinase"})
```

You can compile more complex queries using the `and_`, `or_` and `not_` keys.
These first two operators take a list of query dictionaries: 

```python
UniprotkbClient.search(query={
    "and_": [
        {"family": "kinase"},
        {"organism_id": "9606"},
    ]
})
```

Most "leaf" nodes of the query tree (ie those that aren't operators like `and_`) are strings, integers or floats, which you input as normal Python literals as you can see above.
For string fields, you also have access to wildcards, namely the `*` character. 
For example, if you want every human protein belonging to a gene whose name starts with `PRO`, you could use:

```python
UniprotkbClient.search(query={
    "and_": [
        {"gene": "PRO*"},
        {"organism_id": "9606"},
    ]
})
```

A few query fields are *ranges*, which you input using a tuple with two elements, indicating the start and end of the range.
If you use the literal `"*"` then you can leave the range open at one end. 
For example, this query returns any protein that is in the range $[5000, \infty)$

```python
UniprotkbClient.search(query={"length": (5000, "*")})
```

Finally, a few query fields take dates.
These you input as a Python `datetime.date` object.
For example, to find proteins added to UniProt since July 2022, we would do:

```python
from datetime import date

UniprotkbClient.search(query={"date_created": (date(2022, 7, 1), "*")})
```

### Use with Visual Studio Code
To get VS Code to offer suggestions, press the `Trigger Suggest` shortcut which is usually bound to `Ctrl + Space`.
In particular, code completion generally won't work *until* you open a string literal using a quotation mark.

Secondly, to get live access to the documentation, you can either use the `Show Hover` shortcut, which is usually bound to `Ctrl + K, Ctrl + I`, or you can install the [`docs-view`](https://marketplace.visualstudio.com/items?itemName=bierner.docs-view) extension, which lets you view the docstrings in the sidebar without interfering with your code.


            

Raw data

            {
    "_id": null,
    "home_page": "https://multimeric.github.io/Unipressed",
    "name": "unipressed",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Michael Milton",
    "author_email": "michael.r.milton@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/57/f3/1bff788016e59c20228e0afd5336766723a2ad07dcc2de63de2fce8943af/unipressed-1.4.0.tar.gz",
    "platform": null,
    "description": "# Unipressed\n\n**Please visit the [project website](https://multimeric.github.io/Unipressed/) for more comprehensive documentation.**\n\n## Introduction\n\nUnipressed (Uniprot REST) is an API client for the protein database [Uniprot](https://www.uniprot.org/).\nIt provides thoroughly typed and documented code to ensure your use of the library is easy, fast, and correct!\n\n### Example\nLet's say we're interested in very long proteins that are encoded within a chloroplast, in any organism:\n\n```python\nfrom unipressed import UniprotkbClient\n\nfor record in UniprotkbClient.search(\n    query={\n        \"and_\": [\n            {\"organelle\": \"chloroplast\"},\n            {\"length\": (5000, \"*\")}\n        ]\n    },\n    fields=[\"length\", \"gene_names\"]\n).each_record():\n    display(record)\n```\n\n\n<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n<span style=\"font-weight: bold\">{</span>\n    <span style=\"color: #008000; text-decoration-color: #008000\">'primaryAccession'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'A0A088CK67'</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'genes'</span>: <span style=\"font-weight: bold\">[</span>\n        <span style=\"font-weight: bold\">{</span>\n            <span style=\"color: #008000; text-decoration-color: #008000\">'geneName'</span>: <span style=\"font-weight: bold\">{</span>\n                <span style=\"color: #008000; text-decoration-color: #008000\">'evidences'</span>: <span style=\"font-weight: bold\">[{</span><span style=\"color: #008000; text-decoration-color: #008000\">'evidenceCode'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'ECO:0000313'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'source'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'EMBL'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'id'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'AID67672.1'</span><span style=\"font-weight: bold\">}]</span>,\n                <span style=\"color: #008000; text-decoration-color: #008000\">'value'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'ftsH'</span>\n            <span style=\"font-weight: bold\">}</span>\n        <span style=\"font-weight: bold\">}</span>\n    <span style=\"font-weight: bold\">]</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'sequence'</span>: <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'length'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5242</span><span style=\"font-weight: bold\">}</span>\n<span style=\"font-weight: bold\">}</span>\n</pre>\n\n\n\n### Advantages\n\n* Detailed type hints for autocompleting queries as you type\n* Autocompletion for return fields\n* Documentation for each field\n* Automatic results parsing, for `json`, `tsv`, `list`, and `xml`\n* Built-in pagination, so you don't have to handle any of that yourself!\n* Most of the API is automatically generated, ensuring very rapid updates whenever the API changes\n* Thoroughly tested, with 41 unit tests and counting!\n\n## Usage\n\n### Installation\n\nIf you're using poetry:\n```bash\npoetry add unipressed\n```\n\nOtherwise:\n```bash\npip install unipressed\n```\n\n### Dataset Clients\n\nThe `unipressed` module exports a client object for each UniProt dataset:\n\n```python\nfrom unipressed import UniprotkbClient, UniparcClient\n```\n\nWith one of these clients, you can search the dataset:\n\n```python\nrecords = UniprotkbClient.search({\n    \"length\": (5000, 6000)\n}).each_record()\n\n# Show the first record\nnext(records)\n```\n\n\n<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n<span style=\"font-weight: bold\">{</span>\n    <span style=\"color: #008000; text-decoration-color: #008000\">'entryType'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'UniProtKB reviewed (Swiss-Prot)'</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'primaryAccession'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'Q96RW7'</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'secondaryAccessions'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'uniProtkbId'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'HMCN1_HUMAN'</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'entryAudit'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'annotationScore'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5.0</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'organism'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'proteinExistence'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'1: Evidence at protein level'</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'proteinDescription'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'genes'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'comments'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'features'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'keywords'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'references'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'uniProtKBCrossReferences'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'sequence'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'extraAttributes'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n<span style=\"font-weight: bold\">}</span>\n</pre>\n\n\n\nYou can request a single record by ID:\n\n```python\nUniprotkbClient.fetch_one(\"Q96RW7\")\n```\n\n\n<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n<span style=\"font-weight: bold\">{</span>\n    <span style=\"color: #008000; text-decoration-color: #008000\">'entryType'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'UniProtKB reviewed (Swiss-Prot)'</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'primaryAccession'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'Q96RW7'</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'secondaryAccessions'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'uniProtkbId'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'HMCN1_HUMAN'</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'entryAudit'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'annotationScore'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5.0</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'organism'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'proteinExistence'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'1: Evidence at protein level'</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'proteinDescription'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'genes'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'comments'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'features'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'keywords'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'references'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'uniProtKBCrossReferences'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'sequence'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n    <span style=\"color: #008000; text-decoration-color: #008000\">'extraAttributes'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n<span style=\"font-weight: bold\">}</span>\n</pre>\n\n\n\nYou can also request multiple records:\n\n```python\nUniprotkbClient.fetch_many([\"A0A0C5B5G6\", \"A0A1B0GTW7\"])\n```\n\n\n<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n<span style=\"font-weight: bold\">[</span>\n    <span style=\"font-weight: bold\">{</span>\n        <span style=\"color: #008000; text-decoration-color: #008000\">'entryType'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'UniProtKB reviewed (Swiss-Prot)'</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'primaryAccession'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'A0A0C5B5G6'</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'uniProtkbId'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'MOTSC_HUMAN'</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'entryAudit'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'annotationScore'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5.0</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'organism'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'proteinExistence'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'1: Evidence at protein level'</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'proteinDescription'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'genes'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'comments'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'features'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'geneLocations'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'keywords'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'references'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'uniProtKBCrossReferences'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'sequence'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'extraAttributes'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n    <span style=\"font-weight: bold\">}</span>,\n    <span style=\"font-weight: bold\">{</span>\n        <span style=\"color: #008000; text-decoration-color: #008000\">'entryType'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'UniProtKB reviewed (Swiss-Prot)'</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'primaryAccession'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'A0A1B0GTW7'</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'secondaryAccessions'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'uniProtkbId'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'CIROP_HUMAN'</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'entryAudit'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'annotationScore'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5.0</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'organism'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'proteinExistence'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'1: Evidence at protein level'</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'proteinDescription'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'genes'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'comments'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'features'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'keywords'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'references'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'uniProtKBCrossReferences'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'sequence'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>,\n        <span style=\"color: #008000; text-decoration-color: #008000\">'extraAttributes'</span>: <span style=\"color: #808000; text-decoration-color: #808000\">...</span>\n    <span style=\"font-weight: bold\">}</span>\n<span style=\"font-weight: bold\">]</span>\n</pre>\n\n\n\n### ID Mapping\n\nUnipressed also provides one other unique client, which is designed for mapping identifiers. You provide the source and destination database (both of which will autocomplete in VS Code), and a list of identifiers for the source database.\n\n```python\nfrom unipressed import IdMappingClient\nrequest = IdMappingClient.submit(\n    source=\"UniProtKB_AC-ID\", dest=\"Gene_Name\", ids={\"A1L190\", \"A0JP26\", \"A0PK11\"}\n)\nlist(request.each_result())\n```\n\n\n<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n<span style=\"font-weight: bold\">[</span>\n    <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'from'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'A1L190'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'to'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'SYCE3'</span><span style=\"font-weight: bold\">}</span>,\n    <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'from'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'A0PK11'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'to'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'CLRN2'</span><span style=\"font-weight: bold\">}</span>,\n    <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'from'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'A0JP26'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'to'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'POTEB3'</span><span style=\"font-weight: bold\">}</span>\n<span style=\"font-weight: bold\">]</span>\n</pre>\n\n\n\nNote that, if you submit a large number of IDs, you might need to add a `sleep()` call between submitting the request and retrieving the results.\n\n### Query Syntax\n\nThe query syntax refers to the values you pass in to the `query` argument of the `search()` method.\n\nIn general, you can't go wrong by following the type hints.\nI strongly recommend using something like [`pylance`](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) for [Visual Studio Code](https://code.visualstudio.com/), which will provide automatic completions and warn you when you have used the wrong syntax.\n\nIf you already know how to use the Uniprot query language, you can always just input your queries as strings:\n\n```python\nUniprotkbClient.search(query=\"(gene:BRCA*) AND (organism_id:10090)\")\n```\n\nHowever, if you want some built-in query validation and code completion using Python's type system, then you can instead use a dictionary.\nThe simplest query is a dictionary with a single key: \n\n```python\nUniprotkbClient.search(query={\"family\": \"kinase\"})\n```\n\nYou can compile more complex queries using the `and_`, `or_` and `not_` keys.\nThese first two operators take a list of query dictionaries: \n\n```python\nUniprotkbClient.search(query={\n    \"and_\": [\n        {\"family\": \"kinase\"},\n        {\"organism_id\": \"9606\"},\n    ]\n})\n```\n\nMost \"leaf\" nodes of the query tree (ie those that aren't operators like `and_`) are strings, integers or floats, which you input as normal Python literals as you can see above.\nFor string fields, you also have access to wildcards, namely the `*` character. \nFor example, if you want every human protein belonging to a gene whose name starts with `PRO`, you could use:\n\n```python\nUniprotkbClient.search(query={\n    \"and_\": [\n        {\"gene\": \"PRO*\"},\n        {\"organism_id\": \"9606\"},\n    ]\n})\n```\n\nA few query fields are *ranges*, which you input using a tuple with two elements, indicating the start and end of the range.\nIf you use the literal `\"*\"` then you can leave the range open at one end. \nFor example, this query returns any protein that is in the range $[5000, \\infty)$\n\n```python\nUniprotkbClient.search(query={\"length\": (5000, \"*\")})\n```\n\nFinally, a few query fields take dates.\nThese you input as a Python `datetime.date` object.\nFor example, to find proteins added to UniProt since July 2022, we would do:\n\n```python\nfrom datetime import date\n\nUniprotkbClient.search(query={\"date_created\": (date(2022, 7, 1), \"*\")})\n```\n\n### Use with Visual Studio Code\nTo get VS Code to offer suggestions, press the `Trigger Suggest` shortcut which is usually bound to `Ctrl + Space`.\nIn particular, code completion generally won't work *until* you open a string literal using a quotation mark.\n\nSecondly, to get live access to the documentation, you can either use the `Show Hover` shortcut, which is usually bound to `Ctrl + K, Ctrl + I`, or you can install the [`docs-view`](https://marketplace.visualstudio.com/items?itemName=bierner.docs-view) extension, which lets you view the docstrings in the sidebar without interfering with your code.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Comprehensive Python client for the Uniprot REST API",
    "version": "1.4.0",
    "project_urls": {
        "Homepage": "https://multimeric.github.io/Unipressed",
        "Repository": "https://github.com/multimeric/Unipressed"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ff39e4144e6fdfcc9fb8de255564e9773dc3ee9499a27ca706fda8b495fbb0f",
                "md5": "49cfd245fc7de82f0b9e7b206feaf486",
                "sha256": "f3c53280668846b3164eae066a575b28399d1606d124f6cce5ac0bf405cf24e1"
            },
            "downloads": -1,
            "filename": "unipressed-1.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "49cfd245fc7de82f0b9e7b206feaf486",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 35784,
            "upload_time": "2024-08-16T12:05:19",
            "upload_time_iso_8601": "2024-08-16T12:05:19.904823Z",
            "url": "https://files.pythonhosted.org/packages/2f/f3/9e4144e6fdfcc9fb8de255564e9773dc3ee9499a27ca706fda8b495fbb0f/unipressed-1.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "57f31bff788016e59c20228e0afd5336766723a2ad07dcc2de63de2fce8943af",
                "md5": "b0cd80a7f349d0aafff962cde407d0f0",
                "sha256": "a590f4b8f41b4daf5485400b6149449face7ca91e3e93a113dacefbfdc684887"
            },
            "downloads": -1,
            "filename": "unipressed-1.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b0cd80a7f349d0aafff962cde407d0f0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 27337,
            "upload_time": "2024-08-16T12:05:21",
            "upload_time_iso_8601": "2024-08-16T12:05:21.310111Z",
            "url": "https://files.pythonhosted.org/packages/57/f3/1bff788016e59c20228e0afd5336766723a2ad07dcc2de63de2fce8943af/unipressed-1.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-16 12:05:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "multimeric",
    "github_project": "Unipressed",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "unipressed"
}
        
Elapsed time: 0.50802s