def test_with_peripheral_edges_creates_unitigs(self, tmpdir): # given record1 = 'AAACCCGAA' d = command.TraverseDriver(tmpdir) d.with_json_output() d.with_kmer_size(3) d.with_record('ACCG') d.with_record(record1) d.with_record(record1 + 'G', name='sample_1') d.with_initial_contigs('CCC') d.with_traversal_colors(0) # when expect = d.run() expect.has_node_repr('C').has_coverages_by_kmer([1, 1]) expect.has_node_repr('AAACC').has_coverages_by_kmer([1, 1], [1, 1], [2, 1]) expect.has_node_repr('GAA').has_coverages_by_kmer([2, 1], [1, 1], [1, 1]) expect.has_node_repr('G').has_coverages_by_kmer([1, 1]) expect.has_n_nodes(4) for color in [0, 1]: for edge in [['AAACC', 'C'], ['C', 'GAA']]: expect.has_repr_edge(edge[0], edge[1], color) expect.has_repr_edge('AAACC', 'GAA', 0) expect.has_repr_edge('GAA', 'G', 1) expect.has_n_edges(6)
def test_with_initial_kmers(self, tmpdir): # given record1 = 'AAACCCGAA' record2 = 'ACCG' for query_string_idx, query_string in enumerate( ['CCC', record1, record2]): query_dir = tmpdir / str(query_string_idx) query_dir.ensure(dir=True) d = command.TraverseDriver(query_dir) d.with_records(record1, record2) d.with_kmer_size(3) d.with_json_output() # when expect = d.run() expect.has_n_nodes(3) expect.has_node_reprs('C', 'AAACC', 'GAA') expect.has_node_repr('C').has_coverages_by_kmer([1]) expect.has_node_repr('AAACC').has_coverages_by_kmer([1], [1], [2]) expect.has_node_repr('GAA').has_coverages_by_kmer([2], [1], [1]) for color in [0]: for edge in [['AAACC', 'C'], ['C', 'GAA']]: expect.has_repr_edge(edge[0], edge[1], color) expect.has_repr_edge('AAACC', 'GAA', 0) expect.has_n_edges(3)
def test_of_three_colors_returns_complete_graph(self, tmpdir): # given d = command.TraverseDriver(tmpdir) d.with_sample_records( 'AAAT', 'AAAGG', 'CAAA', ) d.with_kmer_size(3) d.with_json_output() # when expect = d.run() # then expect.has_node_repr('A').has_coverages_by_color(1, 1, 1) expect.has_node_repr('CAA').has_coverages_by_color(0, 0, 1) expect.has_node_repr('T').has_coverages_by_color(1, 0, 0) expect.has_node_repr('GG').has_coverages_by_color([0, 0], [1, 1], [0, 0]) expect.has_n_nodes(4) expect.has_node_unitig('AAA') expect.has_node_unitig('CAA') expect.has_node_unitig('AAT') expect.has_node_unitig('AAGG') expect.has_repr_edge('A', 'T', 0) expect.has_repr_edge('A', 'GG', 1) expect.has_repr_edge('CAA', 'A', 2) expect.has_n_edges(3)
def test_multiple_kmers_without_seed_provides_no_output(self, tmpdir): # given d = command.TraverseDriver(tmpdir) d.with_records('CCCACCC') d.with_kmer_size(3) # when expect = d.run() # then expect.has_no_records()
def test_traverses_tangle_with_non_lexlo_kmer_into_two_paths(self, tmpdir): # given d = command.TraverseDriver(tmpdir) d.with_kmer_size(5) d.with_records('CAAATGGGGG', 'TAAATGGGGT') d.with_link_records('CAAATGGGGT', 'TAAATGGGGG') # when expect = d.run() # then expect.has_records('CAAATGGGGT', 'TAAATGGGGG')
def test_traverses_two_subgraphs_into_three_records(self, tmpdir): # given d = command.TraverseDriver(tmpdir) d.with_records('CCCGC', 'CCCGA', 'AAAT') d.with_kmer_size(3) # when expect = d.run() # then expect.has_record_ids('g0_p0', 'g0_p1', 'g0_p2') expect.has_n_groups(1)
def test_traverses_two_bubbles_into_two_paths(self, tmpdir): # given d = command.TraverseDriver(tmpdir) d.with_kmer_size(5) d.with_records('AACCACAAAACCCCCGAACA', 'AACCATAAAACCCCTGAACA') d.with_link_records('AACCACAAAACCCCTGAACA', 'AACCATAAAACCCCCGAACA') # when expect = d.run() # then expect.has_records('AACCACAAAACCCCTGAACA', 'AACCATAAAACCCCCGAACA')
def test_traverses_into_two_records_with_custom_graph_idx(self, tmpdir): # given d = command.TraverseDriver(tmpdir) d.with_records('CCCGC', 'CCCGA') d.with_graph_index(7) d.with_kmer_size(3) # when expect = d.run() # then expect.has_record_ids('g7_p0', 'g7_p1') expect.has_n_groups(1)
def test_with_non_matching_start_string_returns_empty_json(self, tmpdir): # given d = command.TraverseDriver(tmpdir) d.with_json_output() d.with_records('AAACCCGAA') d.with_kmer_size(3) d.with_initial_contigs('GCGC') # when expect = d.run() # then expect.has_n_nodes(0)
def test_contig_with_extra_start_kmer_that_is_start_reports_same_contig( self, tmpdir): # given d = command.TraverseDriver(tmpdir) d.with_records('ACCCAAA') d.with_extra_start_kmer('ACC') d.with_kmer_size(3) # when expect = d.run() # then expect.has_record('ACCCAAA') expect.has_n_records(1)
def test_multiple_kmers_with_extra_start_kmer_reports_pseudo_linear_contig( self, tmpdir): # given d = command.TraverseDriver(tmpdir) d.with_records('CCCACCC') d.with_extra_start_kmer('CAC') d.with_kmer_size(3) # when expect = d.run() # then expect.has_record('CACCCA') expect.has_n_records(1)
def test_with_revcomp_seed_kmer(self, tmpdir): # given record1 = 'AAACCCGAG' record2 = 'ACCG' query_string = 'CTC' d = command.TraverseDriver(tmpdir) d.with_records(record1, record2) d.with_kmer_size(3) d.with_seed_strings(query_string) d.with_json_output() # when expect = d.run() expect.has_node_reprs('G', 'TTT', 'CTCGG') expect.has_node_repr('G').has_coverages_by_kmer([1]) expect.has_node_repr('TTT').has_coverages_by_kmer([2], [1], [1]) expect.has_node_repr('CTCGG').has_coverages_by_kmer([1], [1], [2]) expect.has_n_edges(3) expect.has_repr_edge('G', 'TTT', 0) expect.has_repr_edge('CTCGG', 'G', 0) expect.has_repr_edge('CTCGG', 'TTT', 0)