1

Here is the exact command

bcftools norm -f /path/hg19/ucsc.hg19.fasta -c s ./user1.vcf -o ../fixed/user2.vcf

When I run it in the shell directly it works fine.
When i put it into a bash script it fails

The error message comes from bcftools itself

[main] Unrecognized command.

Script is encoded in ascii:

#!/bin/bash
bcftools norm -f /path/hg19/ucsc.hg19.fasta -c s ./user1.vcf -o ../fixed/user2.vcf

So bcftools accept argument when received directly from prompt but not within the script. It is like spaces from prompt and from script are not interpreted the same way

Timur Shtatland
  • 12,024
  • 2
  • 30
  • 47
zakrapovic
  • 413
  • 3
  • 17
  • 1
    Likely to be an issue with path.. Is the paths in your script relative to the location of the script? – sjsam Jul 19 '16 at 16:15
  • @sjsam Thx for answering. No it is not. Anyway, I execute the script and the command line from the same directory. – zakrapovic Jul 19 '16 at 16:18
  • Most likely an environment difference -- is `$BASH_ENV` set? If so, does that file set any environment variables that affect the running of `bcftools`? You might try using `#!/bin/sh` or `#!/bin/bash --posix` – Chris Dodd Jul 19 '16 at 16:28
  • 1
    Can you run *any* `bcftools` command, or is `norm` the only one that causes a problem? Did you type the command in the script, or did you copy and paste it from somewhere? – chepner Jul 19 '16 at 16:33
  • What's the output of `type -all bcftools`, at the prompt, and in the script? – tripleee Jul 19 '16 at 17:30
  • 1
    Is that the full error message? Usually after 'Unrecognised command' it gives which command is unrecognised. Looking at the C source: `fprintf(stderr, "[E::%s] unrecognized command '%s'\n", __func__, argv[1]);` So there should be something inside single quotes. Do you have more than one version of `bcftools` installed? – cdarke Jul 19 '16 at 19:36
  • A useful tool when debugging is to change your hashbang to `#!/bin/bash -x`, which will print out every command as it's run. – Xiong Chiamiov Jul 19 '16 at 21:24
  • Thanks to everyone I was not expecting so much answers. I got it thanks to @cdarke. I was using an alias to bcftools that was refering a recent version while there were an old version used by everyone else in /usr/bin. I added mine in the beginning of $PATH for my user. If you want to rephrase it cdarke, I will make it the answer. – zakrapovic Jul 20 '16 at 08:43

1 Answers1

1

Is that the full error message? Usually after 'Unrecognised command' it gives which command is unrecognised. Looking at the C source:

fprintf(stderr, "[E::%s] unrecognized command '%s'\n", __func__, argv[1]); 

So there should be something inside single quotes - the argv[1] in the code.

The most common reason in web chatter for this message is that certain commands are not available in early versions of bcftools. So, do you have more than one version of bcftools installed?

Comment (above) by the OP confirms that an alias referred to an earlier version.

cdarke
  • 42,728
  • 8
  • 80
  • 84