<jupyter_start><jupyter_text>With the `NaiveLabeledAssembler`, we expect this configuration to produce only one shortened contig: we get two possible branches with spanning reads, neither of which has coverage of 1 (being a putative error / tip).<jupyter_code>K = 21
graph = khmer.Countgraph(K, 1e6, 4)
labeller = khmer._GraphLabels(graph)

graph.consume(contig)
bubble = mutate_position(contig, 100)

reads = list(itertools.chain(reads_from_sequence(contig), reads_from_sequence(bubble)))
random.shuffle(reads)

for n, read in enumerate(reads):
    graph.consume(read)

    hdns = graph.find_high_degree_nodes(read)
    labeller.label_across_high_degree_nodes(read, hdns, n)
paths = labeller.assemble_labeled_path(contig[:K])
print(*[str(len(p)) + ' ' + p for p in paths], sep='\n\n')<jupyter_output>1000 TGCCGCCCAGCACCGGGTGACTAGGTTGAGCCATGATTAACCTGCAATGAAGGTCATTCACACGCAGCGTCATTTAATGGATTGGTGCACACTTAACTGGGTGCCGCGCTGGTGCTGATCCATGAAGTTCATCTGGACTTGTACGTGCGACAGCTCCTTCCATTTCCGCCTTGCCATACAGACCACCTAAGACCGCAGACCCTCCTCCTTACCACATGCGATGCGTGGGAACCGGTGTCAAAGACGGGTGCCGCTACACAGGAAGGCACCCAGGGAAAGTCGTTTGCCGGAAGAGAGTGGAGCTCCTACGTAAACGGGGAAACCACTTGTTTGGATTCCCCCTTGCCGATTCGGCCCTATCAGGATGTATTTAACTTAGGAGAAACCGAACAACTGCCACCGCTTATTGCCCCGGCAGGCGGTAGTTTCCACGATCTAACAATCGAAGCAATTCGGACAGGCTTAAGCTACAAAGCTCGGATTTTGTAAGTGCTCTATCCTTTGTAGGAAGTGAAAGATGACGTTGCGGCCGTCGCTGTTGGAGGAACCGCAGCACCATGGCGCCTGTGCGAGCTGGAGATCCTCTCATAGCGTCAGAGCACGGGATGCTGTATATTAAGCACACAATAGCCCGGGGACCGGCCCCAACGTGAAATGCCTGGCCTGCCGTTCTTTATAGTGCTCGTGATAGTGTTATAAAGGAACTAACATCAAGTTATGTAAGGACTTTTACAATAGCGTGGTCCGTCAAGTCGTCCACGTGTGTAAATTCATTGGTACCTTTTGCCGAAAAATTTGAAAGCTAAGCACATTCTGCTTACTCACAGGGTAAGTTCCTGAAGTATTAATGTAATGTGGAAAGACAGGCATATGAACACTATTGGGCTTTGTAGACATTCCTCATCCATGCTGTATCAGTAATGTACAATTCGCCCCTTTCGTAAAGGAGAGCCGTGCTAACGTTATATTCGGTCTTACCACGGGCTCGATAGTTT[...]<jupyter_text>Let's try introducing an error in a singe read. This should trip the filter and cause one full length contig to be produced, so long as the coverage at the branch is greater than the arbitrarily selected minimum.<jupyter_code>K = 21
graph = khmer.Countgraph(K, 1e6, 4)
labeller = khmer._GraphLabels(graph)

bubble = mutate_position(contig, 100)

reads = itertools.chain(reads_from_sequence(contig, N=50), 
                        [bubble],
                        reads_from_sequence(contig, N=50))

for n, read in enumerate(reads):
    graph.consume(read)

    hdns = graph.find_high_degree_nodes(read)
    if list(hdns):
        print('Read:', n)
        print([str_tag(h, K) for h in hdns])
    labeller.label_across_high_degree_nodes(read, hdns, n)
paths = labeller.assemble_labeled_path(contig[:K])
print(*[str(len(p)) + ' ' + p for p in paths], sep='\n\n')
nodegraph = khmer.Nodegraph(K, 1e5, 4)
lh = khmer._GraphLabels(nodegraph)

nodegraph.consume(contig)
branch = contig[:120] + 'TGATGGACAG'
nodegraph.consume(branch)  # will add a branch

hdn = nodegraph.find_high_degree_nodes(contig)
hdn += nodegraph.find_high_degree_nodes(branch)
print(list(hdn))
lh.label_across_high_degree_nodes(contig, hdn, 1)
lh.label_across_high_degree_nodes(branch, hdn, 2)
print(lh.get_tag_labels(list(hdn)[0]))

paths = lh.assemble_labeled_path(contig[:K])
print([len(x) for x in paths])
len_path = len(paths)

print('len path:', len_path)<jupyter_output>[3405415116682]
[1, 2]
[1000, 130]
len path: 2
{'fraction_non_alphanumeric': 0.08519637462235649, 'fraction_numerical': 0.017220543806646525, 'mean_word_length': 7.8766756032171585, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '608193', 'license': 'MIT', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1284, 'n_words': 198, 'path': 'notebooks/LabeledLinearAssembler_review.ipynb', 'repo_name': 'camillescott/goetia', 'size': '3310'}