extract the aligned read names and their reference fasta sequence name
1
1
Entering edit mode
6.7 years ago
trisha ▴ 10

Its a silly question
How to extract list of read names and their corresponding aligned fasta sequence name as table from the reference provided based on alignment.bam file

RNA-Seq alignment • 3.2k views
ADD COMMENT
0
Entering edit mode

Just in case your end goal is to find how many reads are aligned to each chromosome. You can just use:

samtools idxstats input.bam
ADD REPLY
0
Entering edit mode

Thank you, this gives me the number of the reads mapped to each chromosome, However I would like to know the name of the read corresponding to its mapped chromosome
for example from your given samtools indexstats
chr1 38193400 19672 0
I would like to know the name of the reads that mapped to the chromosome one

ADD REPLY
0
Entering edit mode

What about my suggestion?

ADD REPLY
0
Entering edit mode

Thank you for your suggestion, However I get the following error. may be I did not understand correctly.
samtools view sorted_trimmed_corrected_merged.bam | cut -f1,3 Unless fasta identifier != "fasta sequence name"
cut: Unless: No such file or directory
cut: fasta: No such file or directory
cut: identifier: No such file or directory
cut: fasta sequence name: No such file or directory

ADD REPLY
1
Entering edit mode

What?! But. The last sentence was not part of the command. You just need to run the following:

samtools view alignment.bam | cut -f1,3
ADD REPLY
0
Entering edit mode

Thank you so much, I really apologies for this stupid blunder. This works perfectly well.

ADD REPLY
0
Entering edit mode

Great, I have moved my comment to an answer so you can mark it as accepted and as such mark this question as solved.

ADD REPLY
3
Entering edit mode
6.7 years ago

Probably I don't understand the question, but what about this?

samtools view alignment.bam | cut -f1,3

Unless fasta identifier != "fasta sequence name"

ADD COMMENT
0
Entering edit mode

Indeed, I may have missed the "name" part at the end (on my screen it's showing up on a separate line). I saw the title and thought that the sequence from the fasta file itself was what was needed.

ADD REPLY

Login before adding your answer.

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