예제 #1
0
 def __init__(self, numberOfBins, multiplicity, recordedSpecies=[]):
     """Construct an empty data structure."""
     SimulationOutput.__init__(self, recordedSpecies, [])
     self.numberOfBins = numberOfBins
     self.multiplicity = multiplicity
     self.numberOfTrajectories = 0
     self.setRecordedSpecies(recordedSpecies)
예제 #2
0
 def __init__(self, recordedSpecies=[]):
     """Construct an empty data structure."""
     # No recorded reactions.
     SimulationOutput.__init__(self, recordedSpecies, [])
     # The list of (mean, standard deviation) tuples.
     # self.statistics[species] gives the tuple for the specified species
     # index.
     self.statistics = None
예제 #3
0
 def __init__(self, recordedSpecies=[]):
     """Construct an empty data structure."""
     # No recorded reactions.
     SimulationOutput.__init__(self, recordedSpecies, [])
     # The list of frame times.
     self.frameTimes = None
     # The 2-D list of (mean, standard deviation) tuples.
     # self.statistics[frame][species] gives the tuple for the specified
     # frame and species indices.
     self.statistics = None
예제 #4
0
 def __init__(self,
              frameTimes=[],
              recordedSpecies=[],
              recordedReactions=[]):
     SimulationOutput.__init__(self, recordedSpecies, recordedReactions)
     # The frame times.
     self.setFrameTimes(frameTimes)
     # The list of population arrays.
     self.populations = []
     # The list of reaction count arrays.
     self.reactionCounts = []
예제 #5
0
 def __init__(self, recordedSpecies, recordedReactions, initialTime,
              finalTime):
     """The recorded species and reactions should be all of the species
     and reactions."""
     SimulationOutput.__init__(self, recordedSpecies, recordedReactions)
     # The initial time.
     self.initialTime = initialTime
     # The final time.
     self.finalTime = finalTime
     # The initial species populations.
     self.initialPopulations = []
     # The list of reaction index arrays.
     self.indices = []
     # The list of reaction time arrays.
     self.times = []
예제 #6
0
 def hasErrors(self):
     """Return None if the trajectory is valid. Otherwise return an error
     message."""
     error = SimulationOutput.hasErrors(self)
     if error:
         return error
     if self.frameTimes is None or len(self.frameTimes) <= 0:
         return 'There are no frame times.'
     if not isSorted(self.frameTimes):
         return 'The frame times are not in order.'
     if len(self.populations) != len(self.reactionCounts):
         return 'The number of population and reaction count trajectories are not the same.'
     for x in self.populations:
         # Populations must be non-negative.
         flat = numpy.reshape(x, (-1, ))
         if min(flat) < 0:
             return 'There are negative populations.'
     for x in self.reactionCounts:
         # Reaction counts must be non-negative.
         flat = numpy.reshape(x, (-1, ))
         if min(flat) < 0:
             return 'There are negative reaction counts.'
         # Reaction counts must be non-decreasing.
         for i in range(x.shape[1]):
             if not isSorted(x[:, i]):
                 return 'There are decreasing reaction counts.'
     return None
예제 #7
0
 def hasErrors(self):
     """Return None if the trajectory is valid. Otherwise return an error
     message."""
     error = SimulationOutput.hasErrors(self)
     if error:
         return error
     numberOfReactions = len(self.recordedReactions)
     if numberOfReactions == 0:
         return 'There are no reactions.'
     if not (self.initialTime < self.finalTime):
         return 'Invalid time interval: [' + str(self.initialTime) +\
             ' .. ' + str(self.finalTime) + '].'
     if len(self.initialPopulations) != len(self.indices):
         return 'The number of initial populations and reation indices does not match.'
     if len(self.initialPopulations) != len(self.times):
         return 'The number of initial populations and reation times does not match.'
     for i in range(len(self.initialPopulations)):
         initialPopulations = self.initialPopulations[i]
         indices = self.indices[i]
         times = self.times[i]
         if min(initialPopulations) < 0:
             return 'The initial populations must be non-negative.'
         if len(indices) != len(times):
             return 'The number of reaction indices does not match the number of reaction times.'
         if min(indices) < 0 or max(indices) >= numberOfReactions:
             return 'Invalid reaction index.'
         if min(times) < self.initialTime or max(times) > self.finalTime:
             return 'Reaction time is outside the simulation time interval.'
         if not isSorted(times):
             return 'The reaction times are not ordered.'
     return None
예제 #8
0
 def hasErrors(self):
     """Return None if data structure is valid. Otherwise return an error
     message."""
     error = SimulationOutput.hasErrors(self)
     if error:
         return error
     if len(self.histograms) != len(self.recordedSpecies):
         return 'The list of histograms is incomplete.'
     # CONTINUE: Check the histograms.
     return None
예제 #9
0
 def hasErrors(self):
     """Return None if data structure is valid. Otherwise return an error
     message."""
     error = SimulationOutput.hasErrors(self)
     if error:
         return error
     if self.statistics is None or \
            len(self.statistics) != len(self.recordedSpecies):
         return 'The list of statistics is incomplete.'
     return None
예제 #10
0
 def hasErrors(self):
     """Return None if data structure is valid. Otherwise return an error
     message."""
     error = SimulationOutput.hasErrors(self)
     if error:
         return error
     if self.frameTimes is None or len(self.frameTimes) <= 0:
         return 'There are no frame times.'
     if not isSorted(self.frameTimes):
         return 'The frame times are not in order.'
     if not len(self.statistics) == len(self.frameTimes):
         return 'The list of frames is incomplete.'
     for x in self.statistics:
         if not len(x) == len(self.recordedSpecies):
             return 'The list of statistics is incomplete.'
     return None
예제 #11
0
 def test(self):
     x = SimulationOutput([0, 1], [0, 1])
     assert not x.hasErrors()