I have run bam2cfg.pl on some bam files and had it produce empty cfg files. I checked the contents of these bam files and they contain a line in the header that starts:
@RG ID:0 ....
This is the only @RG line in the header of the file, so all of the read lines in the file have an entry that says "RG:Z:0". In bam2cfg.pl, lines 98 and 99 say
my $lib=($t->{readgroup})?$RGlib{$t->{readgroup}}:'NA'; #when multiple libraries are in a BAM file
next unless(defined $lib && $libs{$lib});
Because $t->{readgroup} is set to 0, the value associated with 0 in %RGlib should be assigned to $lib, but 0 also means FALSE in perl, so 'NA' is assigned to $lib instead. The fix is simply to change line 98 to say
my $lib=(defined $t->{readgroup})?....