public ICommand AddSimulationIntervalTo(OutputSchema simulationOutput) { var simulationInterval = _outputIntervalFactory.CreateDefault(); simulationInterval.Name = _containerTask.CreateUniqueName(simulationOutput, simulationInterval.Name); return(new AddSimulationIntervalToSimulationOutputCommand(simulationInterval, simulationOutput, _executionContext).Run(_executionContext)); }
protected override void Context() { _containerTask = A.Fake <IContainerTask>(); _objectBaseFactory = A.Fake <IObjectBaseFactory>(); _projectRetriever = A.Fake <IMoBiProjectRetriever>(); _eventPublisher = A.Fake <IEventPublisher>(); _cloneManagerForModel = A.Fake <ICloneManagerForModel>(); _formulaTask = A.Fake <IFormulaTask>(); sut = new PassiveTransportConverter(_objectBaseFactory, _projectRetriever, _containerTask, _eventPublisher, _cloneManagerForModel, _formulaTask); A.CallTo(() => _containerTask.CreateUniqueName(A <IEnumerable <IWithName> > ._, A <string> ._, true)) .ReturnsLazily(x => x.Arguments[1].ToString()); _passiveTransportKinetic = new ExplicitFormula("1+2"); _moleculeWithPassiveTransport = new MoleculeBuilder().WithName("MOLECULE"); _passiveTransport = new TransportBuilder().WithName("PASSIVE TRANSPORT").WithFormula(_passiveTransportKinetic); _moleculeWithPassiveTransport.Add(_passiveTransport); _passiveTransports = new PassiveTransportBuildingBlock(); _molecules = new MoleculeBuildingBlock { _moleculeWithPassiveTransport }.WithName("MBB"); _project = new MoBiProject(); A.CallTo(() => _projectRetriever.Current).Returns(_project); A.CallTo(() => _eventPublisher.PublishEvent(A <ShowNotificationsEvent> ._)) .Invokes(x => _showNotificationEvent = x.GetArgument <ShowNotificationsEvent>(0)); }
public ICommand AddOuputIntervalTo(ISimulationSettings simulationSettings, IMoBiSimulation simulation) { var schema = simulationSettings.OutputSchema; var interval = _outputIntervalFactory.CreateDefault(); interval.Name = _containerTask.CreateUniqueName(schema, interval.Name); return(getAddCommand(schema, interval, simulationSettings, simulation).Run(_context)); }
public SchemaItem Create(ApplicationType applicationType, IContainer container = null) { var applicationSchemaItem = _objectBaseFactory.Create <SchemaItem>().WithName(PKSimConstants.UI.SchemaItem); if (container != null) { applicationSchemaItem.Name = _containerTask.CreateUniqueName(container, PKSimConstants.UI.SchemaItem); } applicationSchemaItem.ApplicationType = applicationType; applicationSchemaItem.FormulationKey = string.Empty; foreach (var parameter in _schemaItemParameterRetriever.AllParametersFor(applicationSchemaItem.ApplicationType)) { applicationSchemaItem.Add(parameter); } return(applicationSchemaItem); }
public SensitivityAnalysis Create() { var sensitivityAnalysis = _objectBaseFactory.Create <SensitivityAnalysis>(); var project = _executionContext.Project; sensitivityAnalysis.Name = _containerTask.CreateUniqueName(project.AllSensitivityAnalyses, Captions.SensitivityAnalysis.SensitivityAnalysisDefaultName); sensitivityAnalysis.Icon = IconNames.SENSITIVITY_ANALYSIS; sensitivityAnalysis.IsLoaded = true; return(sensitivityAnalysis); }
public void AddObservedDataToProject(DataRepository observedData) { if (observedDataAlreadyExistsInProject(observedData)) { return; } observedData.Name = _containerTask.CreateUniqueName(_executionContext.Project.AllObservedData, observedData.Name, canUseBaseName: true); _executionContext.AddToHistory(new AddObservedDataToProjectCommand(observedData).Run(_executionContext)); }
public ParameterIdentification Create() { var parameterIdentification = _objectBaseFactory.Create <ParameterIdentification>(); var project = _executionContext.Project; parameterIdentification.Name = _containerTask.CreateUniqueName(project.AllParameterIdentifications, Captions.ParameterIdentification.ParameterIdentificationDefaultName); parameterIdentification.Icon = ApplicationIcons.ParameterIdentification.IconName; parameterIdentification.IsLoaded = true; return(parameterIdentification); }
public override async Task <ModelOutputSchema> MapToModel(SnapshotOutputSchema snapshot) { var outputSchema = _outputSchemaFactory.CreateEmpty(); var intervals = await _outputIntervalMapper.MapToModels(snapshot); intervals?.Each(interval => { interval.Name = _containerTask.CreateUniqueName(outputSchema, interval.Name); outputSchema.AddInterval(interval); }); return(outputSchema); }
public void AddSimulationAnalysisTo(IAnalysable analysable, ISimulationAnalysis simulationAnalysis) { if (simulationAnalysis == null) { return; } var defaultAnalysisName = string.IsNullOrEmpty(simulationAnalysis.Name) ? DefaultAnalysisNameFor(simulationAnalysis) : simulationAnalysis.Name; simulationAnalysis.Name = _containerTask.CreateUniqueName(analysable.Analyses, defaultAnalysisName, canUseBaseName: true); analysable.AddAnalysis(simulationAnalysis); _executionContext.PublishEvent(new SimulationAnalysisCreatedEvent(analysable, simulationAnalysis)); }
public Schema Create(IContainer container) { var schema = _objectBaseFactory.Create <Schema>().WithName(PKSimConstants.UI.Schema); if (container != null) { schema.Name = _containerTask.CreateUniqueName(container, PKSimConstants.UI.Schema); } schema.Add(_parameterFactory.CreateFor(Constants.Parameters.START_TIME, 0, Constants.Dimension.TIME, PKSimBuildingBlockType.Protocol)); schema.Add(_parameterFactory.CreateFor(CoreConstants.Parameters.NUMBER_OF_REPETITIONS, 1, PKSimBuildingBlockType.Protocol)); schema.Add(_parameterFactory.CreateFor(CoreConstants.Parameters.TIME_BETWEEN_REPETITIONS, 0, Constants.Dimension.TIME, PKSimBuildingBlockType.Protocol)); return(schema); }
public Schema Create(IContainer container) { var schema = _objectBaseFactory.Create <Schema>(); var usedNames = new List <string>(); if (container != null) { usedNames.AddRange(container.GetChildren <Schema>().Select(x => x.Name)); } schema.Name = _containerTask.CreateUniqueName(usedNames, PKSimConstants.UI.Schema); schema.Add(_parameterFactory.CreateFor(Constants.Parameters.START_TIME, 0, Constants.Dimension.TIME, PKSimBuildingBlockType.Protocol)); schema.Add(_parameterFactory.CreateFor(CoreConstants.Parameter.NUMBER_OF_REPETITIONS, 1, PKSimBuildingBlockType.Protocol)); schema.Add(_parameterFactory.CreateFor(CoreConstants.Parameter.TIME_BETWEEN_REPETITIONS, 0, Constants.Dimension.TIME, PKSimBuildingBlockType.Protocol)); return(schema); }
private void renameContainerBuildingBlockInSimulation(Simulation simulation, IPKSimBuildingBlock templateBuildingBlock) { _lazyLoadTask.Load(simulation); var usedBuildingBlock = simulation.UsedBuildingBlockByTemplateId(templateBuildingBlock.Id); foreach (var containerToRename in getContainersToRename(simulation, templateBuildingBlock, usedBuildingBlock.BuildingBlock.Name)) { containerToRename.Name = _containerTask.CreateUniqueName(containerToRename.ParentContainer, templateBuildingBlock.Name, canUseBaseName: true); //now some parameters in the simulation might reference parameters defined in the container that was renamed. We need to update //the formula paths of these parameters renameFormulaPathReferencingContainerInSimulation(simulation, containerToRename, usedBuildingBlock.BuildingBlock.Name); //make sure we mark the simulation has changed so that it will be saved simulation.HasChanged = true; } }
private void addExpressionProfilesUsedBySimulationSubjectToProject(ISimulationSubject simulationSubject) { var project = _projectRetriever.Current; foreach (var molecule in simulationSubject.AllMolecules()) { var defaultExpressionProfileName = CoreConstants.ContainerName.ExpressionProfileName(molecule.Name, simulationSubject.Species, simulationSubject.Name); var expressionProfileName = _containerTask.CreateUniqueName(project.All <ExpressionProfile>(), defaultExpressionProfileName, canUseBaseName: true); var expressionProfile = _expressionProfileFactory.Create(molecule.GetType(), simulationSubject.Species, molecule.Name); //Use a unique name in project expressionProfile.Name = expressionProfileName; _expressionProfileUpdater.SynchronizeExpressionProfileWithSimulationSubject(expressionProfile, simulationSubject); //Some parameters are probably marked as FixedValue event thought they have not changed (Formula=>constant) due to change in //definition of Fraction expressed basolateral going from a constant to a formula. We reset is fixed value and default state expressionProfile.Individual.AllMoleculeParametersFor(expressionProfile.Molecule) .Where(x => !x.Visible) .Where(x => x.IsFixedValue) .Each(x => x.IsFixedValue = false); expressionProfile.Individual.AllMoleculeParametersFor(expressionProfile.Molecule) .Where(x => !x.Editable) .Where(x => !x.IsDefault) .Each(x => x.IsDefault = true); //only add at the end once the expression profile has been updated simulationSubject.AddExpressionProfile(expressionProfile); project.AddBuildingBlock(expressionProfile); _registrationTask.Register(expressionProfile); _eventPublisher.PublishEvent(new BuildingBlockAddedEvent(expressionProfile, _projectRetriever.Current)); } _converted = true; }
public OutputInterval CreateFor(OutputSchema outputSchema, double startTimeInMinute, double endTimeInMinute, double resolutionInPtsPerMin) { return(Create(startTimeInMinute, endTimeInMinute, resolutionInPtsPerMin) .WithName(_containerTask.CreateUniqueName(outputSchema, Constants.OUTPUT_INTERVAL, canUseBaseName: true))); }
private string createUniqueComparisonName() { return(_containerTask.CreateUniqueName(_executionContext.CurrentProject.AllSimulationComparisons, PKSimConstants.UI.SimulationComparison)); }
private string createIndividualName(Population population, int individualId, IndividualExtractionOptions options) { var proposedName = options.GenerateIndividualName(population.Name, individualId); return(_containerTask.CreateUniqueName(_buildingBlockRepository.All <Individual>(), proposedName, canUseBaseName: true)); }
private string uniqueNameFor(ParameterIdentification parameterIdentification, IReadOnlyList <IParameter> parameters) { var name = parameters.AllDistinctValues(x => x.Name).First(); return(_containerTask.CreateUniqueName(parameterIdentification.AllIdentificationParameters, name, canUseBaseName: true)); }
private string getNextSuggestedName(IEnumerable <string> usedNames, string oldName) { return(_containerTask.CreateUniqueName(usedNames.ToList(), oldName)); }
private string uniqueNameFor(SensitivityAnalysis sensitivityAnalysis, IParameter parameter) { var defaultName = _fullPathDisplayResolver.FullPathFor(parameter); return(_containerTask.CreateUniqueName(sensitivityAnalysis.AllSensitivityParameters, defaultName, canUseBaseName: true)); }
private IPassiveTransportBuildingBlock createPassiveTransportBuildingBlockForMolecule(string name) { return(_objectBaseFactory.Create <IPassiveTransportBuildingBlock>() .WithName(_containerTask.CreateUniqueName(_projectRetriever.Current.PassiveTransportCollection, name, canUseBaseName: true))); }