Entering edit mode
7.9 years ago
Bioinfonext
▴
470
Hi please suggest command to extract mapped and unmapped pair end reads from bam file.
Hi please suggest command to extract mapped and unmapped pair end reads from bam file.
It's more straightforward from a fastq file... in that case you can use "outu=" for unmapped pairs and "outm=" for the mapped pairs in a single command. From a bam you need to use two commands:
reformat.sh in=x.bam out=y.bam mappedonly
reformat.sh in=x.bam out=z.bam unmappedonly
Depending on exactly what you want to do with unmapped mates of mapped reads, you can get a finer degree of control with these two flags:
requiredbits=0 (rbits) Toss sam lines with any of these flag bits unset. Similar to samtools -f.
filterbits=0 (fbits) Toss sam lines with any of these flag bits set. Similar to samtools -F.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
I dont want any unmapped mate of mapped reads in case of extracting mapped pair end read.
same is in the case of unmapped reads only unmapped reads with pair when extracting unmapped reads.
OK, then use the reformat commands I gave with "mappedonly" and "unmappedonly".
when running above cammand:
Found samtools. /home/yog/software/bbmap/reformat.sh in=216_5W_Ca1.bam out=216_5W_Ca1.mapped.bam mappedonly
Input is being processed as unpaired
Waiting on header to be read from a sam file. Input: 17336990 reads 2067204125 bases Output: 11202398 reads (64.62%) 1348474253 bases (65.23%)
why it reading input as unpaired?
Sam and bam files are always processed as "unpaired", because Reformat is a streaming tool and there is no way to ensure paired reads in a sam/bam file are located near each other. It doesn't matter in this case - the end result is that you get a file containing all of the mapped records from the input bam, with the read number information intact.
Do I need to sort mapping bam file before extraction fo unmap and mapped reads in bam file format. then need to convert fastq using bamtool.
Is there any direct way to extract pair mapped reads in fastq format from bam file and also unmaaped pair end reads.
Sorting is unnecessary in this case. For fastq output, just change the output names and add "primaryonly":