def walkCdsFwd(self, twobit): """ given a twobit object generator to walk CDS feature and yield codon, aa & codonStart, codonEnd intervals """ #walk the CDS feature in frame, so adjust the counter variable i if needed i=self.start if self.frame == 1: i=i+1 if self.frame == 2: i= i+2 while (i +3 < self.end): sequence =twobit[self.seqname][i:i+3] sequence=sequence.upper() yield sequence, codonTable.translateCodon(sequence), i, i+3 i=i+3
def walkCdsMinus(self, twobit): """ given a twobit object generator to walk CDS feature and yield codon, aa & codonStart, codonEnd intervals """ #walk the CDS feature in frame, so adjust the counter variable i if needed i=self.end if self.frame == 1: i=i-1 if self.frame == 2: i=i-2 while ( i > self.start+1): sequence=twobit[self.seqname][i-3:i] sequence=sequence.upper() sequence=codonTable.reverse_complement(sequence) yield sequence, codonTable.translateCodon(sequence), i-3, i i=i-3
def walkExonSequence(sequence): while (i < len(sequence) ): yield sequence[i:i+3], codonTable.translateCodon(sequence[i:i+3]) i+=3