def _test(self, data_file_path): with open(data_file_path, 'r') as datafile: lines = [line.strip() for line in datafile.readlines()] peptide = lines[1] expected = lines[3] actual = ' '.join([str(mass) for mass in cyclospectrum(peptide)]) self.assertTrue(AreStringListsEqual(expected, actual))
def _test(self, data_file_path): with open(data_file_path, 'r') as datafile: lines = [line.strip() for line in datafile.readlines()] spectrum = [int(mass) for mass in lines[1].split(' ')] expected = lines[3].split(' ') actual = [str(mass) for mass in spectral_convolution(spectrum)] self.assertTrue(AreStringListsEqual(expected, actual))
def _test(self, data_file_path): with open(data_file_path, 'r') as datafile: lines = [line.strip() for line in datafile.readlines()] dna = lines[1] peptide = lines[2] expected = lines[4:] actual = find_peptide_encoding(dna, peptide) self.assertTrue(AreStringListsEqual(expected, actual))
def _test(self, data_file_path): with open(data_file_path, 'r') as datafile: lines = [line.strip() for line in datafile.readlines()] n = int(lines[1]) spectrum = [int(mass) for mass in lines[2].split(' ')] expected = lines[4].split('-') actual = [str(mass) for mass in leaderboard_cyclopeptide(spectrum, n)] self.assertTrue(AreStringListsEqual(expected, actual))
def _test(self, datafile_name): with open(datafile_name, 'r') as datafile: lines = [line.strip() for line in datafile.readlines()] index_of_output_start = lines.index("Output:") kmers = lines[1:index_of_output_start] expected = lines[index_of_output_start + 1:] result = generate_contigs(kmers) self.assertTrue(AreStringListsEqual(expected, result))
def _test(self, datafile_name): with open(datafile_name, 'r') as datafile: lines = datafile.readlines() k = int(lines[1].strip()) text = lines[2].strip() expected_outputs = [line.strip() for line in lines[4:]] outputs = construct_de_Bruijn_graph(k, text) self.assertTrue(AreStringListsEqual(expected_outputs, outputs))
def _test(self, data_file_path): with open(data_file_path, 'r') as datafile: lines = [line.strip() for line in datafile.readlines()] m = int(lines[1]) n = int(lines[2]) spectrum = [int(mass) for mass in lines[3].split(' ')] expected = lines[5].split('-') actual = [str(mass) for mass in convolution_cyclopeptide_sequencing(m, n, spectrum)] self.assertTrue(AreStringListsEqual(expected, actual))
def _test(self, data_file_path): with open(data_file_path, 'r') as datafile: lines = [line.strip() for line in datafile.readlines()] leaderboard = lines[1].split(' ') spectrum = [int(mass) for mass in lines[2].split(' ')] n = int(lines[3]) expected = lines[5].split(' ') actual = trim(leaderboard, spectrum, n) self.assertTrue(AreStringListsEqual(expected, actual))
def _test(self, datafile_name): with open(datafile_name, 'r') as datafile: lines = datafile.readlines() k = int(lines[1].strip()) text = lines[2].strip() expected_compositions = [line.strip() for line in lines[4:]] compositions = string_composition(k, text) self.assertTrue( AreStringListsEqual(expected_compositions, compositions))
def _test(self, datafile_name): with open(datafile_name, 'r') as datafile: datafile.readline() # "Input" args = datafile.readline().strip().split(" ") k = int(args[0]) t = int(args[1]) dnas = [] for i in range(t): dnas.append(datafile.readline().strip()) datafile.readline() # "Output" expected_motifs = [] for i in range(t): expected_motifs.append(datafile.readline().strip()) motifs = greedy_motif_search_laplace(dnas, k) self.assertTrue(AreStringListsEqual(expected_motifs, motifs))
def _test(self, datafile_name): with open(datafile_name, 'r') as datafile: kmers = [] expected_outputs = [] current_data_set = None while True: line = datafile.readline().strip() if not line: break if line.__contains__("Input"): current_data_set = kmers elif line.__contains__("Output"): current_data_set = expected_outputs else: current_data_set.append(line) outputs = construct_de_Bruijn_graph_from_kmers(kmers) self.assertTrue(AreStringListsEqual(expected_outputs, outputs))
def _test(self, datafile_name): with open(datafile_name, 'r') as datafile: datafile.readline() # "Input" args = datafile.readline().strip().split(" ") k = int(args[0]) t = int(args[1]) dna_list = [] for i in range(t): dna_list.append(datafile.readline().strip()) datafile.readline() # "Output" expected_motifs = [] for i in range(t): expected_motifs.append(datafile.readline().strip()) motifs = randomized_motif_search(dna_list, k, t) passed = AreStringListsEqual(expected_motifs, motifs) if not passed: print("Expected: " + ' '.join(expected_motifs)) print("Actual: " + ' '.join(motifs)) self.assertTrue(passed)