Commit ac032937 authored by mirandaa's avatar mirandaa
Browse files

add feature remove scans with unusually increased Ion Injection Time

indicates the scan is in transition and is invalid  
parent f0b65429
......@@ -15,10 +15,11 @@ from utils.peakStrainer_util import write2templateMzXML
import itertools
import math
import collections
from sqlalchemy.sql.expression import false
log = logging.getLogger(os.path.basename(__file__))
from lib import MSFileReader
__version__ = "17.03.29.0"
__version__ = "17.12.15.0"
def main(file):
......@@ -32,8 +33,7 @@ def main(file):
# raise SystemExit
filename = file #" ".join(sys.argv[1:])
scans = ThermoRawfile2Scans(filename)
if log.level == logging.DEBUG: ThermoRawfile2Scans_csv(scans)
if log.level == logging.DEBUG: ThermoRawfile2Scans_csv(scans, dropElbowIIT = True)
scans = filterScanBy_first(scans)
''' filtering by scan
......@@ -98,7 +98,18 @@ def main(file):
log.debug('finish %f', time.clock())
def ThermoRawfile2Scans(file_path):
def isElbowIIT(rawfile, end, scanNum, filterLine):
nextScan = min(scanNum + 1, end)
next_filterLine = rawfile.GetFilterForScanNum(nextScan)
if filterLine != next_filterLine:
return False
ion_injection_time = rawfile.GetTrailerExtraForScanNum(scanNum)['Ion Injection Time (ms)']
next_ion_injection_time = rawfile.GetTrailerExtraForScanNum(nextScan)['Ion Injection Time (ms)']
isElbow = ion_injection_time > next_ion_injection_time * 2
return isElbow
def ThermoRawfile2Scans(file_path, dropElbowIIT = True):
# NOTE: for testing use ThermoRawfile2Scans_sample instead
log.info('file: %s', file_path)
rawfile = MSFileReader.ThermoRawfile(file_path)
......@@ -112,6 +123,12 @@ def ThermoRawfile2Scans(file_path):
filterLine = rawfile.GetFilterForScanNum(scanNum)
retTime = rawfile.RTFromScanNum(scanNum)*60
row = (scanNum, filterLine, peak_datas, retTime)
isElbow = isElbowIIT(rawfile, end, scanNum, filterLine)
if dropElbowIIT and isElbow:
log.info(' Scan Number {} is removed, it has increased Ion Injection Time, is probably invalid'.format(scanNum))
continue
MSrawscans.append(row)
log.info('Scan Count is %d', len(MSrawscans))
......
......@@ -141,11 +141,10 @@ class MyFrame(MyFrame2):
log.debug('Start %f', time.clock())
self.statusLog('Read and select scans from raw file...')
scans = ThermoRawfile2Scans(filepath)
dropElbowIIT = self.m_checkBox611.GetValue()
scans = ThermoRawfile2Scans(filepath, dropElbowIIT)
if self.m_checkBox8.GetValue(): ThermoRawfile2Scans_csv(scans, self.getCSVpath_file(rawfilename)+'-raw.csv')
scans = filterScanBy_first(scans)
if self.m_checkBox5.GetValue(): scans = filterScanBy_retentionTime(scans, float(self.m_textCtrl2.GetValue()), float(self.m_textCtrl3.GetValue()) )
#NOTE use try catch notify to validate input
if self.m_checkBox6.GetValue(): scans = filterScanBy_filterline(scans, self.m_textCtrl4.GetValue(), self.m_radioBox1.GetSelection()==0)
......
This diff is collapsed.
......@@ -251,6 +251,24 @@ class MyFrame2 ( wx.Frame ):
bSizer19.Add( bSizer231, 0, wx.EXPAND, 5 )
self.m_staticline153 = wx.StaticLine( self.m_panel5, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
bSizer19.Add( self.m_staticline153, 0, wx.EXPAND |wx.ALL, 5 )
bSizer2311 = wx.BoxSizer( wx.HORIZONTAL )
self.m_checkBox611 = wx.CheckBox( self.m_panel5, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_checkBox611.SetValue(True)
bSizer2311.Add( self.m_checkBox611, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.m_staticText1111 = wx.StaticText( self.m_panel5, wx.ID_ANY, u"Remove Scans with increased Ion Injection Time", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText1111.Wrap( -1 )
self.m_staticText1111.SetToolTipString( u"unusually increased Ion Injection Time indicates the scan is in transition and is invalid" )
bSizer2311.Add( self.m_staticText1111, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
bSizer19.Add( bSizer2311, 0, wx.EXPAND, 5 )
self.m_panel5.SetSizer( bSizer19 )
self.m_panel5.Layout()
......@@ -570,6 +588,7 @@ class MyFrame2 ( wx.Frame ):
self.m_checkBox5.Bind( wx.EVT_CHECKBOX, self.checkScanRet )
self.m_checkBox6.Bind( wx.EVT_CHECKBOX, self.checkScanHead )
self.m_checkBox61.Bind( wx.EVT_CHECKBOX, self.checkScanHead )
self.m_checkBox611.Bind( wx.EVT_CHECKBOX, self.checkScanHead )
self.m_radioBtn10.Bind( wx.EVT_RADIOBUTTON, self.radioPre )
self.m_radioBtn11.Bind( wx.EVT_RADIOBUTTON, self.radioPre )
self.m_radioBtn9.Bind( wx.EVT_RADIOBUTTON, self.radioBin )
......@@ -606,6 +625,7 @@ class MyFrame2 ( wx.Frame ):
event.Skip()
def radioPre( self, event ):
event.Skip()
......
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