Question: Error in some hog codes using pyham
gravatar for Biojl
6 months ago by
Biojl1.7k wrote:

Hi, I am having trobules with the pyham library to access OMA database from python.

from omadb import Client
c = Client()
prot_id = 'PADI1_HUMAN'
r = c.proteins[prot_id]  # Can also be called as

import pyham
# Initialise pyHam with a phyloxml tree and orthoXML HOGs
phyloxml_path = "simpleEx.phyloxml"
orthoxml_path3 = "simpleEx.orthoxml"

pyham_analysis = pyham.Ham(phyloxml_path, orthoxml_path3, use_internal_name=True, tree_format='phyloxml')

# Get the hog of interest
hog = pyham_analysis.get_hog_by_id(r['oma_hog_id'])

Using the above code I obtain a

KeyError: ' Id HOG:0374330 cannot match any HOG Id.'

I have tried other proteins with the same problem. I have browsed the website and the HOG ID is apparently correct. The HOG code in the Treeprofile example seems to work:

hog = pyham_analysis.get_hog_by_id(a)

Not sure what is happening or where is my mistake.

oma • 235 views
ADD COMMENTlink modified 6 months ago by clement.train10 • written 6 months ago by Biojl1.7k

this is the best name for a package in the history of bioinformatics!

ADD REPLYlink written 6 months ago by Martombo2.6k
gravatar for clement.train
6 months ago by
clement.train10 wrote:

Hi Biojl,

If you want to load a single HOG from the public OMA database please consider using the following code:

my_gene_query = 'P53_RAT'
pyham_analysis = pyham.Ham(query_database=my_gene_query, use_data_from='oma')

This will automatically fetch all required data from OMA to launch a pyHam session with your HOG of interest. You can find a bit more in the documentation regarding the 'remote load' here

I hope this is answering your question,


ADD COMMENTlink written 6 months ago by clement.train10

I am able to generate the pyham_analysis object but one of the things I want to do is generate a TreeProfile for a specific HOG as explained here.

It requires hog_of_interest = ham_analysis.get_hog_by_id(HOG_ID), there is where the package fails.

The other error I get is this one (if I start from ham_analysis):

>>> treeprofile = ham_analysis.create_tree_profile(outfile="treeprofile_example.html")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jl/.local/lib/python3.6/site-packages/pyham/", line 404, in create_tree_profile
    tp = TreeProfile(self, hog=hog)
  File "/home/jl/.local/lib/python3.6/site-packages/pyham/", line 34, in __init__
    self.treemap = self.compute_tree_profile_full()
  File "/home/jl/.local/lib/python3.6/site-packages/pyham/", line 168, in compute_tree_profile_full
    node_genome =
  File "/home/jl/.local/lib/python3.6/site-packages/pyham/", line 638, in get_ancestral_genome_by_name
    raise KeyError('No ancestral genomes match the query name: {}'.format(name))
KeyError: 'No ancestral genomes match the query name: LUCA'
ADD REPLYlink modified 5 months ago • written 6 months ago by Biojl1.7k

Hi Biojl

indeed, that seems to be a bug in the pyham library. will fix it asap and release a fixed version on pypi. Thanks for reporting.


ADD REPLYlink written 5 months ago by adrian.altenhoff620

Hi Biojl,

I've fixed the problem, please upgrade to pyham >= 1.1.7 e.g.

   pip install --upgrade pyham
ADD REPLYlink modified 5 months ago • written 5 months ago by adrian.altenhoff620
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2022 users visited in the last hour