I have a bam file called test.bam with malformed @RG line. @RG line has only one parameter as following:
I want to add the parameters like SM, LB, PL to @RG line, but I have difficulties to do it.
I already tried with samtools as following:
samtools view -H test.bam | sed 's,^@PG.*,@PG\tID:None\tSM:None\tLB:None\tPL:Illumina,g' | samtools reheader - test.bam > test.rg.bam
However, It gives an error like this:
[E::sam_hdr_error] Missing tab at line 198: "@PGtID:NonetSM:NonetLB:NonetPL:Illumina"
I also tried picard with AddOrReplaceReadGroups function, but it also replied with errors!
java -jar picard.jar AddOrReplaceReadGroups I=test.bam O=test.out.bam RGID=4 RGLB=lib1 RGPL=illumina RGPU=unit1 RGSM=20 Exception in thread "main" htsjdk.samtools.SAMFormatException: Error parsing SAM header. @RG line missing SM tag. Line: @RG ID:foo
Thank you in advance