コード例 #1
0
 def buildNetwork(self):
     net = GRNetwork(self.nodes)
     c = np.random.random(len(self.nodes))
     self.buildPaStore()
     for index in range(len(self.nodes)):
         ntempDist = self.buildPaDistribution(index)
         pachoice = mysample(ntempDist, c[index], self.paStore[index])
         net.initializeParent(self.nodes[index], pachoice)
     return net
コード例 #2
0
def buildNetwork2(gdict, paDict, logWeightMap):
    net = GRNetwork(list(gdict.values()))
    for k, v in gdict.items():
        allPaSets = paDict[k]
        dist1 = []
        for paSet in allPaSets:
            hkey = buildHKey(v, paSet)
            dist1.append(logWeightMap[hkey])
        dist2 = np.array(dist1)
        distribution = dist2 / np.sum(dist2)
        initPa = mysample(distribution, np.random.random(), allPaSets)
        net.initializeParent(v, initPa)
    return net
コード例 #3
0
def buildNetwork(gdict, paDict, weightMap):
    net = GRNetwork(list(gdict.values()))
    for k, v in gdict.items():
        allPaSets = paDict[k]
        distribution = []
        for paSet in allPaSets:
            speciesId = v.getSpeciesId()
            gid = v.getGeneId()
            pasId = ':'.join([pa.getGeneId() for pa in paSet])
            distribution.append(weightMap[buildKey(speciesId, gid, pasId)])
        initPa = mysample(distribution, np.random.random(), allPaSets)
        net.initializeParent(v, initPa)
    return net
コード例 #4
0
def parseNetwork(gdict, netfile):
    net = GRNetwork(list(gdict.values()))
    for line in netfile:
        temp = line.strip()
        if temp == '<end>':
            break
        elif temp == '<begin>' or temp == '':
            continue
        else:
            parts = temp.strip().split(',')
            currGene = gdict[parts[0].strip()]
            paSet = [gdict[gid.strip()] for gid in parts[1:]]
            net.updateParent(currGene, paSet)
    return net