def test_gather_features(self):
        """Test gather_features() function"""
        def mocked_get_cnc(apo):
            residues = {}
            for i, res in enumerate(
                ('ALA', 'MET', 'GLU', 'ASN', 'PHE', 'GLN', 'LYS', 'VAL', 'GLU',
                 'LYS', 'ILE', 'GLY')):
                residues[(res, i + 1, 'A')] = 42.
            return residues, ('1', '1')

        with utils.temporary_working_directory() as tmpdir:
            shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'pm_XXX.pdb'),
                        'XXX_mdl.pdb')
            shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'XXX_mdlA.sqc'),
                        '.')
            shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'XXX_mdlA.hcs'),
                        '.')
            with utils.mocked_object(bmi_feature_parser, 'get_cnc',
                                     mocked_get_cnc):
                bmi_feature_parser.gather_features('XXX_mdl', ['A'])
            with open('XXX_mdlA.feat') as fh:
                data = fh.readlines()
            self.assertEqual(len(data), 96)
            self.assertEqual(
                data[0][:116],
                'ATOM      1  N   ALA A   1     -17.647  -2.542  37.435  '
                '1.00 25.00           N'
                '\t12.16\t11.0\t42.0\t18.98\t-\t0.17\t0.0\t2.00')
 def test_gather_features(self):
     """Test gather_features() function"""
     def mocked_get_cnc(apo):
         residues = {}
         for i, res in enumerate(('ALA', 'MET', 'GLU', 'ASN', 'PHE', 'GLN',
                                  'LYS', 'VAL', 'GLU', 'LYS', 'ILE', 'GLY')):
             residues[(res, i + 1, 'A')] = 42.
         return residues, ('1', '1')
     with utils.temporary_working_directory() as tmpdir:
         shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'pm_XXX.pdb'),
                     'XXX_mdl.pdb')
         shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'XXX_mdlA.sqc'),
                     '.')
         shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'XXX_mdlA.hcs'),
                     '.')
         with utils.mocked_object(bmi_feature_parser, 'get_cnc',
                                  mocked_get_cnc):
             bmi_feature_parser.gather_features('XXX_mdl', ['A'])
         with open('XXX_mdlA.feat') as fh:
             data = fh.readlines()
         self.assertEqual(len(data), 96)
         self.assertEqual(data[0][:116],
                  'ATOM      1  N   ALA A   1     -17.647  -2.542  37.435  '
                  '1.00 25.00           N'
                  '\t12.16\t11.0\t42.0\t18.98\t-\t0.17\t0.0\t2.00')
Exemple #3
0
    def test_build_model_gaps(self):
        """Test build_model() with gaps"""
        import modeller.automodel

        def mocked_loopmodel_make(self):
            self.loop.outputs.append({
                'failure': None,
                'name': 'input.pdb',
                'Normalized DOPE score': -1.
            })

        with utils.temporary_working_directory() as tmpdir:
            with open('alignment.pir', 'w') as fh:
                fh.write(">P1;XXX\n")
                fh.write("structureX:input.pdb:1:A:2:A::::\n")
                fh.write("A--A*\n")
                fh.write(">P1;xxx_X\n")
                fh.write("sequence:input::::::::\n")
                fh.write("AAAA*\n")
            with open('input.pdb', 'w') as fh:
                fh.write(pdb_line + '\n')
                fh.write(pdb_line[:25] + '2' + pdb_line[26:] + '\n')
            with utils.mocked_object(modeller.automodel.loopmodel, 'make',
                                     mocked_loopmodel_make):
                cleaning.build_model('XXX', ['A'])
            os.unlink('XXX_mdl.pdb')
Exemple #4
0
 def test_main(self):
     """Test complete run of predict"""
     indir = os.path.join(TOPDIR, 'test', 'input')
     with utils.temporary_working_directory():
         shutil.copy(os.path.join(indir, 'XXX.features'), '.')
         shutil.copy(os.path.join(indir, 'XXX_mdl.pdb'), '.')
         with utils.mocked_object(pickle, 'load', mock_pickle_load):
             cryptosite.predict.predict('XXX.features', model='final')
         os.unlink('XXX.pol.pred')
         os.unlink('XXX.pol.pred.pdb')
