Commit 35844e8c authored by mirandaa's avatar mirandaa
Browse files

add validation to check if sims are continous

parent 08613d3e
......@@ -9,6 +9,7 @@ import re
from base64 import b64decode
from array import array
from collections import namedtuple
import warnings
log = logging.getLogger(os.path.basename(__file__))
from utils.peakStrainer_util import getMZXMLEncondedScans, decode_mzXML_Peaks, write2templateMzXML
from itertools import compress
......@@ -228,7 +229,7 @@ def project_ms2sim(matchingSims, popts):
simIntens_Corrected = [matchingSim[1] * correctionFactors[idx] for idx, matchingSim in enumerate(matchingSims)]
return [matchingSim + (simIntens_Corrected[idx],) for idx, matchingSim in enumerate(matchingSims)]
def simStitcher(filePath = None, doCompare = True):
def simStitcher(filePath = None, doCompare = True, callback = None):
log.addHandler(logging.StreamHandler()) # log to console
if log.level == logging.DEBUG: logging.basicConfig(filename='simSitcher.log',filemode='w')
......@@ -267,6 +268,8 @@ def simStitcher(filePath = None, doCompare = True):
masses, intens = scan.nonOverlapPeaks()
scans_stitched.setdefault(head, ([],[]))[0].extend(masses)
scans_stitched.setdefault(head, ([],[]))[1].extend(intens)'stitched scans:')'\n'.join(scans_stitched.keys()))
......@@ -284,7 +287,22 @@ def simStitcher(filePath = None, doCompare = True):'renamed stitched scans:')'\n'.join(scans_stitched.keys()))'check if stitched scans have gaps')
maxGap = scans[0].filterLine._high() - scans[0].filterLine._low()
delList =set()
for key in scans_stitched:
masses, _ = scans_stitched[key]
for next, mass in zip(masses[1:], masses[:-1]):
if next - mass > maxGap:
log.error("***gap between two sims is larger than sim, {} it will be removed ***".format(key))
if callback:
callback("***gap between two sims is larger than sim, {} it will be removed ***".format(key))
for key in delList:
del scans_stitched[key]'writing to :'+outputStitchedFile(filePath))
write2templateMzXML(outputStitchedFile(filePath), scans_stitched)
......@@ -363,4 +381,4 @@ if __name__ == '__main__':
\ No newline at end of file
......@@ -14,7 +14,10 @@ class mySimStitcherFrame(SimStitcherFrame):
def filecChanged( self, event ):
filepath = self.m_filePicker1.GetPath()
doCompare = self.m_checkBox1.GetValue()
simStitcher(filepath, doCompare)
simStitcher(filepath, doCompare, self.callback)
def callback(self, message):
def main():
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