Exemple #1
0
    def test_gesamt_radius(self):
        # Test we can reproduce the original thresholds
        gesamt_exe = ample_util.find_exe("gesamt" + ample_util.EXE_EXT)
        clusterer = subcluster.GesamtClusterer(executable=gesamt_exe)
        pdb_list = glob.glob(
            os.path.join(self.testfiles_dir, "models", '*.pdb'))

        radius = 4
        clusterer.generate_distance_matrix(pdb_list, purge=True)
        cluster_files1 = set(
            [os.path.basename(x) for x in clusterer.cluster_by_radius(radius)])
        ref = set([
            '1_S_00000002.pdb',
            '1_S_00000004.pdb',
            '1_S_00000005.pdb',
            '2_S_00000001.pdb',
            '2_S_00000005.pdb',
            '3_S_00000003.pdb',
            '3_S_00000004.pdb',
            '3_S_00000006.pdb',
            '4_S_00000002.pdb',
            '4_S_00000005.pdb',
            '5_S_00000004.pdb',
            '5_S_00000005.pdb',
        ])
        # clusterer.dump_pdb_matrix('foo')
        self.assertEqual(0, len(ref - cluster_files1))
        return
Exemple #2
0
 def subclusterer_factory(self, subcluster_program):
     """Return an instantiated subclusterer based on the given program"""
     if subcluster_program == 'gesamt':
         clusterer = subcluster.GesamtClusterer(self.gesamt_exe, nproc=self.nproc)
     elif subcluster_program == 'lsqkab':
         clusterer = subcluster.LsqkabClusterer(self.lsqkab_exe)
     else:
         raise RuntimeError("Unrecognised subcluster_program: {0}".format(subcluster_program))
     return clusterer
Exemple #3
0
    def test_gesamt_matrix_generic(self):
        # Test we can reproduce the original thresholds
        gesamt_exe = ample_util.find_exe("gesamt" + ample_util.EXE_EXT)
        clusterer = subcluster.GesamtClusterer(executable=gesamt_exe)
        pdb_list = sorted(
            glob.glob(os.path.join(self.testfiles_dir, "models", '*.pdb')))
        clusterer._generate_distance_matrix_generic(pdb_list, purge_all=True)
        # Test two files manually
        index1 = 2
        index2 = 25
        f1 = pdb_list[index1]
        f2 = pdb_list[index2]
        # Run gesamt to get the score between the two
        logfile = 'gesamt.log'
        ample_util.run_command([gesamt_exe, f1, f2], logfile=logfile)
        qscore = None
        with open(logfile) as f:
            for l in f.readlines():
                if l.startswith(' Q-score'):
                    qscore = float(l.split()[2])

        self.assertIsNotNone(qscore, "No q-score found")
        # read score matrix
        matrix = []
        with open(subcluster.SCORE_MATRIX_NAME) as f:
            for l in f.readlines():
                if not l.strip():
                    continue
                fields = l.split()
                matrix.append(
                    (int(fields[0]), int(fields[1]), float(fields[2])))
        # Make sure the score matches
        for l in matrix:
            if l[0] == index1 and l[1] == index2:
                # Gesamt log and out file formats have different precisions
                self.assertAlmostEqual(
                    l[2], qscore, 3,
                    "Q-scores differ: {0} - {1}".format(l[2], qscore))
        os.unlink(logfile)
        os.unlink(subcluster.SCORE_MATRIX_NAME)
        os.unlink(subcluster.FILE_LIST_NAME)
        return