def test_make_study_sffs(self): """Runs the original SFF through split-lib, then runs the filtered one one through split-lib and verifies they are the same.""" #Run original SFF throught split-lib run_process_sff_through_split_lib(0,'Fasting_subset',\ sff_input_fp=self.sff_fp,\ mapping_fp=self.fasting_mapping_fp,\ output_dir=self.wf_out, \ command_handler=call_commands_serially,\ params=self.params,\ qiime_config=self.qiime_config,\ convert_to_flx=False,\ write_to_all_fasta=False,\ status_update_callback=no_status_updates) #Create a per study SFF per_library_output=join(self.wf_out,'per_study_sff') create_dir(per_library_output) make_study_sffs(per_library_output,609) #Run the new SFF through split-lib new_map_fp=join(per_library_output, 'study_609_run_Fasting_subset_mapping.txt') new_sff_fp=join(per_library_output,'filtered_sffs', 'study_609_Fasting_subset.sff') new_processed_output=join(self.wf_out,'filtered_wf_da') create_dir(new_processed_output) run_process_sff_through_split_lib(0,'Fasting_subset',\ sff_input_fp=new_sff_fp,\ mapping_fp=new_map_fp,\ output_dir=new_processed_output, \ command_handler=call_commands_serially,\ params=self.params,\ qiime_config=self.qiime_config,\ convert_to_flx=False,\ write_to_all_fasta=False,\ status_update_callback=no_status_updates) #parse the split-library fasta files old_split_lib_seqs=MinimalFastaParser(open(join(self.wf_out, 'split_libraries','seqs.fna')),'U') new_split_lib_seqs=MinimalFastaParser(open(join(new_processed_output, 'split_libraries','seqs.fna')),'U') #Convert original SFF split-lib fasta into a Dictionary for easy lookup old_seqs={} for key,val in old_split_lib_seqs: new_key_head=key.split(' ') new_key_head[0]=new_key_head[0].split('_')[0] old_seqs[' '.join(new_key_head)]=val #Convert new SFF split-lib fasta into a Dictionary for easy lookup new_seqs={} for key,val in new_split_lib_seqs: new_key_head=key.split(' ') new_key_head[0]=new_key_head[0].split('_')[0].split('.')[1] new_seqs[' '.join(new_key_head)]=val #Check that the seqs and headers match for key in old_seqs: self.assertTrue(old_seqs[key]==new_seqs[key]) #Check that the output histograms are equal old_histogram=open(join(self.wf_out,'split_libraries', 'histograms.txt')).readlines() new_histogram=open(join(new_processed_output,'split_libraries', 'histograms.txt')).readlines() self.assertEqual(old_histogram,new_histogram) #Check that the output log files are equal old_log=open(join(self.wf_out,'split_libraries', 'split_library_log.txt')).readlines() new_log=open(join(new_processed_output,'split_libraries', 'split_library_log.txt')).readlines() self.assertEqual(old_log[:23],new_log[:23])