This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error in some hog codes using pyham

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

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

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:

a='HOG:0355161'
hog = pyham_analysis.get_hog_by_id(a)

Not sure what is happening or where is my mistake.

oma

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

1 answer

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,

Clement

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. https://zoo.cs.ucl.ac.uk/tutorials/tutorial_pyHam_get_started.html#genomedef

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/ham.py", line 404, in create_tree_profile
    tp = TreeProfile(self, hog=hog)
  File "/home/jl/.local/lib/python3.6/site-packages/pyham/TreeProfile.py", line 34, in __init__
    self.treemap = self.compute_tree_profile_full()
  File "/home/jl/.local/lib/python3.6/site-packages/pyham/TreeProfile.py", line 168, in compute_tree_profile_full
    node_genome = self.ham.get_ancestral_genome_by_namenode.name)
  File "/home/jl/.local/lib/python3.6/site-packages/pyham/ham.py", 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'

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.

Adrian

Hi Biojl,

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

   pip install --upgrade pyham

Log in to answer this question.