예제 #1
0
        for cur_record in SeqIO.parse(handle, "fasta"):
            codon_position = 0
            codon_freq_sequence = str(cur_record.seq).strip().split("@")
            for codon_freq in codon_freq_sequence:
                if codon_freq != "":
                    codon = CODON_LABELS[codon_position]
                    if codon in self.codon_count:
                        self.codon_count[codon] += int(codon_freq)
                    else:
                        pass  #raise TypeError("illegal codon %s in gene: %s" % (codon, cur_record.id))
                    codon_position += 1


#Add this method to CAI class
CAI._count_codons2 = MethodType(_count_codons2, CAI)
CAI._count_codons3 = MethodType(_count_codons3, CAI)


def header_matrix_rcsu(self):
    tmp_header = []
    tmp_header.append("Name")
    for aa in SynonymousCodons:
        codons = SynonymousCodons[aa]
        for codon in codons:
            #first create header for all codons
            tmp_header.append(codon)
    print '\t'.join(tmp_header)


def generate_matrix_rcsu(self, fasta_file):
    """