<commit_before>﻿Imports Microsoft.VisualBasic.Language.UnixBash
Imports SMRUCC.genomics.Assembly.KEGG.DBGET.bGetObject

Module Program

    ''' <summary>
    ''' 生成MetaDNA进行计算所需要的数据包
    ''' </summary>
    Sub Main()

    End Sub

    Sub BuildNetwork(repository As (reaction$, compound$), rda$)
        Dim reactions = (ls - l - r - "*.Xml" <= repository.reaction).Select(AddressOf LoadXml(Of Reaction))
        Dim compounds = ScanLoad(repository.compound) _
            .GroupBy(Function(c) c.Entry) _
            .ToDictionary(Function(c) c.Key,
                          Function(g)
                              Return g.First
                          End Function)


    End Sub
End Module
<commit_msg>build network<commit_after>﻿Imports Microsoft.VisualBasic.Language.UnixBash
Imports SMRUCC.genomics.Assembly.KEGG.DBGET.bGetObject
Imports R_server = RDotNet.Extensions.VisualBasic.RSystem
Imports Rbase = RDotNet.Extensions.VisualBasic.API.base
Imports VisualBasic = Microsoft.VisualBasic.Language.Runtime

Module Program

    ''' <summary>
    ''' 生成MetaDNA进行计算所需要的数据包
    ''' </summary>
    Sub Main()

    End Sub

    Sub BuildNetwork(repository As (reaction$, compound$), rda$)
        Dim reactions = (ls - l - r - "*.Xml" <= repository.reaction).Select(AddressOf LoadXml(Of Reaction))
        Dim compounds = ScanLoad(repository.compound) _
            .GroupBy(Function(c) c.Entry) _
            .ToDictionary(Function(c) c.Key,
                          Function(g)
                              Return g.First
                          End Function)

        ' network <- list(rxnID, reactants, products);
        Dim network = Rbase.list()

        SyncLock R_server.R
            With R_server.R

                With New VisualBasic

                    network = Rbase.lapply(
                        x:=reactions,
                        FUN:=Function(reaction)
                                 Dim model = reaction.ReactionModel

                                 Return Rbase.list(
                                    !rxnID = reaction.ID,
                                    !define = reaction.Definition,
                                    !reactants = Rbase.c(model.Reactants.Keys, stringVector:=True),
                                    !products = Rbase.c(model.Products.Keys, stringVector:=True)
                                 )
                             End Function)

                End With

            End With
        End SyncLock
    End Sub
End Module

{'fraction_non_alphanumeric': 0.0888, 'fraction_numerical': 0.0, 'mean_word_length': 1.5339412360688955, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '506665', 'n_tokens_mistral': 694, 'n_tokens_neox': 650, 'n_words': 139}