forked from synbiochem/galaxytools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesign2doeTool.py
47 lines (43 loc) · 1.9 KB
/
design2doeTool.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 19 09:29:08 2019
@author: Pablo Carbonell, SYNBIOCHEM
@description: After running design2doe, run doepy and postprocessing
"""
import argparse
import os
import shutil
import zipfile
import glob
import subprocess
import re
def doepy(input1, input2, input3):
""" Run doepy, to do: replace by import doepy """
""" python3 $__tool_directory__/code/sbc-doe/doepy.py $input1 $input2 -j $input3 -v "DoE Template" -o -b -r -V -bro """
doepypath = os.path.join( os.path.dirname(__file__), 'code', 'sbc-doe', 'doepy.py' )
call = ['python3', doepypath, input1, input2, '-j', input3, '-v', "DoE Template", '-o', '-b', '-r', '-V', '-bro']
print( ' '.join(call) )
return subprocess.call( call )
def arguments():
parser = argparse.ArgumentParser(description='Postprocessing after running design2doe. Pablo Carbonell, SYNBIOCHEM, 2020')
parser.add_argument('input', help='Input design file')
parser.add_argument('name', help='Design name')
parser.add_argument('lib', help='Combinatorial library file')
parser.add_argument('output', help='Output diagram file')
parser.add_argument('output2', help='Output zip file')
parser.add_argument('output3', help='Output txt file')
return parser
if __name__ == '__main__':
parser = arguments()
arg = parser.parse_args()
for f in glob.glob( os.path.join( os.path.dirname(arg.input),arg.name+'.*') ):
os.unlink(f)
doepy( arg.input, arg.name, arg.lib )
pdf = os.path.join( os.path.dirname(arg.input), arg.name + '.pdf' )
txt = os.path.join( os.path.dirname(arg.input), arg.name + '.txt' )
shutil.copy( pdf, arg.output )
shutil.copy( txt, arg.output3 )
with zipfile.ZipFile( arg.output2, 'w' ) as myzip:
for f in glob.glob( os.path.join(os.path.dirname(arg.input),arg.name+'.*') ):
myzip.write( f,arcname=os.path.basename(f) )