コード例 #1
0
 def test_write_pdb(self):
     """write_pdb should create a file."""
     s = RNAChain('file', MINI_TEMPLATE)
     if os.access(OUTPUT, os.F_OK):
         os.remove(OUTPUT)
     s.write_pdb_file(OUTPUT)
     self.assertTrue(os.access, os.F_OK)
コード例 #2
0
 def test_sort_residues(self):
     m = RNAChain('file', MINI_TEMPLATE)  #residues_mixed.ent')
     m.sort_residues()
     residues = []
     for resi in m:
         residues.append(resi.id[1])
     residues_copy = residues[:]
     residues_copy.sort()
     self.assertEqual(residues, residues_copy)
コード例 #3
0
    def test_PDB_file_with_negative_numbering(self):
        """Checks whether the order of residues with negative NRs is correct"""
        # ...because this was the major problem with negative numbering...
        # ...that ModeRNA read residues in a wrong order!
        s = RNAChain('file', NEG_NUM_PDB, 'E')
        self.assertEqual(s.get_sequence().seq_with_modifications, \
        'GGCUGCCUGGGUCCGCCUUGAGUGCCCGGGUGAGAAGCAUGAUCCCGGGUAAUUAUGGCGGACCCACA')

        self.assertEqual(s.get_sequence().seq_without_modifications, \
        'GGCUGCCUGGGUCCGCCUUGAGUGCCCGGGUGAGAAGCAUGAUCCCGGGUAAUUAUGGCGGACCCACA')
コード例 #4
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'))
コード例 #5
0
 def test_load_iter(self):
     """Should load PDB files and iterate over all residues."""
     s = RNAChain('file', MINI_TEMPLATE)
     i = 0
     for resi in s:
         i += 1
     self.assertEqual(i, 15)
コード例 #6
0
    def test_write_load_sanity(self):
        """After re-reading written file, there should be the same residues."""
        s = RNAChain('file', MINI_TEMPLATE)
        if os.access(OUTPUT, os.F_OK):
            os.remove(OUTPUT)
        s.write_pdb_file(OUTPUT)
        t = RNAChain('file', OUTPUT)
        i = 0
        while i < 15:
            i += 1
            self.assertEqual(s[str(i)].id[1], t[str(i)].id[1])
            self.assertEqual(s[str(i)].long_abbrev, t[str(i)].long_abbrev)

        s_atoms = sum([len(r) for r in s])
        t_atoms = sum([len(r) for r in t])
        self.assertEqual(s_atoms, t_atoms)
コード例 #7
0
 def test_getitem_slice(self):
     """Residues should be accessible by slice."""
     s = RNAChain('file', MINI_TEMPLATE)
     struc_slice = s['2':'5']
     self.assertEqual(len(struc_slice), 4)
     self.assertEqual(struc_slice[0].identifier, '2')
     self.assertEqual(struc_slice[3].identifier, '5')
コード例 #8
0
 def test_iterate(self):
     """Iteration over RNAResidues with correct numbers."""
     s = RNAChain('file', MINI_TEMPLATE)
     i = 1
     for resi in s:
         self.assertTrue(isinstance(resi, RNAResidue))
         self.assertEqual(resi.id[1], i)
         i += 1
コード例 #9
0
 def test_getitem(self):
     """Residues should be accessible by their number as string."""
     s = RNAChain('file', MINI_TEMPLATE)
     self.assertEqual(s['1'].long_abbrev, 'G')
     self.assertEqual(s['8'].long_abbrev, 'U')
     self.assertEqual(s['9'].long_abbrev, 'A')
     self.assertEqual(s['12'].long_abbrev, 'U')
     self.assertEqual(s['15'].long_abbrev, 'G')
     self.assertRaises(RNAChainError, s.__getitem__, '17')
コード例 #10
0
 def add_op12(self):
     """Adds OP1 OP2 atoms"""
     self.remove_op1_op2()
     phos = RNAChain('file', DATA_PATH + 'phosphate_group.pdb')['1']
     #TODO: replace by Bio.PDB --> faster
     mobile = [phos['OP3'], phos['P'], phos["O5'"]]
     fixed = [self.r1["O3'"], self.r2['P'], self.r2["O5'"]]
     s = ModernaSuperimposer(fixed, mobile, phos.child_list)
     self.r2.add(phos['OP1'])
     self.r2.add(phos['OP2'])
