rotifer.db.uniprot.FastaCursor#

class rotifer.db.uniprot.FastaCursor(readers=['easel', 'webapi'], writers=[], local_fasta_path=['/databases/fadb/uniprot/uniprotDB', '/databases/fadb/uniprot/uniref100', '/databases/fadb/uniprot/uniref90', '/databases/fadb/uniprot/uniref50'], database='auto', progress=True, tries=None, batch_size=None, threads=None, *args, **kwargs)[source]#

Bases: SequenceCursor, BaseUniProtRecordCursor

Fetch UniProt sequences, without annotation, from the fastest source.

This is the cursor to use whenever the residues are what is wanted. A local FASTA database answers first, in milliseconds and without a round trip, and the web service covers whatever that copy does not hold. SequenceCursor is the other half of the pair: it returns the features and cross-references a UniProtKB flat file carries, which no FASTA file can, and it never reads a local FASTA database, since a sequence taken from one would arrive with none of that annotation.

The local databases are the prepared copies under fadb, whose headers have been rewritten so that a sequence is keyed by the identifier a caller would ask for: a bare accession in uniprotDB, a cluster name in the UniRef files. The mirror’s own FASTA files are not usable here, since esl-sfetch would index them under sp|P00750|TPA_HUMAN. Files that do not exist are dropped from the list, and if none are left the backend is dropped with them, so the query still runs against the web service.

Parameters:
readerslist of str, default ['easel', 'webapi']

Backend reader modules, tried in order.

writerslist of str, default []

Backend writer modules.

local_fasta_pathlist of str, optional

FASTA files indexed by esl-sfetch. Defaults to the local_fasta_path configuration entry. Note that this is not local_database_path, which names the root of the mirror MappingCursor scans.

databasestr, default ‘auto’

Which UniProt resource to ask the web service for. auto decides from each identifier.

progressbool, default True

Whether to report progress.

triesint, optional

Attempts per request. Defaults to each backend’s own setting.

batch_sizeint, optional

Identifiers per batch.

threadsint, optional

Simultaneous workers.

**kwargs

Passed to the backends.

See also

SequenceCursor

the same entries with their annotation

rotifer.db.local.easel.FastaCursor

the local backend

rotifer.db.ncbi.FastaCursor

the same idea, for NCBI

Examples

>>> from rotifer.db import uniprot
>>> fc = uniprot.FastaCursor()
>>> records = fc.fetchall(['A0A0F6NZX8','UniRef50_P00750'])

Skip the local copy, for instance to be sure of the current release:

>>> fc = uniprot.FastaCursor(readers=['webapi'])
classmethod resolve_fasta_path(paths)[source]#

Keep the local FASTA databases that are ready to be read.

Ready means two things: the file is there, and so is the .ssi index beside it. Both are checked here so that a query never starts an index build, which for a hundred gigabyte database is hours of work nobody asked for.

Symbolic links are deliberately not resolved. esl-sfetch looks for the index at <path>.ssi, and these databases are commonly a link to a mirrored file with the index kept next to the link, so following it would look for the index in the wrong directory and conclude there is none.

Parameters:
pathsstr or iterable of str

Files to look for.

Returns:
list of str

Those that can be read, as absolute paths.

backend_arguments(name, arguments)[source]#

Give the local FASTA files only to the backend that reads them.

Every keyword the web cursors do not recognise is forwarded to UniProt as a query parameter, so a path handed to one would be sent over the wire rather than ignored.

Parameters:
namestr

Which backend is being built.

argumentsdict

The shared attributes, as they would be passed.

Returns:
dict
getids(obj, *args, **kwargs)[source]#

Every identifier a record might have been requested by.

Parameters:
objBio.SeqRecord.SeqRecord, list or None
Returns:
set of str