0

I have samtools installed, and I have used it before on my computer. I am trying to get it to work now, but when I type in samtools in terminal (mac os), it returns "command not found". I have navigated into my samtools folder too and it is still not working. Am i missing something? Thank you for your help

Emily
  • 23
  • 5
  • Where is the executable located? Is that location in your PATH? If you provide a fully-qualified path to the binary, does _that_ work? If not, and the executable is actually a script, what's the interpreter that executable is using (which is to say, what's the first line of the file, and does the binary it refers to actually exist?) – Charles Duffy Sep 14 '20 at 19:43
  • ...if you get an ENOENT from something that's a compiled executable rather than a script, then you need to look into whether the shared libraries it links to exist, but before diving into doing that we should figure out if it's necessary. – Charles Duffy Sep 14 '20 at 19:45
  • ...so, to run over the decision tree again: (1) Is the executable in the PATH of the shell that's trying to start it? (1.no) Add it to the PATH, or symlink to it from a location already in the PATH, etc. (1.yes)->(2) Can you run it with a fully-qualified path? (2.yes) Go back and reinvestigate for PATH issues, make sure the PATH you tested matches the one in use for the specific process, etc. (2.no)->(3) Is the file you want to execute a script? (3.no) List its shared libraries and make sure they exist. [continued] – Charles Duffy Sep 14 '20 at 19:49
  • (3.yes) Check its shebang to find the interpreter, and jump back to step 1 to investigate that interpreter. – Charles Duffy Sep 14 '20 at 19:50
  • the executable is in the samtools folder, when I launch it it does have the full path. even if I am in that directory, simple calling samtools does not work, but when I call the whole path, it works. Now navigating into a different directory where I have my bam files, I can call samtools with the full path. so the tree, 1 yes, 2, yes but I do not understand your explanation for that... – Emily Sep 15 '20 at 00:07
  • Could you provide the exact output from `printf '%q\n' "$PATH"`, and the exact text of the fully qualified invocation that works? – Charles Duffy Sep 15 '20 at 01:37
  • The current directory isn't included in your path by default. If you're in the samtools directory, you can use ./samtools (or bin/samtools etc if it's in a subdirectory) – Tom Morris Sep 15 '20 at 19:37
  • @CharlesDuffy, the output is /Library/Frameworks/Python.framework/Versions/3.8/bin:/Users/el/miniconda3/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin – Emily Sep 16 '20 at 14:53
  • additionally, I can run the samtools commands, "view", "flagstats" etc, but then any code that I include after that does not work. for instance: `samtools view file.bam | cut –f7 | grep –c ‘*’` returns: `usage: cut -b list [-n] [file ...] cut -c list [file ...] cut -f list [-s] [-d delim] [file ...] grep: ‘*’: No such file or directory` – Emily Sep 16 '20 at 15:20
  • That pipeline with the `grep –c ‘*’` has a completely independent set of problems, entirely unrelated to the installation of samtools. You can't use curly quotes like `‘` and `’` as syntax in shell. – Charles Duffy Sep 16 '20 at 15:31
  • I'd suggest using `set -x` to enable logging so you see how your commands are actually being interpreted. – Charles Duffy Sep 16 '20 at 15:34
  • @CharlesDuffy okay, so never mind the complete line that I am interested it. I did `set -x` and a long list of code was returned and I am not familiar with the meanings. the same response is returned when I enter `samtools view file.bam` with `-bash: samtools: command not found`. If i use the whole path for samtools, then I can view the bam file and it still returns the weird list. – Emily Sep 16 '20 at 17:24
  • You said `samtools view file.bam` worked. That claim is incompatible with the claim that you get that command not found. – Charles Duffy Sep 16 '20 at 17:53
  • Anyhow, though, I asked you not just for the PATH but for the fully qualified location so we can check whether that location is listed in the PATH. – Charles Duffy Sep 16 '20 at 17:54
  • @CharlesDuffy, it only works if I include the whole path. I abbreviated it in the comment above to make a different point. How is the fully qualified location different from the PATH? `/Users/el/Desktop/NKRsession/samtools-1.10 samtools view file.bam` is what I need to type in in order for it to execute samtools. I can do one command like `view`, but when I ask for it to cut a column `|cut -f7` it does not work, I get the response above. and what am I looking for in the `set -x` response? – Emily Sep 17 '20 at 13:07
  • `/Users/el/Desktop/NKRsession/samtools-1.10 samtools`, or `/Users/el/Desktop/NKRsession/samtools-1.10/samtools`? If the latter, just update your shell configuration so `$HOME/Desktop/NKRsession/samtools-1.10` is listed in your PATH. – Charles Duffy Sep 17 '20 at 13:24
  • With respect to `cut -f7` giving the usage error, that implies that it's being passed arguments other than just `-f7`. The `set -x` logs will show the precise argument list for each command in a way that makes it clear if there's a non-ASCII hidden character (like a non-breaking space), or something else in the command line that shouldn't be.. – Charles Duffy Sep 17 '20 at 13:25

0 Answers0