File: test_CodonUsage.py

package info (click to toggle)
python-biopython 1.54-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 25,400 kB
  • ctags: 10,975
  • sloc: python: 116,757; xml: 33,167; ansic: 8,622; sql: 1,488; makefile: 147
file content (23 lines) | stat: -rw-r--r-- 931 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from Bio.SeqUtils import CodonUsage
import os
import sys

# first make a CAI object
X = CodonUsage.CodonAdaptationIndex()
# now generate an index from a file
if os.path.exists("./CodonUsage/HighlyExpressedGenes.txt"):
    X.generate_index("./CodonUsage/HighlyExpressedGenes.txt")
elif os.path.exists("./Tests/CodonUsage/HighlyExpressedGenes.txt"):
    X.generate_index("./Tests/CodonUsage/HighlyExpressedGenes.txt")
else:
    print "Cannot find the file HighlyExpressedGene.txt\nMake sure you run the tests from within the Tests folder"
    sys.exit()
# alternatively you could use any predefined dictionary like this:
# from CaiIndices import SharpIndex # you can save your dictionary in this file.
# X.SetCaiIndex(SharpIndex)

print "The current index used:"
X.print_index()

print "-" * 60
print "codon adaptation index for test gene: %.2f" % X.cai_for_gene("ATGAAACGCATTAGCACCACCATTACCACCACCATCACCATTACCACAGGTAACGGTGCGGGCTGA")