@@ -1043,7 +1043,7 @@ def addSpeciesToEdge(self, spec):
10431043 """
10441044 self .edge .species .append (spec )
10451045
1046- def prune (self , reactionSystems , fluxToleranceKeepInEdge , maximumEdgeSpecies ):
1046+ def prune (self , reactionSystems , toleranceKeepInEdge , maximumEdgeSpecies ):
10471047 """
10481048 Remove species from the model edge based on the simulation results from
10491049 the list of `reactionSystems`.
@@ -1062,55 +1062,57 @@ def prune(self, reactionSystems, fluxToleranceKeepInEdge, maximumEdgeSpecies):
10621062
10631063 # Get the maximum species rates (and network leak rates)
10641064 # across all reaction systems
1065- maxEdgeSpeciesRates = numpy .zeros ((numEdgeSpecies ), numpy .float64 )
1065+ maxEdgeSpeciesRateRatios = numpy .zeros ((numEdgeSpecies ), numpy .float64 )
10661066 for reactionSystem in reactionSystems :
10671067 for i in range (numEdgeSpecies ):
1068- rate = reactionSystem .maxEdgeSpeciesRates [i ]
1069- if maxEdgeSpeciesRates [i ] < rate :
1070- maxEdgeSpeciesRates [i ] = rate
1068+ rateRatio = reactionSystem .maxEdgeSpeciesRateRatios [i ]
1069+ if maxEdgeSpeciesRateRatios [i ] < rateRatio :
1070+ maxEdgeSpeciesRateRatios [i ] = rateRatio
10711071
10721072 for i in range (len (self .networkList )):
10731073 network = self .networkList [i ]
1074- rate = reactionSystem .maxNetworkLeakRates [i ]
1074+ rateRatio = reactionSystem .maxNetworkLeakRateRatios [i ]
10751075 # Add the fraction of the network leak rate contributed by
10761076 # each unexplored species to that species' rate
10771077 # This is to ensure we have an overestimate of that species flux
10781078 ratios = network .getLeakBranchingRatios (reactionSystem .T .value_si ,reactionSystem .P .value_si )
10791079 for spec , frac in ratios .iteritems ():
10801080 index = self .edge .species .index (spec )
1081- maxEdgeSpeciesRates [index ] += frac * rate
1081+ maxEdgeSpeciesRateRatios [index ] += frac * rateRatio
10821082 # Mark any species that is explored in any partial network as ineligible for pruning
10831083 for spec in network .explored :
10841084 if spec not in ineligibleSpecies :
10851085 ineligibleSpecies .append (spec )
10861086
10871087 # Sort the edge species rates by index
1088- indices = numpy .argsort (maxEdgeSpeciesRates )
1089-
1088+ indices = numpy .argsort (maxEdgeSpeciesRateRatios )
10901089 # Determine which species to prune
10911090 speciesToPrune = []
10921091 pruneDueToRateCounter = 0
10931092 for index in indices :
10941093 # Remove the species with rates below the pruning tolerance from the model edge
1095- if maxEdgeSpeciesRates [index ] < fluxToleranceKeepInEdge and self .edge .species [index ] not in ineligibleSpecies :
1094+ if maxEdgeSpeciesRateRatios [index ] < toleranceKeepInEdge and self .edge .species [index ] not in ineligibleSpecies :
10961095 speciesToPrune .append ((index , self .edge .species [index ]))
10971096 pruneDueToRateCounter += 1
10981097 # Keep removing species with the lowest rates until we are below the maximum edge species size
10991098 elif numEdgeSpecies - len (speciesToPrune ) > maximumEdgeSpecies and self .edge .species [index ] not in ineligibleSpecies :
1099+ logging .info ('Pruning species {0} to make numEdgeSpecies smaller than maximumEdgeSpecies' .format (self .edge .species [index ]))
11001100 speciesToPrune .append ((index , self .edge .species [index ]))
11011101 else :
1102- break
1102+ continue
11031103
11041104 # Actually do the pruning
11051105 if pruneDueToRateCounter > 0 :
1106- logging .info ('Pruning {0:d} species whose rates did not exceed the minimum threshold of {1:g}' .format (pruneDueToRateCounter , fluxToleranceKeepInEdge ))
1106+ logging .info ('Pruning {0:d} species whose rate ratios against characteristic rate did not exceed the minimum threshold of {1:g}' .format (pruneDueToRateCounter , toleranceKeepInEdge ))
11071107 for index , spec in speciesToPrune [0 :pruneDueToRateCounter ]:
1108- logging .debug (' {0:<56} {1:10.4e}' .format (spec , maxEdgeSpeciesRates [index ]))
1108+ logging .info ('Pruning species {0:<56}' .format (spec ))
1109+ logging .debug (' {0:<56} {1:10.4e}' .format (spec , maxEdgeSpeciesRateRatios [index ]))
11091110 self .removeSpeciesFromEdge (spec )
11101111 if len (speciesToPrune ) - pruneDueToRateCounter > 0 :
11111112 logging .info ('Pruning {0:d} species to obtain an edge size of {1:d} species' .format (len (speciesToPrune ) - pruneDueToRateCounter , maximumEdgeSpecies ))
11121113 for index , spec in speciesToPrune [pruneDueToRateCounter :]:
1113- logging .debug (' {0:<56} {1:10.4e}' .format (spec , maxEdgeSpeciesRates [index ]))
1114+ logging .info ('Pruning species {0:<56}' .format (spec ))
1115+ logging .debug (' {0:<56} {1:10.4e}' .format (spec , maxEdgeSpeciesRateRatios [index ]))
11141116 self .removeSpeciesFromEdge (spec )
11151117
11161118 # Delete any networks that became empty as a result of pruning
0 commit comments