Question: How can I run a same command in mac terminal for multiple files in a folder?
0
gravatar for vermaakhilkr01
6 months ago by
vermaakhilkr010 wrote:

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)

sequencing rna-seq alignment • 239 views
ADD COMMENTlink modified 6 months ago by genomax59k • written 6 months ago by vermaakhilkr010

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 REPLYlink modified 6 months ago • written 6 months ago by genomax59k

Mouse genome. And RAM isn't the problem. I've got a RAM 64 GB desktop(Mac, currently using) and 192 GB RAM Workstation Dell.

ADD REPLYlink written 6 months ago by vermaakhilkr010
2
gravatar for genomax
6 months ago by
genomax59k
United States
genomax59k wrote:

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 COMMENTlink modified 6 months ago • written 6 months ago by genomax59k

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

ADD REPLYlink written 6 months ago by vermaakhilkr010

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 REPLYlink modified 6 months ago • written 6 months ago by genomax59k
Please log in to add an answer.

Help
Access

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