def test_transfer_fedids_files(self): soakdb_rows = SoakdbFiles.objects.all() soakdb_rows.delete() run_luigi_worker(FindSoakDBFiles(filepath=str(self.working_dir + '*'))) print('TESTING FEDIDS: test_transfer_fedids_files') transfer = run_luigi_worker( TransferAllFedIDsAndDatafiles( date=self.date, soak_db_filepath=str(self.working_dir + '*'))) self.assertTrue(transfer)
def test_transfers(self): print('TESTING TRANSFERS: test_transfers') find_file = run_luigi_worker( FindSoakDBFiles(filepath=str(self.working_dir + '*'))) self.assertTrue(find_file) test_new_file = run_luigi_worker( TransferNewDataFile(data_file=self.db_full_path, soak_db_filepath=str(self.working_dir + '*'))) self.assertTrue(test_new_file) # get the status value from soakdb entry for current file status = list(SoakdbFiles.objects.values_list('status', flat=True)) # check == 2 (not changed - ie. has been successfully added) self.assertEqual(int(status[0]), 2)
def test_findsoakdb(self): print('TESTING FINDSOAKDB: test_findsoakdb') os.chdir(self.working_dir) print(os.path.join(self.working_dir) + '*') find_file = run_luigi_worker( FindSoakDBFiles(filepath=str(self.working_dir + '*'))) self.assertTrue(find_file)
def test_run_ranker(self): subwell_directory = 'SubwellImages' plate_directories = [ x[0] for x in os.walk(os.path.join(os.getcwd(), subwell_directory)) if os.path.join(os.getcwd(), 'SubwellImages') not in x ] imagers = [] plate_types = [] plates = [] for plate in plate_directories: components = plate.split('/') plate_components = components[-1].split('_') print(plate_components) imagers.append( str(plate_components[-1].split('-')[0]) + '-' + plate_components[-1].split('-')[1]) plate_types.append(plate_components[-1].split('-')[2]) plates.append(components[-1]) print(imagers) print(plate_types) print(plates) ranker = run_luigi_worker( RunRanker(plate=plates[0], plate_type=plate_types[0], imager=imagers[0])) self.assertTrue(ranker) self.assertTrue( os.path.isfile( 'ranker_jobs/RANK_90j8_2018-04-11_RI1000-0081-2drop.sh'))
def test_find_pandda_logs(self): find_logs = run_luigi_worker( FindPanddaLogs( search_path= '/dls/science/groups/i04-1/software/luigi_pipeline/pipelineDEV/tests/docking_files/panddas_alice', soak_db_filepath=str(self.working_dir + '*'))) self.assertTrue(find_logs)
def test_grid_prep(self): grid_prep = run_luigi_worker( luigi_classes.prepare_dock.GridPrepADT( ligand_file_name=self.ligand_pdbqt, receptor_file_name=self.protein_pdbqt, docking_dir='', root_dir=self.working_dir)) self.assertTrue(grid_prep)
def test_add_pandda_runs(self): remove_files = [] log_files = pf.find_log_files( '/dls/science/groups/i04-1/software/luigi_pipeline/pipelineDEV/tests/docking_files/' ) log_files = log_files.split() for log_file in log_files: pver, input_dir, output_dir, sites_file, events_file, err = pf.get_files_from_log( log_file) if not err and sites_file and events_file and '0.1.' not in pver: remove_path = str('/'.join(log_file.split('/')[:-1])) remove_files.append(remove_path) add_run = run_luigi_worker( AddPanddaRun(log_file=log_file, pver=pver, input_dir=input_dir, output_dir=output_dir, sites_file=sites_file, events_file=events_file)) self.assertTrue(add_run) add_sites = run_luigi_worker( AddPanddaSites(log_file=log_file, pver=pver, input_dir=input_dir, output_dir=output_dir, sites_file=sites_file, events_file=events_file, soakdb_filename=os.path.join( self.working_dir, 'soakDBDataFile.sqlite'))) self.assertTrue(add_sites) if os.path.isfile(str(log_file + '.sites.done')): os.remove(str(log_file + '.sites.done'))
def test_get_plate_types(self): # test the GetPlateTypes task runs test = run_luigi_worker(GetPlateTypes()) # test that task was successful self.assertTrue(test) # get csv files creates by task two_drops = glob.glob('barcodes_2drop/*.csv') three_drops = glob.glob('barcodes_3drop/*.csv') # check that files were created self.assertTrue(two_drops) self.assertTrue(three_drops)
def test_run_autodock(self): run_autodock = run_luigi_worker(luigi_classes.run_dock.RunAutoDock(ligand_pdbqt=self.ligand_pdbqt, receptor_pdbqt=self.protein_pdbqt, docking_dir='', root_dir=self.working_dir)) self.assertTrue(run_autodock) self.assertTrue(os.path.isfile(os.path.join(self.working_dir, 'autodock.job.id'))) out, job_id = kill_job(self.working_dir, 'autodock.job.id') # make sure communicated with queue successfully self.assertTrue(str(job_id) in out.decode('ascii'))
def test_check_files(self): print('TESTING CHECK_FILES: test_check_files') check_files = run_luigi_worker( CheckFiles(soak_db_filepath=str(self.working_dir + '*'))) self.assertTrue(check_files) # get the status value from soakdb entry for current file print('\n') print('status:') status = list(SoakdbFiles.objects.values_list('status', flat=True)) print(status) print('\n')
def test_lig_prep(self): # run test data on luigi worker lig_prep = run_luigi_worker(luigi_classes.prepare_dock.PrepLigand( root_dir=self.working_dir, ligand_sdf=self.ligand_sdf, docking_dir='')) # check that the task was run successfully self.assertTrue(lig_prep) # define the file that should have been produced, and the example file expected_file = os.path.join(self.root_dir, 'comp_chem', self.ligand_sdf.replace('.pdb', '_prepared.pdbqt')) produced_file = os.path.join(self.working_dir, str(self.ligand_sdf).replace('.pdb', '_prepared.pdbqt')) # run file checks self.file_checks(expected_file=expected_file, produced_file=produced_file)
def test_protein_prep(self): # run test data on luigi worker protein_prep = run_luigi_worker(luigi_classes.prepare_dock.PrepProtein( root_dir=self.working_dir, protein_pdb=self.protein_pdb, docking_dir='')) # check that the job ran successfully self.assertTrue(protein_prep) # define the file that should have been produced, and the example file expected_file = os.path.join(self.root_dir, 'comp_chem', self.protein_pdb.replace('.pdb', '_prepared.pdbqt')) produced_file = os.path.join(self.working_dir, str(self.protein_pdb).replace('.pdb', '_prepared.pdbqt')) # run file checks self.file_checks(expected_file=expected_file, produced_file=produced_file)
def test_vina(self): # run vina task via luigi vina_submit = run_luigi_worker(luigi_classes.run_dock.RunVinaDock(root_dir=self.working_dir, docking_dir='', ligand_pdbqt=self.ligand_pdbqt, receptor_pdbqt=self.protein_pdbqt)) # check job ran successfully, and that a job id was generated from cluster self.assertTrue(vina_submit) self.assertTrue(os.path.isfile(os.path.join(self.working_dir, 'vina.job.id'))) out, job_id = kill_job(self.working_dir, 'vina.job.id') # make sure communicated with queue successfully self.assertTrue(str(job_id) in out.decode('ascii'))