RunIdentificationMx Method |
Namespace: Biolomics.BioCallback
public static XMatrix IdentificationMx( XRecordMap p_SrceRecMap, XRecordMap p_RefRecMap, string p_ScenarioName )
Imports System Imports System.Collections Imports System.Text ' for StringBuilder Imports Biolomics.BioCallback Imports Biolomics.SharedClasses Imports Biolomics.Utility.databaseConstants Public Class Program <STAThread()> Shared Sub Main() Dim program As New Program() program.Test() End Sub ' Write sub functions here Public Sub Test() ' get the current connection Dim SqlCo As XConnection = Run.GetCurrentConnection() If SqlCo Is Nothing Then Return End If ' get a table from its User name Dim TableDef As XTableDef = SqlCo.GetTableDefByUserNameEng("Your_Table_Name") If TableDef Is Nothing Then ' may happen if that table doesn't exist Return End If ' load records #1 and #2 in the source record map Dim SrceRecMap As XRecordMap = Run.LoadRecords(TableDef.Key, Nothing, XWhere.Eq(StaticFields.id, 1).Or_(StaticFields.id, XWhere.OperationEnum.EQ, 2)) ' load records #1 to #10 in the reference record map Dim RefRecMap As XRecordMap = Run.LoadRecords(TableDef.Key, Nothing, XWhere.GTE(StaticFields.id, 1).And_(StaticFields.id, XWhere.OperationEnum.LTE, 10)) ' add record #20 to the references Run.LoadRecords(RefRecMap, TableDef.Key, Nothing, XWhere.Eq(StaticFields.id, 20), Nothing) ' run identification between SrceRecMap and RefRecMap, supposing that table_00_Scenario_3 has been created from the Identification page ' Mx contains one column per source record (2 columns here) and one row for each Reference record (11 rows here) Dim Mx As XMatrix = Run.IdentificationMx(SrceRecMap, RefRecMap, "Your_identification_Scenario") ' matrix result ' MsXtr contain the same matrix as a tab-delimited text Dim MxStr As String = Mx.ToString() ' transform Mx from a Similarity matrix to a distance matrix. (Distance = 1.0 - Similarity) Mx.Complement() ' Sim => Dist ' these are long texts describing in details all comparison results, including DNA alignments Dim IdentificationResults As Generic.List(Of String) = Run.IdentificationStr(SrceRecMap, RefRecMap, "Your_identification_Scenario") Dim IdentificationString As String = IdentificationResults(0) ' full string human readable, sorted for each source separately Console.WriteLine(IdentificationString) Dim DnaString As String = IdentificationResults(1) ' DNA comparison results ' To compare all reference records with each other, use the classification function ' the result is a 11 * 11 matrix of similarity in this case Dim SimMx As XMatrix = Run.ClassificationMx(RefRecMap, "Your_identification_Scenario") ' transform SimMx from a Similarity matrix to a distance matrix. SimMx.Complement() ' Sim => Dist ' display the distance between 2 records Console.Write("Distance between " & RefRecMap(1).Name & " and " & RefRecMap(3).Name & " = " & SimMx(1)(3).ToString) End Sub End Class