def test_extract_mutations_from_lines_to_file_w_non_default_extractor(self): """extract_mutations_from_lines_to_file: functions w baseline extractor """ from tempfile import mktemp from os import remove actual_output_filepath = mktemp() # BaselineMutationExtractor does not provide spans -- requesting # them results in a properly handled error self.assertRaises(MutationFinderError,\ extract_mutations_from_lines_to_file,self.fake_input_file,\ actual_output_filepath,BaselineMutationExtractor(),\ store_spans=True) # remove the temp file that was created remove(actual_output_filepath) actual_output_filepath = mktemp() extract_mutations_from_lines_to_file(self.fake_input_file,\ actual_output_filepath,BaselineMutationExtractor()) actual_output = list(open(actual_output_filepath)) # remove the temp file that was created remove(actual_output_filepath) # compare the lines in the fake output file with those in the # real output file expected_output = ['id1','id2\tG88Y\tG88Y\tW42A\tW42A',\ 'id3','id4','id5'] for actual,expected in zip(actual_output,expected_output): self.assertEqual(actual.strip(),expected)
def test_extract_mutations_from_lines_to_file_w_spans(self): """extract_mutations_from_lines_to_file: spans""" from tempfile import mktemp from os import remove actual_output_filepath = mktemp() extract_mutations_from_lines_to_file(self.fake_input_file,\ actual_output_filepath,self.mf,store_spans=True) actual_output = list(open(actual_output_filepath)) # remove the temp file that was created remove(actual_output_filepath) # compare the lines in the fake output file with those in the # real output file for i,line in zip(range(len(actual_output)),actual_output): self.assertEqual(line.strip(),self.fake_output_file_w_spans[i])