Samtools Filter by CIGAR string
1
0
Entering edit mode
2.2 years ago
Ruoshui • 0

Hi,

I have a bam file and want to filter it by CIGAR string. I want to keep the lines that have a match larger than 100. For example, the CIGAR string is 20S80M12S, then I want to discard this sequence.

How should use samtools to do this?

I'm currently using

./samtools view -h -e '$6 =~ "(^|[^0-9])([1-9][0-9]{2,}|[1-9][0-9]{3,})M[^0-9]"' -o D1.sorted.dup.filt.bam D1.sorted.dup.bam

But this doesn't work, what should I do?

samtools bam • 658 views
ADD COMMENT
1
Entering edit mode
2.2 years ago

using samjdk



java -jar  dist/jvarkit.jar samjdk -e 'return !record.getReadUnmappedFlag() && record.getCigar().getCigarElements().stream().filter(CE->CE.getOperator().equals(CigarOperator.M)).anyMatch(CE->CE.getLength()>100);' in.bam

similar to Filter bam file based on cigar string?

biostars is broken. I need to add stuff to validate my answer. I need to add stuff to validate my answer. I need to add stuff to validate my answer. I need to add stuff to validate my answer. I need to add stuff to validate my answer.

ADD COMMENT

Login before adding your answer.

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