Skip to content

Commit

Permalink
make impriovements of the annotyation data model
Browse files Browse the repository at this point in the history
  • Loading branch information
xieguigang committed Jan 13, 2025
1 parent d006e9e commit 1133d7e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 14 deletions.
12 changes: 12 additions & 0 deletions src/mzmath/MSEngine/Search/AnnotationData.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Imports BioNovoGene.Analytical.MassSpectrometry.Math.Ms1.Annotations
Imports BioNovoGene.Analytical.MassSpectrometry.Math.Spectra.Xml
Imports BioNovoGene.BioDeep.Chemoinformatics
Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic

Expand All @@ -21,4 +22,15 @@ Public Class AnnotationData(Of T As ICrossReference)
''' <returns></returns>
Public Property Xref As T

''' <summary>
''' MSDIAL score
''' </summary>
''' <returns></returns>
Public Property Score As MsScanMatchResult
''' <summary>
''' Spectrum alignment result
''' </summary>
''' <returns></returns>
Public Property Alignment As AlignmentOutput

End Class
26 changes: 19 additions & 7 deletions src/mzmath/MSEngine/Search/MsScanMatchResult.vb
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,26 @@ End Enum
''' <summary>
''' ms spectrum annotation result
''' </summary>
''' <remarks>
''' contains the score matched result
''' </remarks>
Public Class MsScanMatchResult
' basic annotated information

''' <summary>
''' basic annotated information
''' </summary>
''' <returns></returns>
Public Property Name As String

Public Property InChIKey As String


Public Property TotalScore As Single

' spectral similarity

''' <summary>
''' spectral similarity
''' </summary>
''' <returns></returns>
Public Property WeightedDotProduct As Single

Public Property SimpleDotProduct As Single
Expand Down Expand Up @@ -144,8 +152,10 @@ Public Class MsScanMatchResult

Public Property AcurateMassSimilarity As Single

' Link to database

''' <summary>
''' Link to database
''' </summary>
''' <returns></returns>
Public Property LibraryID As Integer = -1

Public Property LibraryIDWhenOrdered As Integer = -1
Expand Down Expand Up @@ -184,8 +194,10 @@ Public Class MsScanMatchResult
End Get
End Property

' Support for multiple annotation method

''' <summary>
''' Support for multiple annotation method
''' </summary>
''' <returns></returns>
Public ReadOnly Property IsManuallyModified As Boolean
Get
Return (Source And SourceType.Manual) <> 0
Expand Down
40 changes: 33 additions & 7 deletions src/mzmath/MSEngine/Search/MsScanMatching.vb
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,20 @@ Public NotInheritable Class MsScanMatching
End Sub

Public Shared Function IsComparedAvailable(Of T)(obj1 As IReadOnlyCollection(Of T), obj2 As IReadOnlyCollection(Of T)) As Boolean
If obj1 Is Nothing OrElse obj2 Is Nothing OrElse obj1.Count = 0 OrElse obj2.Count = 0 Then Return False
If obj1 Is Nothing OrElse
obj2 Is Nothing OrElse
obj1.Count = 0 OrElse
obj2.Count = 0 Then Return False

Return True
End Function

Public Shared Function IsComparedAvailable(obj1 As IMSScanProperty, obj2 As IMSScanProperty) As Boolean
If obj1.Spectrum Is Nothing OrElse obj2.Spectrum Is Nothing OrElse obj1.Spectrum.Count = 0 OrElse obj2.Spectrum.Count = 0 Then Return False
If obj1.Spectrum Is Nothing OrElse
obj2.Spectrum Is Nothing OrElse
obj1.Spectrum.Count = 0 OrElse
obj2.Spectrum.Count = 0 Then Return False

Return True
End Function

Expand Down Expand Up @@ -187,7 +195,11 @@ Public NotInheritable Class MsScanMatching
'}


Public Shared Function CompareMS2ProteomicsScanProperties(scanProp As IMSScanProperty, chargestate As Integer, refSpec As PeptideMsReference, param As MsRefSearchParameterBase, andromedaDelta As Single, andromedaMaxPeaks As Single) As MsScanMatchResult
Public Shared Function CompareMS2ProteomicsScanProperties(scanProp As IMSScanProperty, chargestate As Integer,
refSpec As PeptideMsReference,
param As MsRefSearchParameterBase,
andromedaDelta As Single,
andromedaMaxPeaks As Single) As MsScanMatchResult

Dim result = CompareBasicMSScanProperties(scanProp, refSpec, param, param.Ms2Tolerance, param.MassRangeBegin, param.MassRangeEnd)
Dim matchedPeaks = GetMachedSpectralPeaks(scanProp, chargestate, refSpec, param.Ms2Tolerance, param.MassRangeBegin, param.MassRangeEnd)
Expand All @@ -197,7 +209,12 @@ Public NotInheritable Class MsScanMatching
result.MatchedPeaksCount = matchedPeaks.Where(Function(n) n.IsMatched).Count
result.MatchedPeaksPercentage = CSng((result.MatchedPeaksCount / matchedPeaks.Count()))

If result.WeightedDotProduct >= param.WeightedDotProductCutOff AndAlso result.SimpleDotProduct >= param.SimpleDotProductCutOff AndAlso result.ReverseDotProduct >= param.ReverseDotProductCutOff AndAlso result.MatchedPeaksPercentage >= param.MatchedPeaksPercentageCutOff AndAlso result.MatchedPeaksCount >= param.MinimumSpectrumMatch AndAlso result.AndromedaScore >= param.AndromedaScoreCutOff Then
If result.WeightedDotProduct >= param.WeightedDotProductCutOff AndAlso
result.SimpleDotProduct >= param.SimpleDotProductCutOff AndAlso
result.ReverseDotProduct >= param.ReverseDotProductCutOff AndAlso
result.MatchedPeaksPercentage >= param.MatchedPeaksPercentageCutOff AndAlso
result.MatchedPeaksCount >= param.MinimumSpectrumMatch AndAlso
result.AndromedaScore >= param.AndromedaScoreCutOff Then
result.IsSpectrumMatch = True
End If
result.TotalScore = CSng(GetTotalScore(result, param))
Expand Down Expand Up @@ -252,7 +269,11 @@ Public NotInheritable Class MsScanMatching

result.MatchedPeaksCount = CSng(matchedPeaksScores(1))
result.MatchedPeaksPercentage = CSng(matchedPeaksScores(0))
If result.WeightedDotProduct >= param.WeightedDotProductCutOff AndAlso result.SimpleDotProduct >= param.SimpleDotProductCutOff AndAlso result.ReverseDotProduct >= param.ReverseDotProductCutOff AndAlso result.MatchedPeaksPercentage >= param.MatchedPeaksPercentageCutOff AndAlso result.MatchedPeaksCount >= param.MinimumSpectrumMatch Then
If result.WeightedDotProduct >= param.WeightedDotProductCutOff AndAlso
result.SimpleDotProduct >= param.SimpleDotProductCutOff AndAlso
result.ReverseDotProduct >= param.ReverseDotProductCutOff AndAlso
result.MatchedPeaksPercentage >= param.MatchedPeaksPercentageCutOff AndAlso
result.MatchedPeaksCount >= param.MinimumSpectrumMatch Then
result.IsSpectrumMatch = True
End If

Expand Down Expand Up @@ -1148,7 +1169,9 @@ Public NotInheritable Class MsScanMatching
''' <returns>
''' The similarity score which is standadized from 0 (no similarity) to 1 (consistency) will be return.
''' </returns>
Public Shared Function GetTotalSimilarity(accurateMassSimilarity As Double, rtSimilarity As Double, isotopeSimilarity As Double, spectraSimilarity As Double, reverseSearchSimilarity As Double, presenceSimilarity As Double, spectrumPenalty As Boolean, targetOmics As TargetOmics, isUseRT As Boolean) As Double
Public Shared Function GetTotalSimilarity(accurateMassSimilarity As Double, rtSimilarity As Double, isotopeSimilarity As Double,
spectraSimilarity As Double, reverseSearchSimilarity As Double,
presenceSimilarity As Double, spectrumPenalty As Boolean, targetOmics As TargetOmics, isUseRT As Boolean) As Double
Dim dotProductFactor = 3.0
Dim revesrseDotProdFactor = 2.0
Dim presensePercentageFactor = 1.0
Expand Down Expand Up @@ -1189,7 +1212,10 @@ Public NotInheritable Class MsScanMatching
End If
End Function

Public Shared Function GetTotalSimilarity(accurateMassSimilarity As Double, rtSimilarity As Double, ccsSimilarity As Double, isotopeSimilarity As Double, spectraSimilarity As Double, reverseSearchSimilarity As Double, presenceSimilarity As Double, spectrumPenalty As Boolean, targetOmics As TargetOmics, isUseRT As Boolean, isUseCcs As Boolean) As Double
Public Shared Function GetTotalSimilarity(accurateMassSimilarity As Double, rtSimilarity As Double, ccsSimilarity As Double,
isotopeSimilarity As Double, spectraSimilarity As Double, reverseSearchSimilarity As Double,
presenceSimilarity As Double, spectrumPenalty As Boolean, targetOmics As TargetOmics,
isUseRT As Boolean, isUseCcs As Boolean) As Double
Dim dotProductFactor = 3.0
Dim revesrseDotProdFactor = 2.0
Dim presensePercentageFactor = 1.0
Expand Down

0 comments on commit 1133d7e

Please sign in to comment.