def findORFs(kozakfp): for read in reads: try: for translation in translations(read): for orf in translation.ORFs(allowOpenORFs): # Check the length requirements, if any. if ((minORFLength is None or len(orf) >= minORFLength) and (maxORFLength is None or len(orf) <= maxORFLength)): if kozakOnly: for kozakread in findKozakConsensus(read): start = orf.start * 3 if (start + 1 <= kozakread.stop <= start + 3): print(orf.toString('fasta'), end='') else: print(orf.toString('fasta'), end='') if kozakfp: for kozakread in findKozakConsensus(read): start = orf.start * 3 if (start + 1 <= kozakread.stop <= start + 3): writeToKozakOut(kozakread, kozakfp) except TranslationError as error: print('Could not translate read %r sequence %r (%s).' % (read.id, read.sequence, error), file=sys.stderr) if not aa: print('Did you forget to run ' '%s with "--readClass AARead"?' % (basename(sys.argv[0])), file=sys.stderr) sys.exit(1)
def testKozakConsensusAtEndPart(self): """ In a given sequence without a Kozak consensus, the output should be as expected. """ read = DNARead('id', 'AAAAAAATTGCCGCCATG') self.assertEqual([], list(findKozakConsensus(read)))
def testKozakConsensusAtEnd(self): """ In a given sequence without a Kozak consensus, the output should be as expected. """ read = DNARead('id', 'AAAAAAATTGCCGCCATGG') expectedKozakRead = DNAKozakRead(read, 9, 19, 100.0) (result, ) = list(findKozakConsensus(read)) self.assertEqual(expectedKozakRead, result)
def testOneKozakConsensus(self): """ In a given sequence with an exact Kozak consensus sequence, the offset and quality percentage should be as expected. """ read = DNARead('id', 'ATTGCCGCCATGGGGG') expectedKozakRead = DNAKozakRead(read, 3, 13, 100.0) (result, ) = list(findKozakConsensus(read)) self.assertEqual(expectedKozakRead, result)
def testKozakConsensusAtEnd(self): """ In a given sequence without a Kozak consensus, the output should be as expected. """ read = DNARead('id', 'AAAAAAATTGCCGCCATGG') expectedKozakRead = DNAKozakRead(read, 9, 19, 100.0) (result,) = list(findKozakConsensus(read)) self.assertEqual(expectedKozakRead, result)
def testOneKozakConsensus(self): """ In a given sequence with an exact Kozak consensus sequence, the offset and quality percentage should be as expected. """ read = DNARead('id', 'ATTGCCGCCATGGGGG') expectedKozakRead = DNAKozakRead(read, 3, 13, 100.0) (result,) = list(findKozakConsensus(read)) self.assertEqual(expectedKozakRead, result)
def testFindTwoKozakConsensi(self): """ In a given sequence with two Kozak consensuses with different offsets and qualities, the output should be as expected. """ read = DNARead('id', 'ATTGCCGCCATGGGGGGCCATGG') expectedRead1 = DNARead('id', 'ATTGCCGCCATGGGGGGCCATGG') expectedRead2 = DNARead('id', 'ATTGCCGCCATGGGGGGCCATGG') expectedKozakRead1 = DNAKozakRead(expectedRead1, 3, 13, 100.0) expectedKozakRead2 = DNAKozakRead(expectedRead2, 13, 23, 60.0) self.assertEqual([expectedKozakRead1, expectedKozakRead2], list(findKozakConsensus(read)))
def testShortSequence(self): """ If a 4 nt long sequence is given, no Kozak sequence should be found. """ read = DNARead('id', 'ATTG') self.assertEqual([], list(findKozakConsensus(read)))
def testNoSequence(self): """ If no sequence is given, no Kozak sequence should be found. """ read = DNARead('id', '') self.assertEqual([], list(findKozakConsensus(read)))