コード例 #1
0
 def test_adjust_target_seq(self):
     """Gaps inserted in target for extra _ in template."""
     modified = Sequence("GCG7APU_UALCYC.G")
     expected  = 'GCG7A----PU_UALCUC.G'
     a = AlignmentMatcher(self.ali)
     a.fix_template_seq(modified)
     self.assertEqual(self.ali.aligned_target_seq, Sequence("ACUGUGAYUA[-UACCU#PG"))
コード例 #2
0
 def test_missing_phosphates2(self):
     """Messy residues with missing phosphates are not delted."""
     st2 = ModernaStructure('file',  MISSING_PHOSPHATES2)
     pc = PdbController(st2)
     self.assertEqual(st2.get_sequence(), Sequence('C_C_G_A_C_C_U_U_C_G_G_C_C_A_C_C_U_G'))
     pc.clean_structure()
     self.assertEqual(st2.get_sequence(), Sequence('CCGACCUUCGGCCACC_UG'))
コード例 #3
0
 def test_equal_unmodified(self):
     """unmodified sequences should be comparable."""
     s1 = Sequence(self.normal)
     s2 = Sequence(self.normal)
     s3 = Sequence(self.longer)
     self.assertEqual(s1,s2)
     self.assertNotEqual(s1,s3)
コード例 #4
0
 def test_attributes(self):
     """object attributes are set up correctly."""
     f1 = ModernaFragment53(self.s1,
                            anchor5=self.m['10'],
                            anchor3=self.m['13'])
     self.assertEqual(len(f1.struc), 4)
     self.assertEqual(f1.anchor5.fixed_resi, self.m['10'])
     self.assertEqual(f1.anchor3.fixed_resi, self.m['13'])
     self.assertEqual(f1.struc.get_sequence(), Sequence("GCGG"))
     self.assertTrue(str(f1))
     # anchor residues
     self.assertEqual(len(f1.anchor_residues), 2)
     self.assertEqual(f1.anchor_residues[0].mobile_resi.identifier, '1')
     self.assertEqual(f1.anchor_residues[1].mobile_resi.identifier, '4')
     f1.prepare_anchor_residues()
     self.assertEqual(f1.anchor_residues[0].mobile_resi.identifier, '1')
     self.assertEqual(f1.anchor_residues[1].mobile_resi.identifier, '4')
     # non-anchors
     self.assertEqual(len(f1.nonanchor_residues), 2)
     # second example
     f2 = ModernaFragment53(self.s2,
                            anchor5=self.m['1'],
                            anchor3=self.m['4'],
                            new_sequence=Sequence('GL'))
     self.assertEqual(len(f2.struc), 4)
     self.assertEqual(f2.struc.get_sequence(), Sequence("GCGG"))
     self.assertEqual(f2.new_sequence, Sequence("GL"))
コード例 #5
0
 def test_ligand_removal(self):
     """Should remove RNA ligand from 3FU2 when there is no ribose and phosphate group."""
     st2 = ModernaStructure('file',  PDB_WITH_LIGAND)
     pc2 = PdbController(st2)
     self.assertEqual(st2.get_sequence(), Sequence('AGAGGUUCUAG_._CACCCUCUAUAAAAAACUAA_x_._._._._._._._._._._._._.'))
     pc2.clean_structure()
     self.assertEqual(st2.get_sequence(), Sequence('AGAGGUUCUAG_CACCCUCUAUAAAAAACUAA'))
コード例 #6
0
 def create_hit_from_line(self, line):
     """Creates a LirHit object."""
     lir_hit = LirHit(
         query=self.query,
         fr_length=int(line[0]),
         structure=line[1],
         chain=line[2],
         preceding_resi=line[3],
         following_resi=line[4],
         sequence=Sequence(line[5]),
         sequence_anchor=Sequence(line[6]),
         secstruc=line[7],
         x=0.0,  #float(line[7]),
         y=0.0,  #float(line[8]),
         dist_anchor=0.0,  #float(line[9]),
         beta=0.0,  #float(line[10]),
         gamma=0.0,  #float(line[11]), 
         omega5=0.0,  #float(line[12]), 
         omega3=0.0,  #float(line[13])
         P_dist=float(line[8]),
         O5p_dist=float(line[9]),
         C5p_dist=float(line[10]),
         C4p_dist=float(line[11]),
         C3p_dist=float(line[12]),
         O3p_dist=float(line[13]),
         O2p_dist=float(line[14]),
         C1p_dist=float(line[15]),
         N_dist=float(line[16]))
     return lir_hit
