Question: How to get ungapped single-end reads from the STAR output bam file?
0
gravatar for caggtaagtat
8 months ago by
caggtaagtat470
caggtaagtat470 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 8 months ago by Pierre Lindenbaum118k • written 8 months ago by caggtaagtat470

Are deletions OK or do you want them filtered too?

ADD REPLYlink written 8 months ago by Devon Ryan88k

I would like to remove deletions as well

ADD REPLYlink written 8 months ago by caggtaagtat470

GAP = single nucleotide variation + indels ?

ADD REPLYlink written 8 months ago by Pierre Lindenbaum118k

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 8 months ago • written 8 months ago by caggtaagtat470
2
gravatar for Pierre Lindenbaum
8 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum118k 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 8 months ago by Pierre Lindenbaum118k
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 8 months ago • written 8 months ago by caggtaagtat470
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: 764 users visited in the last hour