I am not sure if bamtools sort can do that but maybe bamtools filter could help.
[UPDATE]: Thanks for the suggestions. It turns out I don't need to perform the custom sort after all though
Hi everyone,
I hoping someone may be able to point towards a tool for custom sorting a sam/bam file? Essentially I want to sort by a meta-contig feature which will not be encoded within the samfile. The resultant sorted sam will not need to be sorted on contig or position whatsoever.
I can perform the sort myself using pysam to extract the contigs associated with each meta-contig and then outputting to the sorted sam, but I'm hoping this functionality may exists already elsewhere?
A fuller explanation of the motivation can be found here
Cheers
2 answers
You can easily implement a new sorting algorithm using java+ and the class 'SortingCollection' from the htsjdk library. See https://github.com/lindenb/jvarkit/blob/master/src/main/java/com/github/lindenb/jvarkit/tools/misc/SortSamRefName.java for an example (sorts reads on REF and then on NAME)
Bamtools allows different sorting schemes. If i remember correctly it allows users to specify their own sort functions... maybe?
Log in to answer this question.
Link to the
fuller explanationseems to require a github account and is not otherwise visible.It is not a proper link. It is pointing to "https://github.com/CGATOxford/UMI-tools/issues/new"
Right link.
Thanks. Link updated in the questions.