<commit_before>﻿Imports System.Runtime.CompilerServices
Imports System.Xml
Imports Microsoft.VisualBasic.Math.Scripting
Imports MathCore = Microsoft.VisualBasic.Math

Public Class SSM2MatrixFragment

    ''' <summary>
    ''' The m/z value of the query fragment
    ''' </summary>
    ''' <returns></returns>
    Public Property mz As Double
#Region "Fragment intensity"
    Public Property query As Double
    Public Property ref As Double
#End Region

    ''' <summary>
    ''' Mass delta between the query and reference fragment in unit ``da``
    ''' </summary>
    ''' <returns></returns>
    Public Property da As String

    Public Shared Function FromXml(node As XmlNode, nodeName$) As SSM2MatrixFragment()
        Return (From child As XmlNode
                In node.ChildNodes
                Where child.Name = nodeName) _
 _
            .Select(Function(feature)
                        Dim data = feature.Attributes
                        Dim mz, query, ref As Double
                        Dim da As String

                        With data
                            mz = !mz.Value
                            query = !query.Value
                            ref = !ref.Value
                            da = !da.Value
                        End With

                        Return New SSM2MatrixFragment With {
                            .mz = mz,
                            .query = query,
                            .ref = ref,
                            .da = da
                        }
                    End Function) _
            .ToArray
    End Function

    Public Overrides Function ToString() As String
        Return mz
    End Function
End Class

Public Class Ms2AlignMatrix : Inherits IVector(Of SSM2MatrixFragment)

    ''' <summary>
    ''' 计算两个色谱矩阵之间的余弦相似度
    ''' </summary>
    ''' <returns></returns>
    Public ReadOnly Property SSM As Double
        <MethodImpl(MethodImplOptions.AggressiveInlining)>
        Get
            With Me
                Return MathCore.SSM(!query, !ref)<commit_msg>parse numeric<commit_after>﻿Imports System.Runtime.CompilerServices
Imports System.Xml
Imports Microsoft.VisualBasic.Math.Scripting
Imports MathCore = Microsoft.VisualBasic.Math

Public Class SSM2MatrixFragment

    ''' <summary>
    ''' The m/z value of the query fragment
    ''' </summary>
    ''' <returns></returns>
    Public Property mz As Double
#Region "Fragment intensity"
    Public Property query As Double
    Public Property ref As Double
#End Region

    ''' <summary>
    ''' Mass delta between the query and reference fragment in unit ``da``
    ''' </summary>
    ''' <returns></returns>
    Public Property da As String

    Public Shared Function FromXml(node As XmlNode, nodeName$) As SSM2MatrixFragment()
        Return (From child As XmlNode
                In node.ChildNodes
                Where child.Name = nodeName) _
 _
            .Select(Function(feature)
                        Dim data = feature.Attributes
                        Dim mz, query, ref As Double
                        Dim da As String

                        With data
                            mz = !mz.Value
                            query = !query.Value.ParseDouble
                            ref = !ref.Value.ParseDouble
                            da = !da.Value
                        End With

                        Return New SSM2MatrixFragment With {
                            .mz = mz,
                            .query = query,
                            .ref = ref,
                            .da = da
                        }
                    End Function) _
            .ToArray
    End Function

    Public Overrides Function ToString() As String
        Return mz
    End Function
End Class

Public Class Ms2AlignMatrix : Inherits IVector(Of SSM2MatrixFragment)

    ''' <summary>
    ''' 计算两个色谱矩阵之间的余弦相似度
    ''' </summary>
    ''' <returns></returns>
    Public ReadOnly Property SSM As Double
        <MethodImpl(MethodImplOptions.AggressiveInlining)>
        Get
            With Me
                Return MathCore.SSM(!query, !ref)
{'fraction_non_alphanumeric': 0.0733365711510442, 'fraction_numerical': 0.0024283632831471587, 'mean_word_length': 1.4517857142857142, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5382146', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1002, 'n_words': 316}