Reputation: 3
I am rather new to bioinformatic but trying my best to learn. I am running into an issue and I was hoping someone would know what to do, and explain me how bash tool for multiple file is actually working.
I have a folder with 160 RNAseq libraries unzip just look like name.fastq
.
I want to run cutadapt
(a software which will remove all the adapters sequence from my libraries) on all of them at the same time; so, for one library, the command looks just like this:
python2.6 /imports/home/w/workshop/oibc2013/oibc1/Apps/cutadapt-1.2.1/bin/cutadapt -a name_adapter input_file.fastq > out
So I tried to make a bash array loop to be able to do it on all 160 files I have, but it still does not work.
!/bin/bash
. $HOME/.bashrc
my_array=(*.fastq)
echo ${myarray["SGE_TASK_ID"-1]}
python2.6 \
/imports/home/w/workshop/oibc2013/oibc1/Apps/cutadapt-1.2.1/bin/cutadapt \
-a CTGTCTCTTATACACATCT \
-b AATTGCAGTGGTATCAACGCAGAGCGGCCGC \
-b GCGGCCGCTCTGCGTTGATACCACTGCAATT \
-b AAGCAGTGGTATCAACGCAGAGTACATGGG \
-b CCCATGTACTCTGCGTTGATACCACTGCTT \
inputs.$SGE_TASK_ID \
results.$SGE_TASK_ID]}
Upvotes: 0
Views: 437
Reputation: 97938
Rather than an array, you just want a loop. In this case, since you're matching a glob pattern (*.fastq
), a for ... in
loop would make sense.
The general syntax is for variable_name in list_of_words; do something_with $variable_name; done;
. In your case:
#!/bin/bash
. $HOME/.bashrc
path=/imports/home/w/workshop/oibc2013/oibc1/Apps/cutadapt-1.2.1/bin
for file in *.fastq
do
python2.6 "$path"/cutadapt -a name_adapter "$file" > "$file.out"
done
Upvotes: 2