Пример #1
0
 def test_get_external_data_submissions_two_extdatasubmission(self):
     temp_dir = tempfile.mkdtemp()
     try:
         year = os.path.join(temp_dir, '2017')
         week = os.path.join(year, 'dataset.week.13')
         os.makedirs(week)
         dr = ExternalDataSubmissionFactory.DOCKEDRESULTS
         params = D3RParameters()
         fac = ExternalDataSubmissionFactory(week, params)
         mockft = D3RParameters()
         mockft.connect = Mock()
         mockft.delete_file = Mock(return_value=True)
         mockft.get_remote_challenge_dir = Mock(return_value='/chall')
         mockft.get_remote_submission_dir = Mock(return_value='/remote')
         mockft.list_dirs = Mock(return_value=['yo', 'yuck'])
         mockft.list_files = Mock(return_value=['hi',
                                                'celpp_week13_2017' + dr +
                                                'yo.tar.gz',
                                                'celpp_week13_2017' + dr +
                                                'yuck.tar.gz'])
         fac.set_file_transfer(mockft)
         tlist = fac.get_external_data_submissions()
         self.assertEqual(len(tlist), 2)
         self.assertEqual(tlist[0].get_name(), 'yo.extsubmission')
         self.assertEqual(tlist[0].get_remote_challenge_data_package(),
                          '/remote/yo/celpp_week13_2017' + dr + 'yo.tar.gz')
         self.assertEqual(tlist[1].get_name(), 'yuck.extsubmission')
         self.assertEqual(tlist[1].get_remote_challenge_data_package(),
                          '/remote/yuck/celpp_week13_2017' + dr +
                          'yuck.tar.gz')
         mockft.list_dirs.assert_called_with('/remote')
         mockft.list_files.assert_called_with('/remote/yuck')
         mockft.delete_file.assert_called_with('/chall/latest.txt')
     finally:
         shutil.rmtree(temp_dir)
Пример #2
0
 def test_get_external_data_submissions_no_chall_packages(self):
     temp_dir = tempfile.mkdtemp()
     try:
         year = os.path.join(temp_dir, '2016')
         week = os.path.join(year, 'dataset.week.13')
         os.makedirs(week)
         dr = ExternalDataSubmissionFactory.DOCKEDRESULTS
         params = D3RParameters()
         fac = ExternalDataSubmissionFactory(week, params)
         mockft = D3RParameters()
         mockft.connect = Mock()
         mockft.disconnect = Mock()
         mockft.get_remote_submission_dir = Mock(return_value='/remote')
         mockft.list_dirs = Mock(return_value=['yo'])
         mockft.list_files = Mock(return_value=['hi',
                                                'celpp_week13_2015' + dr +
                                                'dname.tar.gz',
                                                'celpp_week13_2016' + dr +
                                                'yuck.tar.gz'])
         fac.set_file_transfer(mockft)
         tlist = fac.get_external_data_submissions()
         self.assertEqual(len(tlist), 0)
         mockft.list_dirs.assert_called_with('/remote')
         mockft.list_files.assert_called_with('/remote/yo')
     finally:
         shutil.rmtree(temp_dir)
Пример #3
0
 def test_get_external_data_submissions_no_dirs(self):
     params = D3RParameters()
     fac = ExternalDataSubmissionFactory('/foo', params)
     mockft = D3RParameters()
     mockft.list_dirs = Mock(return_value=[])
     fac.set_file_transfer(mockft)
     tlist = fac.get_external_data_submissions()
     self.assertEqual(len(tlist), 0)
Пример #4
0
 def test_get_external_data_submissions_raise_exception(self):
     params = D3RParameters()
     fac = ExternalDataSubmissionFactory('/foo', params)
     tlist = fac.get_external_data_submissions()
     self.assertEqual(len(tlist), 0)
Пример #5
0
def get_task_list_for_stage(theargs, stage_name):
    """Factory method that generates a list of tasks for given stage

       Using stage_name get the list of tasks that need to
       be run.
       :param theargs: parameters set via commandline along with
                       ``theargs.latest_weekly`` which should be set to
                       to base directory where stages will be run
       :param stage_name:  Name of stage to run
    """
    if stage_name is None:
        raise NotImplementedError('stage_name is None')

    task_list = []

    logger.debug('Getting task list for ' + stage_name)

    if stage_name == CREATE_CHALLENGE:
        task_list.append(MakeBlastDBTask(theargs.latest_weekly, theargs))
        task_list.append(DataImportTask(theargs.latest_weekly, theargs))
        task_list.append(BlastNFilterTask(theargs.latest_weekly, theargs))
        task_list.append(ChallengeDataTask(theargs.latest_weekly, theargs))

    if stage_name == 'makedb':
        task_list.append(MakeBlastDBTask(theargs.latest_weekly, theargs))

    if stage_name == 'import':
        task_list.append(DataImportTask(theargs.latest_weekly, theargs))

    if stage_name == 'blast':
        task_list.append(BlastNFilterTask(theargs.latest_weekly, theargs))

    if stage_name == 'challengedata':
        task_list.append(ChallengeDataTask(theargs.latest_weekly, theargs))

    if stage_name == 'proteinligprep':
        task_list.append(ProteinLigPrepTask(theargs.latest_weekly, theargs))

    if stage_name == 'glide':
        task_list.append(GlideTask(theargs.latest_weekly, theargs))

    if stage_name == 'vina':
        task_list.append(AutoDockVinaTask(theargs.latest_weekly, theargs))

    if stage_name == CHIMERA_PREP:
        task_list.append(
            ChimeraProteinLigPrepTask(theargs.latest_weekly, theargs))
    if stage_name == 'extsubmission':
        extfac = ExternalDataSubmissionFactory(theargs.latest_weekly, theargs)
        task_list.extend(extfac.get_external_data_submissions())

    if stage_name == 'evaluation':
        # use util function call to get all evaluation tasks
        # append them to the task_list
        eval_task_factory = EvaluationTaskFactory(theargs.latest_weekly,
                                                  theargs)
        task_list.extend(eval_task_factory.get_evaluation_tasks())

    if len(task_list) is 0:
        raise NotImplementedError('uh oh no tasks for ' + stage_name +
                                  ' stage')

    return task_list