Skip to content
Snippets Groups Projects
Commit a897d661 authored by Amandine  PERRIN's avatar Amandine PERRIN
Browse files

fastme: if alignment in phylip already exists do not redo it

parent dc700a0e
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,11 @@ def convert2phylip(infile, outfile):
Input alignment is in fasta format. Input of fastME must be in Phylip-relaxed format.
Convert it here.
"""
if os.path.isfile(outfile):
logger.info("Phylip alignment file already existing.")
logger.warning(("The Phylip alignment file {} already exists. The program "
"will use it instead of re-converting {}.").format(outfile, infile))
return
logger.info("Converting fasta alignment to PHYLIP-relaxed format.")
with open(infile, 'r') as input_handle, open(outfile, 'w') as output_handle:
alignments = AlignIO.parse(input_handle, "fasta")
......
......@@ -191,8 +191,10 @@ def run_cmd(cmd, error, eof=False, **kwargs):
if not "stderr" in kwargs:
kwargs["stderr"] = None
try:
retcode = subprocess.call(shlex.split(cmd), stdout=kwargs["stdout"],
call = subprocess.Popen(shlex.split(cmd), stdout=kwargs["stdout"],
stderr=kwargs["stderr"])
call.wait()
retcode = call.returncode
except OSError:
logger.error(error + ": " + "{} does not exist".format(cmd))
if eof:
......@@ -203,7 +205,7 @@ def run_cmd(cmd, error, eof=False, **kwargs):
logger.error(error)
if eof:
sys.exit(retcode)
return retcode
return call
def plot_distr(values, limit, outfile, title, text):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment