0
$\begingroup$

I am annotating some .txt files by Annovar software by this code

nnovar]$ module load annovar/2016Feb01

[cyan01 annovar]$ table_annovar.pl 

But I really got confused to do that by awk for all of my files in the path; Can somebody help me?

Many thanks

EDITED

I found this but not working

module load annovar/20

for file in *.vcf; do
    table_annovar.pl example/a.txt humandb/ -buildver hg19 -out file -remove -protocol refGene,cytoBand,exac03,avsnp147,dbnsfp30a -operation gx,r,f,f,f "$f" > "${f%.*}.txt"
done;
$\endgroup$
1
  • $\begingroup$ What do you mean by "not working"? What is the error message you are getting? $\endgroup$
    – haci
    Nov 19, 2019 at 11:58

2 Answers 2

4
$\begingroup$

$f in your command is not pointing anywhere since your for loop was defined as for file in *.vcf;. You should use $file instead of $f.

EDIT AS THE OP HAS EDITED THE QUESTION:

First of all, please copy and paste the error messages you are getting when seeking answers from the community, most of the time the error messages are clear enough to point to the right direction.

In you case, the problem is that you are trying to use a variable that you did not declare in the first place. It is explained above in my original answer but here I go again:

With this bit for file in *.vcf;, you are creating a variable file that you will using throughout the iteration. But then within the iteration, the next line (... -operation gx,r,f,f,f "$f" > ..., you try to use another variable file, that has not been declared yet (as far as I can see from your code bit).

$\endgroup$
1
$\begingroup$

The basic outline for loops is

for sample in *; do mycommand "$sample" ; done

You might need some way of incorporating the name of $sample into the output file name, so you don't keep overwriting the same output file over and over again (or do mkdir with each sample name and write everything for each sample in its own folder).

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.