How can I run a same command in mac terminal for multiple files in a folder?
1
0
Entering edit mode
6.5 years ago

How can I run the same command in mac terminal for multiple files in a folder? The files are named like 24538_7#1_paired1.fq, 24538_7#1_paired2.fq, 24538_7#2_paired1.fq, 24538_7#2_paired2.fq, 24538_7#3_paired1.fq, 24538_7#3_paired2.fq, and so on.

The command is:

STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/24538_7#1_paired1.fq data/24538_7#1_paired2.fq --outFileNamePrefix results/STAR/

Since filename involves a counter, so, obviously the filenames need to be changed.

I was trying to write command, but it's giving segmentation fault. My effort for the command is below:

for file in 24538_7#*.fq; do STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/"${file%.fq}_paired1.fq" data/"${file%.fq}_paired2.fq" --outFileNamePrefix results/STAR/ ; done

(PS- I use MacOS)

RNA-Seq alignment sequencing rna-seq • 2.3k views
ADD COMMENT
0
Entering edit mode

What genome are you aligning against? STAR requires at least 30+G of free RAM (for human sized genomes) so unless you have that available that may be your first problem.

ADD REPLY
0
Entering edit mode

Mouse genome. RAM isn't an issue for me. I've got a RAM 64 GB desktop(Mac- currently in use) and a 192 GB RAM Workstation Dell (in-store).

ADD REPLY
2
Entering edit mode
6.5 years ago
GenoMax 147k

This looks correct. Remove the word echo when ready to run.

for file in 24538_7#*paired1.fq; do echo STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/"${file%%_paired1.fq}_paired1.fq" data/"${file%%_paired1.fq}_paired2.fq" --outFileNamePrefix results/STAR/ ; done
STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/24538_7#1_paired1.fq data/24538_7#1_paired2.fq --outFileNamePrefix results/STAR/
STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/24538_7#2_paired1.fq data/24538_7#2_paired2.fq --outFileNamePrefix results/STAR/
STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/24538_7#3_paired1.fq data/24538_7#3_paired2.fq --outFileNamePrefix results/STAR/
ADD COMMENT
0
Entering edit mode

It's creating only 1 output file. (actually, it's rewriting the same output file for every input file)

ADD REPLY
0
Entering edit mode

For an idea of how you can get unique names for the output. Modify the last part as needed.

for file in 24538_7#*paired1.fq; do echo STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/"${file%%_paired1.fq}_paired1.fq" data/"${file%%_paired1.fq}_paired2.fq" --outFileNamePrefix results/STAR/${file%%_paired1.fq}.STAR ; done
STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/24538_7#1_paired1.fq data/24538_7#1_paired2.fq --outFileNamePrefix results/STAR/24538_7#1.STAR
STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/24538_7#2_paired1.fq data/24538_7#2_paired2.fq --outFileNamePrefix results/STAR/24538_7#2.STAR
STAR --runThreadN 12 --genomeDir indices/STAR --twopassMode Basic --readFilesIn data/24538_7#3_paired1.fq data/24538_7#3_paired2.fq --outFileNamePrefix results/STAR/24538_7#3.STAR
ADD REPLY

Login before adding your answer.

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