rotifer.db.local.ete3.TaxonomyCursor#

class rotifer.db.local.ete3.TaxonomyCursor(*args, **kwargs)[source]#

Bases: BaseCursor

Fetch NCBI Taxonomy data from the local ETE toolkit database.

Phased out taxonomy identifiers are transparently replaced by their current equivalents, and the original identifiers are reported in the alternative_taxids column.

Parameters:
progressbool, default False

Whether to print a progress bar.

Attributes:
ete3ete3.ncbi_taxonomy.ncbiquery.NCBITaxa

The underlying ETE toolkit database handle.

taxcolslist of str

Columns of the returned dataframes: taxid, organism, superkingdom, lineage, classification and alternative_taxids.

See also

rotifer.db.ncbi.TaxonomyCursor

delegator that falls back to NCBI Entrez

Examples

>>> from rotifer.db.local import ete3
>>> tc = ete3.TaxonomyCursor()
>>> t = tc.fetchall([2599])
__getitem__(accessions)[source]#

Fetch taxonomy data for one or more taxids, dictionary style.

Parameters:
accessionsint, str or iterable

NCBI Taxonomy identifiers.

Returns:
pandas.DataFrame

One row per taxon, with the columns listed in taxcols. Identifiers not found in the database are registered as missing.

fetchall(accessions)[source]#

Fetch taxonomy data for all taxids as one dataframe.

Parameters:
accessionsiterable

NCBI Taxonomy identifiers.

Returns:
pandas.DataFrame

One row per taxon, with the columns listed in taxcols.

fetchone(accessions)[source]#

Iterate over taxonomy records, one taxon at a time.

Parameters:
accessionsiterable

NCBI Taxonomy identifiers.

Yields:
pandas.DataFrame

The rows of one taxon.

getids(obj)[source]#

Extract taxonomy identifiers from taxonomy dataframes.

Parameters:
objpandas.DataFrame or list of pandas.DataFrame

Taxonomy dataframes produced by the cursor.

Returns:
set of str

All identifiers in the taxid and alternative_taxids columns.

update_database()[source]#

Download the latest NCBI taxdump and rebuild the local database.

The download is performed by the ETE toolkit in a temporary directory. This is the only method of this class that uses the network.