コード例 #7
0
 def test_validate_seq(self):
     seq_str = "AGCU:PY_7"
     seq = Sequence(seq_str)
     self.assertEqual(validate_seq(seq), seq)
     self.assertEqual(validate_seq(seq_str), seq)
     self.assertEqual(validate_seq(''), Sequence(''))
     self.assertRaises(ParameterError, validate_seq, 12345)
コード例 #8
0
 def test_fill_doublegap(self):
     """Should insert fragments into correct sites."""
     # prepare model
     t = Template(DOUBLEGAP, 'file', 'A')
     m = RnaModel()
     for r in t:
         m.copy_residue(r)
     # insert first fragment
     struc = ModernaStructure('file', FRAGMENT1)
     f1 = ModernaFragment53(struc, anchor5=m['20'], anchor3=m['24'], \
         new_sequence=Sequence('AUA'), keep=keep_first_last)
     m.insert_fragment(f1)
     resids = [r.identifier for r in m]
     expected_resids1 = [
         '18', '19', '20', '21', '21A', '23', '24', '27', '28', '29', '30',
         '31', '32', '33', '34', '35'
     ]
     self.assertEqual(resids, expected_resids1)
     # insert second fragment
     struc = ModernaStructure('file', FRAGMENT2)
     f2 = ModernaFragment53(struc, anchor5=m['23'], anchor3=m['28'], \
         new_sequence=Sequence('AUUA'), keep=keep_first_last)
     m.insert_fragment(f2)
     resids = [r.identifier for r in m]
     expected_resids2 = [
         '18', '19', '20', '21', '21A', '23', '24', '24A', '24B', '27',
         '28', '29', '30', '31', '32', '33', '34', '35'
     ]
     self.assertEqual(resids, expected_resids2)
コード例 #9
0
 def test_load_alignment(self):
     """Return alignment loaded from fasta file."""
     a = load_alignment(MINI_ALIGNMENT)
     self.assertTrue(isinstance(a, RNAAlignment))
     self.assertEqual(a.aligned_template_seq,
                      Sequence('GCGGA----UUUALCUCAG'))
     self.assertEqual(a.aligned_target_seq, Sequence('ACUGUGAYUA[UACCU#PG'))
コード例 #10
0
 def setUp(self):
     """
     fragment attached at 5' end of model.
     """
     self.m = RnaModel(data_type='file',data=MINI_TEMPLATE, seq=Sequence("GCGGAUUUALCUCAG"))
     self.s1 = ModernaStructure('file', SMALL_FRAGMENT, seq=Sequence("GCGG"))
     self.s2 = ModernaStructure('file',SMALL_FRAGMENT, seq=Sequence("GCGG"))
コード例 #11
0
ファイル: test_search_lir.py プロジェクト: lenarother/moderna
 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)
コード例 #12
0
ファイル: test_helix.py プロジェクト: lenarother/moderna
 def test_insertion(self):
     """Insert helical fragment into a model."""
     frag = self.hfb.build_fragment(anchor5=self.rna['30'], anchor3=self.rna['40'], \
                                    sequence=Sequence('GGG_CCC'), model=self.rna)
     self.rna.insert_fragment(frag)
     self.assertEqual(self.rna.get_sequence(),
                      Sequence('CUGGGGCCUQUC/CGCCCC'))
     self.assertEqual(self.rna.get_secstruc(), '..(((((.......)))))')
コード例 #13
0
 def test_init_with_sequence(self):
     """Allows to skip sequence recognition"""
     s = RNAChain('file', MINI_TEMPLATE, seq=Sequence("GCGGAUUUALCUCAG"))
     self.assertEqual(s.get_sequence(), Sequence("GCGGAUUUALCUCAG"))
     # wrong sequence should also be applied
     #TODO: check whether this is OK
     s = RNAChain('file', MINI_TEMPLATE, seq=Sequence("UUULLYYDDAAGAGA"))
     self.assertEqual(s.get_sequence(), Sequence("UUULLYYDDAAGAGA"))
