def getSequence(self, twobit): """ return sequence of Gtf object's feature given a bx seq twobit object""" sequence='' try: sequence = twobit[self.seqname][self.start:self.end] sequence=sequence.upper() except: sys.stderr.write("Unable to fetch the sequence\n") if self.strand == '-': return codonTable.reverse_complement(sequence) return sequence
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