Get per-nucleotide mapping position for each mapped reads from bam file
1
0
Entering edit mode
3.4 years ago

Hello!

I'm trying to get per-nucleotide mapping position for each mapped read from a bam file.

Specifically, for each read from a bam file, I want to know the mapping position for the 13th nt in the read. Because its RNAseq bam, there should be lots of splicing reads. So we cannot just count 13 from the first mapping position.

So does anyone have any scripts to solve this problem? Many thanks in advance.

mapping nucleotide position • 1.5k views
ADD COMMENT
3
Entering edit mode
3.4 years ago

I wrote sam2tsv : http://lindenb.github.io/jvarkit/Sam2Tsv.html

$  java -jar dist/sam2tsv.jar -R src/test/resources/toy.fa src/test/resources/toy.bam 


#Read-Name  Flag  MAPQ  CHROM  READ-POS0  READ-BASE  READ-QUAL  REF-POS1  REF-BASE  CIGAR-OP
r001        163   30    ref    0          T          .          7         T         M
r001        163   30    ref    1          T          .          8         T         M
r001        163   30    ref    2          A          .          9         A         M
r001        163   30    ref    3          G          .          10        G         M
r001        163   30    ref    4          A          .          11        A         M
r001        163   30    ref    5          T          .          12        T         M
r001        163   30    ref    6          A          .          13        A         M
r001        163   30    ref    7          A          .          14        A         M
r001        163   30    ref    8          A          .          .         .         I
r001        163   30    ref    9          G          .          .         .         I
r001        163   30    ref    10         A          .          .         .         I
r001        163   30    ref    11         G          .          .         .         I
ADD COMMENT
0
Entering edit mode

Thank you very much Pierre! I will try your method.

ADD REPLY
0
Entering edit mode

Hi Pierre,

I have one more question is that do you consider strandness in your scripts. For example, if one read mapped to the negative strand, the 5' of the read should map to the 3' of the reference.

ADD REPLY
0
Entering edit mode

have one more question is that do you consider strandness in your scripts. For example, if one read mapped to the negative strand, the 5' of the read should map to the 3' of the reference.

no, it's always from 5' to 3' of the REF.

ADD REPLY
0
Entering edit mode

So for the negative mapped reads, if the READ-POS0 is 0, actually it should be the last nucleotide, right?

ADD REPLY
0
Entering edit mode

So for the negative mapped reads, if the READ-POS0 is 0, actually it should be the last nucleotide, right?

yes !

ADD REPLY
0
Entering edit mode

OK, thank you very much!

ADD REPLY

Login before adding your answer.

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