Hi, I have another question with bash. In the folder, I have 400 result files. I want all result to compare with his reference file.
My file structure looks like:
resFileXXX.fasta
XXX.afa
resFileYYYYYY.fasta
YYYYYY.afa
resFileU.fasta
U.afa
I need to create script comparing this by mscore. mscore command looks that:
mscore -cftit <referenceFile> <restultFile> >output
So in my case it will be something like this:
mscore -cftit XXX.afa resFileXXX.fasta >finalXXX.txt
Can someone tell me how to create a proper script in bash? It's unfamiliar to me yet, and files are too much to do that manually.
Now my script looks like this (didn't work):
#!/bin/bash
ls *.afa | while read A; do B=`echo $A | sed 's/^file/Res/;s/.afa$//'`; ./mscore -cftit $A $B.fasta > ${B}final.txt; done
It didn't work coz it creates blank files, and they have weird names like XXXresXXX.fasta.afa As I said bash is unfamiliar to me, so I think it's a syntax error. I don't even know that script is in good convention :)
Can someone help with this problem?
1 answer
input:
$ ls
resFileU.fasta resFileXXX.fasta resFileYYYYYY.fasta U.afa XXX.afa YYYYYY.afa
in bash:
$ for i in *.afa; do echo "mscore -cftit $i resFile$i > final${i%.afa}.txt"; done
mscore -cftit U.afa resFileU.afa > finalU.txt
mscore -cftit XXX.afa resFileXXX.afa > finalXXX.txt
mscore -cftit YYYYYY.afa resFileYYYYYY.afa > finalYYYYYY.txt
using GNU-parallel:
$ parallel --dry-run 'mscore -cftit {} resFile{} > final{.}.txt' ::: *.afa
mscore -cftit U.afa resFileU.afa > finalU.txt
mscore -cftit XXX.afa resFileXXX.afa > finalXXX.txt
mscore -cftit YYYYYY.afa resFileYYYYYY.afa > finalYYYYYY.txt
Log in to answer this question.
is the most uninformative error message in all of science ;-) Please avoid this and expain what the problem is.
OK! I explained in edit :)
Use these for some inspiration :
Bash Script Loop Help
C: looping a list of trimed fasta files to run spades assembler