Hey guys, I'm writting a python script to automatize a lot of tasks, one of this tasks is the use of GLAPD (a tool to desing primers of lamp (http://cgm.sjtu.edu.cn/GLAPD/)).
So I have a list with the name of files that I want to use in the GLAPD, and use subprocess to execute GLAPD.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os, subprocess, shlex
uniq_list = ['file1.fasta','file2.fasta','file3.fasta','file4.fasta']
for x in uniq_list:
GLAPD_SINGLE = './Single -in ../'+x+' -out '+x+'_glapd_single'
GLAPD_SINGLE = shlex.split(GLAPD_SINGLE)
GLAPD_LAMP = './LAMP -in '+x+'_glapd_single'+' -ref ../'+x+' -out '+x+'_lamp_primers.txt'
GLAPD_LAMP = shlex.split(GLAPD_LAMP)
subprocess.Popen(GLAPD_SINGLE)
subprocess.Popen(GLAPD_LAMP)
Which is my problem,
when I run the script, in a first moment appear that the GLAPD_LAMP process runs before the end of GLAPD_SINGLE run, and this message is showed:
Sorry! Don't have any candidate single primers in /home/GLAPD/Outer/file1.fasta_glapd_single!
but after that, the GLADP_SINGLE continues running.
I think that GLAPD_SINGLE run much quickly in the first time, so the script continues to GLAPD_LAMP, but GLAPD_SINGLE continues running in background.
Can anyone help me? P.S: I know that is much more easy to do this with a shell script, but this is only one part of a great python scrypt.
I'm testing now, Idk of
x = subprocess.wait()
the correct syntax for python 3.5 or previous versions, but for python 3.6 shoud be:When my current analysis ends, I'll give the feedback, thanks Joe !
Everything runs ok Joe, thanks for your support.
Best,
Sorry yep, thats my mistake (serves my right for trying to do it from memory).
x.wait()
is correct.