Problem with Bio.codonalign.codonseq.cal_dn_ds in Biopython
1
0
Entering edit mode
4.5 years ago

I am trying to calculate the dN/dS ratio for a series of HIV viral sequences. I have two in this example. The first is the standard HXB-2 and the second comes from one of our samples. I managed to read in both as CodonSeqs. However, the function codonseq.cal_dn_ds throws an error that comes from one of its internal functions. I'm not sure how to track it down (I'm really an R programmer rather than a Python whiz).

Here is my code:

import Bio.codonalign as bca
C:\Users\james\Anaconda3\lib\site-packages\Bio\codonalign\__init__.py:27: BiopythonExperimentalWarning: Bio.codonalign is an experimental module which may undergo significant changes prior to its future official release.
  BiopythonExperimentalWarning)

hxbcodon = bca.codonseq.CodonSeq("CAAGAAATGGAGCCAGTAGATCCTAGACTAGAGCCCTGGAAGCATCCAGGAAGTCAGCCTAAAACTGCTTGTACCAATTGCTATTGTAAAAAGTGTTGCTTTCATTGCCAAGTTTGTTTCATAACAAAAGCCTTAGGCATCTCCTATGGCAGGAAGAAGCGGAGACAGCGACGAAGAGCTCATCAGAACAGTCAGACTCATCAAGCTTCTCTATCAAAGCAGTAA")

aalcodon = bca.codonseq.CodonSeq("CAAGAAATGGAGCCAGTAGATCCTAGACTAGAGCCCTGGCAGCATCCAGGGAGTCAGCCTAAGACTCCCTGTAACAATTGCTATTGTAAAAAATGTTGCTATCATTGCCAAATGTGTTTCACAACAAAAGGCTTAGGCATCTCCTATGGCAGGAAGAAGCGGAGACAGCGACGAAGACCTCCTAAGGACAGTCAGCATCATCAAGTTTCTCTATCAAAGCAGTAA")

res_aal = bca.codonseq.cal_dn_ds(hxbcodon, aalcodon, method = "NG86")
Traceback (most recent call last):

  File "<ipython-input-4-98365f54275b>", line 1, in <module>
    res_aal = bca.codonseq.cal_dn_ds(hxbcodon, aalcodon, method = "NG86")

  File "C:\Users\james\Anaconda3\lib\site-packages\Bio\codonalign\codonseq.py", line 365, in cal_dn_ds
    return dnds_func[method](seq1, seq2, k, codon_table)

  File "C:\Users\james\Anaconda3\lib\site-packages\Bio\codonalign\codonseq.py", line 375, in _ng86
    codon_table=codon_table, k=k)

  File "C:\Users\james\Anaconda3\lib\site-packages\Bio\codonalign\codonseq.py", line 438, in _count_site_NG86
    aa = codon_table.forward_table[codon]

Am I doing something wrong? My sequences do get a result when run through the LANL Snap program -- wrong result, but they do calculate.

From Biopython's docs and warning messages, I gather this is an experimental module. Is the error something to do with the code itself?

I appreciate any help this community can give.

Jim Hunter

Biopython dS/dN codonalign • 1.3k views
ADD COMMENT
0
Entering edit mode
4.5 years ago
Joe 21k

Is that the full error you're given? The traceback is useful, but the snippet doesn't actually say what specific error was encountered.

I've tried to run the code too and I get a KeyError - presumably this is what you're getting too?

It appears that the code does not consider stop codons (TAA), which perhaps makes sense for codon bias, I'm not sure.

Your code appears to work for me if you drop the stop codons off each sequence.

ADD COMMENT

Login before adding your answer.

Traffic: 2210 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6