Exemple #5
0
 def test_main(self):
     """Test complete run of predict"""
     indir = os.path.join(TOPDIR, 'test', 'input')
     with utils.temporary_working_directory() as tmpdir:
         shutil.copy(os.path.join(indir, 'XXX.features'), '.')
         shutil.copy(os.path.join(indir, 'XXX_mdl.pdb'), '.')
         with utils.mocked_object(pickle, 'load', mock_pickle_load):
             cryptosite.predict.predict('XXX.features', model='final')
         os.unlink('XXX.pol.pred')
         os.unlink('XXX.pol.pred.pdb')
 def test_get_cnc_pockets(self):
     """Test get_cnc() parsing of pocket information"""
     with utils.temporary_working_directory() as tmpdir:
         os.mkdir('test_out')
         shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'test_out.pdb'),
                     'test_out')
         shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'test_info.txt'),
                     'test_out')
         with utils.mocked_object(subprocess, 'check_call', mock_check_call):
             res, num = bmi_feature_parser.get_cnc('test')
         self.assertAlmostEqual(res[('ALA', 2, 'A')], 0.0, places=1)
         self.assertAlmostEqual(res[('ALA', 1, 'A')], 0.8, places=1)
 def test_get_cnc_pockets(self):
     """Test get_cnc() parsing of pocket information"""
     with utils.temporary_working_directory() as tmpdir:
         os.mkdir('test_out')
         shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'test_out.pdb'),
                     'test_out')
         shutil.copy(os.path.join(TOPDIR, 'test', 'input', 'test_info.txt'),
                     'test_out')
         with utils.mocked_object(subprocess, 'check_call',
                                  mock_check_call):
             res, num = bmi_feature_parser.get_cnc('test')
         self.assertAlmostEqual(res[('ALA', 2, 'A')], 0.0, places=1)
         self.assertAlmostEqual(res[('ALA', 1, 'A')], 0.8, places=1)
 def test_parse_blast(self):
     """Test parse_blast() function"""
     blast_out = os.path.join(TOPDIR, 'test', 'input', 'XXXA.blast')
     with utils.temporary_working_directory() as tmpdir:
         with utils.mocked_object(cryptosite.seq_conservation, 'ucluster',
                                  mock_ucluster):
             # Should get a ValueError if the sequences don't match
             self.assertRaises(ValueError,
                      cryptosite.seq_conservation.parse_blast,
                      blast_out, 'XXX', 'CC')
             cryptosite.seq_conservation.parse_blast(blast_out, 'XXX',
                                                     'AMENFQKVEKIGEGTYGVVYKARNKLTGEVVALKKIRVPSTAIREISLLKELNHPNIVKLLDVIHTENKLYLVFEFLHQDLKKFMDASALTGIPLPLIKSYLFQLLQGLAFCHSHRVLHRDLKPQNLLINTEGAIKLADFGLARAEVVTLWYRAPEILLGCKYYSTAVDIWSLGCIFAEMVTRRALFPGDSEIDQLFRIFRTLGTPDEVVWPGVTSMPDYKPSFPKWARQDFSKVVPPLDEDGRSLLSQMLHYDPNKRISAKAALAHPFFQDVTKPVPHLRL')
         os.unlink('XXX.ali')
         os.unlink('XXX.sqc')
Exemple #9
0
    def test_soap_module(self):
        """Test soap script as a module"""
        with utils.temporary_working_directory() as tmpdir:
            for pdb in ('test.pdb', 'pm.pdb0.pdb', 'pm.pdb1.pdb',
                        'pm.pdb2.pdb', 'pm.pdb.B10010002.pdb'):
                fname = os.path.join(tmpdir, pdb)
                with open(fname, 'w') as fh:
                    fh.write("""
ATOM      1  N   CYS A   1      18.511  -1.416  15.632  1.00  6.84           C
""")
            with utils.mocked_object(soap_protein_od, 'Scorer', MockScorer):
                cryptosite.soap.soap_score()
            with open('SnapList.txt') as fh:
                data = fh.readlines()
            # don't know glob order
            self.assertEqual(len(data), 2)
            self.assertTrue(re.match('pm\.pdb\d\.pdb\t10\.0', data[0]))
            self.assertTrue(re.match('pm\.pdb\d\.pdb\t20\.0', data[1]))
Exemple #10
0
    def test_soap_module(self):
        """Test soap script as a module"""
        with utils.temporary_working_directory() as tmpdir:
            for pdb in ('test.pdb', 'pm.pdb0.pdb', 'pm.pdb1.pdb',
                        'pm.pdb2.pdb', 'pm.pdb.B10010002.pdb'):
                fname = os.path.join(tmpdir, pdb)
                with open(fname, 'w') as fh:
                    fh.write("""
ATOM      1  N   CYS A   1      18.511  -1.416  15.632  1.00  6.84           C
""")
            with utils.mocked_object(soap_protein_od, 'Scorer', MockScorer):
                cryptosite.soap.soap_score()
            with open('SnapList.txt') as fh:
                data = fh.readlines()
            # don't know glob order
            self.assertEqual(len(data), 2)
            self.assertTrue(re.match('pm\.pdb\d\.pdb\t10\.0', data[0]))
            self.assertTrue(re.match('pm\.pdb\d\.pdb\t20\.0', data[1]))
Exemple #11
0
 def test_build_model_gaps(self):
     """Test build_model() with gaps"""
     import modeller.automodel
     def mocked_loopmodel_make(self):
         self.loop.outputs.append({'failure':None, 'name':'input.pdb',
                                   'Normalized DOPE score':-1.})
     with utils.temporary_working_directory() as tmpdir:
         with open('alignment.pir', 'w') as fh:
             fh.write(">P1;XXX\n")
             fh.write("structureX:input.pdb:1:A:2:A::::\n")
             fh.write("A--A*\n")
             fh.write(">P1;xxx_X\n")
             fh.write("sequence:input::::::::\n")
             fh.write("AAAA*\n")
         with open('input.pdb', 'w') as fh:
             fh.write(pdb_line + '\n')
             fh.write(pdb_line[:25] + '2' + pdb_line[26:] + '\n')
         with utils.mocked_object(modeller.automodel.loopmodel, 'make',
                                  mocked_loopmodel_make):
             cleaning.build_model('XXX', ['A'])
         os.unlink('XXX_mdl.pdb')
Exemple #12
0
 def test_run_blast(self):
     """Test run_blast() function"""
     with utils.mocked_object(subprocess, 'check_call', mock_check_call):
         cryptosite.seq_conservation.run_blast('test')