rotifer.db.uniprot.SequenceCursor#
- class rotifer.db.uniprot.SequenceCursor(readers=['webapi'], writers=[], database='auto', progress=True, tries=None, batch_size=None, threads=None, *args, **kwargs)[source]#
Bases:
SequenceCursor,BaseUniProtRecordCursorFetch UniProt entries, with their annotation, from the fastest source.
One call may mix identifiers of different kinds: UniProtKB accessions, UniParc UPIs, UniRef cluster names and proteome identifiers are each sent to the resource that knows about them and the records come back together. UniProtKB entries are taken as flat files, so they carry features and cross-references; the other resources publish no such format and come back as plain sequences.
Use this cursor when the annotation is what is wanted. When it is only the residues, use
FastaCursorinstead: it answers from a local FASTA database first and so does not wait on a round trip. Those databases are deliberately not available here – a sequence read from one would arrive with none of the annotation this cursor exists to return – and naming such a backend raises rather than quietly returning bare sequences.This is the UniProt counterpart of
rotifer.db.ncbi.SequenceCursorand takes the same arguments, so switching source is mostly a matter of switching import.- Parameters:
- readerslist of str, default
['webapi'] Backend reader modules, tried in order. Only the web service has annotated entries today: the local mirror holds
idmapping.datrather than the flat files, and the SQL backends hold mappings. The list is here so a backend that carries annotation can be added without changing any calling code; a FASTA one cannot.- writerslist of str, default []
Backend writer modules.
- databasestr, default ‘auto’
Which UniProt resource to ask.
autodecides from each identifier, which is what lets one call mix them; naming a resource explicitly skips detection.- progressbool, default True
Whether to report progress.
- triesint, optional
Attempts per request. Defaults to the backend’s own setting.
- batch_sizeint, optional
Identifiers per batch.
- threadsint, optional
Simultaneous workers. Kept low by default: UniProt asks that clients not open many connections at once.
- **kwargs
Passed to the backends, so UniProt query parameters such as
fieldsorincludeIsoformremain available.
- readerslist of str, default
See also
FastaCursorthe same entries without annotation, from a local copy
rotifer.db.uniprot.webapi.SequenceCursorthe backend this delegates to
rotifer.db.ncbi.SequenceCursorthe same idea, for NCBI
Examples
>>> from rotifer.db import uniprot >>> sc = uniprot.SequenceCursor() >>> records = sc.fetchall(['P00750','UPI0000000001'])
Write them out, as any other Biopython records:
>>> import sys >>> from Bio import SeqIO >>> for record in sc.fetchone(['P00750','P02766']): ... SeqIO.write(record, sys.stdout, 'genbank')
- getids(obj, *args, **kwargs)[source]#
Every identifier a record might have been requested by.
An entry can be named by accession, by entry name or by a secondary accession, and what comes back depends on the format: FASTA carries
sp|P00750|TPA_HUMANwhere the flat file carriesP00750. Reporting all of them is what keeps an entry from being counted as missing, and handed to the next backend, merely because it was asked for by another of its names.- Parameters:
- objBio.SeqRecord.SeqRecord, list or None
Records produced by a backend.
- Returns:
- set of str