Source code

Download source archive ↓

upstream-extended/community/tools/biopython/codon_count.py

1#!/usr/bin/env python
2"""
3Input: DNA Fasta File
4Output: gezaehlte Codons ueber das gesamte File, nicht jedes einzelne ORF
5Anika Erxleben
6"""
7import sys
8
9import Bio.SeqUtils.CodonUsage as cu
10
11"""
12strepto_orf2dna_out_plus1: anika/Annotation/data/strepto_orf2dna_out_plus1
13codon_count: anika/Annotation/data/codon_count2  outputfile
14"""
15
16
17def __main__():
18
19    if len(sys.argv) >= 3:
20        orf2dna_out = sys.argv[1]
21        codon_count = open(sys.argv[2], "w")
22
23    else:
24        print("da fehlt was da oben")
25        sys.exit()
26
27    a = cu.CodonAdaptationIndex()
28    a.generate_index(orf2dna_out)
29
30    # for record in Bio.SeqIO.parse(open(orf2dna_out), "fasta"):
31    #    print record.seq
32
33    for key, value in a.codon_count.items():
34        codon_count.write(key + "\t" + str(value) + "\n")
35
36    codon_count.close()
37
38
39if __name__ == "__main__":
40    __main__()