This is a test version of Biostars. For the public version, visit https://www.biostars.org.
picard: error reading BAM file

I am having problems processing a BAM file with UnifiedGenotyper. It says at the beginning that "java.lang.Character cannot be cast to java.lang.String". I have run this to validate the format: java -jar ./picard-tools-2.1.1/picard.jar ValidateSamFile I=prueba2.bam MODE=SUMMARY

I get this error: Exception in thread "main" java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String at htsjdk.samtools.SAMRecord.isValid(SAMRecord.java:2000) at htsjdk.samtools.SAMRecord.isValid(SAMRecord.java:1854) at htsjdk.samtools.SamFileValidator.validateSamRecordsAndQualityFormat(SamFileValidator.java:274) at htsjdk.samtools.SamFileValidator.validateSamFile(SamFileValidator.java:200) at htsjdk.samtools.SamFileValidator.validateSamFileSummary(SamFileValidator.java:128) at picard.sam.ValidateSamFile.doWork(ValidateSamFile.java:187) at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:209) at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:95) at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:105)

Samtools is perfectly able to read it. The error seem to have arisen after rescaling base qualities according to DNA damage patterns (using mapDamage) because the BAM before is perfectly digested by GATK. Any hint on how can I fix this?

Many thanks Federico

bam htsjdk picard

This is what I have in the header:

@RG     ID:1    PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-5E363840   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-3BE5F6C2   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-295BE5CC   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-122FA23D   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-52D9FBD5   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-4FFDBCC4   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-76011FCC   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-7A503F15   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-489B658D   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-2868CCF9   PL:illumina     PU:whatever     LB:whatever     SM:whatever
@RG     ID:1-20FFF29D   PL:illumina     PU:whatever     LB:whatever     SM:whatever

Then, for the mapped reads I have things like:

RG:Z:1-295BE5CC
RG:A:1
RG:Z:1-122FA23D
RG:Z:1-2868CCF9

etc

Do you see a problem there? Thanks! Federico

Unless you have a good reason to do so, I would suggest to use Haplotypecaller. Unifiedgenotypecaller is outdated.

@decoserwouter he/she never said he/she was using Unifiedgenotypecaller

2 answers

the problem is in the tool that generated your input bam:

RG:A:1

is wrong, it should be

RG:Z:1

the spec https://samtools.github.io/hts-specs/SAMv1.pdf says:

RG : Z : Read group. Value matches the header RG-ID tag if @RG is present in the header.

please validate this answer (icon on the left) so the questioncan be closed.

There is an issue with read groups (as others have pointed out already). Usually, any read group errors can be fixed with Picard AddOrReplaceReadGroups: http://broadinstitute.github.io/picard/command-line-overview.html#AddOrReplaceReadGroups

Thanks for the idea. Unfortunately, Picard was unable to digest the file.

Log in to answer this question.