This is a test version of Biostars. For the public version, visit https://www.biostars.org.
sorting a BAM file

Dear all,

would you please advise: beside SAMTOOLS, PICARD or SAMBAMBA, is there any tool that you would recommend in order to sort a BAM based on read name ? It is a BAM file from EGA that contains cancer sequencing data, and when I do run PICARD SortSam, I am getting the following error (below), and the file does not get sorted. Thanks !

Exception in thread "main" htsjdk.samtools.SAMFormatException: SAM validation error: ERROR: Record 957453876, Read name HWI-ST7001002R:223:C14GPACXX:3:1305:7471:56486, MAPQ should be 0 for unmapped read

bam sort

1 answer

That seems to be a very strange read, how can it have a MAPQ > 0?

Anyway, you can either try samtools sort -n to sort by name, or try setting PICARD's VALIDATION_STRINGENCY to 'lenient', so for example

java -jar picard.jar SortSam I=your_input O=your_sorted_output VALIDATION_STRINGENCY=LENIENT

By default VALIDATION_STRINGENCY is set to STRICT, which is probably the reason why it stops.

Thank you Philipp for your suggestion !

Log in to answer this question.