コード例 #11
0
 def test_1ehz(self):
     """Everything should work for a more complicated structure."""
     m = RNAChain('file', RNA_1EHZ)
     # atom count
     self.assertEqual(len(m), 76)
     # write
     if os.access(OUTPUT, os.F_OK): os.remove(OUTPUT)
     m.write_pdb_file(OUTPUT)
     self.assertTrue(os.access(OUTPUT, os.F_OK))
     # reload
     n = RNAChain('file', OUTPUT)
     self.assertEqual(len(n), 76)
     # check iter
     res = [r for r in n]
     self.assertEqual(len(res), 76)
     # check residues
     self.assertEqual(n['1'].long_abbrev, 'G')
     self.assertEqual(n['8'].long_abbrev, 'U')
     self.assertEqual(n['10'].long_abbrev, 'm2G')
     self.assertEqual(n['76'].long_abbrev, 'A')
     self.assertEqual(n['16'].long_abbrev, 'D')
     self.assertRaises(RNAChainError, n.__getitem__, '77')
コード例 #12
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"))
コード例 #13
0
 def test_getitem_slice_with_letters(self):
     """Residues should be accessible by slice."""
     s = RNAChain('file', BAD_LOOP_INSERTION)
     struc_slice = s['944':'961']
     self.assertEqual(len(struc_slice), 9)
     self.assertRaises(RNAChainError, s.__getitem__, slice('0', '961'))
コード例 #14
0
 def test_len(self):
     """should return correct number of residues."""
     s = RNAChain('file', MINI_TEMPLATE)
     self.assertEqual(len(s), 15)
コード例 #15
0
 def test_get_sequence(self):
     s = RNAChain('file', MINI_TEMPLATE)
     seq = s.get_sequence()
     self.assertEqual(seq, Sequence("GCGGAUUUALCUCAG"))
コード例 #16
0
 def test_get_sequence_with_hydromods(self):
     """Modifications with hydrogens should be recognized."""
     s = RNAChain('file', MOD_WITH_HYDROGENS, 'B')
     seq = s.get_sequence()
     self.assertEqual(seq, Sequence("UPA"))
コード例 #17
0
 def test_true(self):
     """Should always be true."""
     s = RNAChain()
     self.assertTrue(s)
コード例 #18
0
 def test_init_residues(self):
     struc = PDBParser().get_structure('test', MINI_TEMPLATE)
     s = RNAChain('residues',
                  struc[0]['A'].child_list,
                  seq=Sequence("GCGGAUUUALCUCAG"))
     self.assertEqual(s.get_sequence(), Sequence("GCGGAUUUALCUCAG"))
コード例 #19
0
 def test_init_chain(self):
     struc = PDBParser().get_structure('test', MINI_TEMPLATE)
     s = RNAChain('chain', struc[0]['A'], seq=Sequence("GCGGAUUUALCUCAG"))
     self.assertEqual(s.get_sequence(), Sequence("GCGGAUUUALCUCAG"))
コード例 #20
0
 def test_init_empty(self):
     """Empty chain can be initialized."""
     s = RNAChain()
コード例 #21
0
 def test_fast(self):
     for i in range(10):
         s = Sequence(
             'GCGGAUUUALCUCAGDDGGGAGAGCRCCAGABU#AAYAP?UGGAG7UC?UGUGTPCG"UCCACAGAAUUCGCACCA'
         )
         m = RNAChain('file', RNA_1EHZ, seq=s)
コード例 #22
0
 def test_slow(self):
     for i in range(10):
         m = RNAChain('file', RNA_1EHZ)
コード例 #23
0
 def test_getitem_number(self):
     """Calling getitem with a number gives an error."""
     s = RNAChain('file', MINI_TEMPLATE)
     self.assertRaises(RNAChainError, s.__getitem__, 1)
コード例 #24
0
 def test_last_resi(self):
     """Should return firs residue"""
     s = RNAChain('file', MINI_TEMPLATE)
     self.assertEqual(s.last_resi.identifier, '15')
コード例 #25
0
 def test_ignore_empty_residues(self):
     """Check whether residues with only one H are read and written."""
     s = RNAChain('file', H_ONLY, ' ')
     self.assertEqual(len(s), 0)