annotate msms_extractor.py @ 0:4bef80b09854 draft default tip

"planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
author galaxyp
date Tue, 29 Oct 2019 11:09:46 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
1 #
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
2 # Developed by Praveen Kumar
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
3 # Galaxy-P Team (Griffin's Lab)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
4 # University of Minnesota
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
5 #
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
6 #
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
7 #
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
8
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
9
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
10 from pyteomics import mzml
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
11 import os
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
12 import sys
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
13 import shutil
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
14 import subprocess
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
15 import re
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
16 import pandas as pd
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
17 from operator import itemgetter
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
18 from itertools import groupby
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
19 import random
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
20 import argparse
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
21
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
22 def main():
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
23 if len(sys.argv) >= 7:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
24 parser = argparse.ArgumentParser()
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
25 parser.add_argument("msms", help="mzML File")
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
26 parser.add_argument("psm", help="PSM Report File")
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
27 parser.add_argument("out", help="Output filename")
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
28 parser.add_argument("filestring", help="MSMS File string as identifier")
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
29 parser.add_argument("remove_retain", help="Remove scans reported in the PSM report")
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
30 parser.add_argument("random", help="Random MSMS scans used with to use with --retain (default=0)", default=0)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
31 args = parser.parse_args()
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
32 # Start of Reading Scans from PSM file
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
33 # Creating dictionary of PSM file: key = filename key = list of scan numbers
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
34
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
35 # removeORretain = sys.argv[5].strip()
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
36 # randomScans = int(sys.argv[6].strip())
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
37
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
38 removeORretain = args.remove_retain
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
39 randomScans = int(args.random)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
40
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
41
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
42 # ScanFile = sys.argv[2]
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
43 ScanFile = args.psm
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
44 spectrumTitleList = list(pd.read_csv(ScanFile, "\t")['Spectrum Title'])
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
45 scanFileNumber = [[".".join(each.split(".")[:-3]), int(each.split(".")[-2:-1][0])] for each in spectrumTitleList]
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
46 scanDict = {}
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
47 for each in scanFileNumber:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
48 if each[0] in scanDict.keys():
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
49 scanDict[each[0]].append(int(each[1]))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
50 else:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
51 scanDict[each[0]] = [int(each[1])]
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
52 # End of Reading Scans from PSM file
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
53
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
54 # inputPath = sys.argv[1]
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
55 inputPath = args.msms
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
56 ##outPath = "/".join(sys.argv[3].split("/")[:-1])
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
57 # outPath = sys.argv[3]
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
58 outPath = args.out
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
59 ##outFile = sys.argv[3].split("/")[-1]
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
60 allScanList = []
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
61 # Read all scan numbers using indexedmzML/indexList/index/offset tags
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
62 for k in mzml.read(inputPath).iterfind('indexedmzML/indexList/index/offset'):
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
63 if re.search("scan=(\d+)", k['idRef']):
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
64 a = re.search("scan=(\d+)", k['idRef'])
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
65 allScanList.append(int(a.group(1)))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
66 allScanList = list(set(allScanList))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
67 # End of Reading mzML file
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
68 # fraction_name = sys.argv[4]
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
69 fraction_name = args.filestring
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
70 if fraction_name in scanDict.keys():
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
71 scansInList = scanDict[fraction_name]
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
72 else:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
73 scansInList = []
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
74 scansNotInList = list(set(allScanList) - set(scansInList))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
75 flag = 0
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
76 if removeORretain == "remove":
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
77 scan2retain = scansNotInList
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
78 scan2retain = list(set(scan2retain))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
79 scan2retain.sort()
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
80 scansRemoved = scansInList
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
81 # scan2retain contains scans that is to be retained
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
82 elif removeORretain == "retain" and randomScans < len(scansNotInList):
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
83 # Randomly select spectra
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
84 random_scans = random.sample(scansNotInList, randomScans)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
85
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
86 scan2retain = random_scans + scansInList
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
87 scan2retain = list(set(scan2retain))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
88 scan2retain.sort()
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
89 scansRemoved = list(set(allScanList) - set(scan2retain))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
90 # scan2retain contains scans that is to be retained
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
91 else:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
92 flag = 1
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
93
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
94 if flag == 1:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
95 scan2retain = scansInList
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
96 scan2retain = list(set(scan2retain))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
97 scan2retain.sort()
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
98 scansRemoved = list(set(allScanList) - set(scan2retain))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
99
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
100 # scan2retain contains scans that is to be retained
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
101 print("ERROR: Number of Random Scans queried is more than available. The result has provided zero random scans.", file=sys.stdout)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
102 print("Number of available scans for random selection: " + str(len(scansNotInList)), file=sys.stdout)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
103 print("Try a number less than the available number. Thanks!!", file=sys.stdout)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
104 print("Number of Scans retained: " + str(len(scan2retain)), file=sys.stdout)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
105 else:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
106 # Print Stats
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
107 print("Total number of Scan Numbers: " + str(len(list(set(allScanList)))), file=sys.stdout)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
108 print("Number of Scans retained: " + str(len(scan2retain)), file=sys.stdout)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
109 print("Number of Scans removed: " + str(len(scansRemoved)), file=sys.stdout)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
110
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
111
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
112 # Identifying groups of continuous numbers in the scan2retain and creating scanString
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
113 scanString = ""
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
114 for a, b in groupby(enumerate(scan2retain), lambda x:x[1]-x[0]):
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
115 x = list(map(itemgetter(1), b))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
116 scanString = scanString + "["+str(x[0])+","+str(x[-1])+"] "
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
117 # end identifying
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
118 # start create filter file
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
119 filter_file = open("filter.txt", "w")
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
120 filter_file.write("filter=scanNumber %s\n" % scanString)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
121 filter_file.close()
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
122 # end create filter file
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
123
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
124 # Prepare command for msconvert
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
125 inputFile = fraction_name+".mzML"
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
126 os.symlink(inputPath,inputFile)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
127 outFile = "filtered_"+fraction_name+".mzML"
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
128 # msconvert_command = "msconvert " + inputFile + " --filter " + "\"scanNumber " + scanString + " \" " + " --outfile " + outFile + " --mzML --zlib"
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
129 msconvert_command = "msconvert " + inputFile + " -c filter.txt " + " --outfile " + outFile + " --mzML --zlib"
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
130
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
131
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
132 # Run msconvert
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
133 try:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
134 subprocess.check_output(msconvert_command, stderr=subprocess.STDOUT, shell=True)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
135 except subprocess.CalledProcessError as e:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
136 sys.stderr.write( "msconvert resulted in error: %s: %s" % ( e.returncode, e.output ))
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
137 sys.exit(e.returncode)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
138 # Copy output to
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
139 shutil.copyfile(outFile, outPath)
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
140 else:
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
141 print("Please contact the admin. Number of inputs are not sufficient to run the program.\n")
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
142
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
143 if __name__ == "__main__":
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
144 main()
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
145
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
146
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
147
4bef80b09854 "planemo upload commit 498440b547e1feaa6a81764b55ac8208626d70a8"
galaxyp
parents:
diff changeset
148