Back to index

python-biopython  1.60
test_CodonUsage.py
Go to the documentation of this file.
00001 from Bio.SeqUtils import CodonUsage
00002 import os
00003 import sys
00004 
00005 # first make a CAI object
00006 X = CodonUsage.CodonAdaptationIndex()
00007 # now generate an index from a file
00008 if os.path.exists("./CodonUsage/HighlyExpressedGenes.txt"):
00009     X.generate_index("./CodonUsage/HighlyExpressedGenes.txt")
00010 elif os.path.exists("./Tests/CodonUsage/HighlyExpressedGenes.txt"):
00011     X.generate_index("./Tests/CodonUsage/HighlyExpressedGenes.txt")
00012 else:
00013     print "Cannot find the file HighlyExpressedGene.txt\nMake sure you run the tests from within the Tests folder"
00014     sys.exit()
00015 # alternatively you could use any predefined dictionary like this:
00016 # from CaiIndices import SharpIndex # you can save your dictionary in this file.
00017 # X.SetCaiIndex(SharpIndex)
00018 
00019 print "The current index used:"
00020 X.print_index()
00021 
00022 print "-" * 60
00023 print "codon adaptation index for test gene: %.2f" % X.cai_for_gene("ATGAAACGCATTAGCACCACCATTACCACCACCATCACCATTACCACAGGTAACGGTGCGGGCTGA")