Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging bam files memento Bioinformatics 1 02-17-2012 04:39 PM
merging many bam files-novice needs help please shawpa Bioinformatics 2 01-06-2012 09:03 AM
Problem merging BAM files hlwright Bioinformatics 6 10-11-2011 12:36 AM
Merging multiple BAM files unibegenomics Bioinformatics 1 08-25-2011 03:03 AM
merging 2 sam files papori Bioinformatics 0 07-29-2011 05:44 AM

Thread Tools
Old 02-06-2012, 08:05 AM   #1
Senior Member
Location: Spain

Join Date: Jul 2009
Posts: 133
Default merging bam files with different headers


Is it possible to merge bam files from the same sample but different reference sequence and thus different headers, so that I work with one single alignment file instead of two?.

I tried

java -Xmx4g -jar ~/picard-tools-1.61/MergeSamFiles.jar  INPUT=Sample1_exon1.bam INPUT=Sample1_exon2.bam OUTPUT=Sample1_merged.bam ASSUME_SORTED=true USE_THREADING=true VALIDATION_STRINGENCY=LENIENT
but I got the following error:

Exception in thread "main" net.sf.samtools.util.SequenceUtil$SequenceListsDifferException: Sequences at index 0 don't match



p.s.: I must say that the MERGE_SEQUENCE_DICTIONARIES flag seems to be related to this task but I am not sure what it actually means

Last edited by dnusol; 02-06-2012 at 08:14 AM.
dnusol is offline   Reply With Quote
Old 02-06-2012, 08:13 AM   #2
Richard Finney
Senior Member
Location: bethesda

Join Date: Feb 2009
Posts: 700

Even it if were possible, it wouldn't be a good idea.

Check samtools merge documentation at

merge samtools merge [-nur1f] [-h inh.sam] [-R reg] <out.bam> <in1.bam> <in2.bam> [...]

Merge multiple sorted alignments. The header reference lists of all the input BAM files, and the @SQ headers of inh.sam, if any, must all refer to the same set of reference sequences. The header reference list and (unless overridden by -h) ‘@’ headers of in1.bam will be copied to out.bam, and the headers of other files will be ignored.
Richard Finney is offline   Reply With Quote
Old 02-07-2012, 12:09 AM   #3
Senior Member
Location: Spain

Join Date: Jul 2009
Posts: 133

Thanks Richard,

I was afraid of that. I see it as doing two steps of alignment against two different reference files instead of doing one single alignment against a file with two fasta entries. I guess the issue here is that you loose the ability of finding reads if multiple alignment is taking place. Unless this is done in a late step. But why a bad idea? to me it seems just a technical issue (samtools will only take into account headers of first in.bam file)
dnusol is offline   Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -8. The time now is 11:40 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO