oggmap.qlin module
Author: Kristian K Ullrich date: February 2025 email: ullrich@evolbio.mpg.de License: GPL-3
- oggmap.qlin.add_argparse_args(parser: ArgumentParser)
This function attaches individual argument specifications to the parser.
- Parameters:
parser (argparse.ArgumentParser) – An argparse.ArgumentParser.
- oggmap.qlin.define_parser()
A helper function for using qlin.py via the terminal.
- Returns:
An argparse.ArgumentParser.
- Return type:
argparse.ArgumentParser
- oggmap.qlin.get_lineage_topo(qt, ncbi=None, dbname=None)
This function returns a species lineage as a tree object for a query species given as taxID.
- Parameters:
qt (str) – The taxID of the queried species.
ncbi (dict) – The NCBI taxonomic database.
dbname (str) – Specify taxadb.sqlite file.
- Returns:
The lineage of the queried species as a Bio.Phylo.Newick.Tree.
- Return type:
Bio.Phylo.Newick.Tree
Example
>>> from oggmap import qlin >>> lineage_tree = qlin.get_lineage_topo(qt='10090', >>> dbname='taxadb.sqlite') >>> lineage_tree
- oggmap.qlin.get_oldest_common(ql, tl)
This function returns the oldest common ancestor (OCA) by comparing the lineage information of a query species and a target species.
The target species can also be a list of LCA values to find the oldest among the given LCA.
- Parameters:
ql (list) – Query species lineage information.
tl (list) – Target species lineage information.
- Returns:
oldest common ancestor (OCA).
- Return type:
str
Example
>>> from oggmap import qlin >>> # get query species taxonomic lineage information >>> _, _, query_lineage, _, _, _, _, _ = qlin.get_qlin(q='Caenorhabditis elegans', >>> dbname='taxadb.sqlite') >>> # get target species taxonomic lineage information >>> _, _, target_lineage, _, _, _, _, _ = qlin.get_qlin(q='Mus musculus', >>> dbname='taxadb.sqlite') >>> # get oldest common node >>> qlin.get_oldest_common(ql=query_lineage, tl=target_lineage)
- oggmap.qlin.get_qlin(q=None, qt=None, quiet=False, ncbi=None, dbname=None)
This function searches the NCBI taxonomic database for results matching the query name or query taxID.
Note that if the user specifies both the name and the taxID of a species, the returning result is based on the taxID.
- Parameters:
q (str) – The name of the queried species.
qt (str) – The taxID of the queried species.
quiet (bool) – Specify if output should be quiet.
ncbi (dict) – The NCBI taxonomic database.
dbname (str) – Specify taxadb.sqlite file.
- Returns:
A list of information for the queried species such as: query name, query taxID, query lineage, query lineage dictionary, query lineage zip, query lineage names, reverse query lineage, query kingdom
- Return type:
list
Example
>>> from oggmap import qlin >>> qlin.get_qlin(q='Danio rerio', >>> dbname='taxadb.sqlite')
- oggmap.qlin.get_youngest_common(ql, tl)
This function returns the lowest common ancestor (LCA) by comparing the lineage information of a query and a target species.
- Parameters:
ql (list) – Query species lineage information.
tl (list) – Target species lineage information.
- Returns:
lowest common ancestor (LCA).
- Return type:
str
Example
>>> from oggmap import qlin >>> # get query species taxonomic lineage information >>> _, _, query_lineage, _, _, _, _, _ = qlin.get_qlin(q='Caenorhabditis elegans', >>> dbname='taxadb.sqlite') >>> # get target species taxonomic lineage information >>> _, _, target_lineage, _, _, _, _, _ = qlin.get_qlin(q='Mus musculus', >>> dbname='taxadb.sqlite') >>> # get youngest common node >>> qlin.get_youngest_common(ql=query_lineage, tl=target_lineage)
- oggmap.qlin.load_taxadb(ncbi, dbname)
Load taxadb.sqlite database or exit if neither ncbi nor dbname are provided.
- Parameters:
ncbi – Existing ncbi dictionary, if any.
dbname – Path to taxadb.sqlite file.
- Return type:
dict
- oggmap.qlin.main()
The main function that is being called when qlin is used via the terminal.
- oggmap.qlin.ncbi_get_lineage(qt, ncbi=None, dbname=None)
This function returns a species lineage for a query species given as taxID.
- Parameters:
qt (str) – The taxID of the queried species.
ncbi (dict) – The NCBI taxonomic database.
dbname (str) – Specify taxadb.sqlite file.
- Return type:
list
- oggmap.qlin.ncbi_get_taxid_translator(qt_vec, ncbi=None, dbname=None)
This function returns a dictionary for a vector of taxIDs as integers.
- Parameters:
qt_vec (list of int) – A vector of taxIDs as integers.
ncbi (dict) – The NCBI taxonomic database.
dbname (str) – Specify taxadb.sqlite file.
- Return type:
dict
- oggmap.qlin.traverse_postorder(clade)
Yield each clade (node) in a post-order traversal (children before parent)
- Parameters:
clade (Bio.Phylo.Newick.Clade) – A Clade object from a Bio.Phylo.Newick.Tree.