Perl error in batch command but works one at a time

In the below perl executes if one file is processed perfect. However, when multiple files are processed in batch which is preferred I get the below error that I can not seem to fix it as the '' necessary for the command to execute, but seem to only work for one -arg option. Thank you :).

command to process one file at a time

perl -ne 'chomp; system ("perl table_annovar.pl -vcfinput file.vcf humandb/ -buildver hg19 -arg '-hgvs',,,,, -remove -protocol IDP.refGene,avsnp147,popfreq_all_20150413,spidex,dbnsfp33a,clinvar_20161128 -operation g,f,f,f,f,f -otherinfo -nastring .")' < target.txt

Using a batch command I get:

Batch command to process all files in target.txt

perl -ne 'chomp; system ("perl table_annovar.pl -vcfinput $_ humandb/ -buildver hg19 -arg '-splicing_threshold 50 -hgvs',,,,, -remove -protocol IDP.refGene,avsnp147,popfreq_all_20150413,spidex,dbnsfp33a,clinvar_20161128 -operation g,f,f,f,f,f -otherinfo -nastring .")' < target.txt
Can't find string terminator '"' anywhere before EOF at -e line 1.
perl -ne 'chomp; system ("perl table_annovar.pl -vcfinput $_ humandb/ -buildver hg19 -arg -splicing_threshold 50 -hgvs,,,,, -remove -protocol IDP.refGene,avsnp147,popfreq_all_20150413,spidex,dbnsfp33a,clinvar_20161128 -operation g,f,f,f,f,f -otherinfo -nastring .")' < target.txt
Unknown option: hgvs,,,,,

That is not Perl. The membrane-thin wrapper of Perl serves literally no purpose. That is nothing but shell code. If you write the loop inside shell you'll save so much trouble and CPU time.

I too made this error when first learning to program in Perl and shell. Learn a little more shell and it will make more sense.

You can also split across multiple lines for readability by putting backslash-newline wherever you need to split it.

while read LINE
do
        echo perl table_annovar.pl -vcfinput "$LINE" humandb/ -buildver hg19 -arg '-hgvs',,,,, -remove -protocol \
                IDP.refGene,avsnp147,popfreq_all_20150413,spidex,dbnsfp33a,clinvar_20161128 \
                -operation g,f,f,f,f,f -otherinfo -nastring .
done < target.txt

Remove the echo once you've tested and made sure it does what you want.

1 Like

Thank you very much :slight_smile: