Question: How to get ungapped single-end reads from the STAR output bam file?
0
gravatar for caggtaagtat
16 months ago by
caggtaagtat860
caggtaagtat860 wrote:

Hello,

After mapping with STAR, I would like to remove all reads (single-end) from my Bam file, which show a gap in their alignment. Can this be done with samtools somehow?

ADD COMMENTlink modified 16 months ago by Pierre Lindenbaum124k • written 16 months ago by caggtaagtat860

Are deletions OK or do you want them filtered too?

ADD REPLYlink written 16 months ago by Devon Ryan92k

I would like to remove deletions as well

ADD REPLYlink written 16 months ago by caggtaagtat860

GAP = single nucleotide variation + indels ?

ADD REPLYlink written 16 months ago by Pierre Lindenbaum124k

I mean the remaining reads should be only continiously mapped to the reference genome, without a gap in their alignment, through splicing or deletions. The occurrence of SNPs was allowed during mapping and should be disregarded at this step.

Edit: Sry, with gap, I meant a splice junction in the reads alignment

ADD REPLYlink modified 16 months ago • written 16 months ago by caggtaagtat860
2
gravatar for Pierre Lindenbaum
16 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum124k wrote:

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

$ java -jar dist/samjdk.jar -e 'return !record.getReadUnmappedFlag() && record.getCigar()!=null && record.getCigar().getCigarElements().stream().map(C->C.getOperator()).noneMatch(OP->OP.equals(CigarOperator.N) || OP.equals(CigarOperator.D));'  in.bam
  • !record.getReadUnmappedFlag() read must be mapped
  • record.getCigar()!=null read has cigar
  • record.getCigar().getCigarElements().stream(). get a stream of cigar componenets
  • map(C->C.getOperator()) map to the cigar operator
  • noneMatch(OP->OP.equals(CigarOperator.N) || OP.equals(CigarOperator.D)); no operator can be 'N' or 'D'
ADD COMMENTlink written 16 months ago by Pierre Lindenbaum124k
1

Thank you very much! This is a very interesting tool and it seems to work.

Edit: It definitly worked right away

ADD REPLYlink modified 16 months ago • written 16 months ago by caggtaagtat860
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1245 users visited in the last hour