'****************************************************************************
'* Copyright (C) 2004 Peter Mortensen and Matthias Mann *
'* This file is part of MSQuant. *
'* *
'* MSQuant is distributed under the terms of *
'* the GNU General Public License. See src/COPYING.TXT or *
'* <http://www.gnu.org/licenses/gpl.txt> for details. *
'* *
'* MSQuant is free software; you can redistribute it *
'* and/or modify it under the terms of the GNU *
'* General Public License as published by the Free *
'* Software Foundation; either version 2 of the *
'* License, or (at your option) any later version. *
'* *
'* MSQuant is distributed in the hope that it will be *
'* useful, but WITHOUT ANY WARRANTY; without even the *
'* implied warranty of MERCHANTABILITY or FITNESS FOR *
'* A PARTICULAR PURPOSE. See the GNU General Public *
'* License for more details. *
'* *
'* You should have received a copy of the GNU General *
'* Public License along with MSQuant; if not, write to *
'* the Free Software Foundation, Inc., 59 Temple *
'* Place, Suite 330, Boston, MA 02111-1307 USA *
'* *
'* Purpose: Holds Class spectrumClassifier, see also below *
'* for documentation. *
'* *
'****************************************************************************
'****************************************************************************
'* CEBI *
'* Software Development Group *
'* Peter Mortensen *
'* E-mail: NUKESPAMMERSdrmortensen@get2netZZZZZZ.dk *
'* WWW: http://www.cebi.sdu.dk/ *
'* *
'* Program for post-processing of result from search in mass *
'* spectrometric data. *
'* *
'* FILENAME: newFinneganRawDataFileHandling.vb *
'* MAIN_CLASS: betterFinneganRawDataFileHandling *
'* STRUCTS_AND_CLASSES: <none> *
'* TYPE: VISUAL_BASIC *
'* *
'* CREATED: PM 2003-08-21 Vrs 1.0. Cloned from *
'* FinneganRawDataFileHandling.vb *
'* UPDATED: PM 2003-xx-xx *
'* *
'****************************************************************************
'Future:
' 1.
' 2.
Option Strict On
Option Explicit On
Imports System.Text.RegularExpressions 'For Regex.Match.
Imports System.Xml.Serialization 'For XmlArray and XmlArrayItem.
Imports System.Collections.Generic 'For Dictionary
'****************************************************************************
'd$ <summary>
'd$ Purpose: Namespace for lower layers of mass spectrometric
'd$ applications: raw data file handling, descriptive statistics,
'd$ fragment masses, digestion, file associations, etc.
'd$ <see cref="T:VBXMLDoc.CVBXMLDoc" />.
'd$ <isUnitTest></isUnitTest>
'd$ <applicationname>test_rawDataFileHandling</applicationname>
'd$ <author>Peter Mortensen</author>
'd$ <seealso>http://www.cebi.sdu.dk/</seealso>
'd$ <codetype>PLATFORM independent / GUI</codetype>
'd$ </summary>
Namespace massSpectrometryBase
'Changed PM_MASCOT2_ZOOMSCAN_QUANT_FILTER 2004-03-16
'Later: move to the new class....
Public Structure SpectrumClassificationStructure
Dim mainClassification As spectrumTypeEnum
Dim MSsubType As spectrumSubTypeEnum
Dim dataSourceName As String
End Structure 'SpectrumClassificationStructure
'Changed PM_GENERALISED_SPECTRUMCLASSIFICATION 2005-03-13
'****************************************************************************
'* SUBROUTINE NAME: SortByMatchIndex *
'd$ <summary> N/A. ...
'd$ Note: xyz </summary>
Class SortByMatchIndex
Implements System.Collections.Generic.IComparer( _
Of classificationMatchingStructure)
Function Compare( _
ByVal aItem1 As classificationMatchingStructure, _
ByVal aItem2 As classificationMatchingStructure) _
As Integer _
Implements _
System.Collections.Generic.IComparer( _
Of classificationMatchingStructure).Compare
Dim toReturn As Integer = 0
If aItem1.matchOrder > aItem2.matchOrder Then
toReturn = 1
Else
If aItem1.matchOrder < aItem2.matchOrder Then
toReturn = -1
Else
'Equal....
Dim peter9 As Integer = 9
End If
End If
Return toReturn
End Function 'Compare
End Class 'SortByMatchIndex
'****************************************************************************
'd$ <summary>
'd$ Purpose: Classifies spectra. At the moment oriented towards
'd$ parsing of Finnigan spectrum headers.
'd$
'd$
'd$
'd$ <see cref="T:VBXMLDoc.CVBXMLDoc" />.
'd$ <applicationname>test_rawDataFileHandling</applicationname>
'd$ <author>Peter Mortensen</author>
'd$ <seealso>http://www.cebi.sdu.dk/</seealso>
'd$ <codetype>PLATFORM independent</codetype>
'd$ </summary>
Public Class spectrumClassifier
'Changed PM_GENERALISED_SPECTRUMCLASSIFICATION 2005-03-13
Dim mClassificationInfo As spectrumClassificationDefinitionsStructure
Dim mHasSortedClassifications As Boolean
'****************************************************************************
'* SUBROUTINE NAME: New *
'd$ <summary> N/A </summary>
Public Sub New()
MyBase.New() 'Is this necessary? Yes!
'InitializeComponent() Is this necessary??
'Add any initialization after the InitializeComponent() call
'Changed PM_GENERALISED_SPECTRUMCLASSIFICATION 2005-03-13
If False Then
spectrumClassifier.defaultClassifications(mClassificationInfo)
End If
mHasSortedClassifications = False
End Sub 'New()
'****************************************************************************
'* SUBROUTINE NAME: setClassificationInfo *
'd$ <summary> N/A </summary>
Public Sub setClassificationInfo( _
ByRef anInSpectrumClassificationDefinitions As _
spectrumClassificationDefinitionsStructure)
mClassificationInfo = anInSpectrumClassificationDefinitions
'Just in case...
mClassificationInfo.classificationList2.Sort(New SortByMatchIndex)
End Sub 'setClassificationInfo
'Changed PM_GENERALISED_SPECTRUMCLASSIFICATION 2005-03-13
'****************************************************************************
'* SUBROUTINE NAME: addClassificationMatch *
'd$ <summary> Convenience function for clients to add a new item
'd$ to the datastructure used for classification of spectra.
'd$ </summary>
Private Shared Sub addClassificationMatch( _
ByRef anInMatchFirst As String, _
ByRef anInMatchSecond As String, _
ByVal anInMainClassification As spectrumTypeEnum, _
ByVal anInMSsubType As spectrumSubTypeEnum, _
ByRef anInOutMatchOrder As Integer, _
ByVal aDefaultSource As sourceTypeEnum, _
ByVal aMatchFirst_Source As String, _
ByVal aMatchSecond_Source As String, _
ByVal aDataSource As sourceTypeEnum, _
ByRef aMSsubTypeAndFragmentationMechanismName As String, _
ByRef aDataSourceName As String, _
ByVal anInOutList2 As _
Generic.List(Of classificationMatchingStructure) _
)
'Changed PM_DTASC_FRAGANDSOURCE_LABELS 2006-04-28
'New parameters: aMSsubTypeAndFragmentationMechanismName, aDataSourceName.
Dim newItem As classificationMatchingStructure
newItem.matchFirst = anInMatchFirst
newItem.matchSecond = anInMatchSecond
newItem.mainClassification = anInMainClassification
newItem.MSsubType = anInMSsubType
newItem.matchOrder = anInOutMatchOrder
'Changed PM_ECD 2006-01-12
newItem.defaultSource = aDefaultSource
newItem.matchFirst_Source = aMatchFirst_Source
newItem.matchSecond_Source = aMatchSecond_Source
newItem.dataSource = aDataSource
'Changed PM_DTASC_FRAGANDSOURCE_LABELS 2006-04-28
newItem.MSsubTypeAndFragmentationMechanismName = _
aMSsubTypeAndFragmentationMechanismName
newItem.dataSourceName = aDataSourceName
anInOutList2.Add(newItem)
anInOutMatchOrder += 1
End Sub 'addClassificationMatch
'Changed PM_ECD 2006-01-16
'****************************************************************************
'* SUBROUTINE NAME: getFragmentTypes *
'd$ <summary> .
'd$ </summary>
Public Function getFragmentTypes() _
As Dictionary(Of String, String)
'Keys are a combination of the fragment type and the
'source (e.g. LTQ or FT).
'
'Sample (key,value) pairs:
'
' "enumIsFragmentMS3_LTQ", "LTQ, CID MS3"
' "enumIsFragmentCID_LTQ", "LTQ, CID MS2"
' "enumIsFragmentCID_FT", "FT, CID MS2"
'Dim someHash As Hashtable = New Hashtable
Dim toReturn As Dictionary(Of String, String) = _
New Dictionary(Of String, String)
Dim descrString As String = ""
Dim curItem As classificationMatchingStructure
For Each curItem In mClassificationInfo.classificationList2
Dim subType As spectrumSubTypeEnum = curItem.MSsubType
Dim dataSourceName As String = curItem.dataSourceName
'Changed PM_DTASC_FRAGANDSOURCE_LABELS 2006-04-28
Dim useIt As Boolean = True
If curItem.mainClassification <> _
spectrumTypeEnum.enumIsFragmentSpectrum Then
useIt = False
Else
descrString = _
dataSourceName & ", " & _
curItem.MSsubTypeAndFragmentationMechanismName
End If
'Old
'Select Case subType
' Case spectrumSubTypeEnum.enumIsFragmentCID
' descrString = "CID"
' Case spectrumSubTypeEnum.enumIsFragmentECD
' descrString = "ECD"
' Case spectrumSubTypeEnum.enumIsFragmentMPD
' descrString = "MPD"
' Case spectrumSubTypeEnum.enumIsFragmentMS3
' descrString = "MS3"
'
' 'Case spectrumSubTypeEnum.enumIsFragmentNormal
' ' 'descrString = "Normal fragment (phased out)"
' ' descrString = "xyz"
' Case Else
' useIt = False
'End Select
If useIt Then 'Ignore MS types
'Changed PM_DTASC_FRAGANDSOURCE_LABELS 2006-05-01
Dim key As String = subType.ToString & "_" & dataSourceName
If toReturn.ContainsKey(key) Then
'No need to count
'Dim oldCount As Integer = CInt(toReturn(AA))
'toReturn(AA) = oldCount + 1
Dim peter9 As Integer = 9
Else
toReturn.Add(key, descrString)
End If
End If
Next
Return toReturn
End Function 'getFragmentTypes
'Changed PM_GENERALISED_SPECTRUMCLASSIFICATION 2005-03-13
'****************************************************************************
'* SUBROUTINE NAME: classify *
'd$ <summary> Classifies based on Finnigan spectrum header, MS or MS/MS
'd$ or MS3. There are also subtypes, e.g. full MS and SIM MS.
'd$ </summary>
Public Function classify( _
ByRef anInSpectrumHeader As String) _
As SpectrumClassificationStructure
Dim toReturn As SpectrumClassificationStructure
toReturn.mainClassification = _
spectrumTypeEnum.enumIsUndefinedSpectrumType
toReturn.MSsubType = spectrumSubTypeEnum.enumST_DoesNotApply
toReturn.dataSourceName = Nothing
Trace.Assert(Not mClassificationInfo.classificationList2 Is Nothing, _
"PIL ASSERT. Object mClassificationInfo.classificationList was not created....")
'AndAlso/short-circuit boolean is crucial here...
If Not anInSpectrumHeader Is Nothing AndAlso _
anInSpectrumHeader.Length > 0 Then
If Not mHasSortedClassifications Then
mClassificationInfo.classificationList2.Sort( _
New SortByMatchIndex)
mHasSortedClassifications = True
End If
Dim matched As Boolean = False
Dim curItem As classificationMatchingStructure
For Each curItem In mClassificationInfo.classificationList2
Dim result As Match = _
Regex.Match(anInSpectrumHeader, curItem.matchFirst)
If result.Success Then
If curItem.matchSecond = "" Then
matched = True
Else
Dim result2 As Match = _
Regex.Match(anInSpectrumHeader, curItem.matchSecond)
If result2.Success Then
matched = True
End If
End If
End If
If matched Then
toReturn.mainClassification = curItem.mainClassification
toReturn.MSsubType = curItem.MSsubType
toReturn.dataSourceName = curItem.dataSourceName
Exit For
End If
Next
If Not matched Then
'Changed PM_INFINITELOOP_SPECCLASSIFY 2006-02-09
toReturn.mainClassification = _
spectrumTypeEnum.enumIsUndefinedSpectrumType
toReturn.MSsubType = spectrumSubTypeEnum.enumST_DoesNotApply
toReturn.dataSourceName = Nothing
Dim spectrumNum As Integer = -999999 'Later....
Dim msg As String = _
"Unknown spectrum type for spectrum " & spectrumNum & _
", could not be derived from spectrum title '" & _
anInSpectrumHeader & " '"
MsgBox(msg)
Dim msg2 As String = _
"Unknown spectrum type for spectrum " & spectrumNum & _
", could not be derived from " & _
" spectrum title '" & _
anInSpectrumHeader & " '. " & _
"The configuration file " & _
MSQconstants.NEW_SPECCLASSIFICATION_FILENAME & " does " & _
"not contain information to recognise the spectrum type, " & _
"MS or MS/MS. Edit " & _
MSQconstants.NEW_SPECCLASSIFICATION_FILENAME & "."
End If
Else
Dim peter7 As Integer = 7
End If
Return toReturn
End Function 'classify
'****************************************************************************
'* SUBROUTINE NAME: defaultClassifications *
'd$ <summary> Current program default classifications settings. Is used if
'd$ the appropriate XML file could not be found on disk.
'd$ To parameters, anInOutClassificationInfo. Real type of items
'd$ is classificationMatchingStructure.
'd$ </summary>
Public Shared Sub defaultClassifications( _
ByRef anInOutSpectrumClassificationDefinitions As _
spectrumClassificationDefinitionsStructure)
anInOutSpectrumClassificationDefinitions.someExtraInfo = "xyz"
anInOutSpectrumClassificationDefinitions.classificationList2 = _
New Generic.List(Of classificationMatchingStructure)
'For notational convenience.
Dim ali As Generic.List(Of classificationMatchingStructure) = _
anInOutSpectrumClassificationDefinitions.classificationList2
If False Then 'Older
' 'Changed PM_MORE_CLASSIFICATIONS 2005-03-14
' 'addClassificationMatch( _
' ' "FTMS \+ p ESI Full ms", "", _
' ' spectrumTypeEnum.eIsMSspectrum, spectrumSubTypeEnum.eIsNormalMS, 0, _
' ' ali)
' addClassificationMatch( _
' "FTMS \+ (p|c) ESI Full ms", "", _
' spectrumTypeEnum.eIsMSspectrum, spectrumSubTypeEnum.eIsNormalMS, 0, _
' ali)
'
' addClassificationMatch( _
' "FTMS \+ (p|c) ESI d SIM ms", "", _
' spectrumTypeEnum.eIsMSspectrum, spectrumSubTypeEnum.eIsZoomMS, 1, _
' ali)
'
' addClassificationMatch( _
' "Full ms3", "", _
' spectrumTypeEnum.eIsFragmentSpectrum, spectrumSubTypeEnum.eIsFragmentMS3, 2, _
' ali)
'
' 'addClassificationMatch( _
' ' "xyz", "", _
' ' spectrumTypeEnum.eIsFragmentSpectrum, spectrumSubTypeEnum.eIsFragmentMS3, -1, _
' ' ali)
'
' 'Virtual; "ITMS" alone: guard for Ref 7 and Ref 8.
'
' addClassificationMatch( _
' "ITMS", "d Z ms\s", _
' spectrumTypeEnum.eIsMSspectrum, spectrumSubTypeEnum.eIsZoomMS, 3, _
' ali)
'
' addClassificationMatch( _
' "ITMS", "Full ms2", _
' spectrumTypeEnum.eIsFragmentSpectrum, spectrumSubTypeEnum.eIsFragmentNormal, 4, _
' ali)
'
' addClassificationMatch( _
' "FTMS", "Full ms2", _
' spectrumTypeEnum.eIsFragmentSpectrum, spectrumSubTypeEnum.eIsFragmentNormal, 5, _
' ali)
'
' 'Changed PM_MORE_CLASSIFICATIONS 2005-03-14
' 'Sample: "FTMS + p ESI SIM ms"
' addClassificationMatch( _
' "FTMS", "SIM ms", _
' spectrumTypeEnum.eIsMSspectrum, spectrumSubTypeEnum.eIsZoomMS, 6, _
' ali)
'
' 'Changed PM_LTQ_ONLY_DATA 2005-06-03
' 'Note trailing whitespace in order not to match "Full ms2" or "Full ms3".
' addClassificationMatch( _
' "ITMS", "Full ms\s", _
' spectrumTypeEnum.eIsMSspectrum, spectrumSubTypeEnum.eIsNormalMS, 7, _
' ali)
'
' 'Changed PM_LTQ_ONLY_DATA 2005-06-03. Moved down here, as last item.
' 'Default if the ITMS matches above does not match.
' 'Why is it classified as MS ?????
' addClassificationMatch( _
' "ITMS", "", _
' spectrumTypeEnum.eIsMSspectrum, spectrumSubTypeEnum.eIsNormalMS, 8, _
' ali)
End If 'Older
If True Then
Dim matchOrder As Integer = 0 'Let the match be the same as listed.
'asdasd() 'Add the rest from the standard CEBI file.
If True Then 'NSI part
'These two must come before the original ms2 - because they
'look very much like the original ms2...
If True Then
addClassificationMatch( _
"ecd\@", "", _
spectrumTypeEnum.enumIsFragmentSpectrum, _
spectrumSubTypeEnum.enumIsFragmentECD, _
matchOrder, _
sourceTypeEnum.enumUltraHighResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"ECD MS2", _
"FT", _
ali)
addClassificationMatch( _
"mpd\@", "", _
spectrumTypeEnum.enumIsFragmentSpectrum, _
spectrumSubTypeEnum.enumIsFragmentMPD, _
matchOrder, _
sourceTypeEnum.enumUltraHighResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"MPD MS2", _
"FT", _
ali)
End If
If True Then 'Replacement for frag normal comes first.
End If
'NSI (Proxeon) specific
If True Then
addClassificationMatch( _
"FTMS \+ (p|c) NSI Full ms", "", _
spectrumTypeEnum.enumIsMSspectrum, _
spectrumSubTypeEnum.enumIsNormalMS, _
matchOrder, _
sourceTypeEnum.enumUltraHighResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"***", _
"***", _
ali)
addClassificationMatch( _
"FTMS \+ (p|c) NSI d SIM ms", "", _
spectrumTypeEnum.enumIsMSspectrum, _
spectrumSubTypeEnum.enumIsZoomMS, _
matchOrder, _
sourceTypeEnum.enumUltraHighResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"***", _
"***", _
ali)
End If
'ESI (source??) specific
If True Then
addClassificationMatch( _
"FTMS \+ (p|c) ESI Full ms", "", _
spectrumTypeEnum.enumIsMSspectrum, _
spectrumSubTypeEnum.enumIsNormalMS, _
matchOrder, _
sourceTypeEnum.enumUltraHighResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"***", _
"***", _
ali)
addClassificationMatch( _
"FTMS \+ (p|c) ESI d SIM ms", "", _
spectrumTypeEnum.enumIsMSspectrum, _
spectrumSubTypeEnum.enumIsZoomMS, _
matchOrder, _
sourceTypeEnum.enumUltraHighResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"***", _
"***", _
ali)
End If
addClassificationMatch( _
"Full ms3", "", _
spectrumTypeEnum.enumIsFragmentSpectrum, _
spectrumSubTypeEnum.enumIsFragmentMS3, _
matchOrder, _
sourceTypeEnum.enumUltraHighResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"CID MS3", _
"LTQ", _
ali)
'Used for ion-trap only acquisition.
addClassificationMatch( _
"ITMS", "d Z ms\s", _
spectrumTypeEnum.enumIsMSspectrum, _
spectrumSubTypeEnum.enumIsZoomMS, _
matchOrder, _
sourceTypeEnum.enumBetterResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"***", _
"***", _
ali)
'Used for ion-trap only acquisition.
' enumIsFragmentNormal -> enumIsFragmentCID
addClassificationMatch( _
"ITMS", "Full ms2", _
spectrumTypeEnum.enumIsFragmentSpectrum, _
spectrumSubTypeEnum.enumIsFragmentCID, _
matchOrder, _
sourceTypeEnum.enumBetterResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"CID MS2", _
"LTQ", _
ali)
'Older note:
' 'Note trailing whitespace in order not to match "Full ms2" or "Full ms3".
'Ref 7
'Back stop (?).
addClassificationMatch( _
"ITMS", "", _
spectrumTypeEnum.enumIsMSspectrum, _
spectrumSubTypeEnum.enumIsNormalMS, _
matchOrder, _
sourceTypeEnum.enumBetterResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"***", _
"***", _
ali)
'Ref 8
'CID !
addClassificationMatch( _
"FTMS", "Full ms2", _
spectrumTypeEnum.enumIsFragmentSpectrum, _
spectrumSubTypeEnum.enumIsFragmentCID, _
matchOrder, _
sourceTypeEnum.enumUltraHighResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"CID MS2", _
"FT", _
ali)
'Ref 9
'Back stop (?).
addClassificationMatch( _
"FTMS", "SIM ms", _
spectrumTypeEnum.enumIsMSspectrum, _
spectrumSubTypeEnum.enumIsZoomMS, _
matchOrder, _
sourceTypeEnum.enumUltraHighResolution, "", "", _
sourceTypeEnum.enumIsUndefinedSourceType, _
"***", _
"***", _
ali)
End If
End If
End Sub 'defaultClassifications
End Class 'spectrumClassifier
End Namespace 'massSpectrometryBase
Generated by script codePublish.pl at 2008-09-23T11:59:18.