yes exactly!! Thank you so much!!
• 0 views
•
link
Hello! I have a very simple question, I think, as I am only now learning and studying NGS. Supposing we have a bam file, how do I know the name of a specific read? For example, which is the name of read 313? Thank you very much!
For example, which is the name of read 313?
do you mean the 313th read ?
$ samtools view in.bam | cut -f 1 | head -n 313 | tail -n 1
yes exactly!! Thank you so much!!
you can also try:
$ samtools view <in.bam> | awk 'NR==313 {print $1;exit}'
$ samtools view <in.bam> | sed -n '313{s/\s.*//p;q}'
what if I want to know the name of a fastq read? like 568th read
$ samtools view <in.bam> | awk 'NR== 568 {print $1;exit}'
bash shell#! /usr/bin/env bash samtools view $1 | awk -v line=$2 ' NR==line {printf "%s %d %s - %s\n", "read", line, "is",$1;exit}'
chmod +x read_name.shExecute the script in bash shell
./read_name.sh <input.bam> <read_number>
For eg
$ read_name.sh s1454.bam 123
Log in to answer this question.