rotifer.db.uniprot.MappingCursor#
- class rotifer.db.uniprot.MappingCursor(readers=['clickhouse', 'webapi', 'mirror'], writers=[], sqlitedb=None, release=None, local_database_path='/databases/uniprot', engine=None, host=None, port=None, dbname=None, initialize=False, cache=False, progress=True, tries=None, batch_size=None, threads=None, *args, **kwargs)[source]#
Bases:
BaseUniProtDelegatorCursorTranslate identifiers through UniProt, from the fastest source.
One cursor answers every direction of the question. The identifiers given are matched in the databases named by
source, their UniProtKB accessions are found, and the identifiers those accessions carry in the databases named bytargetare returned. Pinning either end toUNIPROTKBgives the accession itself:source=UNIPROTKBthe cross-references of a UniProtKB accession
target=UNIPROTKBthe accession an external identifier belongs to
- neither
a translation between two external databases
Both ends are arguments of
fetchall()andfetchone()rather than of the constructor, because they describe a question and not a data source: one cursor can be asked many of them.- Parameters:
- readerslist of str, default
['clickhouse', 'webapi', 'mirror'] Backend reader modules, tried in order, cheapest first. The web service comes before the mirror because it answers in seconds where a mirror scan costs about ninety, whatever is asked of it; the mirror stays last as the source that has everything, for whatever the other two could not map.
A query that names no databases is answered by all of them, since they hold different vocabularies and none can be said to have covered a list that was never given. Drop a backend from this list to trade that completeness for speed.
- sqlitedbbool or str, optional
Use a local SQLite3 file as well, inserted before the web service: it answers the same question in milliseconds where a round trip cannot beat about a second, however little is asked of it. True takes the default file,
~/.rotifer/share/ rotifer.sqlite3; a string names one of your own, which need not exist yet. Left out, no SQLite3 backend is built, since there is no file to assume.- writerslist of str, default []
Backend writer modules.
- releasestr, optional
Restrict the ClickHouse backend to one UniProt release.
- local_database_pathstr, optional
Root directory of the local UniProt mirror.
- enginestr, optional
Matching engine of the
mirrorbackend.- host, port, dbnameoptional
Which server and database the ClickHouse backend should use. Each defaults to that backend’s own configuration. The tables it reads are not among these: they are declared by the cursor classes themselves.
- initializebool or str, default False
Create the storage table, and load it, before querying.
- cachebool, default False
Store what the slower backends return, so that the next query for the same identifiers is answered by the table.
- progressbool, default True
Whether backends report progress.
- readerslist of str, default
Examples
Every cross-reference of an accession:
>>> from rotifer.db import uniprot >>> mc = uniprot.MappingCursor()
The same, consulting a local SQLite3 file first:
>>> mc = uniprot.MappingCursor(sqlitedb=True) >>> mc = uniprot.MappingCursor(sqlitedb='project.sqlite3') >>> mc.fetchall(["Q6GZX4"], source=mc.UNIPROTKB)
Which accession a RefSeq protein belongs to:
>>> mc.fetchall(["YP_031579.1"], target=mc.UNIPROTKB)From GenBank CDS to RefSeq and KEGG at once:
>>> mc.fetchall(["AAT09660.1"], source=['EMBL-CDS'], ... target=['RefSeq','KEGG'])