I know this question have been asked multiple times, I read multiple questions trying to solve this issue. However, none of those actually worked.
I have a python script I downloaded from: https://github.com/endrebak/kg
I'm trying to run the following command from inside python. It works when I run it directly from the terminal but throws an error when I run it from inside python:
/usr/packages/kg-master/bin/kg --mergecol=0 --noheader --genes --definition --species=hsa <(echo 01200)
using the following code:
pathwayID = 01200
cmd="/usr/packages/kg-master/bin/kg --mergecol=0 --noheader --genes --definition --species=hsa <(echo {})".format(pathwayID)
tmp = os.popen(cmd).read()
However, I'm getting the following error:
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `/usr/packages/kg-master/bin/kg --mergecol=0 --noheader --genes --definition --species=hsa <(echo 05200)'
I tried multiple suggestions, like adding python
before calling the script
cmd="python /usr/packages/kg-master/bin/kg --mergecol=0 --noheader --genes --definition --species=hsa <(echo {})".format(pathwayID)
Another suggestion was using:
subprocess.call(['/usr/packages/kg-master/bin/kg', "--mergecol=0","--noheader","--genes","--definition","--species=hsa <(echo '01200')"])
This solution was the closest to solving the issue since the actual script is executed. however, it seems that the parameters are not being passed correctly which I don't know why.
any help would be appreciated.