Question: extract the aligned read names and their reference fasta sequence name
1
gravatar for trisha
2.4 years ago by
trisha10
India
trisha10 wrote:

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 • 1.2k views
ADD COMMENTlink modified 2.4 years ago • written 2.4 years ago by trisha10

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 REPLYlink written 2.4 years ago by James Ashmore2.8k

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 REPLYlink modified 2.4 years ago • written 2.4 years ago by trisha10

What about my suggestion?

ADD REPLYlink written 2.4 years ago by WouterDeCoster42k

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 REPLYlink modified 2.4 years ago • written 2.4 years ago by trisha10
1

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 REPLYlink written 2.4 years ago by WouterDeCoster42k

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

ADD REPLYlink modified 2.4 years ago • written 2.4 years ago by trisha10

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 REPLYlink written 2.4 years ago by WouterDeCoster42k
3
gravatar for WouterDeCoster
2.4 years ago by
Belgium
WouterDeCoster42k wrote:

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 COMMENTlink written 2.4 years ago by WouterDeCoster42k

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 REPLYlink written 2.4 years ago by Devon Ryan93k
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: 604 users visited in the last hour