Exemple #1
0
    def check(self, sequence, expected, dbParams=None):
        """
        Check that, given a read with the sequence in C{sequence}, a
        C{THAlphaHelix} finder finds all the helices given in C{expected}.

        @param sequence: A C{str} of amino acids.
        @param expected: A C{str}, consisting of '-' and 'H' characters, where
            spans of 'H' characters indicate where helices are expected to be
            found in C{sequence}. (The non-'H' characters do not have to be
            hyphens, use whatever you like that is not an 'H'.)
        @param dbParams: A C{DatabaseParameters} instance or C{None} if default
            parameters should be used. This can be used to pass a non-default
            featureLengthBase.
        """
        self.assertEqual(len(sequence), len(expected))
        read = AARead('id', sequence)
        finder = THAlphaHelix(dbParams)
        featureLengthBase = finder._dbParams.featureLengthBase
        expectedHelices = []
        for symbol, start, end in stringSpans(expected):
            if symbol == 'H':
                length = end - start
                detail = scaleLog(length, featureLengthBase)
                expectedHelices.append(
                    Landmark('THAlphaHelix', 'THA', start, length, detail))
        self.assertEqual(expectedHelices, list(finder.find(read)))
Exemple #2
0
 def testAllLengthOne(self):
     """
     A string whose spans are all of length one should give the expected
     result.
     """
     self.assertEqual([('a', 0, 1), ('b', 1, 2), ('c', 2, 3), ('d', 3, 4)],
                      list(stringSpans('abcd')))
Exemple #3
0
    def find(self, read):
        """
        Find landmarks based on known secondary structures.

        @param read: An instance of C{dark.reads.SSAARead}.
        @return: A generator that yields C{Landmark} instances.
        """
        for letter, start, end in stringSpans(read.structure):
            if letter == self.STRUCTURE_LETTER:
                yield Landmark(self.NAME, self.SYMBOL, start, end - start)
Exemple #4
0
 def testTwoSpans(self):
     """
     A string with two spans should give the expected result.
     """
     self.assertEqual([('a', 0, 4), ('b', 4, 6)],
                      list(stringSpans('aaaabb')))
Exemple #5
0
 def testIdentical(self):
     """
     A string consists of just one character should give one span.
     """
     self.assertEqual([('a', 0, 4)], list(stringSpans('aaaa')))
Exemple #6
0
 def testEmpty(self):
     """
     An empty string has no spans.
     """
     self.assertEqual([], list(stringSpans('')))