Ejemplo n.º 1
0
def savePathsWithSecVec(currSecVec):
    currSecMets = list(np.nonzero(currSecVec)[0])
    augNutrientSet = currSecMets[:]

    if not currSecVec.any():
        return
    elif not os.path.exists(saveDir + str(bool2int(currSecVec)) +
                            '_prebSeed_randRxnSets_core' + str(Core[-1]) +
                            '_' + str(NUM_PATHS - 1) + '.txt'):
        for coreTBP in Core:
            print('Finding paths to ' + cpd_string_dict[id_to_kegg[coreTBP]] +
                  '.')
            coreProdRxns = (prodMat[:, coreTBP] == 1) * 1
            satMetVec, satRxnVec = giveRevScope(rxnMat, prodMat, sumRxnVec,
                                                augNutrientSet, Currency,
                                                coreTBP)
            satMets, satRxns = np.nonzero(satMetVec)[0], np.nonzero(
                satRxnVec)[0]

            # Randomizing pathways to coreTBP.
            rMinSubnetsRxns = []
            for netNum in range(NUM_PATHS):
                rMinSubnetsRxns.append(
                    randMinSubnet(satRxnVec, rxnMat, prodMat, sumRxnVec,
                                  coreProdRxns, coreTBP, augNutrientSet,
                                  Currency))

                # Saving the made pathway.
                np.savetxt(
                    saveDir + str(bool2int(currSecVec)) +
                    '_prebSeed_randRxnSets_core' + str(coreTBP) + '_' +
                    str(netNum) + '.txt', rMinSubnetsRxns[-1])
Ejemplo n.º 2
0
    currSecVec = secByproducts(currPath.astype(int), rxnMat, prodMat, Core) * 1
    currSecMets = list(np.nonzero(currSecVec)[0])

    augNutrientSet = currSecMets

    if not currSecVec.any():
        continue
    elif not os.path.exists(saveDir + str(bool2int(currSecVec)) +
                            '_prebSeed_randRxnSets_core' + str(Core[-1]) +
                            '_' + str(NUM_PATHS - 1) + '.txt'):
        for coreTBP in Core:
            print('Finding paths to ' + cpd_string_dict[id_to_kegg[coreTBP]] +
                  '.')
            coreProdRxns = (prodMat[:, coreTBP] == 1) * 1
            satMetVec, satRxnVec = giveRevScope(rxnMat, prodMat, sumRxnVec,
                                                augNutrientSet, Currency,
                                                coreTBP)
            satMets, satRxns = np.nonzero(satMetVec)[0], np.nonzero(
                satRxnVec)[0]

            # Randomizing pathways to coreTBP.
            rMinSubnetsRxns = []
            for netNum in range(NUM_PATHS):
                rMinSubnetsRxns.append(
                    randMinSubnet(satRxnVec, rxnMat, prodMat, sumRxnVec,
                                  coreProdRxns, coreTBP, augNutrientSet,
                                  Currency))

                # Saving the made pathway.
                np.savetxt(
                    saveDir + str(bool2int(currSecVec)) +