Question: (Closed) Running Batch Files From Command Line
0
gravatar for bioinfo
4.6 years ago by
bioinfo680
EU
bioinfo680 wrote:

I have around 50 similar .txt files in a folder. I extracted the info I need from txt files. I was wondering how to run all these 50 files (less *.gz.txt| awk '... doesn't create .output.txt for individual input .txt files) in a single run with individual output files?

Input files look like below:

BACP0000929|xaiA|gi|302543193|ref|ZP_07295535.1|_<97>:0:664:+  0       0.0     0.0     0.0
BACP0000011|fytD|gi|340626483|ref|YP_004744935.1|_<97>:0:657:+ 0       0.0     0.0     0.0
BACP0008288|cuyD|gi|365866299|ref|ZP_09405920.1|_<97>:0:660:+  0       0.0     0.0     0.0

Used command:

less 9673.fna.gz.txt |  awk '{OFS="\t";  split($1,x,"|"); print x[2], $2}'| awk '$2 > 0'| sort -k2r| uniq –c | sort -rn > output.txt

Output:

286 xaiA    1
236 FabB    1
170 uyTB    1
166 yuTB    1
152 iopC    1
perl awk • 1.5k views
ADD COMMENTlink written 4.6 years ago by bioinfo680
1

for i in *.txt;do cat $i | awk . . . >$(basname $i .txt).output.txt;done

ADD REPLYlink written 4.6 years ago by Chris Miller20k
1

Use GNU Parallel to parallelize:

do_one() {
  cat $1 | awk '{OFS="\t";  split($1,x,"|"); print x[2], $2}'| awk '$2 > 0'| sort -k2r| uniq –c | sort -rn 
}
export -f do_one
parallel do_one {} ">" {.}.output.txt ::: *.txt
ADD REPLYlink modified 4.5 years ago • written 4.5 years ago by ole.tange3.2k

And now that I've sent you on the right track, I'm closing this question because it's really a programming question, not a bioinformatics question. You'd have better luck with stack overflow, or better yet, a basic BASH tutorial website.

ADD REPLYlink written 4.6 years ago by Chris Miller20k
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

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