The Picard FilterSAM READ is throwing error
1
0
Entering edit mode
4.4 years ago
a.james ▴ 240

Dear All,

I am using Picard FilterSamReads for filtering a list of sorted reads from a read_name/_id sorted BAM file. I am wanna sort the list of reads which are of certain mapping quality.

Here is what I tried,

java -jar -Xmx4G /path/picard-2.18.4-0/picard.jar FilterSamReads I=simulate_50X_pat_sorted_read.bam O=simulate_50X_pat_sorted_quality_pat.bam READ_LIST_FILE=pat_quality2 FILTER=includeReadList

And the above line is throwing the following error,

INFO    2019-11-19 16:51:40 FilterSamReads  Filtering [presorted=true] simulate_50X_pat_sorted_read.bam -> OUTPUT=simulate_50X_pat_sorted_quality_pat.bam [sortorder=queryname]
ERROR   2019-11-19 16:51:40 FilterSamReads  Failed to filter simulate_50X_pat_sorted_read.bam
java.lang.IllegalArgumentException: Alignments added out of order in SAMFileWriterImpl.addAlignment for file:///cluster/work/projects/simulate_50X_pat_sorted_quality_pat.bam. Sort order is queryname. Offending records are at [1-93166-:1-93466--:::::::::::52438MzI4MTAy:1] and [1-102419--:1-102119-:::::::::::199592NzM1MA==:1]
    at htsjdk.samtools.SAMFileWriterImpl.assertPresorted(SAMFileWriterImpl.java:213)
    at htsjdk.samtools.SAMFileWriterImpl.addAlignment(SAMFileWriterImpl.java:200)
    at picard.sam.FilterSamReads.filterReads(FilterSamReads.java:256)
    at picard.sam.FilterSamReads.doWork(FilterSamReads.java:345)
    at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:282)
    at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:103)
    at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:113)
[Tue Nov 19 16:51:40 CET 2019] picard.sam.FilterSamReads done. Elapsed time: 0.20 minutes.
Runtime.totalMemory()=3706716160

I have tried to remove the above reads from my input list and tried again, however, the same ERROR message appeared with different read names.

I would like to know, what else other than sorting the inputs should be done before running the FilterSamReads tool?

Any help or suggestion is much appreciated.

RNA-Seq picard Assembly reads • 1.7k views
ADD COMMENT
1
Entering edit mode
4.4 years ago

was the sam sorted with samtools ? it might be that error: https://github.com/samtools/hts-specs/issues/5

try

samtools view -h simulate_50X_pat_sorted_read.bam |\
grep -v '^@HD'  |\
java -jar -Xmx4G /path/picard-2.18.4-0/picard.jar FilterSamReads I=/dev/stdin O=simulate_50X_pat_sorted_quality_pat.bam READ_LIST_FILE=pat_quality2 FILTER=includeReadList
ADD COMMENT
0
Entering edit mode

Thanks for the reply. It was previously sorted on the read_id using samtools sort -n.

ADD REPLY
0
Entering edit mode

yeah, the order between samtools and picard is not the same, that's why picard crashed. https://github.com/samtools/hts-specs/issues/5#issuecomment-29213725

ADD REPLY

Login before adding your answer.

Traffic: 2675 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6