I spent hours figuring out why bam2cfg does not work for my bam. Here's what I found. It may not apply to your case depending on what your bam file is like.
My bam file failed bam2cfg because the @RG header does not have the LB tag.
Solution 1: change the header line:
this won't work
@RG ID:s_1 PL:Illumina SM:88LN
this will work
@RG ID:s_1 PL:Illumina SM:88LN LB:LB_88LN
Solution 2: However, I did not want to change my bam file, so I modified bam2cfg.pl as follows (commenting out the first and add the second):
#if(/^\@RG/){ #getting RG=>LIB mapping from the bam header
if (0) {
AND use the -f flag
bam2cfg -g -h -f rg.txt ......
in rg.txt:
s_1 LB_88LN
OR, if you like:
s_1\tLB_88LN(EOF)
NOTE: s_1 is your ReadGroup. In the sam file, each read comes with an RG tag (among the last columns). If you don't have RG tags on reads, then probably you wouldn't have an error from bam2cfg in the first place.
THE BUG: -f flag does not work when you have the @RG header line. The header overrides your -f file. That's why i had to modify bam2cfg.pl.
My bam file failed bam2cfg because the @RG header does not have the LB tag.
Solution 1: change the header line:
this won't work
@RG ID:s_1 PL:Illumina SM:88LN
this will work
@RG ID:s_1 PL:Illumina SM:88LN LB:LB_88LN
Solution 2: However, I did not want to change my bam file, so I modified bam2cfg.pl as follows (commenting out the first and add the second):
#if(/^\@RG/){ #getting RG=>LIB mapping from the bam header
if (0) {
AND use the -f flag
bam2cfg -g -h -f rg.txt ......
in rg.txt:
s_1 LB_88LN
OR, if you like:
s_1\tLB_88LN(EOF)
NOTE: s_1 is your ReadGroup. In the sam file, each read comes with an RG tag (among the last columns). If you don't have RG tags on reads, then probably you wouldn't have an error from bam2cfg in the first place.
THE BUG: -f flag does not work when you have the @RG header line. The header overrides your -f file. That's why i had to modify bam2cfg.pl.