Esempio n. 1
0
 def test_find_fragment_candidates(self):
     """Should return a FragmentCandidates instance"""
     lf = FragmentFinder(self.struc['2'], self.struc['6'], Sequence('AGCU'),
                         self.struc, 10)
     cand = lf.find_fragment_candidates()
     self.assertTrue(isinstance(cand, FragmentCandidates))
     self.assertTrue(1 <= len(cand) <= 10)
Esempio n. 2
0
 def test_init(self):
     """FragmentFinder should be initialized with a place to fit in loops"""
     lf = FragmentFinder(self.struc['2'], self.struc['6'], Sequence('AGCU'),
                         self.struc)
     lf = FragmentFinder(self.struc['2'], self.struc['6'], Sequence('AGCU'),
                         self.struc, 10)
     self.assertTrue(1)
Esempio n. 3
0
 def test_find_fragment(self):
     """Should return a ModernaFragment instance with the right sequence"""
     lf = FragmentFinder(self.struc['2'], self.struc['6'], Sequence('AGCU'),
                         self.struc, 10)
     frag = lf.find_fragment()
     frag.fix_backbone()
     self.assertTrue(isinstance(frag, ModernaFragment))
     self.assertEqual(
         frag.struc.get_sequence().seq_with_modifications[1:-1], 'AGCU')
Esempio n. 4
0
 def setUp(self):
     self.struc = ModernaStructure('file', MINI_TEMPLATE)
     lf = FragmentFinder(self.struc['2'],
                         self.struc['6'],
                         Sequence('AGCU'),
                         self.struc,
                         lir_path=TEST_LIR_PATH)
     self.query = lf.get_query()
     self.lc = FragmentCandidates(self.query, lir_db_filename=FRAGMENT_DB)
Esempio n. 5
0
 def test_find_secstruc(self):
     """Secstruc can be used as an optional search criterion"""
     hairpin = ModernaStructure('file', RNA_HAIRPIN, 'D')
     lf = FragmentFinder(hairpin['30'],
                         hairpin['40'],
                         Sequence('CGGGCG'),
                         self.struc,
                         10,
                         secstruc="(....)")
     frag = lf.find_fragment()
     self.assertEqual(frag.struc.get_secstruc(), "((....))")
Esempio n. 6
0
 def test_insert_in_itself(self):
     """Best fragment for LIR structures should come from itself."""
     for length, struc, chain, stem5, stem3, seq in FRAGMENTS_TO_INSERT:
         m = load_model(PATH_TO_LIR_STRUCTURES + struc, chain)
         lf = FragmentFinder(m[stem5], m[stem3], Sequence(seq), m, 2)
         candidates = lf.find_fragment_candidates()
         if len(candidates) > 0:
             best = candidates[0]
             self.assertEqual(best.structure, struc)
             self.assertEqual(best.chain, chain)
             self.assertEqual(best.preceding_residue, stem5)
             self.assertEqual(best.following_residue, stem3)
             self.assertAlmostEqual(best.rmsd, 0.000, 3)
Esempio n. 7
0
 def test_generate_db_contents(self):
     """The generated file should be parseable."""
     # get query
     lf = FragmentFinder(self.struc['2'], self.struc['6'], Sequence('AGCU'),
                         self.struc)
     query = lf.get_query()
     # prepare loop database
     lirdb = MakeLirFile(LIR_STRUCTURES_DIR, CHAIN_LIST)
     lirdb.generate_lir_db()
     lirdb.write_lir_db_to_file(LIR_TEST_FILE)
     # count entries in it
     lc = FragmentCandidates(query, LIR_TEST_FILE)
     lc.parse_lir_database()
     self.assertTrue(len(lc.lir_cache[1]) > 50)
Esempio n. 8
0
    def find_fragment_candidates(
            self,
            res5,
            res3,
            sequence,
            candidates_number=NUMBER_OF_FRAGMENT_CANDIDATES,
            lir_path=PATH_TO_LIR_STRUCTURES,
            secstruc=None):
        # en: candidate_number
        """
        Looks for fragment candidates for missing fragment in a structure.
        Returns list of fragment candidates.

        Arguments:
        - anchor residue on 5' end as a ModernaResidue instance (residue preceding missing fragment)
        - anchor residue on 3' end as a ModernaResidue instance (residue fallowing missing fragment)
        - missing sequence
        """
        fragment_finder = FragmentFinder(res5, res3, sequence, self,
                                         candidates_number, lir_path, secstruc)
        return fragment_finder.find_fragment_candidates(
        )  # FragmentCandidates instance
Esempio n. 9
0
    def insert_best_fragment(self,
                             start,
                             stop,
                             sequence,
                             candidates_number=NUMBER_OF_FRAGMENT_CANDIDATES):
        """
        Makes a LIR search to fill a gap at a given position.
        looks for possible candidates, checks the first ~20 for clashes,
        takes the best, removes anchor residue and inserts it in the model.        

        Arguments:
        - start position as a string (residue identifier)e.g. '3' - this is an identifier of the preceding anchor residue
        - stop position as above - this is an identifier of the fallowing anchor residue
        - fragment sequence as a Sequence object
        - number of fragment candidates.
        """
        log.write_message(
            '\nSearching fragment between residue %s and residue %s.' %
            (str(start), str(stop)))
        fragment_finder = FragmentFinder(self[start], self[stop], sequence,
                                         self, candidates_number)
        best_fragment = fragment_finder.find_fragment()
        log.write_message('\nBest fragment:\n%s' % str(best_fragment))
        self.insert_fragment(best_fragment)
Esempio n. 10
0
 def test_find_zero_length_fragment(self):
     lf = FragmentFinder(self.struc['2'], self.struc['4'], Sequence(''),
                         self.struc, 10)
     frag = lf.find_fragment()
     self.assertEqual(frag.struc.get_sequence(), Sequence('C_G'))
Esempio n. 11
0
 def test_get_query(self):
     """Should generate a LirQuery instance"""
     lf = FragmentFinder(self.struc['2'], self.struc['6'], Sequence('AGCU'),
                         self.struc)
     q = lf.get_query()
     self.assertTrue(isinstance(q, LirQuery))