run a tool from python
0
0
Entering edit mode
3.9 years ago
Nobody ▴ 30

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 • 790 views
ADD COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode
os.chdir(my path) \\
cmd = perl + pathBam + path... \\
subprocess.call(cmd, shell=true)
ADD REPLY
0
Entering edit mode

How about:

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

Login before adding your answer.

Traffic: 2111 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6