Question: run a tool from python
0
gravatar for Sar
6 weeks ago by
Sar0
Sar0 wrote:

Hello,

I have a command that it is executed normally in a directory where we will generate our results, when we want to do it from linux it suffices to be in the directory "result" and run the command (perl -input .....). I want to run it from python.... I created my variable: cmd = perl input.... subprocess.cal (cmd, shell = true) except that here I am not in the directory where I have to generate my results, do you have a solution ?

sequencing next-gen sequence • 110 views
ADD COMMENTlink written 6 weeks ago by Sar0

You are right that you need subprocess to run the command. You can either express your full paths in the command, or use os.chdir() to move to new folders.

If you're running a perl script from within python though, this strikes me as not the most efficient process.

I'm going to leave the post open for now, but note that this is not obviously a bioinformatics question so may be closed.

ADD REPLYlink written 6 weeks ago by Joe19k

i knew i have to use os.chdir () but i dont know how to apply it. os.chdir (my path) and the line after I type my command and after my subprocess.call?

ADD REPLYlink written 6 weeks ago by Sar0
os.chdir(my path) \\
cmd = perl + pathBam + path... \\
subprocess.call(cmd, shell=true)
ADD REPLYlink modified 6 weeks ago by GenoMax96k • written 6 weeks ago by Sar0

How about:

cmd = 'cd <your directory> ; ' + perl + pathBam + path... \\
ADD REPLYlink written 6 weeks ago by Mensur Dlakic9.2k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1866 users visited in the last hour
_