src/scBONITA/singleCell.py
def __scoreNodes(self, graph):
        """Wrapper function - performs rule determination and node scoring in preparation for pathway analysis"""

        net = nx.read_graphml(graph)
        # print(self.geneList)
        # print(list(net))
        netGenes = [
            self.geneList.index(gene) for gene in list(net) if gene in self.geneList
        ]
        print(netGenes)
        updateBooler = ctypes.cdll.LoadLibrary("./simulator.so")
        scSyncBoolC = updateBooler.scSyncBool
        importanceScore = updateBooler.importanceScore
        self._singleCell__inherit(
            net,
            removeSelfEdges=False,
            restrictIncomingEdges=True,
            maxIncomingEdges=3,
            groundTruth=False,
        )
        self._ruleMaker__updateCpointers()
        self.__setupEmptyKOKI()

        # Genetic algorithm
        population, logbook = self._ruleMaker__eaMuPlusLambdaAdaptive(
            scSyncBoolC, graph
        )
        out1, out2, model = self._ruleMaker__findPopBest(population)
        with open(graph + "_rules_GA.txt", "w") as text_file:
            text_file.write(model.writeModel(out2, model))
        pickle.dump(out2, open(graph + "_out2.pickle", "wb"))

        # Local search
        outputs = [
            self._ruleMaker__checkNodePossibilities(
                node, out2, model.knockoutLists, model.knockinLists, scSyncBoolC
            )
            for node in range(0, len(model.nodePositions))
        ]
        equivs = []
        individual = []
        devs = []
        localErrors = []
        for output in outputs:
            individual.extend(output[0])
            equivs.append(output[1])
            devs.append(output[2])
            localErrors.append(output[3])
        pickle.dump(equivs, open(graph + "_equivs1.pickle", "wb"))
        pickle.dump(localErrors, open(graph + "_localErrors1.pickle", "wb"))
        bruteout2 = []
        for i in range(len(equivs)):
            bruteout2.extend(equivs[i][randint(0, len(equivs[i]) - 1)])
        with open(graph + "_rules_LS.txt", "w") as text_file:
            text_file.write(model.writeModel(bruteout2, model))
        pickle.dump(bruteout2, open(graph + "_bruteout2.pickle", "wb"))

        # Importance score calculation
        importanceScores = self._ruleMaker__calcImportance(
            "", self, importanceScore, graph
        )
        print(importanceScores)
Wrapper function - performs rule determination and node scoring in preparation for pathway analysis
Wrapper function - performs rule determination and node scoring in preparation for pathway analysis
Wrapper function - performs rule determination and node scoring in preparation for pathway analysis
def __scoreNodes(self, graph):
        net = nx.read_graphml(graph)
        netGenes = [
            self.geneList.index(gene) for gene in list(net) if gene in self.geneList
        ]
        print(netGenes)
        updateBooler = ctypes.cdll.LoadLibrary("./simulator.so")
        scSyncBoolC = updateBooler.scSyncBool
        importanceScore = updateBooler.importanceScore
        self._singleCell__inherit(
            net,
            removeSelfEdges=False,
            restrictIncomingEdges=True,
            maxIncomingEdges=3,
            groundTruth=False,
        )
        self._ruleMaker__updateCpointers()
        self.__setupEmptyKOKI()
        population, logbook = self._ruleMaker__eaMuPlusLambdaAdaptive(
            scSyncBoolC, graph
        )
        out1, out2, model = self._ruleMaker__findPopBest(population)
        with open(graph + "_rules_GA.txt", "w") as text_file:
            text_file.write(model.writeModel(out2, model))
        pickle.dump(out2, open(graph + "_out2.pickle", "wb"))
        outputs = [
            self._ruleMaker__checkNodePossibilities(
                node, out2, model.knockoutLists, model.knockinLists, scSyncBoolC
            )
            for node in range(0, len(model.nodePositions))
        ]
        equivs = []
        individual = []
        devs = []
        localErrors = []
        for output in outputs:
            individual.extend(output[0])
            equivs.append(output[1])
            devs.append(output[2])
            localErrors.append(output[3])
        pickle.dump(equivs, open(graph + "_equivs1.pickle", "wb"))
        pickle.dump(localErrors, open(graph + "_localErrors1.pickle", "wb"))
        bruteout2 = []
        for i in range(len(equivs)):
            bruteout2.extend(equivs[i][randint(0, len(equivs[i]) - 1)])
        with open(graph + "_rules_LS.txt", "w") as text_file:
            text_file.write(model.writeModel(bruteout2, model))
        pickle.dump(bruteout2, open(graph + "_bruteout2.pickle", "wb"))
        importanceScores = self._ruleMaker__calcImportance(
            "", self, importanceScore, graph
        )
        print(importanceScores)
def __scoreNodes ( self , graph ) : net = nx . read_graphml ( graph ) netGenes = [ self . geneList . index ( gene ) for gene in list ( net ) if gene in self . geneList ] print ( netGenes ) updateBooler = ctypes . cdll . LoadLibrary ( "./simulator.so" ) scSyncBoolC = updateBooler . scSyncBool importanceScore = updateBooler . importanceScore self . _singleCell__inherit ( net , removeSelfEdges = False , restrictIncomingEdges = True , maxIncomingEdges = 3 , groundTruth = False , ) self . _ruleMaker__updateCpointers ( ) self . __setupEmptyKOKI ( ) population , logbook = self . _ruleMaker__eaMuPlusLambdaAdaptive ( scSyncBoolC , graph ) out1 , out2 , model = self . _ruleMaker__findPopBest ( population ) with open ( graph + "_rules_GA.txt" , "w" ) as text_file : text_file . write ( model . writeModel ( out2 , model ) ) pickle . dump ( out2 , open ( graph + "_out2.pickle" , "wb" ) ) outputs = [ self . _ruleMaker__checkNodePossibilities ( node , out2 , model . knockoutLists , model . knockinLists , scSyncBoolC ) for node in range ( 0 , len ( model . nodePositions ) ) ] equivs = [ ] individual = [ ] devs = [ ] localErrors = [ ] for output in outputs : individual . extend ( output [ 0 ] ) equivs . append ( output [ 1 ] ) devs . append ( output [ 2 ] ) localErrors . append ( output [ 3 ] ) pickle . dump ( equivs , open ( graph + "_equivs1.pickle" , "wb" ) ) pickle . dump ( localErrors , open ( graph + "_localErrors1.pickle" , "wb" ) ) bruteout2 = [ ] for i in range ( len ( equivs ) ) : bruteout2 . extend ( equivs [ i ] [ randint ( 0 , len ( equivs [ i ] ) - 1 ) ] ) with open ( graph + "_rules_LS.txt" , "w" ) as text_file : text_file . write ( model . writeModel ( bruteout2 , model ) ) pickle . dump ( bruteout2 , open ( graph + "_bruteout2.pickle" , "wb" ) ) importanceScores = self . _ruleMaker__calcImportance ( "" , self , importanceScore , graph ) print ( importanceScores )
Wrapper function - performs rule determination and node scoring in preparation for pathway analysis
Wrapper function - performs rule determination and node scoring in preparation for pathway analysis
"""Wrapper function - performs rule determination and node scoring in preparation for pathway analysis""" # print(self.geneList) # print(list(net)) # Genetic algorithm # Local search # Importance score calculation
self
graph