コード例 #14
0
 def test_apply_sequence_modified(self):
     """Applying a sequence with modifications should work."""
     f2 = ModernaFragment(self.s2, new_sequence=Sequence('GCLG'))
     f2.apply_seq()
     self.assertEqual(self.s2.get_sequence(),Sequence("GCLG"))
     modfrag = ModernaFragment(self.s3, new_sequence=Sequence('GL7L7L7ULL7L7AG'))
     modfrag.apply_seq()
     self.assertEqual(self.s3.get_sequence(), Sequence('GL7L7L7ULL7L7AG'))
コード例 #15
0
 def test_init(self):
     """Attributes of seq should work."""
     s = Sequence(self.normal)
     self.assertEqual(s.seq_with_modifications,'AGCU')
     self.assertEqual(s.seq_without_modifications,'AGCU')
     s = Sequence(self.modified)
     self.assertEqual(s.seq_with_modifications,'CCCCDDDGGG')
     self.assertEqual(s.seq_without_modifications,'CCCCUUUGGG')
コード例 #16
0
 def test_special_chars(self):
     """Special characters like gap symbols should work."""
     # gap and unknown symbols
     s = Sequence("._-")
     self.assertEqual(s.seq_with_modifications, "._-")
     # wildcard bases
     s = Sequence("H;<N")
     self.assertEqual(s.seq_with_modifications, "H;<N")
コード例 #17
0
 def test_fix_template_seq(self):
     """Fix template sequence"""
     modified = Sequence("GCG7APU_UALCYC.G")
     expected  = 'GCG7A----PU_UALCUC.G'
     a = AlignmentMatcher(self.ali)
     a.fix_template_seq(modified)
     self.assertEqual(self.ali.template_seq, Sequence(expected.replace('-', '')))
     self.assertEqual(self.ali.aligned_template_seq, Sequence(expected))
コード例 #18
0
 def test_insert(self):
     mf = ModernaFragmentStrand(anchor=self.rna['4'],
                                identifier='20',
                                new_sequence=Sequence('C'))
     self.rna.insert_fragment(mf)
     self.assertEqual(self.rna.get_sequence(),
                      Sequence('GCGGAUUUALCUCAG_C'))
     self.assertEqual(self.rna.get_secstruc(), '...(...........)')
コード例 #19
0
 def test_attributes(self):
     """object attributes should have been set up correctly."""
     f1 = ModernaFragment(self.s1)
     f2 = ModernaFragment(self.s2, new_sequence=Sequence('GCLG'))
     modfrag = ModernaFragment(self.s3, new_sequence=Sequence('GL7L7L7ULL7L7AG'))
     self.assertEqual(len(modfrag.struc), 15)
     self.assertEqual(f1.struc.get_sequence(),Sequence("GCGG"))
     self.assertEqual(f2.struc.get_sequence(),Sequence("GCGG"))
     self.assertTrue(str(f1))
コード例 #20
0
 def remove_positions(self, seq, to_remove, keep):
     """Removes some positions from a Sequence"""
     for pos in to_remove:
         for k in keep:
             if k >= pos and len(seq) > k + 1:
                 seq = Sequence(seq[:k] + [seq[k + 1], seq[k]] +
                                seq[k + 2:])
         seq = Sequence(seq[:pos] + seq[pos + 1:])
     return seq
コード例 #21
0
 def test_add_continuous_exact(self):
     """Model sequence should change accordingly."""
     f2 = ModernaFragment53(self.s2,
                            anchor5=self.m['1'],
                            anchor3=self.m['4'],
                            new_sequence=Sequence('GL'))
     self.m.insert_fragment(f2)
     self.assertEqual(self.m.get_sequence(), Sequence("GGLGAUUUALCUCAG"))
     self.assertAlmostEqual(f2.rmsd, 0.000, 2)
コード例 #22
0
 def test_AMP_detection_and_removal(self):
     """Should detect AMP in the structure and remove it while cleaning."""
     st4 = ModernaStructure('file',  PDB_WITH_AMP)
     self.assertEqual(st4.get_sequence(), Sequence('GGGAAGGGAAGAAACUGCGGCUUCGGCCGGCUUCCC_H'))
     pc4 = PdbController(st4)
     self.assertEqual(len(pc4.rna_ligand), 1)
     pc4.clean_structure()
     self.assertEqual(len(pc4.rna_ligand), 0)
     self.assertEqual(st4.get_sequence(), Sequence('GGGAAGGGAAGAAACUGCGGCUUCGGCCGGCUUCCC'))
