merging multiple sorted.bam.tmp.0000.bam into a single sorted.bam file.
1
0
Entering edit mode
4.1 years ago
jaqx008 ▴ 110

I have been trying to generate sorted.bam files. but haven't been successful. each time I get numerous sorted.bam files individually and I want to merge them into one big sorted.bam. The following command was what is used to obtain this multiple bamfiles.

-S dustMapping.sam && samtools view -S -b dustMapping.sam -o dustMapping.bam && samtools sort dustMapping.bam -odustMapping.sorted.bam && samtools index dustMapping.sorted.bam -o dustMapping.sorted.bam.bai && rm dustMapping.sam && dustMapping.bam

I don't know if the sorting was completed and why and the program terminates after outputting the sorted bam files. I have tried to merge with the following command.

bamtools merge -list folder.bam -out sorted.bam and I got a 64byte sorted.bam output file. what could be wrong please? (Im a Beginner) Thanks

Bamtools samtools mergesorted.bam • 3.1k views
ADD COMMENT
1
Entering edit mode

One likely can't merge the tmp files produced during sort manually. Sorting process, when it completes normally, will automatically delete the tmp files. You may need to assign more RAM to the sort process and/or make sure that you are not running out of disk space during the sorting.

samtools index command does not need a -o directive.

ADD REPLY
0
Entering edit mode

Oh OK. But How do I do that? Im working in a 500Gb external hard drive and has about 250GB of space.

ADD REPLY
0
Entering edit mode

Okay, first step to debugging this...I'd do things one at a time instead of stringing them all together. Confirm whether or not dustMapping.sorted.bam is being made (is "-odustMapping.sorted.bam" in your commandline, or just a typo here?)

Worst case scenario, you can cut your fastq into smaller pieces that are sortable, and maybe you can merge them all after.

ADD REPLY
0
Entering edit mode

Ok let me try doing the commands one after the other. The -o is a typo. thanks. Will let you know how it goes

ADD REPLY
0
Entering edit mode
4.1 years ago
jaqx008 ▴ 110

Thanks everyone, I was able to obtain my sorted.bam file. But when I tried to generate the .bai file, the output i get renamed to "-o". the command I ran was

samtools index dustMapping.sorted.bam -o dustMapping.sorted.bam.bai

is this normal? or I have the right .bai file

ADD COMMENT
0
Entering edit mode

You don't need to specify -o when you index the sorted file. Just samtools index dustMapping.sorted.bam will produce dustMapping.sorted.bam.bai

ADD REPLY
0
Entering edit mode

Oh. Thanks a lot. I will do that

ADD REPLY

Login before adding your answer.

Traffic: 1812 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