Commit b6f523a5 authored by mirandaa's avatar mirandaa
Browse files

fix: ordered output to mzxml, regex instead of split, organize imports

parent b6043586
......@@ -14,6 +14,7 @@ import csv
from utils.peakStrainer_util import write2templateMzXML
import itertools
import math
import collections
log = logging.getLogger(os.path.basename(__file__))
from lib import MSFileReader
......@@ -718,8 +719,12 @@ def bins2Peaks(binsData, peakData):
result = zip(*filteredRowdata)
return result
def reorder4lipidxplorer(filtered_bins):
log.debug('reorder4lipidxplorer so it goes ms+, msms+,ms-, msms-')
filtered_bins1 = collections.OrderedDict(sorted(filtered_bins.items(), key=lambda t: t[0]))
return filtered_bins1
if __name__ == '__main__':
if len(sys.argv) == 1:
print("A filename must be provided")
......
......@@ -151,8 +151,9 @@ def write2templateMzXML(newfilename, scanPeaks):
newScan.remove(newScan.find('.//xmlns:precursorMz', namespaces))
else:
precursorMz = newScan.find('.//xmlns:precursorMz', namespaces)
precursorMz.attrib['activationMethod'] = scan.split()[6][7:10]
precursorMz.text = scan.split()[6][:6]
match = re.match( r'.* (.*)@(...)', scan, re.M|re.I)
precursorMz.attrib['activationMethod'] = match.group(2)
precursorMz.text = match.group(1)
newScan.attrib['msLevel'] = str(msLevel)
newScan.attrib['polarity'] = '-' if ' - ' in scan else '+'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment