Skip to main content

UniProt Database Web Parser Project

Downloads

Table of Contents

Description

This parser can be used to parse UniProt accession IDs and obtain related data from the UniProt web database.

Installation

To install the package, use:

python -m pip install uniprotparser

or

python3 -m pip install uniprotparser

Usage

Basic Usage

With version 1.2.0, we have exposed to and from mapping parameters for UniProt API where you can indicate which database you want to map to and from.

from uniprotparser import get_from_fields, get_to_fields

# To get all available fields to map from
from_fields = get_from_fields()
print(from_fields)

# To get all available fields to map to
to_fields = get_to_fields()
print(to_fields)

These parameters can be passed to the parse method of the UniprotParser class as follows:

from uniprotparser.betaparser import UniprotParser

parser = UniprotParser()
for p in parser.parse(ids=["P06493"], to_key="UniProtKB", from_key="UniProtKB_AC-ID"):
    print(p)

CLI Interface

With version 1.1.0, a simple CLI interface has been added to the package.

Usage: uniprotparser [OPTIONS]

Options:
  -i, --input FILENAME   Input file containing a list of accession ids
  -o, --output FILENAME  Output file
  --help                 Show this message and exit.

Asyncio Support

With version 1.0.5, support for asyncio through aiohttp has been added to betaparser. Usage can be seen as follows:

from uniprotparser.betaparser import UniprotParser
from io import StringIO
import asyncio
import pandas as pd

async def main():
    example_acc_list = ["Q99490", "Q8NEJ0", "Q13322", "P05019", "P35568", "Q15323"]
    parser = UniprotParser()
    df = []
    # Yield result for 500 accession ids at a time
    async for r in parser.parse_async(ids=example_acc_list):
        df.append(pd.read_csv(StringIO(r), sep="\t"))

    # Check if there were more than one result and consolidate them into one dataframe
    if len(df) > 0:
        df = pd.concat(df, ignore_index=True)
    else:
        df = df[0]

asyncio.run(main())

Legacy API

To parse UniProt accession with the legacy API:

from uniprotparser.parser import UniprotSequence

protein_id = "seq|P06493|swiss"

acc_id = UniprotSequence(protein_id, parse_acc=True)

# Access ACCID
print(acc_id.accession)

# Access isoform id
print(acc_id.isoform)

To get additional data from the UniProt online database:

from uniprotparser.parser import UniprotParser
from io import StringIO
import pandas as pd

protein_accession = "P06493"
parser = UniprotParser([protein_accession])

# To get tabulated data
result = []
for i in parser.parse("tab"):
    tab_data = pd.read_csv(i, sep="\t")
    last_column_name = tab_data.columns[-1]
    tab_data.rename(columns={last_column_name: "query"}, inplace=True)
    result.append(tab_data)
fin = pd.concat(result, ignore_index=True)

# To get fasta sequence
with open("fasta_output.fasta", "wt") as fasta_output:
    for i in parser.parse():
        fasta_output.write(i)

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for uniprotparser 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uniprotparser 1.3.1
File Size Uploaded Provenance Actions
uniprotparser-1.3.1.tar.gz 9.4 kB Without provenance Details for uniprotparser-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for uniprotparser 1.3.1
File Interpreter ABI Platform Actions
uniprotparser-1.3.1-py3-none-any.whl Python 3 none any Details for uniprotparser-1.3.1-py3-none-any.whl

Total release size: 19.8 kB

Release files / uniprotparser-1.3.1.tar.gz

Download URL uniprotparser-1.3.1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
758d1393291912f891e1c003255f8e1405bbddaac10aa6bbd235389dc71d4966
BLAKE2b-256 checksum
How to use checksums
2b55b12d9603b07dbf7c30b3ec76aa8364cb66abd2daeb7defcbd4e55bf2a32b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2

Release files / uniprotparser-1.3.1-py3-none-any.whl

Download URL uniprotparser-1.3.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7aeb4b5f0b8b2951abe6e4d695e54250910a6126ae2efa8c01b21f949794257
BLAKE2b-256 checksum
How to use checksums
e0157f7afafbd9f52911d580a0b54ffb786e2b23a42743eee60666629c31fc63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2

Security for uniprotparser 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page