Ejemplo n.º 1
0
 def parameterise_model(self, param_file):
   """Given a parameter file modify the model (possibly in file)
      to obtain a new model with the parameters as specified in the
      param_file
   """
   dom = xml.dom.minidom.parse(self.model_file)
   model = dom.getElementsByTagName("model")[0]
   parameter_dict = parameters.parse_param_file(param_file)
   sbml_parametiser.parameterise_model(model, parameter_dict)
Ejemplo n.º 2
0
def run():
  """The main entry point, parameterise SBML model files given
     on the command line
  """
  description = "Parameterise an SBML model based on a given param file"
  parser = argparse.ArgumentParser(description=description)
  # Might want to make the type of this 'FileType('r')'
  parser.add_argument('filenames', metavar='F', nargs='+',
                      help="input files: parameters and sbml model files")

  arguments = parser.parse_args()

  sbml_extentions = [ ".xml", ".sbml" ]
  param_files = [ x for x in arguments.filenames
                        if not utils.has_extension(x, sbml_extentions) ]

  sbml_files = [ x for x in arguments.filenames
                   if utils.has_extension(x, sbml_extentions) ]

  dictionary = dict()
  for param_file in param_files:
    parameters.parse_param_file(param_file, dictionary=dictionary)
  for sbml_file in sbml_files:
    parameterise_model_file(sbml_file, dictionary)
def run():
  """perform the banalities of command-line argument processing and
     then get on with the proper work
  """ 
  description = "Compare results of two separate optimisations"
  parser = argparse.ArgumentParser(description=description)
  # Might want to make the type of this 'FileType('r')'
  parser.add_argument('filenames', metavar='F', nargs='+',
                      help="the input files, should be exactly two")
  arguments = parser.parse_args()

  if len(arguments.filenames) != 2:
    print ("Must provide at least two best params files")
    sys.exit(1)

  best_params_lists = [ parameters.parse_param_file(f) 
                          for f in arguments.filenames ]

  # We can do better than simply comparing every other file to the
  # first parameter file but for now I'm going to do that.
  first_best_params = best_params_lists[0]
  for other_best_params in best_params_lists[1:]:
    compare_parameters(first_best_params, other_best_params)
def run():
  """Perform the banalities of command-line argument processing and
     and then get under way in parameterising the model"""
  description = "Parameterise an SBML model based on a given param file"
  parser = argparse.ArgumentParser(description=description)
  # Might want to make the type of this 'FileType('r')'
  parser.add_argument('filenames', metavar='F', nargs='+',
                      help="Bio-PEPA and parameter files")

  arguments = parser.parse_args()

  biopepa_extentions = [ ".biopepa" ]
  param_files = [ x for x in arguments.filenames
                        if not utils.has_extension(x, biopepa_extentions) ]

  biopepa_files = [ x for x in arguments.filenames
                      if utils.has_extension(x, biopepa_extentions) ]

  dictionary = dict()
  for param_file in param_files:
    dictionary = parameters.parse_param_file(param_file, dictionary)

  for biopepa_file in biopepa_files:
    parameterise_model_file(dictionary, biopepa_file, "stdout")