Filter our reads in sam file less than specific length
1
0
Entering edit mode
2.3 years ago
daewowo ▴ 80

I have a sam file with reads that are soft and hard clipped. I want to filter out reads less than 32nt including soft and hard clipping, ie the total read length should be less than 32nt irrespective of whether any part of the read aligns to a reference.

Any ideas on how to do this?

sam reads • 675 views
ADD COMMENT
1
Entering edit mode
2.3 years ago

using http://lindenb.github.io/jvarkit/SamJdk.html

java -jar dist/samjdk.jar -e 'final int len=32; if(record.getReadLength()>=len) return true; if(record.getReadUnmappedFlag()) return false; Cigar c = record.getCigar(); if(c==null || c.isEmpty()) return false; int n=0; for(CigarElement ce: c) { CigarOperator op = ce.getOperator(); if(op.isClipping() || op.consumesReadBases()) n+=ce.getLength(); } return n>=len;' in.bam
ADD COMMENT

Login before adding your answer.

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