コード例 #1
0
ファイル: test_chimeraprep.py プロジェクト: ssirimulla/D3R
    def test_run_fails_cause_chimeraprep_fails(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            params.chimeraprep = 'false'
            params.pdbdb = '/foo'
            chall = ChallengeDataTask(temp_dir, params)
            chall.create_dir()
            open(os.path.join(chall.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            task = ChimeraProteinLigPrepTask(temp_dir, params)

            task.run()
            self.assertEqual(
                task.get_error(),
                'Non zero exit code: 1 received. Standard out: ' +
                ' Standard error: ')
            # test file gets created
            errfile = os.path.join(task.get_dir(), D3RTask.ERROR_FILE)
            self.assertEqual(os.path.isfile(errfile), True)

            stderr = os.path.join(task.get_dir(), 'false.stderr')
            self.assertEqual(os.path.isfile(stderr), True)
            stdout = os.path.join(task.get_dir(), 'false.stdout')
            self.assertEqual(os.path.isfile(stdout), True)
        finally:
            shutil.rmtree(temp_dir)
コード例 #2
0
ファイル: test_chimeraprep.py プロジェクト: ssirimulla/D3R
    def test_run_succeeds(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            params.chimeraprep = 'true'
            params.pdbdb = '/foo'
            chall = ChallengeDataTask(temp_dir, params)
            chall.create_dir()
            open(os.path.join(chall.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            task = ChimeraProteinLigPrepTask(temp_dir, params)

            task.run()
            self.assertEqual(task.get_error(), None)
            # test files get created
            errfile = os.path.join(task.get_dir(), D3RTask.ERROR_FILE)
            self.assertEqual(os.path.isfile(errfile), False)

            compfile = os.path.join(task.get_dir(), D3RTask.COMPLETE_FILE)
            self.assertEqual(os.path.isfile(compfile), True)
            stderr = os.path.join(task.get_dir(), 'true.stderr')
            self.assertEqual(os.path.isfile(stderr), True)
            stdout = os.path.join(task.get_dir(), 'true.stdout')
            self.assertEqual(os.path.isfile(stdout), True)
        finally:
            shutil.rmtree(temp_dir)
コード例 #3
0
ファイル: test_chimeraprep.py プロジェクト: ssirimulla/D3R
    def test_run_fails_cause_chimeraprep_is_not_found_rdkitpython_set(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            params.chimeraprep = '/bin/doesnotexist'
            params.pdbdb = '/foo'
            params.rdkitpython = '/data/miniconda2/bin'
            chall = ChallengeDataTask(temp_dir, params)
            chall.create_dir()

            challdir = os.path.join(chall.get_dir(),
                                    chall.get_celpp_challenge_data_dir_name())

            open(os.path.join(chall.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            task = ChimeraProteinLigPrepTask(temp_dir, params)

            task.run()
            self.assertEqual(
                task.get_error(), 'Caught Exception trying to run ' +
                '/bin/doesnotexist --candidatedir ' + challdir +
                ' --rdkitpython \'/data/miniconda2/bin\' ' + '--pdbdb ' +
                '/foo --outdir ' + task.get_dir() +
                ' : [Errno 2] No such file or directory')

            # test files get created
            errfile = os.path.join(task.get_dir(), D3RTask.ERROR_FILE)
            self.assertEqual(os.path.isfile(errfile), True)
        finally:
            shutil.rmtree(temp_dir)
コード例 #4
0
ファイル: test_vina.py プロジェクト: ssirimulla/D3R
    def test_can_run(self):
        temp_dir = tempfile.mkdtemp()
        try:
            # no proteinligprep task found so it cannot run
            params = D3RParameters()
            vina = AutoDockVinaTask(temp_dir, params)
            self.assertEqual(vina.can_run(), False)
            self.assertEqual(vina.get_error(),
                             'chimeraprep task has notfound status')

            # proteinligprep filter running
            proteinligprep = ChimeraProteinLigPrepTask(temp_dir, params)
            proteinligprep.create_dir()
            open(os.path.join(proteinligprep.get_dir(), D3RTask.START_FILE),
                 'a').close()
            vina = AutoDockVinaTask(temp_dir, params)
            self.assertEqual(vina.can_run(), False)
            self.assertEqual(vina.get_error(),
                             'chimeraprep task has start status')

            # proteinligprep failed
            error_file = os.path.join(proteinligprep.get_dir(),
                                      D3RTask.ERROR_FILE)
            open(error_file, 'a').close()
            vina = AutoDockVinaTask(temp_dir, params)
            self.assertEqual(vina.can_run(), False)
            self.assertEqual(vina.get_error(),
                             'chimeraprep task has error status')

            # proteinligprep success
            os.remove(error_file)
            open(os.path.join(proteinligprep.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            vina = AutoDockVinaTask(temp_dir, params)
            self.assertEqual(vina.can_run(), True)
            self.assertEqual(vina.get_error(), None)

            # vina task exists already
            vina = AutoDockVinaTask(temp_dir, params)
            vina.create_dir()
            self.assertEqual(vina.can_run(), False)
            self.assertEqual(
                vina.get_error(),
                vina.get_dir_name() + ' already exists and status is unknown')

            # vina already complete
            vina = AutoDockVinaTask(temp_dir, params)
            open(os.path.join(vina.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            self.assertEqual(vina.can_run(), False)
            self.assertEqual(vina.get_error(), None)

        finally:
            shutil.rmtree(temp_dir)
コード例 #5
0
ファイル: test_vina.py プロジェクト: ssirimulla/D3R
    def test_run_succeeds(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            params.vina = 'true'
            proteinligprep = ChimeraProteinLigPrepTask(temp_dir, params)
            proteinligprep.create_dir()
            open(os.path.join(proteinligprep.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            vina = AutoDockVinaTask(temp_dir, params)

            vina.run()
            self.assertEqual(vina.get_error(), None)
            # test files get created
            errfile = os.path.join(vina.get_dir(), D3RTask.ERROR_FILE)
            self.assertEqual(os.path.isfile(errfile), False)

            compfile = os.path.join(vina.get_dir(), D3RTask.COMPLETE_FILE)
            self.assertEqual(os.path.isfile(compfile), True)
            stderr = os.path.join(vina.get_dir(), 'true.stderr')
            self.assertEqual(os.path.isfile(stderr), True)
            stdout = os.path.join(vina.get_dir(), 'true.stdout')
            self.assertEqual(os.path.isfile(stdout), True)
        finally:
            shutil.rmtree(temp_dir)
コード例 #6
0
ファイル: test_vina.py プロジェクト: ssirimulla/D3R
    def test_run_fails_cause_vina_fails(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            params.vina = 'false'
            proteinligprep = ChimeraProteinLigPrepTask(temp_dir, params)
            proteinligprep.create_dir()
            open(os.path.join(proteinligprep.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            vina = AutoDockVinaTask(temp_dir, params)

            vina.run()
            self.assertEqual(
                vina.get_error(),
                'Non zero exit code: 1 received. Standard out: ' +
                ' Standard error: ')
            # test file gets created
            errfile = os.path.join(vina.get_dir(), D3RTask.ERROR_FILE)
            self.assertEqual(os.path.isfile(errfile), True)

            stderr = os.path.join(vina.get_dir(), 'false.stderr')
            self.assertEqual(os.path.isfile(stderr), True)
            stdout = os.path.join(vina.get_dir(), 'false.stdout')
            self.assertEqual(os.path.isfile(stdout), True)
        finally:
            shutil.rmtree(temp_dir)
コード例 #7
0
ファイル: test_chimeraprep.py プロジェクト: ssirimulla/D3R
 def test_run_fails_cause_chimeraprep_not_set(self):
     temp_dir = tempfile.mkdtemp()
     try:
         params = D3RParameters()
         chall = ChallengeDataTask(temp_dir, params)
         chall.create_dir()
         open(os.path.join(chall.get_dir(), D3RTask.COMPLETE_FILE),
              'a').close()
         task = ChimeraProteinLigPrepTask(temp_dir, params)
         task.run()
         self.assertEqual(task.get_error(), 'chimeraprep not set')
         # test files get created
         self.assertEqual(os.path.isdir(task.get_dir()), True)
         errfile = os.path.join(task.get_dir(), D3RTask.ERROR_FILE)
         self.assertEqual(os.path.isfile(errfile), True)
     finally:
         shutil.rmtree(temp_dir)
コード例 #8
0
ファイル: test_chimeraprep.py プロジェクト: ssirimulla/D3R
    def test_can_run(self):
        temp_dir = tempfile.mkdtemp()
        try:
            # no blastnfilter task found so it cannot run
            params = D3RParameters()
            task = ChimeraProteinLigPrepTask(temp_dir, params)
            self.assertEqual(task.can_run(), False)
            self.assertEqual(task.get_error(),
                             'challengedata task has notfound status')

            # blastnfilter  running
            chall = ChallengeDataTask(temp_dir, params)
            chall.create_dir()
            open(os.path.join(chall.get_dir(), D3RTask.START_FILE),
                 'a').close()
            task = ChimeraProteinLigPrepTask(temp_dir, params)
            self.assertEqual(task.can_run(), False)
            self.assertEqual(task.get_error(),
                             'challengedata task has start status')

            # blastnfilter failed
            error_file = os.path.join(chall.get_dir(), D3RTask.ERROR_FILE)
            open(error_file, 'a').close()
            task = ChimeraProteinLigPrepTask(temp_dir, params)
            self.assertEqual(task.can_run(), False)
            self.assertEqual(task.get_error(),
                             'challengedata task has error status')

            # blastnfilter success
            os.remove(error_file)
            open(os.path.join(chall.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            task = ChimeraProteinLigPrepTask(temp_dir, params)
            self.assertEqual(task.can_run(), True)
            self.assertEqual(task.get_error(), None)

            # chimeraproteinligprep task exists already
            task = ChimeraProteinLigPrepTask(temp_dir, params)
            task.create_dir()
            self.assertEqual(task.can_run(), False)
            self.assertEqual(
                task.get_error(),
                task.get_dir_name() + ' already exists and status is unknown')

            # chimeraproteinligprep already complete
            task = ChimeraProteinLigPrepTask(temp_dir, params)
            open(os.path.join(task.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            self.assertEqual(task.can_run(), False)
            self.assertEqual(task.get_error(), None)

        finally:
            shutil.rmtree(temp_dir)
コード例 #9
0
ファイル: test_vina.py プロジェクト: ssirimulla/D3R
    def test_run_fails_cause_vina_is_not_found(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            params.vina = '/bin/doesnotexist'
            proteinligprep = ChimeraProteinLigPrepTask(temp_dir, params)
            proteinligprep.create_dir()
            open(os.path.join(proteinligprep.get_dir(), D3RTask.COMPLETE_FILE),
                 'a').close()
            vina = AutoDockVinaTask(temp_dir, params)

            vina.run()
            self.assertEqual(
                vina.get_error(), 'Caught Exception trying to run ' +
                '/bin/doesnotexist --structuredir ' +
                proteinligprep.get_dir() + ' --outdir ' + vina.get_dir() +
                ' : [Errno 2] No such file or directory')

            # test files get created
            errfile = os.path.join(vina.get_dir(), D3RTask.ERROR_FILE)
            self.assertEqual(os.path.isfile(errfile), True)
        finally:
            shutil.rmtree(temp_dir)
コード例 #10
0
ファイル: test_chimeraprep.py プロジェクト: ssirimulla/D3R
    def test_get_uploadable_files(self):
        temp_dir = tempfile.mkdtemp()
        try:
            params = D3RParameters()
            task = ChimeraProteinLigPrepTask(temp_dir, params)
            # try with no dir
            self.assertEqual(task.get_uploadable_files(), [])

            # try with empty dir
            task.create_dir()
            self.assertEqual(task.get_uploadable_files(), [])

            # try with final log
            final_log = os.path.join(task.get_dir(),
                                     ChimeraProteinLigPrepTask.FINAL_LOG)
            open(final_log, 'a').close()
            flist = task.get_uploadable_files()
            self.assertEqual(len(flist), 1)
            flist.index(final_log)

            # add error out files and try with second pbdid folder
            # with ligand.mae
            errfile = os.path.join(task.get_dir(),
                                   'chimera_proteinligprep.py.stderr')
            open(errfile, 'a').close()
            outfile = os.path.join(task.get_dir(),
                                   'chimera_proteinligprep.py.stdout')
            open(outfile, 'a').close()

            flist = task.get_uploadable_files()
            self.assertEqual(len(flist), 3)
            flist.index(errfile)
            flist.index(outfile)
            flist.index(final_log)

        finally:
            shutil.rmtree(temp_dir)
コード例 #11
0
ファイル: test_vina.py プロジェクト: ssirimulla/D3R
 def test_run_fails_cause_vina_not_set(self):
     temp_dir = tempfile.mkdtemp()
     try:
         params = D3RParameters()
         proteinligprep = ChimeraProteinLigPrepTask(temp_dir, params)
         proteinligprep.create_dir()
         open(os.path.join(proteinligprep.get_dir(), D3RTask.COMPLETE_FILE),
              'a').close()
         vina = AutoDockVinaTask(temp_dir, params)
         vina.run()
         self.assertEqual(vina.get_error(), 'vina not set')
         # test files get created
         self.assertEqual(os.path.isdir(vina.get_dir()), True)
         errfile = os.path.join(vina.get_dir(), D3RTask.ERROR_FILE)
         self.assertEqual(os.path.isfile(errfile), True)
     finally:
         shutil.rmtree(temp_dir)
コード例 #12
0
ファイル: vina.py プロジェクト: ssirimulla/D3R
    def run(self):
        """Runs AutoDockVinaTask after verifying chimeraproteinligprep was good

           Method requires can_run() to be called before hand with
           successful outcome
           Otherwise method invokes D3RTask.start then this method
           creates a directory and invokes blastnfilter script.  Upon
           completion results are analyzed and success or error status
           is set appropriately and D3RTask.end is invoked
           """
        super(AutoDockVinaTask, self).run()

        if self._can_run is False:
            logger.debug(self.get_dir_name() +
                         ' cannot run cause _can_run flag '
                         'is False')
            return

        try:
            logger.debug('vina set to ' + self.get_args().vina)
        except AttributeError:
            self.set_error('vina not set')
            self.end()
            return

        ligprep = ChimeraProteinLigPrepTask(self._path, self._args)

        #
        # vinadocking.py --structuredir <path to stage.3.chimeraprep> \
        # --outdir <path to stage.4.vina>
        #
        cmd_to_run = (self.get_args().vina + ' --structuredir ' +
                      ligprep.get_dir() + ' --outdir ' + self.get_dir())

        vina_name = os.path.basename(self.get_args().vina)

        self.run_external_command(vina_name, cmd_to_run, True)
        # assess the result
        self.end()