Picard-Addorreplace Error
1
0
Entering edit mode
12.3 years ago

Hi all,

When I tried to add Read Groups using Picard AddOrReplaceReadGroups I got the following error. Help me with a solution.

[ Mon Aug 27 16:22:33 MDT 2012] net.sf.picard.sam.AddOrReplaceReadGroups INPUT=<filename.fastq> OUTPUT=<filename.fastq> SORT_ORDER=coordinate RGID=<rgid> RGLB=<rglib> RGPL=illumina RGPU=<rgpu> RGSM=<rgsm>   VERBOSITY=INFO QUIET=false VALIDATION_STRINGENCY=STRICT COMPRESSION_LEVEL=5 MAX_RECORDS_IN_RAM=500000 CREATE_INDEX=false CREATE_MD5_FILE=false
[Mon Aug 27 16:22:33 MDT 2012] Executing as deepthi@coe03 on Linux 2.6.18-308.4.1.el5 amd64; Java HotSpot(TM) 64-Bit Server VM 1.6.0_21-b06; Picard version: 1.66(1178)
[Mon Aug 27 16:22:33 MDT 2012] net.sf.picard.sam.AddOrReplaceReadGroups done. Elapsed time: 0.01 minutes.
Runtime.totalMemory()=2058027008
FAQ:  http://sourceforge.net/apps/mediawiki/picard/index.php?title=Main_Page
Exception in thread "main" java.lang.IllegalArgumentException: Cannot add sequence that already exists in SAMSequenceDictionary: 7180001696929
        at net.sf.samtools.SAMSequenceDictionary.setSequences(SAMSequenceDictionary.java:62)
        at net.sf.samtools.SAMSequenceDictionary.<init>(SAMSequenceDictionary.java:40)
        at net.sf.samtools.SAMTextHeaderCodec.decode(SAMTextHeaderCodec.java:106)
        at net.sf.samtools.BAMFileReader.readHeader(BAMFileReader.java:393)
        at net.sf.samtools.BAMFileReader.<init>(BAMFileReader.java:146)
        at net.sf.samtools.BAMFileReader.<init>(BAMFileReader.java:114)
        at net.sf.samtools.SAMFileReader.init(SAMFileReader.java:514)
        at net.sf.samtools.SAMFileReader.<init>(SAMFileReader.java:167)
        at net.sf.samtools.SAMFileReader.<init>(SAMFileReader.java:122)
        at net.sf.picard.sam.AddOrReplaceReadGroups.doWork(AddOrReplaceReadGroups.java:68)
        at net.sf.picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:177)
        at net.sf.picard.cmdline.CommandLineProgram.instanceMainWithExit(CommandLineProgram.java:119)
        at net.sf.picard.sam.AddOrReplaceReadGroups.main(AddOrReplaceReadGroups.java:61)
picard • 6.1k views
ADD COMMENT
0
Entering edit mode

Hi I just checked the @SQ lines of the bam files. Chr Y is missing. Why is that so? What should I do to resolve that?

FYI: I used the bam files in the command. That is a typo error. Sorry for that.

ADD REPLY
0
Entering edit mode

I've edited my original answer with my best guess for an answer.

ADD REPLY
0
Entering edit mode

Some @SQ lines are repeating . That may be the reason the error "Cannot add sequence that already exists in SAMSequenceDictionary: 7180001696929" is coming.

I created my sam file using

bowtie -S -q <ref_genome> <filename.fastq> <filename.sam> --un <filename.fastq> --best --quiet

and converted it to bam file

samtools view -S <filename.sam> -b > <filename.bam>

The above bam file is the input to AddOrReplaceReadGroups.

Do you have any idea why the @SQ lines are repeating?

ADD REPLY
0
Entering edit mode

Which file I have to use in

java -Xmx2g -jar CreateSequenceDictionary.jar REFERENCE=reference.fa OUTPUT=reference.dict java -Xmx2g -jar ReorderSam.jar INPUT=filename.bam OUTPUT=filename.reordered.bam REFERENCE=reference.fa

as REFERENCE?

I created the sam file from a Genome.

Steps in my process are:

1.bowtie-build Chr1.fa,Chr2.fa.....ChrY.fa genome_reads 2.bowtie -S -q <ref_genome> <filename.fastq> <filename.sam> --un <filename.fastq> --best --quiet 3.samtools view -S <filename.sam> -b > <filename.bam>

ADD REPLY
3
Entering edit mode
12.3 years ago

Try setting "VALIDATIONSTRINGENCY=LENIENT". This may help, although I have a feeling that there is something wrong with the sequence dictionary (@SQ) lines in the header of your BAM file. You should check this with samtools view -H filename.bam. If there are any chromosomes missing, or any blank lines or whitespace other than tabs, this may cause Picard not to parse that line correctly.

EDIT: I just looked at the command you run, and noticed that you are specifying fastq files as input and output. Do you realize that this tool only runs on BAM or SAM files? This is most likely the cause of your issue. You should map the reads in your fastq files to a reference genome using something like BWA.

EDIT: Since you are missing the Y chromosome in your BAM sequence dictionary, I would recommend running reordering your BAM file based on the reference fasta you used.

java -Xmx2g -jar CreateSequenceDictionary.jar REFERENCE=reference.fa OUTPUT=reference.dict
java -Xmx2g -jar ReorderSam.jar INPUT=filename.bam OUTPUT=filename.reordered.bam REFERENCE=reference.fa

I think this should write any missing chromosomes to the BAM header, but I'm not sure.

ADD COMMENT

Login before adding your answer.

Traffic: 1611 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6