I downloaded a BAM file for chr20 from NCBI (SRR1976036). This is a NA12878 sample.
I wanted to do some variant calling with freebayes and got the following error.
could not find SM: in @RG tag
After some investigation i found that my BAM file does not have a RG tag.
@HD VN:1.2 SO:coordinate
@SQ SN:CM000663.1 LN:249250621
@SQ SN:CM000664.1 LN:243199373
@SQ SN:CM000665.1 LN:198022430
@SQ SN:GL000248.1 LN:39786
@SQ SN:GL000249.1 LN:38502
I looked around the internet for an answer and i though i found an answer using Picard function AddOrReplaceReadGroups.
So i tried the following
java -jar /home/user/Downloads/picard.jar AddOrReplaceReadGroups I=SRR1976036_chr20.bam O=036_RG.bam RGID=4 RGLB=lib1 RGPL=illumina RGPU=unit1 RGSM=test
However i got the following message:
Exception in thread "main" htsjdk.samtools.SAMFormatException: Error parsing SAM header. @RG line missing SM tag. Line: @RG ID:None; File /home/user/NA12878/SRR1976036_chr20.bam; Line number 95
I looked around and couldn't find an answer.
it is the first time working with a BAM directly. I have used variant calling from FASTQ to VCF files and never got this problem.
Could someone tell me what i can do to add the information properly?
Kind regards Covux