Filtration of paired reads with both length higher than 50 from bam file
1
0
Entering edit mode
5 weeks ago
Mgs3 ▴ 30

I understand that for filtering reads based on length i can simply use:

 samtools view -h file.bam | awk 'length($10) > 50 || $1 ~ /^@/' | samtools view -bS - > output.bam

But how can i select paired reads that both are longer than 50?

bam awk sed • 254 views
ADD COMMENT
0
Entering edit mode

Untested but may also work. Using BBMap suite.

samtools sort -n -o - file.bam | reformat.sh -Xmx6g in=stdin.bam out=filtered.bam minlength=50 requirebothbad=f
ADD REPLY
2
Entering edit mode
5 weeks ago

using samjdk with option --pair:

$ java -jar picard.jar SortSam I=in.bam O=/dev/stdout SO=queryname | \
   java -jar dist/samjdk.jar --pair -e 'return records.stream().allMatch(R->R.getReadLength()>50);'
ADD COMMENT

Login before adding your answer.

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