I'm new to bash. I have installed "seqtk" and "magicblast" in my shell calling "conda install" on terminal, and they work properly when I directly called them on terminal or write them in a bash script(test.sh) and then run that script on terminal.
This is test.sh
#!/bin/bash
var1=$(sed 's/\.fastq\.gz/\.fa/' <<< $1)
seqtk seq -a $1 > $(basename $var1)
and this would work
$./test.sh sample_folder/sample_R1.fastq.gz
But when I tried to run the script using python(test.ipynb)
import os
os.system("./test.sh sample_folder/sample_R1.fastq.gz")
it gives me "seqtk: command not found"
I searched on Google and thought it's because I installed the commands in my shell but 'os.system' would start a new shell and run the commands there, that's why test.ipynb shows "command not found" while the commands can work properly on terminal.
I'm wondering how could I solve this issue.
Thanks in advance!
I also tried using "source" to solve this by os.system("source HOME/.bash_aliases"), and this failed and shows "source: not found". I don't really know how to use this command.
seqtk, check again that its a known name by typingwhich seqtkorseqtk --version, and you certainly don't need the source thing which you are doing.type setq(in bash)? If it's an alias or a shell function, that's not expected to work in a noninteractive shell. If it's an executable, make sure it's located in a directory listed inprint(os.environ['PATH'])(in Python).os.system('source anything')isn't expected to work. First,sourceis a bash built-in andsysteminvokessh, not bash. Second, anything that the source command does only lasts as long as the shell does, and by the timeos.systemreturns the shell it invoked has already exited. Third, aliases are only enabled by default in interactive copies of bash, so even if you run thealiascommand in a noninteractive shell it does nothing unless you've gone out of your way to turn that feature on.subprocess.Popen(which is the modern replacement; nobody should be usingos.systemanymore) to invoke the target directly without depending on the alias or using sh or bash at all.type seqtk, rather)