Question: Read In Function for BAM file processing
gravatar for Jonas.Koch
10 months ago by
Jonas.Koch0 wrote:

Hi all,

I want to write a bash script that reads in a BAM file and performs several processing steps with that input file.

Can you recommend some ideas to write such a script? I am a beginner and would be very happy for some input. We want to extract mapped and unmapped reads of the BAM files. I have already written the commands for these purposes, but I don't know how to write such a read in function. Otherwise, I would have to type in all commands again and again for each BAM file.

Many greetings!

script bam • 242 views
ADD COMMENTlink written 10 months ago by Jonas.Koch0

can you show us an outline of what this might look like for a single file?

ADD REPLYlink written 10 months ago by i.sudbery6.6k

Providing you with a skeleton to play with. Remove word echo once your command lines look sane to actually run.

for file in *.bam
do name=$(basename $file .bam) 
# re-use ${name} as needed to reconstruct new file names with relevant steps
echo samtools sort -o ${name}_sorted.bam ${name}.bam
echo samtools view -F 256 ${name}.bam ....
ADD REPLYlink modified 10 months ago by ATpoint28k • written 10 months ago by genomax77k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2057 users visited in the last hour