This is a test version of Biostars. For the public version, visit https://www.biostars.org.
run a tool from python

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 ?

sequence sequencing next-gen

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.

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?

os.chdir(my path) \\
cmd = perl + pathBam + path... \\
subprocess.call(cmd, shell=true)

How about:

cmd = 'cd <your directory> ; ' + perl + pathBam + path... \\

0 answers

No answers yet.

Log in to answer this question.