Filter our reads in sam file less than specific length
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?
• 1,116 views
•
link
1 answer
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
• 0 views
•
link
Log in to answer this question.