def simulateModel(self, request):

        self.form.read(request)
        if not self.form.hasErrors():
            if self.hasCPUTimeQuota(request):
                self.experiment = None
                if self.form.experimentId is not None:
                    t_experiment = Experiment.objects.get(
                        id=self.experiments[self.form.experimentId].id)
                    self.experiment = buildExperiment(t_experiment)

                try:
                    t_simulation = TimeseriesSimulation(
                        list_of_models=[self.getModelInstance()],
                        experiment=self.experiment,
                        time_min=self.form.timeMin,
                        time_max=self.form.timeMax,
                        time_ech=self.form.timeEch)

                    t_simulation.run(timeout=self.getCPUTimeQuota(request))

                    results = t_simulation.getRawData()
                    self.addCPUTime(request,
                                    t_simulation.getSimulationDuration())
                    self.read_timeseries(results)

                except LibSigNetSimException as e:
                    self.form.addError(e.message)
            else:
                self.form.addError(
                    "You exceeded your allowed computation time. Please contact the administrator"
                )
Exemplo n.º 2
0
	def simulateModel(self, request):

		self.form.read(request)
		if not self.form.hasErrors():

			if self.hasCPUTimeQuota(request):
				self.experiment = None
				if self.form.experimentId is not None:
					t_experiment = Experiment.objects.get(id=self.experiments[self.form.experimentId].id)
					self.experiment = buildExperiment(t_experiment)

				try:
					t_simulation = TimeseriesSimulation(
						list_of_models=[self.getModelInstance()],
						experiment=self.experiment,
						time_min=self.form.timeMin,
						time_max=self.form.timeMax,
						time_ech=self.form.timeEch)

					t_simulation.run(timeout=self.getCPUTimeQuota(request))

					results = t_simulation.getRawData()
					self.addCPUTime(request, t_simulation.getSimulationDuration())
					self.read_timeseries(results)

				except LibSigNetSimException as e:
					self.form.addError(e.message)
			else:
				self.form.addError("You exceeded your allowed computation time. Please contact the administrator")
Exemplo n.º 3
0
	def post(self, request, *args, **kwargs):
		self.load(request, *args, **kwargs)

		dataset_ind = int(request.POST['dataset_ind'])

		experiment_data = Experiment.objects.filter(project=self.project)[dataset_ind]
		experiment = buildExperiment(experiment_data)
		experiment_variables = experiment.getVariables()

		model_variables = {}
		model_xpaths = {}
		for variable in experiment_variables:
			if self.getModelInstance().listOfVariables.containsSbmlId(variable):
				var = self.getModelInstance().listOfVariables.getBySbmlId(variable)
				model_variables.update({variable: var.getNameOrSbmlId()})
				model_xpaths.update({variable: var.getXPath()})

			elif self.getModelInstance().listOfVariables.containsName(variable):
				var = self.getModelInstance().listOfVariables.getByName(variable)
				model_variables.update({variable: var.getNameOrSbmlId()})
				model_xpaths.update({variable: var.getXPath()})

			else:
				model_variables.update({variable: None})
				model_xpaths.update({variable: None})

		self.data.update({
			'dataset_ind': dataset_ind,
			'dataset_id': experiment_data.id,
			'dataset_name': experiment_data.name,
			'model_variables': model_variables,
			'model_xpaths': model_xpaths
		})

		return JsonRequest.post(self, request, *args, **kwargs)
	def readSelectedDataset(self, request):

		self.selectedDataSetsIds = []
		self.selectedExperiments = []

		i_dataset_selected = 0

		while ("dataset_%d" % i_dataset_selected) in request.POST:
			t_id = int(request.POST["dataset_%d" % i_dataset_selected])
			self.selectedDataSetsIds.append(t_id)
			self.selectedExperiments.append(buildExperiment(Experiment.objects.get(id=t_id)))
			i_dataset_selected += 1
Exemplo n.º 5
0
def exportProject(project):

	combine_archive = CombineArchive()
	for sbml_model in SbmlModel.objects.filter(project=project):
		combine_archive.addFile(join(settings.MEDIA_ROOT, str(sbml_model.sbml_file)))

	for sedml_model in SEDMLSimulation.objects.filter(project=project):
		combine_archive.addFile(join(settings.MEDIA_ROOT, str(sedml_model.sedml_file)))

	for i, experiment in enumerate(Experiment.objects.filter(project=project)):
		t_experiment = buildExperiment(experiment)
		t_experiment.writeNuMLToFile(join(Settings.tempDirectory, "experiment_%d.xml" % i))
		combine_archive.addFile(join(Settings.tempDirectory, "experiment_%d.xml" % i))

	filename = ''.join(e for e in project.name if e.isalnum()) + ".omex"
	filename = join(Settings.tempDirectory, filename)
	combine_archive.writeArchive(filename)
	return filename
Exemplo n.º 6
0
    def post(self, request, *args, **kwargs):
        self.load(request, *args, **kwargs)

        dataset_ind = int(request.POST['dataset_ind'])

        experiment_data = Experiment.objects.filter(
            project=self.project)[dataset_ind]
        experiment = buildExperiment(experiment_data)
        experiment_variables = experiment.getVariables()

        model_variables = {}
        model_xpaths = {}
        for variable in experiment_variables:
            if self.getModelInstance().listOfVariables.containsSbmlId(
                    variable):
                var = self.getModelInstance().listOfVariables.getBySbmlId(
                    variable)
                model_variables.update({variable: var.getNameOrSbmlId()})
                model_xpaths.update({variable: var.getXPath()})

            elif self.getModelInstance().listOfVariables.containsName(
                    variable):
                var = self.getModelInstance().listOfVariables.getByName(
                    variable)
                model_variables.update({variable: var.getNameOrSbmlId()})
                model_xpaths.update({variable: var.getXPath()})

            else:
                model_variables.update({variable: None})
                model_xpaths.update({variable: None})

        self.data.update({
            'dataset_ind': dataset_ind,
            'dataset_id': experiment_data.id,
            'dataset_name': experiment_data.name,
            'model_variables': model_variables,
            'model_xpaths': model_xpaths
        })

        return JsonRequest.post(self, request, *args, **kwargs)