Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I don't mean this to be pulled in as-is, but rather to start discussion.
Standard convention with VCF is to place an indel at the left-most position, but some tools add additional context to the right of the sequences (e.g. samtools). These common suffixes are undesirable when comparing variants, for example in variant databases.
The
trim_common_suffix
function removes these common suffixes, forcing the INDEL to the left.For example, to get trimmed reference and alternate alleles for a VCF record:
Or if you only want to work with the first alternate allele:
If such functionality should ever be included in PyVCF, a few ideas:
But I think trimming per allele is in practice most useful.
Related to this would be to really left-align the INDEL as far as possible, making use of a reference file, and thereby possibly modifying the start position of the variant. The GATK LeftAlignVariants module and the Freebayes --left-align-indels do this.
Other opinions?