rotifer.db.ncbi.entrez.NucleotideFeaturesCursor#

class rotifer.db.ncbi.entrez.NucleotideFeaturesCursor(exclude_type=['source', 'gene', 'mRNA'], autopid=False, assembly=None, codontable='Bacterial', progress=True, tries=3, sleep_between_tries=1, batch_size=20, threads=10)[source]#

Bases: SequenceCursor

Fetch nucleotide annotation as feature tables.

Nucleotide entries are downloaded in GenBank format and converted to dataframes with one row per annotated feature.

Parameters:
exclude_typelist of str, default ['source', 'gene', 'mRNA']

Feature types to ignore.

autopidbool, default False

Automatically set protein identifiers.

assemblystr, optional

Assembly accession assigned to every parsed feature.

codontablestr or int, default ‘Bacterial’

Codon table used when the data does not define one.

progressbool, default True

Whether to print a progress bar.

triesint, default 3

Number of attempts to download data.

sleep_between_triesint, default 1

Number of seconds to wait between download attempts.

batch_sizeint, default 20

Number of accessions per batch.

threadsint, default 10

Number of simultaneous threads. Capped at 3 without an NCBI API key and at 10 with one.

Examples

>>> from rotifer.db.ncbi import entrez
>>> nfc = entrez.NucleotideFeaturesCursor()
>>> df = nfc.fetchall(['CP084314.1'])
fetchall(accessions)[source]#

Fetch the feature tables of all entries as one dataframe.

Parameters:
accessionslist of str

NCBI nucleotide accessions.

Returns:
pandas.DataFrame

The concatenated feature tables. Empty when nothing could be retrieved.

getids(obj)[source]#

Extract nucleotide accessions from feature tables.

Parameters:
objpandas.DataFrame or list of pandas.DataFrame

Feature tables produced by the cursor.

Returns:
set of str

The values of the nucleotide column.

parser(stream, accession)[source]#

Parse an EFetch GenBank stream into feature tables.

Parameters:
streamfile-like

Open stream returned by the fetcher.

accessionstr or iterable of str

The queried nucleotide accessions, kept for interface compatibility.

Returns:
list of pandas.DataFrame

One feature table per nucleotide sequence.