Repository navigation
Description
When 2 config entries with the same name and same tag sequence length match a read subsequence with the same edit distance at the same position, which entry does splitcode determine to match?
Splitcode's documentation currently does not address this question. The FAQ only notes that splitcode prioritizes matches based on:
- position (left to right)
- length of match
My understanding based on the source code is that splitcode additionally prioritizes based on the following:
- shortest edit distance
Lines 2213 to 2216 in 530d1fe
if (!found_curr || (found_curr && error_prev > x.second)) { error_prev = x.second; tag_id_curr = tag_id_; // if tags have same name but different mismatch errors: choose the tag w/ smallest error } - order in which the entry appeared in the config file (earlier is higher priority)
- The iteration order is over
it->second— the vector stored in thetagshash map for the key corresponding to the current k-mer subsequence of the read being check. This vector is populated byaddToMapin the order the tags were processed during config file loading.
- The iteration order is over
This understanding matches the results from the example below.
@Yenaled would you mind confirming my understanding? If so, I'm happy to submit a pull request to update the documentation.
Example
Both tagA entries match read1 with 1 mismatch, and both tagB entries match read2 with 1 mismatch. How does splitcode choose which tagA entry (the one with sequence ATGT or ACGT) matches read1, and which tagB entry (TCGG or TCAG) matches read2? Is it based on the order in which the entries appear in the config file?
The first tagC entry matches read3 with 1 mismatch, while the second tagC entry matches read3 with 0 mismatches. Does splitcode prioritize matching based on the number of mismatches or the order in which entries appear in the config file?
In each case, splitcode's choice should be reflected in whether the sequence is trimmed or not.
input.fasta
>read1
AGGT
>read2
TCTG
>read3
GCCAT
config.txt
ids tags distance left
tagA ATGT 1 1
tagA ACGT 1 -
tagB TCGG 1 -
tagB TCAG 1 1
tagC GCCAG 1 -
tagC GCCAT 1 1
splitcode command
splitcode -c config.txt --loc-names --out-fasta --output=out.fasta input.fasta
cat out.fasta
Result
* Using a list of 4 tags (vector size: 4; map size: 56; num elements in map: 68)
* will process sample 1: input.fasta
* processing the reads ...
done
* processed 2 reads
>read1 LX:Z:tagA:0,0-4
>read2 LX:Z:tagB:0,0-4
TCTG
>read3 LX:Z:tagC:0,0-5
splitcode matched the first tagA entry ATGT to read1 (so trimming was applied) and the first tagB entry TCGG to read2 (so trimming was not applied), indicating that when the edit distance is the same, splitcode prioritizes entries based on their order in the config file.
splitcode matched the second tagC entry (with 0 mismatches) to read3 (so trimming was applied), even though the first tagC entry could have matched as well (with 1 mismatch), indicating that splitcode prioritizes edit distance above entry order in the config file.
Tested with splitcode version 0.31.6: https://colab.research.google.com/drive/1kPGq5Zi0yii4dTZIeKmXkxvgRbvrdn1x
Activity