-
Notifications
You must be signed in to change notification settings - Fork 0
/
gnpssiriusexport.py
62 lines (46 loc) · 2.05 KB
/
gnpssiriusexport.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
import shutil
import sys
import xmltodict as xtd
'''
#6 module: gnps export
'''
def gnpssiriusexport(featurelinker_file, inputFiles_port, ini_file, output_type, out_port):
in_cm = featurelinker_file
# in_cm = in_port+'/'+get_port_outputs(in_port)[0]
output = out_port + '/' + "gnpsexport.mgf"
# in_cm = in_port+'/'+get_port_outputs(in_port)[0]
output = out_port + '/' + "gnpssiriusexport.mgf"
command = "GNPSSiriusExport -ini " + ini_file + " -in_cm " + in_cm + " -in_mzml "
for file in os.listdir(inputFiles_port):
command += inputFiles_port+'/'+file + " "
command += "-out " + output + " -output_type " + output_type + ' >> ' + out_port+'/logfile.txt'
print("COMMAND: " + command + "\n")
os.system(command)
if __name__ == '__main__':
print("===GNPS SIRIUS EXPORT===")
# set env
if os.environ.has_key("LD_LIBRARY_PATH"):
os.environ["SANS_LD_LIBRARY_PATH"] = os.environ["LD_LIBRARY_PATH"]
os.environ["LD_LIBRARY_PATH"] = "/data/beta-proteomics2/tools/openms_2.4/openms-env/conda/lib"
if os.environ.has_key("PATH"):
os.environ["SANS_PATH"] = os.environ["PATH"]
os.environ["PATH"] = "/data/beta-proteomics2/tools/openms_2.4/openms-env/conda/bin:/data/beta-proteomics2/tools/openms_2.4/openms-env/openms-build/bin:$PATH"
openms_data_path = '/data/beta-proteomics2/tools/openms_2.4/openms-env/share'
os.environ["OPENMS_DATA_PATH"] = os.path.abspath(openms_data_path)
# output type
output_type = 'merged_spectra'
with open(sys.argv[3], 'r') as fp:
params = xtd.parse(fp.read())
for param in params['parameters']['parameter']:
if param['@name'] == "gnpsexport.output_type":
output_type = param['#text']
curr_dir = os.listdir('.')
print(curr_dir)
for dir in curr_dir:
print(dir+":")
print(os.listdir(dir))
# ini file
ini_file = 'iniFiles/'+os.listdir('iniFiles')[0]
# shutil.copyfile(ini_file, sys.argv[3])
gnpssiriusexport(sys.argv[1], sys.argv[2], ini_file, output_type, sys.argv[5])