コード例 #23
0
 def test_equal_modified(self):
     """modified sequences should NOT match."""
     s1 = Sequence(self.modified)
     s2 = Sequence(self.modified)
     s3 = Sequence(self.unmodified)
     s4 = Sequence(self.different)
     self.assertEqual(s1,s2)
     self.assertNotEqual(s1,s3)
     self.assertNotEqual(s1,s4)
コード例 #24
0
 def set_aligned_sequences(self, char_tuples):
     """Resets the sequences in the RNAAlignment object."""
     transposed = map(list, zip(*char_tuples))
     target = Sequence(transposed[0])
     template = Sequence(transposed[1])
     if len(target) != len(template):
         raise AlignmentError(
             "Error correcting alignment; lenghts differ:\n%s\%s" %
             (str(target), str(template)))
     self.align.set_aligned_sequences(target, template)
コード例 #25
0
 def test_missing_phosphates(self):
     """residues with missing phosphates are fixed."""
     st2 = ModernaStructure('file', MISSING_PHOSPHATES)
     pc = PdbController(st2)
     self.assertEqual(len(pc.P_missing), 2)
     self.assertEqual(st2.get_sequence(), Sequence('GCG_GAUUUALCUCAG'))
     pc.clean_structure()
     self.assertEqual(st2.get_sequence(), Sequence('GCG_GAUUUALCUCAG'))
     pc = PdbController(st2)
     self.assertEqual(len(pc.P_missing), 0)
コード例 #26
0
 def test_apply_sequence(self):
     """Should change the sequence of the entire fragment."""
     frag = ModernaFragment(self.s1, new_sequence=Sequence('AAAA'))
     frag.apply_seq()
     self.assertEqual(self.s1.get_sequence(), Sequence('AAAA'))
     # test lengths that do not fit
     frag = ModernaFragment(self.s2, new_sequence=Sequence('AAA'))
     self.assertRaises(ModernaFragmentError, frag.apply_seq)
     frag = ModernaFragment(self.s2, new_sequence=Sequence('AAAAA'))
     self.assertRaises(ModernaFragmentError, frag.apply_seq)
コード例 #27
0
 def setUp(self):
     self.m = RnaModel(data_type='file',
                       data=MINI_TEMPLATE,
                       seq=Sequence("GCGGAUUUALCUCAG"))
     self.s1 = ModernaStructure('file',
                                SMALL_FRAGMENT,
                                seq=Sequence("GCGG"))
     self.s2 = ModernaStructure('file',
                                SMALL_FRAGMENT,
                                seq=Sequence("GCGG"))
コード例 #28
0
 def setUp(self):
     self.s1 = ModernaStructure('file',
                                SMALL_FRAGMENT,
                                seq=Sequence("GCGG"))
     self.s2 = ModernaStructure('file',
                                SMALL_FRAGMENT,
                                seq=Sequence("GCGG"))
     self.s3 = ModernaStructure('file',
                                MINI_TEMPLATE,
                                seq=Sequence("GCGGAUUUALCUCAG"))
コード例 #29
0
 def test_insert(self):
     """Inserts 2D fragment into a model."""
     mf = ModernaFragment2D(self.motif, \
                     anchor5=self.rna['30'], anchor3=self.rna['40'], \
                     anchor5_upper=self.rna['31'], anchor3_upper=self.rna['39'], \
                     frag5_upper=self.motif['196'], frag3_upper=self.motif['217'], \
                     new_sequence=Sequence('C'), \
                     model=self.rna)
     self.rna.insert_fragment(mf)
     self.assertEqual(self.rna.get_sequence(), Sequence('CUGCCUQUC/CGCC'))
     self.assertEqual(self.rna.get_secstruc(), '..((.......).)')
コード例 #30
0
 def test_get_region(self):
     """Checks whether a region can be extracted from structure"""
     s = RNAChain('file', MINI_TEMPLATE)
     s2 = s.get_region('3', '6')
     self.assertTrue(isinstance(s2, RNAChain))
     self.assertEqual(len(s2.moderna_residues), 4)
     self.assertEqual(s2.get_sequence(), Sequence('GGAU'))
     s3 = s.get_region('3')
     self.assertEqual(s3.get_sequence(), Sequence('GGAUUUALCUCAG'))
     s4 = s.get_region(stop_id='6')
     self.assertEqual(s4.get_sequence(), Sequence('GCGGAU'))