NAME
Bio::DB::Taxonomy::sqlite - SQLite-based implementation of Bio::DB::Taxonomy::flatfile
SYNOPSIS
use Bio::DB::Taxonomy;my $db = Bio::DB::Taxonomy->new(-source => 'sqlite',-db => 'mytax.db' # default 'taxonomy.sqlite'-nodesfile => 'nodes.dmp',-namesfile => 'names.dmp');
DESCRIPTION
This is an implementation of Bio::DB::Taxonomy which stores and accesses the NCBI taxonomy using a simple SQLite3 database stored locally on disk.
With this implementation, one can do the same basic searches as with the 'flatfile' database. A test lookup of 1000 NCBI TaxIDs with full lineage information took about 2 seconds on my older MacBook Pro laptop with an on-disk implementation.
A few key differences:
- •
-
You can use typical SQL syntax to run a query search; for instance, if you want you can run:
@ids = sort $db->get_taxonids('Chloroflexi%');
- •
-
In-memory database is allowed
my $db = Bio::DB::Taxonomy->new(-source => 'sqlite',-db => ':memory:',-nodesfile => 'nodes.dmp',-namesfile => 'names.dmp');
The required database files, nodes.dmp and names.dmp can be obtained from ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz
TODO
- •
-
Small optimizations, such as optimizing name lookups
- •
-
Possibly use recursive CTE <http://www.sqlite.org/lang_with.html> to do lineage lookups
- •
-
Clean up SQL (still kind of a mess right now)
- •
-
Check compat. with other NCBI-specific Bio::DB::Taxonomy implementations
- •
-
Plan out feasibility of allowing other backends (Neo4J, other DBI, etc)
- •
-
Optionally calculate left/right ID values for TaxID nodes
Beyond completing the implementation and optimization, this will likely be rolled into a more flexible backend at some future point.
FEEDBACK
Mailing Lists
User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated.
[email protected] - General discussionhttp://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list:
rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.
Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Chris Fields
Email cjfields-at-cpan-dot-org
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
new
Title : newUsage : my $obj = Bio::DB::Taxonomy::flatfile->new();Function: Builds a new Bio::DB::Taxonomy::flatfile objectReturns : an instance of Bio::DB::Taxonomy::flatfileArgs : -directory => name of directory where index files should be created-nodesfile => name of file containing nodes (nodes.dmp from NCBI)-namesfile => name of the file containing names(names.dmp from NCBI)-force => 1 to replace current indexes even if they exist
Bio::DB::Taxonomy interface implementation
get_num_taxa
Title : get_num_taxaUsage : my $num = $db->get_num_taxa();Function: Get the number of taxa stored in the database.Returns : A numberArgs : None
get_taxon
Title : get_taxonUsage : my $taxon = $db->get_taxon(-taxonid => $taxonid)Function: Get a Bio::Taxon object from the database.Returns : Bio::Taxon objectArgs : just a single value which is the database id, OR named args:-taxonid => taxonomy id (to query by taxonid)OR-name => string (to query by a taxonomy name: common name,scientific name, etc)
get_taxonids
Title : get_taxonidsUsage : my @taxonids = $db->get_taxonids('Homo sapiens');Function: Searches for a taxonid (typically ncbi_taxon_id) based on a querystring. Note that multiple taxonids can match to the same suppliedname.Returns : array of integer ids in list context, one of these in scalar contextArgs : string representing taxon's name
get_Children_Taxids
Title : get_Children_TaxidsUsage : my @childrenids = $db->get_Children_TaxidsFunction: Get the ids of the children of a node in the taxonomyReturns : Array of IdsArgs : Bio::Taxon or a taxon_idStatus : deprecated (use each_Descendent())
ancestor
Title : ancestorUsage : my $ancestor_taxon = $db->ancestor($taxon)Function: Retrieve the full ancestor taxon of a supplied Taxon from thedatabase.Returns : Bio::TaxonArgs : Bio::Taxon (that was retrieved from this database)
each_Descendent
Title : each_DescendentUsage : my @taxa = $db->each_Descendent($taxon);Function: Get all the descendents of the supplied Taxon (but not theirdescendents, ie. not a recursive fetchall).Returns : Array of Bio::Taxon objectsArgs : Bio::Taxon (that was retrieved from this database)
Helper methods
index_directory
Title : index_directoryFunction : Get/set the location that index files are stored. (this modulewill index the supplied database)Usage : $obj->index_directory($newval)Returns : value of index_directory (a scalar)Args : on set, new value (a scalar or undef, optional)Note : kept for backwards compatibility with older DB_File implementation
db_name
Title : db_nameFunction : Get/set the name of the SQLite3 database where data is storedUsage : $obj->db_name($newval)Returns : value of db_name (a scalar)Args : on set, new value (a scalar or undef, optional)
cache_size
Title : cache_sizeFunction : Get/set the cachesize used for loading the SQLite3 databaseUsage : $obj->cache_size($newval)Returns : value of cache_size (a scalar)Args : on set, new value (a scalar or undef, optional)Note : we do no checking on whether this value is an integer (SQLite does this for use)