private DataTable createDataToExport(Simulation simulation) { //Id Time Output1 Output2 ... OutputN var dataTable = new DataTable(); if (!simulation.HasResults) { return(dataTable); } var simulationResults = simulation.Results; var allQuantities = _quantityRetriever.QuantitiesFrom(simulation); dataTable.AddColumn <int>(CoreConstants.SimulationResults.IndividualId); dataTable.AddColumn <string>(CoreConstants.NameWithUnitFor(CoreConstants.SimulationResults.Time, _timeDimension.BaseUnit)); var allQuantityPaths = simulationResults.AllQuantityPaths(); foreach (var quantityPath in allQuantityPaths) { var quantity = allQuantities[quantityPath]; if (quantity == null) { continue; } dataTable.AddColumn <string>(CoreConstants.NameWithUnitFor(quantityPath, quantity.Dimension.BaseUnit)); } dataTable.BeginLoadData(); int numberOfValues = simulationResults.Time.Length; foreach (var individualResults in simulationResults.OrderBy(x => x.IndividualId)) { var allQuantitiesCache = new Cache <string, QuantityValues>(x => x.QuantityPath); allQuantitiesCache.AddRange(individualResults); for (int i = 0; i < numberOfValues; i++) { var row = dataTable.NewRow(); row[CoreConstants.SimulationResults.IndividualId] = individualResults.IndividualId; row[CoreConstants.NameWithUnitFor(CoreConstants.SimulationResults.Time, _timeDimension.BaseUnit)] = simulationResults.Time[i].ConvertedTo <string>(); foreach (var quantityPath in allQuantityPaths) { var quantity = allQuantities[quantityPath]; if (quantity == null) { continue; } row[CoreConstants.NameWithUnitFor(quantityPath, quantity.Dimension.BaseUnit)] = allQuantitiesCache[quantityPath][i].ConvertedTo <string>(); } dataTable.Rows.Add(row); } } dataTable.EndLoadData(); return(dataTable); }
public void should_have_created_the_expected_number_of_rows_in_the_datatable() { _dataTable.Rows.Count.ShouldBeEqualTo(6); _dataTable.AllValuesInColumn <float>(_xAxis.Caption).ShouldOnlyContain(1, 2, 3, 1, 2, 3); var values = _dataTable.AllValuesInColumn <object>(CoreConstants.CompositeNameFor(PKSimConstants.UI.LowerValue, _yAxis.Caption)); values[0].ShouldBeEqualTo(DBNull.Value); values[1].ShouldBeEqualTo(20); values[2].ShouldBeEqualTo(10); values[3].ShouldBeEqualTo(20); values[4].ShouldBeEqualTo(30); values[5].ShouldBeEqualTo(DBNull.Value); values = _dataTable.AllValuesInColumn <object>(_yAxis.Caption); values[0].ShouldBeEqualTo(10); values[1].ShouldBeEqualTo(DBNull.Value); values[2].ShouldBeEqualTo(10); values[3].ShouldBeEqualTo(20); values[4].ShouldBeEqualTo(30); values[5].ShouldBeEqualTo(40); values = _dataTable.AllValuesInColumn <object>(CoreConstants.CompositeNameFor(PKSimConstants.UI.UpperValue, _yAxis.Caption)); values[0].ShouldBeEqualTo(DBNull.Value); values[1].ShouldBeEqualTo(30); values[2].ShouldBeEqualTo(10); values[3].ShouldBeEqualTo(20); values[4].ShouldBeEqualTo(30); values[5].ShouldBeEqualTo(DBNull.Value); }
protected override void Context() { base.Context(); _entity = new Observer().WithName(CoreConstants.CompositeNameFor(CoreConstants.Observer.FRACTION_OF_DOSE, _drugName, CoreConstants.Organ.Liver, CoreConstants.Compartment.Intracellular)) .WithParentContainer(_drugContainerInLiverCell) .WithDimension(_fractionDimension); }
private void updateInteractionFactor(IContainer processParameterContainer, string moleculeName, IEnumerable <IInteractionKineticUpdaterSpecification> allUpdatingKinetics, IFormulaCache formulaCache, string parameterName, Func <IParameter, string> createFormulaAction) { var interactionFactor = processParameterContainer.Parameter(parameterName); if (!allUpdatingKinetics.Any() || interactionFactor == null) { return; } var formulaName = CoreConstants.CompositeNameFor(processParameterContainer.Name, moleculeName, parameterName); var formula = formulaCache.FindByName(formulaName) as ExplicitFormula; if (formula != null) { interactionFactor.Formula = formula; return; } formula = _objectBaseFactory.Create <ExplicitFormula>() .WithName(formulaName) .WithDimension(interactionFactor.Dimension); interactionFactor.Formula = formula; formula.FormulaString = createFormulaAction(interactionFactor); formulaCache.Add(formula); }
private IReactionBuilder createReactionFromProcess(IMoleculeBuilder moleculeBuilder, CompoundProcess process, IReadOnlyCollection <string> forbiddenNames) { var reactionName = CoreConstants.CompositeNameFor(moleculeBuilder.Name, process.Name); return(createReactionFromProcess(process, reactionName, forbiddenNames)); }
private void addLiverZoneCompartmentObserver(IObserverBuilder observerBuilder, string compartment, IObserverBuildingBlock observerBuildingBlock, Compound compound) { var observerName = CoreConstants.CompositeNameFor(observerBuilder.Name, CoreConstants.Organ.Liver, compartment); if (observerBuildingBlock.ExistsByName(observerName)) { return; } var observer = _objectBaseFactory.Create <IContainerObserverBuilder>() .WithName(observerName) .WithDimension(_dimensionRepository.Fraction); observer.ForAll = false; observerBuilder.MoleculeNames().Each(observer.AddMoleculeName); observer.ContainerCriteria = Create.Criteria(x => x.With(CoreConstants.Organ.Liver) .And.With(compartment) .And.Not(CoreConstants.Compartment.Pericentral) .And.Not(CoreConstants.Compartment.Periportal)); var formula = _objectBaseFactory.Create <ExplicitFormula>() .WithName(observerName) .WithFormulaString("(M_periportal + M_pericentral)/" + TOTAL_DRUG_MASS_ALIAS) .WithDimension(_dimensionRepository.Fraction); formula.AddObjectPath(createZoneAmoutPath(compartment, CoreConstants.Compartment.Periportal, "M_periportal")); formula.AddObjectPath(createZoneAmoutPath(compartment, CoreConstants.Compartment.Pericentral, "M_pericentral")); formula.AddObjectPath(createTotalDrugMassObjectPath(compound.Name)); observer.Formula = formula; observerBuildingBlock.Add(observer); observerBuildingBlock.AddFormula(formula); }
private void updateOutputFolderFrom(string outputFolder) { OutputFolder = outputFolder; if (string.IsNullOrEmpty(LogFileFullPath)) { LogFileFullPath = CoreConstants.DefaultBatchLogFullPath(OutputFolder); } }
private IReactionBuilder createReactionFromProcess(CompoundProcess process, string reactionName, IReadOnlyCollection <string> forbiddenNames) { //retrieve process for the simulation and create a clone var reaction = createReactionFromProcess(process, _simulationActiveProcessRepository.ProcessFor <PKSimReaction>(process.InternalName), reactionName, forbiddenNames); //make sure formula name is unique as it can be shared among processes reaction.Formula.Name = CoreConstants.CompositeNameFor(reaction.Name, reaction.Formula.Name); return(reaction); }
public void should_have_created_the_expected_number_of_columns_in_the_datatable() { _dataTable.Columns.Count.ShouldBeEqualTo(6); _dataTable.Columns[_xAxis.Caption].ShouldNotBeNull(); _dataTable.Columns[CoreConstants.CompositeNameFor(PKSimConstants.UI.LowerValue, _yAxis.Caption)].ShouldNotBeNull(); _dataTable.Columns[_yAxis.Caption].ShouldNotBeNull(); _dataTable.Columns[CoreConstants.CompositeNameFor(PKSimConstants.UI.UpperValue, _yAxis.Caption)].ShouldNotBeNull(); }
public void should_have_created_a_reaction_using_the_metabolite_as_product_in_liver_pericentral_intracellular() { var reactionInLiver = _simulation.Model.Root.EntityAt <IReaction>(Constants.ORGANISM, CoreConstants.Organ.LIVER, CoreConstants.Compartment.PERICENTRAL, CoreConstants.Compartment.INTRACELLULAR, CoreConstants.CompositeNameFor(_compound.Name, _parentMetabolizationCYP3A4.Name)); reactionInLiver.ShouldNotBeNull(); reactionInLiver.Products.Find(x => x.Partner.Name == _metabolite.Name).ShouldNotBeNull(); }
public void should_have_created_the_expected_number_of_columns_in_the_pivoted_datatable() { _pivotedDataTable.Columns.Count.ShouldBeEqualTo(5); _pivotedDataTable.Columns.Contains(_xAxis.Caption).ShouldBeTrue(); _pivotedDataTable.Columns[_xAxis.Caption].DataType.ShouldBeEqualTo(typeof(float)); _pivotedDataTable.Columns.Contains(string.Format("Male.Liver({0})", CoreConstants.CompositeNameFor(PKSimConstants.UI.LowerValue, _yAxis.Caption))).ShouldBeTrue(); _pivotedDataTable.Columns.Contains(string.Format("Male.Liver({0})", _yAxis.Caption)).ShouldBeTrue(); _pivotedDataTable.Columns.Contains(string.Format("Male.Liver({0})", CoreConstants.CompositeNameFor(PKSimConstants.UI.UpperValue, _yAxis.Caption))).ShouldBeTrue(); _pivotedDataTable.Columns.Contains(string.Format("Female.Kidney({0})", _yAxis.Caption)).ShouldBeTrue(); }
public void should_have_created_the_expected_number_of_rows_in_the_datatable() { _dataTable.Rows.Count.ShouldBeEqualTo(3); _dataTable.AllValuesInColumn <float>(_xAxis.Caption).ShouldOnlyContain(1, 2, 3); _dataTable.AllValuesInColumn <float>(CoreConstants.CompositeNameFor(PKSimConstants.UI.Minimum, _xAxis.Caption)).ShouldOnlyContain(0, 1.8f, 2f); _dataTable.AllValuesInColumn <float>(CoreConstants.CompositeNameFor(PKSimConstants.UI.LowerPercentile, _yAxis.Caption)).ShouldOnlyContain(10, 20, 30); _dataTable.AllValuesInColumn <float>(_yAxis.Caption).ShouldOnlyContain(20, 30, 40); _dataTable.AllValuesInColumn <float>(CoreConstants.CompositeNameFor(PKSimConstants.UI.UpperPercentile, _yAxis.Caption)).ShouldOnlyContain(30, 40, 50); _dataTable.AllValuesInColumn <float>(CoreConstants.CompositeNameFor(PKSimConstants.UI.Maximum, _xAxis.Caption)).ShouldOnlyContain(1.5f, 2.5f, 4f); }
public virtual void SelectOutputFolder() { var outputFolder = _dialogCreator.AskForFolder("Select output folder where results will be exported", CoreConstants.DirectoryKey.BATCH); if (string.IsNullOrEmpty(outputFolder)) { return; } _dto.OutputFolder = outputFolder; _logFileFullPath = CoreConstants.DefaultBatchLogFullPath(outputFolder); }
public void should_create_a_fraction_of_dose_observer_for_the_unspecified_metabolite_in_the_liver_as_sum_of_the_fraction_in_liver_periportal_and_liver_pericentral() { var enzymaticProcessSelection = ProcessSelectionFor(_parentMetabolizationCYP2D6); var observerName = CoreConstants.Observer.ObserverNameFrom(CoreConstants.Observer.FRACTION_OF_DOSE, _compound.Name); var liverCellCYP2D6 = _simulation.Model.Root.EntityAt <Container>(Constants.ORGANISM, CoreConstants.Organ.LIVER, CoreConstants.Compartment.INTRACELLULAR, enzymaticProcessSelection.ProductName()); var observerLiverCell = liverCellCYP2D6.Children.FindByName(CoreConstants.CompositeNameFor(observerName, CoreConstants.Organ.LIVER, CoreConstants.Compartment.INTRACELLULAR)).DowncastTo <IObserver>(); observerLiverCell.ShouldNotBeNull(); observerLiverCell.Formula.DowncastTo <ExplicitFormula>().FormulaString.ShouldBeEqualTo("(M_periportal + M_pericentral)/TotalDrugMass"); }
public void the_created_process_should_have_two_parameters_enzyme_concentration_and_cl_spec_per_enzyme_hidden_set_to_one() { var processName = CoreConstants.CompositeNameFor(_compound.Name, _liverClearance.Name); var processContainer = _simulation.Model.Root.EntityAt <Container>(processName); processContainer.Parameter(CoreConstantsForSpecs.Parameter.ENZYME_CONCENTRATION).Value.ShouldBeEqualTo(1); processContainer.Parameter(CoreConstantsForSpecs.Parameter.ENZYME_CONCENTRATION).Visible.ShouldBeFalse(); processContainer.Parameter(CoreConstantsForSpecs.Parameter.CL_SPEC_PER_ENZYME).Value.ShouldBeEqualTo(processContainer.Parameter(CoreConstants.Parameters.SPECIFIC_CLEARANCE).Value); processContainer.Parameter(CoreConstantsForSpecs.Parameter.CL_SPEC_PER_ENZYME).Visible.ShouldBeFalse(); }
private static string createDataGroupingNameFor(bool hasOnlyOneDoseUnit, Compound compound, SchemaItemDTO schemaItemDTO) { var baseName = schemaItemDTO.DisplayName; if (!string.IsNullOrEmpty(compound.Name)) { baseName = CoreConstants.CompositeNameFor(baseName, compound.Name); } return(hasOnlyOneDoseUnit ? baseName : Constants.NameWithUnitFor(baseName, schemaItemDTO.DoseParameter.DisplayUnit)); }
private string compoundProcessName(IParameter parameter) { var process = parameter.ParentContainer; var processName = process.Name; if (process.ContainerType == ContainerType.Reaction || process.ParentContainer == null) { return(processName); } return(CoreConstants.CompositeNameFor(process.ParentContainer.Name, processName)); }
public void should_have_created_the_expected_number_of_columns_in_the_datatable() { _dataTable.Columns.Count.ShouldBeEqualTo(9); _dataTable.Columns[_xAxis.Caption].ShouldNotBeNull(); _dataTable.Columns[CoreConstants.CompositeNameFor(PKSimConstants.UI.Minimum, _xAxis.Caption)].ShouldNotBeNull(); _dataTable.Columns[CoreConstants.CompositeNameFor(PKSimConstants.UI.Maximum, _xAxis.Caption)].ShouldNotBeNull(); _dataTable.Columns[PKSimConstants.UI.NumberOfIndividuals].ShouldNotBeNull(); _dataTable.Columns[_yAxis.Caption].ShouldNotBeNull(); _dataTable.Columns[CoreConstants.CompositeNameFor(PKSimConstants.UI.LowerPercentile, _yAxis.Caption)].ShouldNotBeNull(); _dataTable.Columns[CoreConstants.CompositeNameFor(PKSimConstants.UI.UpperPercentile, _yAxis.Caption)].ShouldNotBeNull(); }
private async Task exportPopulationSimulationToCsvAsync(PopulationSimulation populationSimulation, string outputFolder, string projectName) { var populationFile = CoreConstants.DefaultPopulationExportNameFor(populationSimulation.Name); var populationFileFullPath = csvPathUnder(outputFolder, populationFile, projectName); _populationExportTask.ExportToCSV(populationSimulation, populationFileFullPath); await exportSimulationResultsToCsv(populationSimulation, outputFolder, projectName); var populationPKAnalysesFile = CoreConstants.DefaultPKAnalysesExportNameFor(populationSimulation.Name); var populationPKAnalysesFullPath = csvPathUnder(outputFolder, populationPKAnalysesFile, projectName); await _simulationExportTask.ExportPKAnalysesToCSVAsync(populationSimulation, populationPKAnalysesFullPath); }
public IReactionBuilder TurnoverReactionFrom(IReactionBuilder templateReaction, IMoleculeBuilder protein, IReadOnlyCollection <string> forbiddenNames, IFormulaCache formulaCache) { var reaction = createReactionFromProcess(templateReaction, forbiddenNames); reaction.Name = reactionNameFor(reaction.Name, protein.Name); reaction.Formula.Name = CoreConstants.CompositeNameFor(reaction.Name, reaction.Formula.Name); replaceKeywordsInProcess(reaction, new[] { CoreConstants.KeyWords.Protein, CoreConstants.KeyWords.Reaction }, new[] { protein.Name, reaction.Name }); reaction.AddProduct(new ReactionPartnerBuilder(protein.Name, 1)); formulaCache.Add(reaction.Formula); return(reaction); }
private IReactionBuilder interactionReactionFrom(InteractionProcess interactionProcess, IMoleculeBuilder protein, IReadOnlyCollection <string> forbiddenNames, IFormulaCache formulaCache) { var compound = interactionProcess.ParentCompound; var reactionName = CoreConstants.CompositeNameFor(compound.Name, interactionProcess.Name); var reaction = createReactionFromProcess(interactionProcess, reactionName, forbiddenNames); //replace keywords replaceKeywordsInProcess(reaction, new[] { CoreConstants.KeyWords.Molecule, CoreConstants.KeyWords.Protein, CoreConstants.KeyWords.Reaction }, new[] { compound.Name, protein.Name, interactionProcess.Name }); formulaCache.Add(reaction.Formula); return(reaction); }
protected override void AddSpecificChartColumns(DataTable dataTable, CurveData <RangeXValue, RangeYValue> curveData, bool exportForPivot) { _xValueColumn = curveData.XAxis.Caption; _yValueColumn = curveData.YAxis.Caption; _yLowerPercentileColumn = CoreConstants.CompositeNameFor(PKSimConstants.UI.LowerPercentile, _yValueColumn); _yUpperPercentileColumn = CoreConstants.CompositeNameFor(PKSimConstants.UI.UpperPercentile, _yValueColumn); _xMinimumColumn = CoreConstants.CompositeNameFor(PKSimConstants.UI.Minimum, _xValueColumn); _xMaximumColumn = CoreConstants.CompositeNameFor(PKSimConstants.UI.Maximum, _xValueColumn); _xNumberOfIndividualsColumn = PKSimConstants.UI.NumberOfIndividuals; dataTable.AddColumn <float>(_xMinimumColumn); dataTable.AddColumn <float>(_xValueColumn); dataTable.AddColumn <float>(_xMaximumColumn); dataTable.AddColumn <float>(_xNumberOfIndividualsColumn); dataTable.AddColumn <float>(_yLowerPercentileColumn); dataTable.AddColumn <float>(_yValueColumn); dataTable.AddColumn <float>(_yUpperPercentileColumn); }
private void addDynamicParameterGroupNodeTo(ITreeNode node, string subGroupName, IEnumerable <IParameter> allParameters, Func <IParameter, string> keySelector, Func <string, bool> keyAvailableFunc) { var group = node.TagAsObject.DowncastTo <IGroup>(); var allGroupParameters = _parameterGroupTask.ParametersInTopGroup(group.Name, allParameters); foreach (var parametersForNewGroup in allGroupParameters.GroupBy(keySelector).OrderBy(x => x.Key)) { if (!keyAvailableFunc(parametersForNewGroup.Key)) { continue; } var compositeKey = CoreConstants.CompositeNameFor(subGroupName, parametersForNewGroup.Key); var parameterContainer = parametersForNewGroup.First().ParentContainer; var dynamicNode = _treeNodeFactory.CreateDynamicGroup(compositeKey, parametersForNewGroup.Key, parametersForNewGroup); dynamicNode.Icon = ApplicationIcons.IconByNameOrDefault(parameterContainer.Icon, node.Icon); node.AddChild(dynamicNode); } }
protected override void TypedDeserialize(SystemicProcessSelection systemicProcessSelection, XElement element, SerializationContext context) { base.TypedDeserialize(systemicProcessSelection, element, context); //in 5.0.1, name of process did not contain data source. if (systemicProcessSelection.ProcessType == null || string.IsNullOrEmpty(systemicProcessSelection.ProcessName)) { return; } var systemicProcessName = systemicProcessSelection.ProcessType.DisplayName; if (systemicProcessSelection.ProcessName.Contains(systemicProcessName)) { return; } //we need to adjust the process name systemicProcessSelection.ProcessName = CoreConstants.CompositeNameFor(systemicProcessName, systemicProcessSelection.ProcessName); }
protected override void AddSpecificChartColumns(DataTable dataTable, CurveData <TimeProfileXValue, TimeProfileYValue> curveData, bool exportForPivot) { _xValueColumn = curveData.XAxis.Caption; _yValueColumn = curveData.YAxis.Caption; _yLowerValueColumn = CoreConstants.CompositeNameFor(PKSimConstants.UI.LowerValue, _yValueColumn); _yUpperValueColumn = CoreConstants.CompositeNameFor(PKSimConstants.UI.UpperValue, _yValueColumn); //Export xValueColumn as string to enable correct pivot on x values if (exportForPivot) { dataTable.AddColumn <string>(_xValueColumn); } else { dataTable.AddColumn <float>(_xValueColumn); } dataTable.AddColumn <float>(_yLowerValueColumn); dataTable.AddColumn <float>(_yValueColumn); dataTable.AddColumn <float>(_yUpperValueColumn); }
public void should_return_a_reaction_having_the_expected_name() { _reaction.Name.ShouldBeEqualTo(CoreConstants.CompositeNameFor(_compound.Name, _interactionProcess.Name)); }
public void should_have_set_the_name_of_the_kinetic_to_the_name_of_the_incoming_process_combine_with_the_name_of_the_formula() { _reaction.Formula.Name.ShouldBeEqualTo(CoreConstants.CompositeNameFor(_reaction.Name, "KINETIC")); }
public void should_have_set_the_name_of_the_reaction_to_the_name_of_the_incoming_process_combine_with_the_name_of_the_drug() { _reaction.Name.ShouldBeEqualTo(CoreConstants.CompositeNameFor(_drug.Name, _process.Name)); }
protected override async Task Context() { await base.Context(); _simulation = A.Fake <Simulation>().WithName("Sim"); A.CallTo(() => _simulation.HasResults).Returns(true); _fileFullPath = "file full path"; A.CallTo(() => _dialogCreator.AskForFileToSave(PKSimConstants.UI.ExportSimulationResultsToCSV, Constants.Filter.CSV_FILE_FILTER, Constants.DirectoryKey.REPORT, CoreConstants.DefaultResultsExportNameFor(_simulation.Name), null)) .Returns(_fileFullPath); }
protected override async Task Context() { await base.Context(); _simulation = A.Fake <IndividualSimulation>(); A.CallTo(() => _simulation.HasResults).Returns(true); A.CallTo(() => _simulation.Name).Returns("toto"); A.CallTo(() => _simulation.DataRepository).Returns(new DataRepository()); _excelFile = "tralala"; A.CallTo(() => _dialogCreator.AskForFileToSave(PKSimConstants.UI.ExportSimulationResultsToExcel, Constants.Filter.EXCEL_SAVE_FILE_FILTER, Constants.DirectoryKey.REPORT, CoreConstants.DefaultResultsExportNameFor(_simulation.Name), null)).Returns(_excelFile); }