For loop to go over all files in a folder to execute bwa mem
1
0
Entering edit mode
17 months ago

Hello friends !!

Actually I am tiring to execute bwa mem to align my reads to reference genome. Here are the manual command I ma doing

#For 1st sample
cd SRR1

 bwa mem -t 20 genome/genomic.fna ./SRR1/good/SRR10176137_1.good.fq  ./SRR1/good/SRR10176137_2.good.fq > mappings/SRR10176137.sam
cd ..

# For 2nd sample

cd SRR2

 bwa mem -t 20 genome/genomic.fna ./SRR2/good/SRR10176138_1.good.fq  ./SRR2/good/SRR10176138_2.good.fq > mappings/SRR10176138.sam

like I have 200 SRR samples so I am trying following code for loop i.e.

my data structure is i.e. = data/SRR......SRR200/good/S_1.fq.

working directory : data list SRR...SRR; mappings; vcf; genome

So each SRR* directory has good directory containing paired sequence .fq files

Here out sam files in data/mapping directory in data directory

#!/bin/bash

for d in SRR*/good; do
     cd $d;
     # my command
     bwa mem -t 40 genome/genomic S*_1.good.fq S*_2.good.fq > ../mappings/*.sam
     cd ..
done

Any modification highly appreciated

Thank you :)

shell bwa • 988 views
ADD COMMENT
0
Entering edit mode

everyone am mem Hello working to i bwa with take a few minutes to write the rights tags please....

ADD REPLY
1
Entering edit mode
17 months ago

For loop to go over all files in a folder to execute bwa mem

this is a good idea, but you'd better use a workflow manager like snakemake or nextflow. If you're not familiar with those tools try to use a simple Makefile. See Parallel for bwa mem - problem with -R argument for ID and SM for an example.

ADD COMMENT
0
Entering edit mode

Hi Pierre, thanks for your suggestion. Actually in my code can you please suggest any modification, or correction because it gives me error i.e. command not found i.e. bwa_mem.bash: line 1: $'\r': command not found

ADD REPLY
0
Entering edit mode

Did you write your script in Windows? $'\r' sounds like a Microsoft style linebreak. Run dos2unix yourScript.sh and then try again

ADD REPLY

Login before adding your answer.

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