Mar 27, 2013

bash Scripts for Lab

Goal: make a bash script that runs convert_fastaqual_fastq.py on all the files in a folder.

Methods: First, we needs a list of all the files we want to run a script on.
Open a terminal, and use cd to move into the folder you want.

Then run:
ls > list.txt
This takes the results of ls and stores it all in list.txt.

Open list.txt in a text editor. If you don't want to run the qiime script on certain file, remove them from list.txt. Make sure there is one file name on each line and no extra or blank lines anywhere in the file.

Save it! Now copy and paste the following into that terminal you still have open:

while read line;
do time convert_fastaqual_fastq.py -f $line -o Output_Fastq -c fastq_to_fastaqual;
done < list.txt


This runs the script convert_fastaqual_fastq.py on each file in list.txt with all the given flags.

Here is the same code generalized to run other scripts:
while read line;
do time <copy and paste your script here, using $line as the input>;
done < list.txt

No comments:

Post a Comment