How to get the statistics of bowtie alignment into a file?
2
0
Entering edit mode
6.7 years ago
Bella_p ▴ 70

Hi,

I'm using bowite for alignment with the following script:

${bowtie_source}  --best  --sam ${ref_genome} ${fastq_file} | ${samtools}  view -bS - |  ${samtools} sort -o ${target_dir}/${sample_name}.bam

and on the terminal I get the statistics:

# reads processed: 12641952
# reads with at least one reported alignment: 5914379 (46.78%)
# reads that failed to align: 5352269 (42.34%)
# reads with alignments suppressed due to -m: 1375304 (10.88%)
Reported 5914379 alignments

Anyone know how to get this statistics into a text file, plus maybe more statistics that can be extracted besides what is printed on the terminal?

ChIP-Seq bowtie • 6.4k views
ADD COMMENT
0
Entering edit mode

Bella_p, I just noticed something: You're using ${samtools} and ${bowtie_source}, not samtools and bowtie. Why is that?

ADD REPLY
1
Entering edit mode
ADD REPLY
1
Entering edit mode
6.7 years ago
GenoMax 147k

Redirect standard error and standard out to a file to capture things printed to screen.

You can use other programs like Qualimap and BamUtils to get additional statistics from BAM files.

Edit: Since @Ram pointed out that the first link may have confusing reference to 2 standing in for to in headers of sections here is a staid Stackoverflow version.

ADD COMMENT
0
Entering edit mode

The first link has weird text. Are they using 2 as a stand-in for to? It's crazy seeing such usage on a popular website.

@Bella_p: The sub-headers in the tldp site have text that goes std### 2 file and so on. Please mentally substitute each 2 with a to when you read those sub-headers. It has nothing to do with the actual 2 in that context, which is the file descriptor for stderr (usage like 2>)

ADD REPLY
2
Entering edit mode
4.3 years ago

To clarify @genomax's correct answer, the output the OP wants to save is stderr. Therefore, to save it to a file you can use 2> stats.file, e.g.

${bowtie_source}  --best  --sam ${ref_genome} ${fastq_file} 2> stats.file | ${samtools}  view -bS - |  ${samtools} sort -o ${target_dir}/${sample_name}.bam
ADD COMMENT

Login before adding your answer.

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