Ham¶
ham is the main object oh Ham. It contains all the information and functions required to performs and HOGs analysis.
- class pyham.ham.Ham(tree_file=None, hog_file=None, type_hog_file='orthoxml', filter_object=None, use_internal_name=False, orthoXML_as_string=False, tree_format='newick_string', phyloxml_internal_name_tag='taxonomy_scientific_name', phyloxml_leaf_name_tag='taxonomy_scientific_name', use_data_from=None, query_database=None, species_resolve_mode=None, with_parser_progress=False, fail_fast=False, id_schema='auto')[source]¶
- Attributes:
- tree_file (
str): Path to the file that contained the taxonomy information.hog_file (str): Path to the file that contained the HOGs information.hog_file_type (str): File type of the hog_file. Can be “orthoxml or “hdf5”. Defaults to “orthoxml”.top_level_hogs (dict): Dictionary that map hog unique id with its list of relatedpyham.abstractgene.HOG.extant_gene_map (dict): Dictionary that map gene unique id with its list of relatedpyham.abstractgene.Gene.external_id_mapper (dict): Dictionary that map a gene external id with its list of relatedpyham.abstractgene.HOGorpyham.abstractGene.gene.filter_obj (pyham.pyham.ParserFilter):ParserFilterused during the instanciation of Ham. Defaults to None.taxonomy: (pyham.mapper.Taxonomy):pyham.pyham.Taxonomybuild and used bypyham.pyham.Haminstance.orthoXML_as_string (Bool) If set to true, hog_file is a string of an orthoxml file. Defaults to False. - Args:
- tree_file (
str): Path to the file that contained the taxonomy information.hog_file (str): Path to the file that contained the HOGs information.type_hog_file (str, optional): File type of the hog_file. Can be “orthoxml or “hdf5”. Defaults to “orthoxml”.filter_object (pyham.pyham.ParserFilter, optional):pyham.pyham.ParserFilterused during the instantiation of pyham.pyham.Ham. Defaults to None.use_internal_name (Boolean, optional): Set to decide to use or not the internal naming of the given taxonomy. This should be set to False when support values are provided in the newick. Defaults to False.tree_format (str): type of inputted tree file. Defaults to newick_string. Can be ‘newick’, ‘phyloxml, ‘newick_string’.phyloxml_leaf_name_tag (str) tag to use in the phyloxml to name the extant species (leaves). Defaults tag is taxonomy.scientific_name to populate species names. available options: ‘clade_name’, ‘taxonomy_scientific_name’, ‘taxonomy_code’. Beware than missing species names will stop pyham working.phyloxml_internal_name_tag (str) tag to use in the phyloxml to name the ancestral species (internal nodes). Defaults will use taxonomy.scientific_name to populate species names. available options: ‘clade_name’, ‘taxonomy_scientific_name’, ‘taxonomy_code’. Beware than missing species names will stop pyham working.use_data_from (str) if specified, use data from a remote databaseto populate pyHam. Defaults to None. Options: ‘oma’.query_database (str) if use_data_from is specified, use this as a query to fetch the orthoxml and tree information for the related query hog (gene family). For ‘oma’, this correspond to the oma gene id (e.g. ‘HUMAN12’ or ‘CHIMP1435’).with_parser_progress (:bool:, optional) whether to show progress bar when parsing the XML file. In a terminal, log messages emitted during parsing can garble the bar; to interleave them cleanly, wrap the call intqdm.contrib.logging.logging_redirect_tqdm().fail_fast (Boolean, optional) if a HOG’s claimed taxonomic level (TaxRange/taxid) conflicts with the given species tree, raisepyham.abstractgene.TaxonomicConflictErrorimmediately at the first conflict found. If False (default), keep parsing and collect every conflict found across the whole file, raising a single combined error (with all conflicts available via its conflicts attribute) once parsing completes.id_schema (str, optional) the HOG id scheme used by the orthoxml file, one of ‘LOFT’, ‘LOFT_TAXID’, ‘GENERIC’ (seepyham.id_formats), used to synthesize ids for HOG levels the species tree implies but the file doesn’t explicitly encode. Defaults to ‘auto’, which samples the first few families of the file to detect the scheme automatically. The resolved value is available afterwards as self.id_schema.
- compare_genomes_lateral(genome1, genome2)[source]¶
Function to compute a
pyham.mapper.MapLateralbased on the 2 given genomes. The genome order doesn’t matter.- Attributes:
- genome1 (
pyham.genome.Genome): Firstpyham.genome.Genometo compare.genome2 (pyham.genome.Genome): Secondpyham.genome.Genometo compare. - Returns:
- Raises:
- TypeError: if genome1 and genome2 are not
pyham.genome.Genome.
- compare_genomes_vertically(genome1, genome2)[source]¶
Function to compute a
MapVerticalbased on the 2 given genomes. The genome order doesn’t matter.- Attributes:
- genome1 (
pyham.genome.Genome): Firstpyham.genome.Genometo compare.genome2 (pyham.genome.Genome): Secondpyham.genome.Genometo compare. - Returns:
- Raises:
- TypeError: if genome1 and genome2 are not
pyham.genome.Genome.
- create_iHam(hog, outfile=None)[source]¶
Function to compute a
pyham.IHAM.If an outfile is specified, export the
pyham.IHAMas html file.- Attributes:
- hog (
pyham.abstractgene.HOG): HOG use as template for thepyham.IHAM.outfile (str, optional): Path to the IHAM html file. - Returns:
- create_tree_profile(hog=None, outfile=None, as_html=True, export_with_histogram=True)[source]¶
Function to compute a
pyham.TreeProfile.If no hog are given the tree profile will be created for the whole Ham setup (all internal nodes with all HOGs). Otherwise, the tree profile is build for the specific hog given.
If an outfile is specified, export the create_tree_profile as image into file.
- Attributes:
- hog (
pyham.abstractgene.HOG, optional): HOG use as template for the create_tree_profile.outfile (str, optional): Path to the create_tree_profile output image file. valid extensions are .SVG, .PDF, .PNG.export_with_histogram (Bool, optional): If True, export image with histogram at each internal node otherwise display internal node information as text.as_html (Bool, optional): If true, the tree profile will be exported as html file containing an interactive viewer to handle tree profile information. - Returns:
- get_ancestral_genome_by_mrca_of_genome_set(genome_set)[source]¶
Get the
pyham.genome.AncestralGenomecorresponding to the MRCA of query genomes.- Args:
genome_set (
set): Set ofpyham.genome.AncestralGenome.- Returns:
pyham.genome.AncestralGenomeor raise KeyError
- get_ancestral_genome_by_name(name)[source]¶
Get the
pyham.genome.AncestralGenomecorresponding of the query name.- Args:
name (
str): Name of thepyham.genome.AncestralGenome.- Returns:
pyham.genome.AncestralGenomeor raise KeyError
- get_ancestral_genome_by_taxon(taxon)[source]¶
Get the
pyham.genome.AncestralGenomecorresponding of the query taxon.- Args:
taxon (
str): treeNode object of thepyham.taxonomy.Taxonomy.tree object.- Returns:
pyham.genome.AncestralGenomeor raise KeyError
- get_dict_extant_genes()[source]¶
Get a dictionary that map all unique gene id with their related
pyham.abstractgene.Gene.- Returns:
a dictionary mapping unique gene Id (
str) withpyham.abstractgene.Gene.
- get_dict_top_level_hogs()[source]¶
Get a dictionary that map all top level hog id with their related
pyham.abstractgene.HOG.- Returns:
a dictionary mapping hog Id (
str) withpyham.abstractgene.HOG.
- get_extant_genome_by_name(name)[source]¶
Get the
pyham.genome.ExtantGenomethat match the query name.- Args:
name (
str): Name of thepyham.genome.ExtantGenome.- Returns:
pyham.genome.ExtantGenomeor raise KeyError
- get_gene_by_id(gene_unique_id)[source]¶
Get the
pyham.abstractgene.Genethat match the query unique gene Id.- Args:
- Returns:
- Raises:
KeyError is not pyham.abstractgene.Gene match the id.
- get_genes_by_external_id(external_gene_id)[source]¶
Get the list of
pyham.abstractgene.Genethat match the query external gene Id.- Args:
- Returns:
a list of
pyham.abstractgene.Gene- Raises:
KeyError if no pyham.abstractgene.Gene match id.
- get_hog_by_gene(gene)[source]¶
Get the top level
HOGthat contain the querypyham.abstractgene.Gene. If thepyham.abstractgene.Geneis a singleton it will return itself.- Args:
gene (
pyham.abstractgene.Gene):pyham.abstractgene.Geneobject.- Returns:
- Raises:
KeyError is gene is not a
pyham.abstractgene.Gene.
- get_hog_by_id(hog_id)[source]¶
Get the top level
HOGthat match the hog id query.- Args:
- Returns:
- Raises:
KeyError if id match no pyham.abstractgene.HOG.
- get_list_ancestral_genomes()[source]¶
Get the list of all
pyham.genome.AncestralGenomecreated during the parsing.- Returns:
a list of
pyham.genome.AncestralGenome.
- get_list_extant_genes()[source]¶
Get the list of all
pyham.abstractgene.Gene.- Returns:
a list of
pyham.abstractgene.Gene.
- get_list_extant_genomes()[source]¶
Get the list of all
pyham.genome.ExtantGenomecreated during the parsing.- Returns:
a list of
pyham.genome.ExtantGenome.
- get_list_top_level_hogs()[source]¶
Get the list of all the top level
pyham.abstractgene.HOG.- Returns:
a list of
pyham.abstractgene.HOG.
- get_taxon_by_name(name)[source]¶
Get the
ete3.TreeNodeobject of thepyham.taxonomy.Taxonomy.tree corresponding of the query name.- Args:
name (
str): Name of the treeNode.- Returns:
ete3.TreeNodeor raise KeyError