This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Problem in MarkDuplicates of picard

Hi, I am running the following command on my bam file coming from rna reads:

java -jar ./picard.jar MarkDuplicates I=./bamOutput/D2.bam O=./markedDuplicatedBams/D2.bam M=./markedDuplicatedBams/D2_metrics.txt

It throws the below exception:

Exception in thread "main" htsjdk.samtools.SAMFormatException: Error parsing SAM header. Problem parsing @PG key:value pair. Line:
@PG     ID:samtools     PN:samtools     PP:hisat2       VN:     CL:./samtools sort -o ./bamOutput/D2.bam ./Temp/D2.sam; File /mnt/d/./bamOutput/D2.bam; Line number 5

When I run the samtools view -H command I got the below output:

@HD     VN:1.0  SO:coordinate
@SQ     SN:NC_045512.2  LN:29903
@RG     ID:ID:D2       SM:D2  PL:ILLUMINA     PM:HISEQ
@PG     ID:hisat2       PN:hisat2       VN:2.2.1        CL:"/mnt/e/hisat2-align-s --wrapper basic-0 --rg-id ID:D2 --rg SM:D2 --rg PL:ILLUMINA --rg PM:HISEQ -x ./reference.fasta -S D2.sam --read-lengths 60 -1 /tmp/9236.inpipe1 -2 /tmp/9236.inpipe2"
@PG     ID:samtools     PN:samtools     PP:hisat2       VN:     CL:./samtools sort -o ./bamOutput/D2.bam ./Temp/D2.sam
@PG     ID:samtools.1   PN:samtools     PP:samtools     VN:1.10 CL:samtools view -H ./bamOutput/D2.bam

I think the problem is with VN: flag in @PG tag. How I should resolve this?

variants markduplicates picard rna

1 answer

VN in VN: should have a value. The htsjdk library _requires_ a value here: https://github.com/gkno/picard/blob/ffb68b5183efdaa561489bb36e47546df852fb5b/src/java/net/sf/samtools/SAMTextHeaderCodec.java#L272

How I should resolve this?

save the header with samtools view -H , fix the header, and then samtools reheader

Log in to answer this question.