This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Best way to obtain reference and non-reference k-mer

Hi everyone,

I'm wondering what would be the best strategy to obtain the list of all k-mers in the graph with each k-mer labeled as reference (i.e., from specific path) or not-reference. A very nice to have extra feature would be to have, for each k-mer, the index(es) of its occurrence(s) in the reference (linear) space.

I see two possible roads:

vg kmers ...
vg find -k ...

Both strategies have prons and cons. The former produces more succinct output but I haven't found a way to discriminate whether k-mers belongs or not to a path (nor I found an easy way to obtain the index). The latter has more extensive output, but also produces much larger outputs.

Thanks for any suggestion, Michele S.

vg

1 answer

The easiest way is probably doing it outside vg:

  1. Extract all kmers (kmer occurrences) with vg kmers.
  2. Extract the selected paths in FASTA format with vg paths -v graph.vg -F -p path-names.txt > output.fa.
  3. Determine the kmers in the paths using an external tool.
  4. Compare the kmer sets with an external tool.

The path positions for non-path kmers are not always well-defined. There is some machinery for determining them (for alignments, not kmers), but even then, we often have to make arbitrary choices or give up trying.

Thank you very much for the prompt and detailed reply. I was considering using external tools, but I wanted to be sure that there were no better ways built in the toolkit.

Log in to answer this question.