'****************************************************************************
'* Copyright (C) 2005 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 spectrumTree, see below for *
'* documentation. *
'* *
'****************************************************************************
'****************************************************************************
'* CEBI *
'* Software Development Group *
'* Peter Mortensen *
'* E-mail: NUKESPAMMERSdrmortensen@get2netZZZZZZ.dk *
'* WWW: http://www.cebi.sdu.dk/ *
'* *
'* Program for postprocessing of MS-MS search result *
'* *
'* FILENAME: spectrumTree.vb *
'* TYPE: VISUAL_BASIC *
'* *
'* CREATED: MM 2005-08-15 Vrs 1.0. Estimated date. *
'* UPDATED: PM 2005-xx-xx *
'* *
'****************************************************************************
Option Strict On
Option Explicit On
'****************************************************************************
'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</codetype>
'd$ </summary>
Namespace massSpectrometryBase 'Class spectrumTree
Public Structure specStruct
Dim specNumb As Integer
Dim experimentNumber As Integer
Dim isMSspectrum As Boolean 'More specific?
'Changed PM_SPECTRUMDOWN_FULLDISPLAY 2007-07-10
Dim isIDspectrum As Boolean
Dim spectrumLevel As Integer '0 for ID spectrum. Negative for
' lower, e.g. MS3. Greater than 0 for higher, typically MS spectra.
End Structure 'specStruct
'Class that knows about relations between spectra related to an identified
'peptide.
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Public Class spectrumTree
Private mRawDataFileHandling As massSpectrometryBase.rawDataFileHandling
'Private mTree2 As ArrayList 'Real type is specStruct.
Private mTree3 As Generic.List(Of specStruct)
Private mCurrentSpectrumIndex As Integer
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Public Sub New( _
ByRef aInRawDataFileHandling As massSpectrometryBase.rawDataFileHandling)
Trace.Assert(Not aInRawDataFileHandling Is Nothing, _
"PIL ASSERT. aInRawDataFileHandling does not exist...")
mRawDataFileHandling = aInRawDataFileHandling
init()
End Sub 'New
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Public Sub init()
mCurrentSpectrumIndex = -1
End Sub 'init
'****************************************************************************
'* setIDspectrum *
'* *
'* Note: side-effects on mRawDataFileHandling.... *
'****************************************************************************
Public Sub setIDspectrum( _
ByVal aRTsecs As Double, Optional ByVal aExperiment As Integer = 1)
'Unit test: in output list field spectrumLevel should
'increase by one for the next item in the
'list (e.g. -1 0 1 2). Max range is [-10; 10]. Currently [-1; 2], for Finnigan.
Dim spectrumSpec As spectrumSpecificationStructure
spectrumSpec.experimentNumber = aExperiment '-1 to offset??
spectrumSpec.spectrumType = spectrumTypeEnum.enumIsFragmentSpectrum
Dim dummy1 As spectrumSpecStructure
dummy1.retentionTime_secs = -2312331.2
dummy1.specNum = -812320
Dim dummy5 As SpectrumClassificationStructure
dummy5.dataSourceName = Nothing 'Keep compiler happy.
Dim IDspectrumNumber As Integer = _
mRawDataFileHandling.newSpectrumByRetentionTime( _
aRTsecs, dummy1, spectrumSpec, dummy5)
If mTree3 Is Nothing Then
mTree3 = New Generic.List(Of specStruct)
Else
mTree3.Clear()
End If
If True Then 'MS3
'Note: if there is more than one MS3 spectrum they end up
' on different levels. This is OK for display/spectrum
' browsing. But it logically incorrect. The user may
' also get confused.
'What about field experimentNumber??
Dim MS3spectra As Generic.List(Of spectrumSpecStructure) = _
rawDataFileHandling.MS3spectraList( _
IDspectrumNumber, mRawDataFileHandling)
Dim len As Integer = MS3spectra.Count()
Dim lastIndex As Integer = len - 1
Dim j As Integer
'Note: reverse order so we see the MS3 spectrum closest to the MS2 spectrum first...
For j = lastIndex To 0 Step -1
Dim someMSspectrum As spectrumSpecStructure = MS3spectra(j)
Dim MS3 As specStruct
MS3.specNumb = someMSspectrum.specNum
MS3.isMSspectrum = False
MS3.isIDspectrum = False
'MS3.experimentNumber = someMSspectrum.experimentNumber
MS3.experimentNumber = 1 'For now.
Dim spectrumLevel3 As Integer = -j - 1
MS3.spectrumLevel = spectrumLevel3 'By definition.
mTree3.Add(MS3)
Next j
End If
If True Then 'ID spectrum
Dim ID As specStruct
ID.experimentNumber = aExperiment
ID.specNumb = IDspectrumNumber
ID.isMSspectrum = False
ID.isIDspectrum = True
ID.spectrumLevel = 0 'By definition.
mTree3.Add(ID)
End If
'Changed PM_SPECTRUMDOWN_MS3DISPLAY 2007-07-11
'mCurrentSpectrumIndex = 0
Dim curLastIndex As Integer = mTree3.Count() - 1
mCurrentSpectrumIndex = curLastIndex
Dim higher As specStruct
Dim spectrumLevel As Integer = 0
Dim curSpectrum As Integer = IDspectrumNumber
Dim curClassi As spectrumSubTypeEnum = _
spectrumSubTypeEnum.enumST_DoesNotApply
Dim done As Boolean = False
While Not done
Dim cl As SpectrumClassificationStructure
cl.dataSourceName = Nothing 'Keep compiler happy.
'Going up in spectrum level.
Dim MSspectrumNumber As Integer = _
mRawDataFileHandling.spectrumNumberForMSspectrum( _
curSpectrum, cl, True)
If MSspectrumNumber <> curSpectrum Then
'Assume MS subtype change for every
'level (e.g. SIM vs. Full scan for Finnigan); otherwise we
'could get an unrelated SIM spectrum...
If curClassi <> cl.MSsubType Then
spectrumLevel += 1
higher.experimentNumber = 1
higher.specNumb = MSspectrumNumber
higher.isMSspectrum = True
'Changed PM_SPECTRUMDOWN_FULLDISPLAY 2007-07-10
higher.isIDspectrum = False
higher.spectrumLevel = spectrumLevel
mTree3.Add(higher)
End If
Else
done = True
End If
curSpectrum = MSspectrumNumber
curClassi = cl.MSsubType
End While
End Sub 'setIDspectrum
'****************************************************************************
'* <placeholder for header> *
'* Return value is false if already at the top *
'****************************************************************************
Private Function move( _
ByVal anOffset As Integer, ByRef anOutSpectrumInfo As specStruct) _
As Boolean
Dim toReturn As Boolean = True
Trace.Assert(anOffset = 1 Or anOffset = -1, _
"PIL ASSERT. anOffset is not 1 or -1....")
anOutSpectrumInfo.experimentNumber = -1
anOutSpectrumInfo.isMSspectrum = False
anOutSpectrumInfo.specNumb = -1
Trace.Assert(mCurrentSpectrumIndex >= 0, _
"PIL ASSERT. mCurrentSpectrumIndex is undefined.")
Dim lastIndex As Integer = mTree3.Count - 1
'Note: not <= or >= because then we are at the start/end and can not
' move.
If (anOffset < 0 AndAlso mCurrentSpectrumIndex < lastIndex) Or _
(anOffset > 0 AndAlso mCurrentSpectrumIndex > 0) Then
mCurrentSpectrumIndex -= anOffset '"-" because level is lower
' number for higher level.
anOutSpectrumInfo = mTree3(mCurrentSpectrumIndex)
Else
toReturn = False
End If
Return toReturn
End Function 'move
'****************************************************************************
'* <placeholder for header> *
'* Return value is false if already at the top *
'****************************************************************************
Public Function moveUp( _
ByRef anOutSpectrumInfo As specStruct) _
As Boolean
Return Me.move(-1, anOutSpectrumInfo)
End Function 'moveUp
'****************************************************************************
'* <placeholder for header> *
'* Return value is false if already at the top *
'****************************************************************************
Public Function moveDown( _
ByRef anOutSpectrumInfo As specStruct) _
As Boolean
Return Me.move(1, anOutSpectrumInfo)
End Function 'moveDown
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Public Function getCurrentSpectrumInfo() _
As specStruct
Dim toReturn As specStruct
toReturn = mTree3(mCurrentSpectrumIndex)
Return toReturn
End Function 'getCurrentSpectrumInfo
End Class 'spectrumTree
End Namespace 'massSpectrometryBase, class spectrumTree
Generated by script codePublish.pl at 2008-09-23T11:59:18.