def main(args): """ Use analyzeAlphaHelices to get a collection of alpha helix reads analyzed and print the results. @param args: Command line arguments as returned by the C{argparse} C{parse_args} method. """ if args.pdb: readClass = SSAARead readsClass = SSFastaReads else: readClass = AARead readsClass = FastaReads reads = readsClass(sys.stdin, readClass=readClass, checkAlphabet=0) if args.minSequenceLength: reads = reads.filter(minLength=args.minSequenceLength) analysis = analyzeAlphaHelices(reads) print('Processed %d alpha helices.' % len(reads)) for key in ('length', 'extremaCount', 'initial', 'final', 'consecutivePeaks', 'consecutiveTroughs', 'noExtremaLength'): if analysis[key]: print(analysis[key]) else: print('No values recorded for', key)
def testFourDifferingHelices(self): """ The analysis of four differing alpha helices must be as expected. """ reads = Reads() reads.add(AARead('id1', 'GGFFFRRFFFG')) reads.add(AARead('id2', 'GRRFFFFGGGRRRGRGRGGFFGGG')) reads.add(AARead('id3', 'RRGRRRFFGFFGGGRRR')) reads.add(AARead('id4', 'GGG')) self.assertEqual( { 'length': [11, 24, 17, 3], 'initial': [2, 1, 0], 'final': [1, 3, 0], 'extremaCount': [8, 13, 12, 0], 'consecutivePeaks': [ 3, 3, # id1 4, 2, # id2 4 ], # id3 'consecutiveTroughs': [ 2, # id1 2, 5, # id2 5, 3 ], # id3 'noExtremaLength': [3], # id4 }, analyzeAlphaHelices(reads))
def testResultDictValuesAreStatsInstances(self): """ In the values analysis C{dict} returned by analyzeAlphaHelices, all values must be C{Stats} instances. """ reads = Reads() for value in analyzeAlphaHelices(reads).values(): self.assertIsInstance(value, Stats)
def testNoHelices(self): """ The analysis of an empty set of alpha helices must be as expected. """ reads = Reads() self.assertEqual( { 'length': [], 'initial': [], 'final': [], 'extremaCount': [], 'consecutivePeaks': [], 'consecutiveTroughs': [], 'noExtremaLength': [], }, analyzeAlphaHelices(reads))
def testNoExtrema(self): """ The analysis of a helix with no extrema must be correct. """ reads = Reads() reads.add(AARead('id', 'GG')) self.assertEqual( { 'length': [2], 'initial': [], 'final': [], 'extremaCount': [0], 'consecutivePeaks': [], 'consecutiveTroughs': [], 'noExtremaLength': [2], }, analyzeAlphaHelices(reads))
def testOneHelix(self): """ The analysis of a single alpha helix must be as expected. """ reads = Reads() reads.add(AARead('id', 'F')) self.assertEqual( { 'length': [1], 'initial': [0], 'final': [0], 'extremaCount': [1], 'consecutivePeaks': [1], 'consecutiveTroughs': [], 'noExtremaLength': [], }, analyzeAlphaHelices(reads))
def testTwoDifferingHelices(self): """ The analysis of two differing alpha helices must be as expected. """ reads = Reads() reads.add(AARead('id', 'FG')) reads.add(AARead('id', 'GRR')) self.assertEqual( { 'length': [2, 3], 'initial': [0, 1], 'final': [1, 0], 'extremaCount': [1, 2], 'consecutivePeaks': [1], 'consecutiveTroughs': [2], 'noExtremaLength': [], }, analyzeAlphaHelices(reads))
def testTwoIdenticalHelices(self): """ The analysis of two identical alpha helices must be as expected. """ reads = Reads() reads.add(AARead('id', 'F')) reads.add(AARead('id', 'F')) self.assertEqual( { 'length': [1, 1], 'initial': [0, 0], 'final': [0, 0], 'extremaCount': [1, 1], 'consecutivePeaks': [1, 1], 'consecutiveTroughs': [], 'noExtremaLength': [], }, analyzeAlphaHelices(reads))