Ejemplo n.º 1
0
 def testFindWithMarginZeroAndMarginPresentBothSides(self):
     """
     A finder must find features when a zero margin is specified and there
     is a margin on both sides.
     """
     read = AARead('id', 'MFRRRFRRRFM')
     landmark = AlphaHelix()
     result = list(landmark.findWithMargin(read, 0))
     self.assertEqual([Landmark('AlphaHelix', 'A', 1, 9, 2)], result)
Ejemplo n.º 2
0
 def testFindWithMarginInsufficientMarginLeft(self):
     """
     A finder must not return a feature that has insufficient margin
     to the left.
     """
     read = AARead('id', 'MMFRRRFRRRF')
     landmark = AlphaHelix()
     result = list(landmark.findWithMargin(read, 2))
     self.assertEqual([], result)
Ejemplo n.º 3
0
 def testFindWithMarginZeroAndNoMarginPresent(self):
     """
     A finder must find features when a zero margin is specified and there
     is no margin present.
     """
     read = AARead('id', 'FRRRFRRRF')
     landmark = AlphaHelix()
     result = list(landmark.findWithMargin(read, 0))
     self.assertEqual([Landmark('AlphaHelix', 'A', 0, 9, 2)], result)
Ejemplo n.º 4
0
 def testFindWithMarginSufficientMargin(self):
     """
     A finder must return a feature that has sufficient margin on both
     sides.
     """
     read = AARead('id', 'MMFRRRFRRRFMM')
     landmark = AlphaHelix()
     result = list(landmark.findWithMargin(read, 2))
     self.assertEqual([Landmark('AlphaHelix', 'A', 2, 9, 2)], result)
Ejemplo n.º 5
0
 def testNegativeMargin(self):
     """
     If a negative margin is passed to findWithMargin, a ValueError must be
     raised.
     """
     read = AARead('id', 'FRRRFRRRF')
     landmark = AlphaHelix()
     error = '^Margin value \(-1\) is less than zero\.$'
     six.assertRaisesRegex(self, ValueError, error, list,
                           landmark.findWithMargin(read, -1))
Ejemplo n.º 6
0
    def testRestore(self):
        """
        The restore method must produce the same parameter values that were
        present in a DatabaseParameters instance when it is saved.
        """
        dbParams = DatabaseParameters(landmarks=[AlphaHelix, BetaStrand],
                                      trigPoints=[Peaks, Troughs],
                                      distanceBase=3.0,
                                      featureLengthBase=3.9,
                                      limitPerLandmark=10,
                                      maxDistance=77,
                                      minDistance=66,
                                      randomLandmarkDensity=0.1,
                                      randomTrigPointDensity=0.9)
        fp = StringIO()
        dbParams.save(fp)
        fp.seek(0)
        result = DatabaseParameters.restore(fp)

        self.assertEqual([AlphaHelix(), BetaStrand()], result.landmarkFinders)
        self.assertEqual([Peaks(), Troughs()], result.trigPointFinders)
        self.assertEqual(3.0, result.distanceBase)
        self.assertEqual(3.9, result.featureLengthBase)
        self.assertEqual(10, result.limitPerLandmark)
        self.assertEqual(77, result.maxDistance)
        self.assertEqual(66, result.minDistance)
        self.assertEqual(0.1, result.randomLandmarkDensity)
        self.assertEqual(0.9, result.randomTrigPointDensity)
Ejemplo n.º 7
0
 def testNotEqual(self):
     """
     Different finders must not compare equal.
     """
     self.assertNotEqual(AlphaHelix(), BetaStrand())
Ejemplo n.º 8
0
 def testEqual(self):
     """
     Two identical finders must compare equal.
     """
     self.assertEqual(AlphaHelix(), AlphaHelix())