'****************************************************************************
'* 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: <to be filled in>. *
'* *
'****************************************************************************
'****************************************************************************
'* 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: MMaaSequence.vb *
'* TYPE: VISUAL_BASIC *
'* *
'* CREATED: PM 2003-??-?? Vrs 1.0. *
'* UPDATED: PM 2004-xx-xx *
'* *
'****************************************************************************
Option Strict On
Option Explicit On 'Changed PM_OPTIONEXPLICIT 2003-02-24
Imports System.Text 'For StringBuilder
Imports System.Collections.Generic 'For List.
Imports massSpectrometryBase 'For quantitation.simpleModificationSpecification
'****************************************************************************
'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
'Changed PM_REFACTOR 2008-05-08. Moved to file PILgeneralisedIonSeries.cs.
' 'Changed PM_DTASC_COMPILE 2008-02-11. Moved to here
' ' from peptideFragments.vb to avoid dependencies
' ' with DTASC. But is this a good place???
' ' In DTASC the dependency is from class SDUPspectrumMarking
' ' and class frmSpectrumDisplay.
' Public Structure fragmentExStructure
'
' Dim MCRcalcLoc As Double
'
' 'Changed PM_REFACTOR 2005-02-24. Now computed on the client side.
' 'Dim yLoc As Double
'
' 'Not cuurently used.
' 'Dim MCRobsLoc As Double
' 'Dim deltaMass As Double
'
' Dim seq As String
' Dim descStr As String
' Dim charge As Integer
'
' 'Enumeration instead of Bion and Yion
' 'Dim Yion As Boolean
' 'Dim Bion As Boolean
' 'Dim precursorIon As Boolean
' Dim ionType As ionTypeEnum
'
' Dim ionMatched As Boolean 'Helper field.
' End Structure 'fragmentExStructure
End Namespace
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Public Class MMaaSequence
Inherits MMSequence
Private mSeq As String
Private mHaveAAComp As Boolean 'PM: Not explicitly initialised....
Private mAACompArr(Asc("Z") - Asc("A")) As Integer
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Public Sub New(ByRef anInSeq As String)
MyBase.New() ' Invoke object() constructor.
mSeq = anInSeq.ToUpper 'make sure we have upper case amino acids
End Sub 'Constructor.
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Public Function numObsTrypPepts() As Integer
Dim numObsPept As Integer = 0
Dim strB As New StringBuilder
Dim peptideEnds As Boolean = False
Dim strBLastIndex As Integer = mSeq.Length - 1
Dim i As Integer
For i = 0 To strBLastIndex
Dim ch As Char = mSeq.Chars(i)
strB.Append(ch)
If (i = strBLastIndex) Then
peptideEnds = True
ElseIf (ch = "K" Or ch = "R") Then
If Not (mSeq.Chars(i + 1) = "P") Then
peptideEnds = True
End If
End If
If peptideEnds Then
Dim peptMass As Double = _
MMaaSequence.monoMass(strB.ToString, "Carbamidomethyl (C)")
If peptMass >= SMALLEST_OBSERVABLE_PEPTIDE_MASS And _
peptMass <= LARGEST_OBSERVABLE_PEPTIDE_MASS Then
numObsPept += 1
End If
strB.Length = 0
peptideEnds = False 'Reset.
End If
Next i
Return numObsPept
End Function 'numObsTrypPepts
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Protected Sub determineAAComp()
If mHaveAAComp Then Exit Sub
Dim i As Integer
For i = 0 To mSeq.Length - 1
mAACompArr(Asc(mSeq.Chars(i)) - Asc("A")) += 1
Next i
End Sub 'determineAAComp
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Public Function hasAA(ByVal anAA As Char) As Integer
Dim toReturn As Integer = 0 'Default if not found/known. See
' comment below.
If Not mHaveAAComp Then
Me.determineAAComp()
End If
If anAA >= "A" And anAA <= "Z" Then
toReturn = mAACompArr(Asc(anAA) - Asc("A"))
Else
Dim peter0 As Integer = 0 'Throw exception?
End If
Return toReturn
End Function 'hasAA
'Changed PM_REFACTOR 2008-05-20. Not used anywhere...
' '****************************************************************************
' '* <placeholder for header> *
' '****************************************************************************
' Public Shared Function monoMassProtonated( _
' ByRef aAASequence As String, ByVal aNumProtons As Integer, _
' ByVal aModStr As String) As Double
'
' 'Changed PM_REFACTOR 2008-05-20
' 'Dim toReturn As Double = _
' ' (monoMass(aAASequence, aModStr) + _
' ' aNumProtons * MSconstants.PROTON_MASS) / _
' ' aNumProtons
' Dim mMass As Double = monoMass(aAASequence, aModStr)
' Dim toReturn As Double = PILmassCalc.chargeTransform(mMass, 0, aNumProtons)
'
' Return toReturn
' End Function 'monoMassProtonated
'Changed PM_REFACTOR 2008-05-20. Not used anywhere...
'
' 'If we have calculated a fragment, this function will return the mass
' 'of mulitply protonated versions.
' 'to do: this should be in a generic MCR object instead.
' '****************************************************************************
' '* <placeholder for header> *
' '****************************************************************************
' Private Shared Function monoMassMuliplyChargedFrag( _
' ByVal aMW As Double, ByVal aChargeState As Integer) _
' As Double
'
' Dim toReturn As Double = _
' (aMW + aChargeState * MSconstants.PROTON_MASS) / aChargeState
'
' Return toReturn
' End Function 'monoMassMuliplyChargedFrag
'Changed PM_REFACTOR 2008-05-17. Moved to file PILgeneralisedIonSeries.cs.
' 'Changed PM_REFACTOR_GLOBALS 2003-10-09
' '****************************************************************************
' '* <placeholder for header> *
' '****************************************************************************
' Private Shared Sub effectiveMasses(ByVal aModStr As String, _
' ByRef anOutArgMass As Double, ByRef anOutLeuMass As Double, _
' ByRef anOutMetMass As Double, ByRef anOutCysMass As Double)
'
' anOutArgMass = MSconstants.ARG_MONO_MASS_NORMAL
' anOutLeuMass = MSconstants.LEU_MONO_MASS_NORMAL
' anOutMetMass = MSconstants.MET_MONO_MASS_NORMAL
'
' 'Changed PM_CYS_TROUBLE 2003-11-14
' 'anOutCysMass = CYS_MONO_MASS_NORMAL
' anOutCysMass = -1000000000.0
'
' Dim lowerModStr As String = aModStr.ToLower
'
' If lowerModStr.IndexOf("arg") >= 0 Then
' anOutArgMass = MSconstants.ARG_C6_MONO_MASS
' End If
'
' If lowerModStr.IndexOf("leu") >= 0 Then
' 'assume single D3 modification for now
' anOutLeuMass = MSconstants.LEU_D3_MONO_MASS
' End If
'
' If lowerModStr.IndexOf("ox") >= 0 Then
' anOutMetMass = MSconstants.MET_OX_MONO_MASS
' End If
'
' 'Changed PM_CYS_TROUBLE 2003-11-20
' Dim someCys As Boolean = False
' If lowerModStr.IndexOf("(c)") >= 0 Then
' someCys = True
' End If
' If lowerModStr.IndexOf("cys") >= 0 Then
' someCys = True
' End If
'
' If someCys Then
' If lowerModStr.IndexOf("carbamido") >= 0 Then
' anOutCysMass = MSconstants.CYS_CARBAMIDOMETHYL_MONO_MASS
' Else
' 'Changed PM_CYS_TROUBLE 2003-11-14
' If lowerModStr.IndexOf("nocysmod") >= 0 Then
' anOutCysMass = MSconstants.CYS_MONO_MASS_NORMAL
' Else
' If lowerModStr.IndexOf("cyshy0") >= 0 Then
'
' 'Changed PM_HYSTAG_BADMASS 2005-07-07
' 'anOutCysMass = CYS_CARBAMIDOMETHYL_MONO_MASS + CYS_HYS_ALA_D0
' anOutCysMass = MSconstants.CYS_HYS_ALA_D0
' Else
' If lowerModStr.IndexOf("cyshy4") >= 0 Then
'
' 'Changed PM_HYSTAG_BADMASS 2005-07-07
' 'anOutCysMass = CYS_CARBAMIDOMETHYL_MONO_MASS + CYS_HYS_ALA_D4
' anOutCysMass = MSconstants.CYS_HYS_ALA_D4
' Else
' Trace.Assert(False, _
' "PIL ASSERT. Cysteine modification not explicit!.")
' End If
' End If
' End If
' End If
' Else
' Dim peter4 As Integer = 4
' anOutCysMass = MSconstants.CYS_CARBAMIDOMETHYL_MONO_MASS
' End If
'
' End Sub 'effectiveMasses
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Public Shared Function monoMass( _
ByRef aAASequence As String, ByVal aModStr As String) As Double
If aModStr = "noCysMod" Then
Dim peter16 As Integer = 16
End If
Dim argEffectiveMass As Double
Dim leuEffectiveMass As Double
Dim metEffectiveMass As Double
Dim cysEffectiveMass As Double
PILgeneralisedIonSeries.effectiveMasses(aModStr, _
argEffectiveMass, leuEffectiveMass, metEffectiveMass, cysEffectiveMass)
'Changed PM_CYS_TROUBLE 2003-11-14
Trace.Assert(aModStr <> "", "PIL ASSERT. Empty modification string!.")
If aModStr.IndexOf("cyshy") < 0 Then
Trace.Assert( _
(cysEffectiveMass > 160.0 AndAlso cysEffectiveMass < 161.0) Or _
aModStr = "noCysMod", _
"PIL ASSERT. Cysteine mass (" & _
cysEffectiveMass & " Da) is far from the expected value.")
End If
Dim mass As Double = _
MSconstants.NORMAL_N_TERMINUS_MONO + _
MSconstants.NORMAL_C_TERMINUS_MONO
Dim i As Integer
Dim maxIndex As Integer = aAASequence.Length - 1
For i = 0 To maxIndex
'Why don't we call monoMassFromLetter()? There is redundancy...
' theMass = theMass + monoMWFromLetter(aAASequence.Chars(i))
'Changed PM_REFACTOR 2007-01-12. To easy debugging and reduce redundancy.
Dim ch2 As String = aAASequence.Chars(i)
'Select Case aAASequence.Chars(i)
Select Case ch2
Case "A"
mass += MSconstants.ALA_MONO_MASS
Case "C"
mass += cysEffectiveMass
Case "D"
mass += MSconstants.ASP_MONO_MASS
Case "E"
mass += MSconstants.GLU_MONO_MASS
Case "F"
mass += MSconstants.PHE_MONO_MASS
Case "G"
mass += MSconstants.GLY_MONO_MASS
Case "H"
mass += MSconstants.HIS_MONO_MASS
Case "I"
mass += MSconstants.IIE_MONO_MASS
Case "K"
mass += MSconstants.LYS_MONO_MASS
Case "L"
mass += leuEffectiveMass
Case "M"
mass += metEffectiveMass
Case "N"
mass += MSconstants.ASN_MONO_MASS
Case "P"
mass += MSconstants.PRO_MONO_MASS
Case "Q"
mass += MSconstants.GLN_MONO_MASS
Case "R"
mass += argEffectiveMass
Case "S"
mass += MSconstants.SER_MONO_MASS
Case "T"
mass += MSconstants.THR_MONO_MASS
Case "V"
mass += MSconstants.VAL_MONO_MASS
Case "W"
mass += MSconstants.TRP_MONO_MASS
Case "Y"
mass += MSconstants.TYR_MONO_MASS
'Changed PM_SNIPS_OUJ_RKN 2006-11-29
Case "U" 'As K
mass += MSconstants.LYS_MONO_MASS
Case "O" 'As R
mass += argEffectiveMass
Case "J" 'As N
mass += MSconstants.ASN_MONO_MASS
Case "X"
'Changed PM_UNUSUAL_AMINOACIDS 2007-01-12
'This does happen (from SWISSPROT?), e.g peptide
' "ASLHXRQIQXLHR"
'
'The effective mass of X in Mascot is some average amino
'acid mass based some distribution of amino acids in
'some sequence database, about 111.0919 Da.
'Should we use the same value??
mass += 0.0 'Ignore X, mass-wise.
Case Else
mass += 0.0 'Does nothing! Why do we have this?? Because
' we can, and have, detected errrors, e.g. if some
' number was parsed as the peptide sequence instead of
' a real amino acid sequence.
If True Then
Dim peter2 As Integer = 2
End If
'if it is not a legal amino acid we return zero
End Select
Next i
Return mass
End Function 'monoMass
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Function monoMassFromLetter( _
ByRef aLetter As Char, ByVal aModStr As String) As Double
Dim toReturn As Double = 0.0 'If it is not a legal amino acid we
' return zero.
Dim argEffectiveMass As Double
Dim leuEffectiveMass As Double
Dim metEffectiveMass As Double
Dim cysEffectiveMass As Double
PILgeneralisedIonSeries.effectiveMasses(aModStr, _
argEffectiveMass, leuEffectiveMass, metEffectiveMass, cysEffectiveMass)
Select Case aLetter
Case CChar("A")
toReturn = MSconstants.ALA_MONO_MASS
Case CChar("C")
toReturn = cysEffectiveMass
Case CChar("D")
toReturn = MSconstants.ASP_MONO_MASS
Case CChar("E")
toReturn = MSconstants.GLU_MONO_MASS
Case CChar("F")
toReturn = MSconstants.PHE_MONO_MASS
Case CChar("G")
toReturn = MSconstants.GLY_MONO_MASS
Case CChar("H")
toReturn = MSconstants.HIS_MONO_MASS
Case CChar("I")
toReturn = MSconstants.IIE_MONO_MASS
Case CChar("K")
toReturn = MSconstants.LYS_MONO_MASS
Case CChar("L")
toReturn = leuEffectiveMass
Case CChar("M")
toReturn = metEffectiveMass
Case CChar("N")
toReturn = MSconstants.ASN_MONO_MASS
Case CChar("P")
toReturn = MSconstants.PRO_MONO_MASS
Case CChar("Q")
toReturn = MSconstants.GLN_MONO_MASS
Case CChar("R")
toReturn = argEffectiveMass
Case CChar("S")
toReturn = MSconstants.SER_MONO_MASS
Case CChar("T")
toReturn = MSconstants.THR_MONO_MASS
Case CChar("V")
toReturn = MSconstants.VAL_MONO_MASS
Case CChar("W")
toReturn = MSconstants.TRP_MONO_MASS
Case CChar("Y")
toReturn = MSconstants.TYR_MONO_MASS
'Changed PM_SNIPS_OUJ_RKN 2006-11-29
Case CChar("U") 'As K
toReturn = MSconstants.LYS_MONO_MASS
Case CChar("O") 'As R
toReturn = argEffectiveMass
Case CChar("J") 'As N
toReturn = MSconstants.ASN_MONO_MASS
End Select
Return toReturn
End Function 'monoMassFromLetter
'Changed PM_REFACTOR 2008-05-16. Moved to PILgeneralisedIonSeries.cs.
' '****************************************************************************
' '* <placeholder for header> *
' '* anInModificationsList: type is simpleModificationSpecification *
' '* *
' '****************************************************************************
' Private Shared Function constructMassTable( _
' ByRef anInModificationsList As _
' Generic.List(Of Generic.List(Of quantitation.AAsetStructure))) _
' As Double()
'
' 'Changed PM_QUANTGENERAL_PREPARATION 2006-07-14
' 'Old:
' ' ByRef anInModificationsList As ArrayList
'
' 'Changed PM_MEMORY_EFFICIENCY_256 2006-10-31
' 'Dim massTable(256) As Double
' Dim massTable(123) As Double 'Corresponding to z. Could it even
' ' be less, 91 for Z ?
'
'
' 'Note: this is repeated in SetAAMassTable()s!!!!
' If True Then 'Default masses
' massTable(AscW("A"c)) = MSconstants.ALA_MONO_MASS
' massTable(AscW("C"c)) = MSconstants.CYS_CARBAMIDOMETHYL_MONO_MASS 'We assume
' ' Cys-carbamido as a fixed modication in the Mascot search.
' massTable(AscW("D"c)) = MSconstants.ASP_MONO_MASS
' massTable(AscW("E"c)) = MSconstants.GLU_MONO_MASS
' massTable(AscW("F"c)) = MSconstants.PHE_MONO_MASS
' massTable(AscW("G"c)) = MSconstants.GLY_MONO_MASS
' massTable(AscW("H"c)) = MSconstants.HIS_MONO_MASS
' massTable(AscW("I"c)) = MSconstants.IIE_MONO_MASS
' massTable(AscW("K"c)) = MSconstants.LYS_MONO_MASS
' massTable(AscW("L"c)) = MSconstants.LEU_MONO_MASS_NORMAL
' massTable(AscW("M"c)) = MSconstants.MET_MONO_MASS_NORMAL
' massTable(AscW("N"c)) = MSconstants.ASN_MONO_MASS
' massTable(AscW("P"c)) = MSconstants.PRO_MONO_MASS
' massTable(AscW("Q"c)) = MSconstants.GLN_MONO_MASS
' massTable(AscW("R"c)) = MSconstants.ARG_MONO_MASS_NORMAL
' massTable(AscW("S"c)) = MSconstants.SER_MONO_MASS
' massTable(AscW("T"c)) = MSconstants.THR_MONO_MASS
' massTable(AscW("V"c)) = MSconstants.VAL_MONO_MASS
' massTable(AscW("W"c)) = MSconstants.TRP_MONO_MASS
' massTable(AscW("Y"c)) = MSconstants.TYR_MONO_MASS
'
' 'Changed PM_SNIPS_OUJ_RKN 2006-11-29
' massTable(AscW("U"c)) = MSconstants.LYS_MONO_MASS 'As K
' massTable(AscW("O"c)) = MSconstants.ARG_MONO_MASS_NORMAL 'As R
' massTable(AscW("J"c)) = MSconstants.ASN_MONO_MASS 'As N
' End If
'
' If True Then 'Apply modifications
' Dim someModItem As Generic.List(Of quantitation.AAsetStructure)
' 'Outer loop: for each modification
' For Each someModItem In anInModificationsList
'
' 'Changed PM_QUANTGENERAL_PREPARATION 2006-07-14
' 'Dim someModItem As quantitation.simpleModificationSpecification
' Dim someAAset As quantitation.AAsetStructure
'
' 'Inner loop: for each AA set (usually only one, but 20 for N15)
' For Each someAAset In someModItem
'
' 'Changed PM_MULTIPLE_AA_FOR_MODIFICATION 2005-08-10
'
' 'Changed PM_QUANTGENERAL_PREPARATION 2006-07-14
' 'Dim AA As String = someModItem.AA
' Dim AA As String = someAAset.AAs
'
' Dim lastIndex As Integer = someAAset.AAs.Length - 1
' Dim j As Integer
' For j = 0 To lastIndex
'
' If lastIndex > 0 Then 'Optimisation as for most
' ' modifications there is only one AA (in
' ' that case it is already set).
' AA = someAAset.AAs.Substring(j, 1)
' End If
' Dim index As Integer = AscW(CChar(AA))
' Dim oldValue As Double = massTable(index)
'
' Dim diffFromBase As Double = someAAset.diffFromBase3
' Dim newValue As Double = oldValue + diffFromBase
'
' 'Changed PM_HYSTAG_BADMASS 2005-07-07. For now: until we
' 'get rid of explicit Carbamido-Cys in the code we assume
' 'that .
' ' The condition is effectively detection of
' ' baseModification greater than 0. Or in order
' ' words HysTag/ICAT like quantitation modes.
' '
'
' 'Changed PM_120DA_RULE 2007-09-12. Partly fixed, but
' ' not a fundamental fix. This will wait until fixed
' ' modificatios are read in from the Mascot result
' ' file and the Carbamido-Cys assumption can be removed
' ' all over the code.
' '
' ''Changed PM_UBIK_ASSERT 2006-03-28
' ''Changed PM_NOT_HYSTAG_FOR_PHOSPHO 2005-07-20
' ''If someModItem.diffFromBase > 30.0 Then
' ''If someModItem.diffFromBase > 100.0 Then
' 'If diffFromBase > 120.0 Then
' 'If diffFromBase > 30.0 AndAlso (AA = "C" OrElse AA = "c") Then
' If diffFromBase > 100.0 AndAlso (AA = "C" OrElse AA = "c") Then
' ' This is a detection of wether fixed mod Carbamido has
' ' been used or not.
' ' Not 30.0: Acetyl N-term is 42 Da!
' '
' 'The mass limit is to allow lower mass modifications to
' 'act on Cysteine, e.g. N15 on Carbamido-Cys.
'
' 'This is for ICAT, HysTag and similar. In this case
' 'it is assumed that Carbamidomethyl is ***not***
' 'a fixed modification. In all other cases this
' 'fixed modification for Cys is assumed.
'
' 'newValue = diffFromBase This made the diff specification
' ' into an absolute value!
' newValue = _
' MSconstants.CYS_MONO_MASS_NORMAL + diffFromBase
' End If
'
' massTable(index) = newValue
' Next j 'Through AA set.
' Next 'Through someModItem.
' Next 'Through modifications.
' End If
'
' Return massTable
' End Function 'constructMassTable
'Changed PM_REFACTOR 2008-05-16. Moved to file .
' '****************************************************************************
' '* <placeholder for header> *
' '* anInModificationsList: type is simpleModificationSpecification *
' '* *
' '****************************************************************************
' Public Shared Sub yIonArray( _
' ByRef anInSeq As String, _
' ByRef anOutFragMasses2 As List(Of Double), _
' ByRef aOutMaxCalcArrIdx As Integer, ByVal aModStr As String, _
' ByRef anInModificationsList As _
' Generic.List(Of Generic.List(Of quantitation.AAsetStructure)), _
' ByVal aMS3_BionFlag As Boolean)
'
' 'Old type for anOutFragMasses:
' ' anOutFragMasses() As Double
'
'
' 'This function takes the peptide sequence as input and fills an
' 'allocated array with doubles for Y ion masses.
'
' ''Changed PM_GENERALISED_QUANT_MODE 2003-12-10
' ''Changed PM_CYS_TROUBLE 2003-11-14
' 'Dim modStrToUse As String = aModStr
' 'If modStrToUse = "" Then
' ' modStrToUse = "noCysMod"
' 'End If
' ''Changed PM_REFACTOR_GLOBALS 2003-10-09
' 'Dim argEffectiveMass As Double
' 'Dim leuEffectiveMass As Double
' 'Dim metEffectiveMass As Double
' 'Dim cysEffectiveMass As Double
' 'effectiveMasses(modStrToUse, _
' ' argEffectiveMass, leuEffectiveMass, metEffectiveMass,
' ' cysEffectiveMass)
'
' 'Changed PM_GENERALISED_QUANT_MODE 2003-12-10
' Dim massTable() As Double = constructMassTable(anInModificationsList)
'
' Dim yIonMass As Double = MSconstants.Y_ION_OFFSET
'
' 'Changed PM_MS3_DTASUPERCHARGE 2004-04-15
' If aMS3_BionFlag Then
' yIonMass = MSconstants.B_ION_OFFSET 'In the case of y ions from b-ion
' ' precusors, the mass is like an internal fragment.
' End If
'
' 'Changed PM_BAD_PRECURSORMASS 2006-10-31.
' ''Changed PM_INFINITE_FRAGMENTS 2005-08-09
' ' '' It is aSeq.Length - 2 because zero based array and n-1 y ions
' ' '' for seq of length n.
' ''aMaxCalcArrIdx = _
' '' Math.Min(aSeq.Length - 2, MAX_Y_IONS_TO_DISPLAY - 1) 'Limit to an
' '' array of currently 100 Y ions.
' 'aOutMaxCalcArrIdx = aSeq.Length - 2
' Dim plen As Integer = anInSeq.Length
'
' 'Changed PM_REFACTOR 2008-05-08
' anOutFragMasses2 = New List(Of Double)(plen)
'
'
' Dim lastIndex As Integer = plen - 1
' aOutMaxCalcArrIdx = lastIndex 'Include yN in the computation
'
' Dim i As Integer
'
' 'Changed PM_BAD_PRECURSORMASS 2006-10-31
' 'For i = aOutMaxCalcArrIdx + 1 To 1 Step -1
' ' Fill the array
' ' from y1 to yn-1 (if we did it to 0 then we would get
' ' the single protonated MW as well.
' For i = lastIndex To 0 Step -1 'Include yN
' Dim curAA As Char = anInSeq.Chars(i)
' Dim curMass As Double = massTable(AscW(curAA))
' yIonMass += curMass
'
' 'Changed PM_REFACTOR 2008-05-08
' 'anOutFragMasses(lastIndex - i) = yIonMass
' anOutFragMasses2.Add(yIonMass)
' Next i
'
' 'Changed PM_TERMMOD_FRAGMENTMASS_TROUBLE 2007-09-14
' If True Then 'Undo for modifications that do not span the entire
' ' peptide sequence, e.g. terminal modifications. In this
' ' case we can still use our mass table above for majority of
' ' the calculations.
'
' Dim someModItem As Generic.List(Of quantitation.AAsetStructure)
' For Each someModItem In anInModificationsList
'
' Dim allPositions As Boolean
' Dim startPos0 As Integer = -1 'Flag for below.
' Dim endPos0 As Integer 'Just in case.
'
' Dim someAAset As quantitation.AAsetStructure
' For Each someAAset In someModItem
'
' If startPos0 = -1 Then '-1 is a flag - we only use the
' ' first item in the someModItem list. It is the only
' ' item for which the INTERNAL fields are defined.
'
' Dim maxMods As Integer
'
' PILpeptide.findPositionsEtc( _
' someAAset.INTERNAL_startPosition3, _
' someAAset.INTERNAL_endPosition3, plen, _
' allPositions, startPos0, endPos0, maxMods)
' Else
' Dim peter2 As Integer = 2 'E.g. for N15
' End If
'
' If Not allPositions Then
' Dim someAA As String
' For Each someAA In someAAset.AAs
'
' Dim corrMass As Double = 0.0
' Dim corrMassIsZero As Boolean = True
'
' For i = lastIndex To 0 Step -1 'Include yN
'
' 'Dim oneBaseIndex As Integer = i + 1
' Dim insideRange As Boolean = _
' i >= startPos0 AndAlso _
' i <= endPos0
'
' If Not insideRange Then
'
' Dim curAA As Char = anInSeq.Chars(i)
' If someAA = curAA Then
' 'New correction mass.
' corrMass += someAAset.diffFromBase3
' corrMassIsZero = False
' End If
'
' 'Changed PM_CODEBRANCH 2007-10-26.
' If Not CODEBRANCH_FIXED Then
'
' 'Changed PM_IMPOSSIBLELOWMASS_ASSERT 2007-10-26. Old location.
' If Not corrMassIsZero Then
' anOutFragMasses2(lastIndex - i) -= _
' corrMass
' End If
' End If
' Else
' 'Inside range. The correction mass should
' 'not be updated, but we still need to
' 'correct the fragment mass (done just
' 'below) as fragment masses are
' 'accumulative - as the mass of an amino
' 'acid residue affects ALL higher mass
' 'fragments.
' Dim peter3 As Integer = 3
' End If
'
' 'Changed PM_CODEBRANCH 2007-10-26.
' If CODEBRANCH_FIXED Then
'
' 'Changed PM_IMPOSSIBLELOWMASS_ASSERT 2007-10-26.
' 'Moved out to this level.
' If Not corrMassIsZero Then
' anOutFragMasses2(lastIndex - i) -= corrMass
' End If
' End If
' Next 'Through peptide sequence.
' Next 'Through affected AAs for a modification, usually
' ' only one. But 20 for N15.
' End If 'Modification with not all positions in peptide.
' Next 'Through one modification - through sets of ***different***
' ' mass diffs.
' Next 'Through modifications.
' End If 'Block, undoing some fragment massses.
'
' End Sub 'yIonArray
'
'
' '****************************************************************************
' '* <placeholder for header> *
' '* anInModificationsList: type is simpleModificationSpecification *
' '****************************************************************************
' Public Shared Sub bIonArray( _
' ByRef anInSeq As String, _
' ByRef anOutFragMasses3 As List(Of Double), _
' ByRef anOutMaxCalcArrIdx As Integer, ByVal aModStr As String, _
' ByRef anInModificationsList As _
' Generic.List(Of Generic.List(Of quantitation.AAsetStructure)) _
' )
'
' 'Old type for anOutFragMasses2:
' ' anOutFragMasses2() As Double
'
'
' 'This function takes the peptide sequence as input and fills an
' 'allocated array with doubles for b ion masses up to a maximum of 100 b ions.
' 'this is so that no array needs to created or re-dimensioned which would
' 'take time
'
' 'Changed PM_CYS_TROUBLE 2003-11-14
' Dim modStrToUse As String = aModStr
' If modStrToUse = "" Then
' modStrToUse = "noCysMod"
' End If
'
' 'Changed PM_REFACTOR_GLOBALS 2003-10-09
' Dim argEffectiveMass As Double
' Dim leuEffectiveMass As Double
' Dim metEffectiveMass As Double
' Dim cysEffectiveMass As Double
' effectiveMasses(modStrToUse, _
' argEffectiveMass, leuEffectiveMass, metEffectiveMass, cysEffectiveMass)
'
' 'Changed PM_GENERALISED_QUANT_MODE 2003-12-10
' Dim massTable() As Double = constructMassTable(anInModificationsList)
'
' Dim BionMass As Double = MSconstants.B_ION_OFFSET
' Dim i As Integer
' ' It is aSeq.Length - 2 because zero based array and n-1 y ions
' ' for seq of length n.
'
' 'Changed PM_INFINITE_FRAGMENTS 2005-08-09
' ''Limit to an array of currently 100 b ions.
' 'maxCalcArrIdx = Math.Min(aSeq.Length - 2, MAX_Y_IONS_TO_DISPLAY - 1)
' Dim plen As Integer = anInSeq.Length
' anOutMaxCalcArrIdx = plen - 2
'
' 'Changed PM_REFACTOR 2008-05-08
' anOutFragMasses3 = New List(Of Double)(plen)
'
' For i = 0 To anOutMaxCalcArrIdx ' + 1
' Dim curAA As Char = anInSeq.Chars(i)
' Dim curMass As Double = massTable(AscW(curAA))
' BionMass += curMass
'
' 'Changed PM_REFACTOR 2008-05-08
' 'anOutFragMasses2(i) = BionMass
' anOutFragMasses3.Add(BionMass)
' Next i
'
' 'Changed PM_TERMMOD_FRAGMENTMASS_TROUBLE 2007-09-14
' If True Then 'Undo for modifications that do not span the entire
' ' peptide sequence, e.g. terminal modifications. In this
' ' case we can still use our mass table above for majority of
' ' the calculations.
'
' Dim someModItem As Generic.List(Of quantitation.AAsetStructure)
' For Each someModItem In anInModificationsList
'
' Dim startPos0 As Integer = -1 'Flag for below.
' Dim endPos0 As Integer 'Just in case.
' Dim allPositions As Boolean
'
' Dim someAAset As quantitation.AAsetStructure
' For Each someAAset In someModItem
'
' If startPos0 = -1 Then '-1 is a flag - we only use the
' ' first item in the someModItem list. It is the only
' ' item for which the INTERNAL fields are defined.
'
' Dim maxMods As Integer
' PILpeptide.findPositionsEtc( _
' someAAset.INTERNAL_startPosition3, _
' someAAset.INTERNAL_endPosition3, plen, _
' allPositions, startPos0, endPos0, maxMods)
' Else
' Dim peter2 As Integer = 2 'E.g. for N15
' End If
'
' If Not allPositions Then
' Dim someAA As String
' For Each someAA In someAAset.AAs
'
' Dim corrMass As Double = 0.0
' Dim corrMassIsZero As Boolean = True
'
' For i = 0 To anOutMaxCalcArrIdx
'
' Dim insideRange As Boolean = _
' i >= startPos0 AndAlso _
' i <= endPos0
'
' If Not insideRange Then
'
' Dim curAA As Char = anInSeq.Chars(i)
' If someAA = curAA Then
' 'New correction mass.
' corrMass += someAAset.diffFromBase3
' corrMassIsZero = False
' End If
'
' 'Changed PM_CODEBRANCH 2007-10-26.
' If Not CODEBRANCH_FIXED Then
'
' 'Changed PM_IMPOSSIBLELOWMASS_ASSERT 2007-10-26. Old location.
' If Not corrMassIsZero Then
' anOutFragMasses3(i) -= corrMass
' End If
' End If
'
' Else
' 'Inside range. The correction mass should
' 'not be updated, but we still need to
' 'correct the fragment mass (done just
' 'below) as fragment masses are
' 'accumulative - as the mass of an amino
' 'acid residue affects ALL higher mass
' 'fragments.
' Dim peter3 As Integer = 3
' End If
'
' 'Changed PM_CODEBRANCH 2007-10-26.
' If CODEBRANCH_FIXED Then
'
' 'Changed PM_CODEBRANCH 2007-10-26. Moved out to this level.
' If Not corrMassIsZero Then
' anOutFragMasses3(i) -= corrMass
' End If
' End If
'
' Next 'Through peptide sequence.
' Next 'Through affected AAs for a modification, usually
' ' only one. But 20 for N15.
' End If 'Modification with not all positions in peptide.
' Next 'Through one modification - through sets of ***different***
' ' mass diffs.
' Next 'Through modifications.
' End If 'Block, undoing some fragment massses.
'
' End Sub 'bIonArray
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Function GetAAFromMasses( _
ByVal aLowerMass As Double, ByVal aHigherMass As Double, _
ByVal aMassAcc As Double, _
ByVal aModStr As String) _
As Char
Dim theAA As Char
Dim massDiff As Double = aHigherMass - aLowerMass
theAA = GetAAFromMass(massDiff, aMassAcc, aModStr)
Return theAA
End Function 'GetAAFromMasses
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Function GetAAFromMass( _
ByVal aMassDiff As Double, ByVal aMassAcc As Double, _
ByVal aModStr As String) _
As Char
'Changed PM_REFACTOR_GLOBALS 2003-10-09
Dim argEffectiveMass As Double
Dim leuEffectiveMass As Double
Dim metEffectiveMass As Double
Dim cysEffectiveMass As Double
PILgeneralisedIonSeries.effectiveMasses(aModStr, _
argEffectiveMass, leuEffectiveMass, metEffectiveMass, cysEffectiveMass)
Dim AA As Char
Select Case CInt(aMassDiff)
Case CInt(MSconstants.ALA_MONO_MASS)
AA = CChar("A")
Case CInt(cysEffectiveMass)
AA = CChar("C")
Case CInt(MSconstants.ASP_MONO_MASS)
AA = CChar("D")
Case CInt(MSconstants.GLU_MONO_MASS)
AA = CChar("E")
Case CInt(MSconstants.PHE_MONO_MASS)
AA = CChar("F")
Case CInt(MSconstants.GLY_MONO_MASS)
AA = CChar("G")
Case CInt(MSconstants.HIS_MONO_MASS)
AA = CChar("H")
Case CInt(MSconstants.IIE_MONO_MASS)
AA = CChar("I")
Case CInt(MSconstants.LYS_MONO_MASS)
AA = CChar("K")
Case CInt(leuEffectiveMass)
AA = CChar("L")
Case CInt(metEffectiveMass)
AA = CChar("M")
Case CInt(MSconstants.ASN_MONO_MASS)
AA = CChar("N")
Case CInt(MSconstants.PRO_MONO_MASS)
AA = CChar("P")
Case CInt(MSconstants.GLN_MONO_MASS)
AA = CChar("Q")
Case CInt(argEffectiveMass)
AA = CChar("R")
Case CInt(MSconstants.SER_MONO_MASS)
AA = CChar("S")
Case CInt(MSconstants.THR_MONO_MASS)
AA = CChar("T")
Case CInt(MSconstants.VAL_MONO_MASS)
AA = CChar("V")
Case CInt(MSconstants.TRP_MONO_MASS)
AA = CChar("W")
Case CInt(MSconstants.TYR_MONO_MASS)
AA = CChar("Y")
'Changed PM_SNIPS_OUJ_RKN 2006-11-29
Case CInt(MSconstants.LYS_MONO_MASS)
AA = CChar("U") 'As K
Case CInt(argEffectiveMass)
AA = CChar("O") 'As R
Case CInt(MSconstants.ASN_MONO_MASS)
AA = CChar("J") 'As N
Case Else
'Changed PM_SNIPS_OUJ_RKN 2006-11-29
'AA = CChar("0")
AA = CChar("*")
End Select
Return AA
End Function 'GetAAFromMass
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Sub SplitToPeptHashTable( _
ByRef aAASeq As String, ByVal aMissedCleav As missedCleavEnum, _
ByVal whichEnzyme As enzymeEnum, ByVal aMissedCleavOnly As Boolean, _
ByRef aPeptHshTbl As Hashtable)
If Not whichEnzyme = enzymeEnum.enumMmTrypsin Then
MsgBox("Only trypsin is implemented so far")
End If
Dim tempStrB As New System.Text.StringBuilder
Dim aStringBLastIndex As Integer = aAASeq.Length - 1
Dim peptideEnds As Boolean = False
Dim i As Integer
For i = 0 To aStringBLastIndex 'loop through all characters
tempStrB.Append(aAASeq.Chars(i))
'Is this the end of our peptide?
'somewhat complicated because we can't peek ahead to the possible
'Proline at i+1 if we are at the end of the string. So we test this first
If (i = aStringBLastIndex) Then
peptideEnds = True
ElseIf (aAASeq.Chars(i) = "K" Or aAASeq.Chars(i) = "R") Then
If Not (aAASeq.Chars(i + 1) = "P") Then peptideEnds = True
End If
If (peptideEnds) Then
'We have a completed tryptic peptide and can stuff it into the
'pept hash table if it is not too short and if it does not
'already exist.
If tempStrB.Length >= MIN_AA_TO_COUNT_PEPT Then
If Not aPeptHshTbl.ContainsKey(tempStrB.ToString) Then
aPeptHshTbl.Add(tempStrB.ToString, 1) 'Could store
' the number and offset here.
Else
aPeptHshTbl.Item(tempStrB.ToString) = CInt(aPeptHshTbl.Item(tempStrB.ToString)) + 1
End If
End If
tempStrB.Length = 0
peptideEnds = False
End If
Next i
End Sub 'SplitToPeptHashTable
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Function SplitToPeptArrayList(ByRef aAASeq As String) _
As ArrayList
'takes a protein sequence and splits it to tryptic peptides which
'are put into a ListArray of strings. Will not cleave at proline.
Dim i As Integer
Dim iMax As Integer = aAASeq.Length - 1
Dim tempStrB As New System.Text.StringBuilder(70) 'make it long enough
Dim peptideEnds As Boolean
Dim peptArrayList As New ArrayList(100)
For i = 0 To iMax
tempStrB.Append(aAASeq.Chars(i))
If i = iMax Then
peptideEnds = True
ElseIf (aAASeq.Chars(i) = "K" Or aAASeq.Chars(i) = "R") Then
If Not (aAASeq.Chars(i + 1) = "P") Then peptideEnds = True
End If
If peptideEnds Then
peptArrayList.Add(tempStrB.ToString)
tempStrB.Length = 0 'Is this the fastest way to do
' it? Capacity doesn't change.
peptideEnds = False
End If
Next i
Return peptArrayList
End Function 'SplitToPeptArrayList
'take out the proline exception and add the proline peptides later?
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Sub AddMissedCleavageWithinTwoAAs(ByRef aPeptList As ArrayList)
'see below for description
Dim i As Integer
Dim iMax As Integer = aPeptList.Count - 1
For i = 1 To iMax
If CStr(aPeptList.Item(i - 1)).Length <= 2 Or CStr(aPeptList.Item(i)).Length <= 2 Then
aPeptList.Add(String.Concat(CStr(aPeptList.Item(i - 1)), CStr(aPeptList.Item(i))))
End If
Next i
End Sub 'AddMissedCleavageWithinTwoAAs
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Sub AddMissedCleavageTwoAAsOrDEPepts( _
ByRef aPeptList As ArrayList)
'This is a typical case: trypsin doesn't cut if cleavage site is
'within two aas from another one, or if previous cleavage site
'had D or E before or after this way we catch most missed cleavage
'sites but we don't increase the number of peptides so much.
Dim i As Integer
Dim iMax As Integer = aPeptList.Count - 1
Dim joinPeptides As Boolean
Dim firstPept, secPept As String
For i = 1 To iMax
firstPept = CStr(aPeptList.Item(i - 1))
secPept = CStr(aPeptList.Item(i))
If firstPept.Length <= 2 Or secPept.Length <= 2 Then
joinPeptides = True 'if the first or second peptide is very short it gets joint
ElseIf firstPept.Chars(firstPept.Length - 2) = "D"c Or firstPept.Chars(firstPept.Length - 2) = "E"c Then 'is the peptide preceeding the cleavage site a D or E
joinPeptides = True
ElseIf secPept.Chars(1) = "D"c Or secPept.Chars(1) = "E"c Then
joinPeptides = True 'if cleavage site is followed by D or E
End If
If joinPeptides = True Then
aPeptList.Add(String.Concat(CStr(aPeptList.Item(i - 1)), CStr(aPeptList.Item(i))))
End If
joinPeptides = False
Next i
End Sub 'AddMissedCleavageTwoAAsOrDEPepts
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Sub AddOneMissedCleavagePepts(ByRef aPeptList As ArrayList)
'Takes a list of tryptic peptides and adds the peptides for one
'missed cleavage. Also respects proline non cleavage.
'We could join two peptides and insert the concatenated peptide
'always after eachpeptide. However, this seems to get complicated
'and is possibly slow, so we append the peptides to the end instead.
Dim i As Integer
Dim iMax As Integer = aPeptList.Count - 1
For i = 1 To iMax
'start with the second and insert the joint peptide
aPeptList.Add( _
String.Concat(CStr(aPeptList.Item(i - 1)), _
CStr(aPeptList.Item(i))))
Next i
End Sub 'AddOneMissedCleavagePepts
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Sub AddMetOxPepts(ByRef aPeptList As ArrayList)
'takes a list of tryptic peptides and appends new ones for MetOx at the end
Dim i As Integer
Dim iMax As Integer = aPeptList.Count - 1
Dim numMet As Integer
For i = 1 To iMax
numMet = MMaaSequence.GetNumMet(CStr(aPeptList.Item(i)))
If numMet = 0 Then
'nothing to do
ElseIf numMet = 1 Then
'append an additional peptide with "B" instead of "M"
Dim metOxPept As String = _
CStr(aPeptList.Item(i)).Replace("M"c, "B"c)
aPeptList.Add(metOxPept)
ElseIf numMet > 1 Then
'append three additional peptides with "B" in appropriate positions
'we don't consider the case of three Metox
'first peptide: first M exchanged; second, last; then *all* Met oxidized
Dim theIndex As Integer = CStr(aPeptList.Item(i)).IndexOf("M"c)
Dim metMultiplOxPept As New StringBuilder(CStr(aPeptList.Item(i)))
metMultiplOxPept.Chars(theIndex) = "B"c
aPeptList.Add(metMultiplOxPept.ToString)
metMultiplOxPept.Chars(theIndex) = "M"c 'change back
theIndex = CStr(aPeptList.Item(i)).LastIndexOf("M"c)
metMultiplOxPept.Chars(theIndex) = "B"c
aPeptList.Add(metMultiplOxPept.ToString)
aPeptList.Add(CStr(aPeptList.Item(i)).Replace("M"c, "B"c))
End If
Next i
End Sub 'AddMetOxPepts
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Sub AddNtermAcet(ByRef aPeptLst As ArrayList)
'Adds an alternative peptide at the N-terminus
'there could be several possibilities for this
Trace.Assert(False, _
"Stop!", "PIL ASSERT. Internal/development assert for stopping execution......")
End Sub 'AddNtermAcet
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Sub AddLeuDxPepts(ByRef aPeptLst As ArrayList, _
ByVal numDeu As Integer)
Trace.Assert(False, _
"Stop!", "PIL ASSERT. Internal/development assert for stopping execution......")
End Sub 'AddLeuDxPepts
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Sub AddArgCxPepts(ByRef aPeptLst As ArrayList, _
ByVal numC13 As Integer)
End Sub
'****************************************************************************
'* <placeholder for header> *
'****************************************************************************
Private Shared Function GetNumMet(ByRef aPeptSeq As String) _
As Integer
Dim toReturn As Integer = 0
Dim i As Integer
For i = 0 To aPeptSeq.Length - 1
If aPeptSeq.Chars(i) = "M" Then
toReturn += 1
End If
Next
Return toReturn
End Function 'GetNumMet
'Changed PM_REFACTOR 2008-05-09. Moved to file PILpeptide.cs. Delete at any
' time.
' 'Changed PM_DTASC_COMPILE 2008-02-11. Moved to here
' ' from clsMolShrStruct.vb. To remove difficult dependencies.
' ''Changed PM_REFACTOR 2007-09-18
' ''Changed PM_REFACTOR 2007-09-18. Moved to here from PTMscorer.vb.
' ' ''Changed PM_BROADER_PTMSCORE 2007-03-23
' '****************************************************************************
' '* Purpose: computes actual peptide positions based on the *
' '* specification for which part of a peptide a modification *
' '* is active, e.g. -1,-1 for a C-terminal modification. *
' '****************************************************************************
' Public Shared Sub findPositionsEtc( _
' ByVal aInStartPos As Integer, _
' ByVal anInEndPos As Integer, _
' ByVal anInPeptideLength2 As Integer, _
' ByRef anOutAllPositions As Boolean, _
' ByRef anOutStartPositionZeroBased As Integer, _
' ByRef anOutEndPositionZeroBased As Integer, _
' ByRef anOutMaxMods As Integer _
' )
'
' 'Changed PM_REFACTOR 2007-09-18
' ''Changed PM_TERMMOD 2007-09-10
' ' ''Default now: all positions.
' ' ''Later: from new fields in quantModificationStructure/ anInSomeMod.
' ''Dim startPosition3 As Integer = 1
' ''Dim endPosition3 As Integer = -1 'Negative: from C-terminal.
' 'Dim startPosition2 As Integer = anInSomeMod.startPosition
' 'Dim endPosition2 As Integer = anInSomeMod.endPosition 'Negative: from C-terminal.
' Dim startPosition2 As Integer = aInStartPos
' Dim endPosition2 As Integer = anInEndPos
'
' Dim lastPepIndex As Integer = anInPeptideLength2 - 1
'
' 'For now.
' 'Later: from new field in quantModificationStructure/ anInSomeMod.
' anOutMaxMods = 1
'
' anOutAllPositions = _
' (startPosition2 = 1) AndAlso (endPosition2 = -1)
'
' If Not anOutAllPositions Then
' If startPosition2 < 0 Then
' startPosition2 = Math.Abs(startPosition2)
' startPosition2 -= 1 'To zero based.
' startPosition2 = anInPeptideLength2 - startPosition2
' Else
' startPosition2 -= 1 'To zero based.
' End If
'
' If endPosition2 < 0 Then
' endPosition2 = Math.Abs(endPosition2)
' endPosition2 = anInPeptideLength2 - endPosition2
' Else
' endPosition2 -= 1 'To zero based.
' End If
' Else
' startPosition2 = 0
' endPosition2 = lastPepIndex
' End If
'
' If endPosition2 < startPosition2 Then
' Dim peter2 As Integer = 2 'Empty subset. What to do?
' End If
'
' 'Changed PM_TERMMOD 2007-09-10
' If startPosition2 < 0 Then 'This can happen for a small
' ' peptide with a specification from the C-terminal.
' startPosition2 = 0
' End If
' If startPosition2 > lastPepIndex Then 'This can happen for a small
' ' peptide with a start specification from the N-terminal, longer than
' ' the peptide.
' startPosition2 = lastPepIndex 'Avoid error. But is this
' ' the proper way?
'
' 'In this case the subset is empty. How do we handle that??
' End If
'
' If endPosition2 < 0 Then 'This can happen for a small
' ' peptide with an end specification from the C-terminal.
' endPosition2 = 0 'Avoid error. But is this
' ' the proper way?
'
' 'In this case the subset is empty. How do we handle that??
' End If
'
' If endPosition2 > lastPepIndex Then 'This can happen for a small
' ' peptide with a specification from the N-terminal, longer than
' ' the peptide.
' endPosition2 = lastPepIndex 'Avoid error. But is this
' ' the proper way?
'
' 'In this case the subset is empty. How do we handle that??
' End If
'
' anOutStartPositionZeroBased = startPosition2
' anOutEndPositionZeroBased = endPosition2
' End Sub 'findPositionsEtc
End Class 'MMaaSequence
Generated by script codePublish.pl at 2009-01-05T15:20:59.