protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_expressionProfileEnzyme);

            _newExpressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>();
            A.CallTo(() => _expressionProfileFactory.Create(_snapshot.Type, _snapshot.Species, _snapshot.Molecule))
            .Returns(_newExpressionProfile);

            _snapshot.Localization = null;
            _snapshot.IntracellularVascularEndoLocation = IntracellularVascularEndoLocation.Interstitial;
            _snapshot.MembraneLocation = MembraneLocation.BloodBrainBarrier;
            _snapshot.TissueLocation   = TissueLocation.Interstitial;
            //Add expression container to simulate v9 format
            _snapshot.Expression = new[] { _relativeExpressionContainerSnapshot1, _relativeExpressionContainerSnapshot2, };
            _relativeExpressionParameter1.Value         = 0;
            _relativeExpressionContainerSnapshot1.Value = 1000;
            A.CallTo(() => _expressionContainerMapper.MapToModel(_relativeExpressionContainerSnapshot1, A <ExpressionContainerMapperContext> ._))
            .Invokes(x => _relativeExpressionParameter1.Value = _relativeExpressionContainerSnapshot1.Value.Value);

            _newExpressionProfile.Molecule.Ontogeny = null;
            A.CallTo(() => _ontogenyMapper.MapToModel(_snapshot.Ontogeny, A <SnapshotContextWithSubject> .That.Matches(x => x.SimulationSubject == _newExpressionProfile.Individual))).Returns(_ontogeny);

            var enzyme = _newExpressionProfile.Molecule.DowncastTo <IndividualEnzyme>();

            //Localization is now set in task. We override behavior here and pretend that command was executed
            A.CallTo(() => _moleculeExpressionTask.SetExpressionLocalizationFor(enzyme, A <Localization> ._, _newExpressionProfile.Individual))
            .Invokes(x => enzyme.Localization = x.GetArgument <Localization>(1));

            //Ensure that the parameter is at the right location so that it will be normalized
            enzyme.Add(_relativeExpressionParameter1);
        }
        protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_expressionProfileOtherProtein);

            _newOtherProteinExpressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualOtherProtein>();
            A.CallTo(() => _expressionProfileFactory.Create(_snapshot.Type, _snapshot.Species, _snapshot.Molecule))
            .Returns(_newOtherProteinExpressionProfile);
        }
Esempio n. 3
0
 protected override void Context()
 {
     base.Context();
     _expressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>();
     _individual        = DomainHelperForSpecs.CreateIndividual();
     _individual.AddExpressionProfile(_expressionProfile);
     _usedBuildingBlock = new UsedBuildingBlock(_expressionProfile.Id, _expressionProfile.BuildingBlockType);
     _simulation1.AddUsedBuildingBlock(_usedBuildingBlock);
     A.CallTo(() => _buildingBlockRepository.All(A <Func <ISimulationSubject, bool> > ._))
     .Returns(new[] { _individual });
 }
        protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_expressionProfileTransporter);

            _newTransporterExpressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualTransporter>();
            A.CallTo(() => _expressionProfileFactory.Create(_snapshot.Type, _snapshot.Species, _snapshot.Molecule))
            .Returns(_newTransporterExpressionProfile);
            _snapshot.TransportType = TransportType.PgpLike;
        }
        protected override void Context()
        {
            _context = A.Fake <IExecutionContext>();
            var expressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>();

            (_molecule, _)     = expressionProfile;
            _protein           = _molecule.DowncastTo <IndividualProtein>();
            _result            = new QueryExpressionResults(_expressionResults);
            _simulationSubject = A.Fake <ISimulationSubject>();
            sut = new EditIndividualMoleculeExpressionInSimulationSubjectFromQueryCommand(_molecule, _result, _simulationSubject);

            A.CallTo(() => _simulationSubject.AllExpressionParametersFor(_molecule)).Returns(_allExpressionParameters);
        }
Esempio n. 6
0
        protected override Task Context()
        {
            _parameterMapper         = A.Fake <ParameterMapper>();
            _expressionProfileMapper = A.Fake <ExpressionProfileMapper>();
            _dimensionRepository     = A.Fake <IDimensionRepository>();
            _individualFactory       = A.Fake <IIndividualFactory>();
            _originDataMapper        = A.Fake <OriginDataMapper>();
            _moleculeExpressionTask  = A.Fake <IMoleculeExpressionTask <ModelIndividual> >();

            sut = new IndividualMapper(_parameterMapper, _expressionProfileMapper, _originDataMapper, _individualFactory, _moleculeExpressionTask);

            _individual             = DomainHelperForSpecs.CreateIndividual();
            _individual.Name        = "Ind";
            _individual.Description = "Model Description";
            var kidney = _individual.EntityAt <IContainer>(Constants.ORGANISM, CoreConstants.Organ.KIDNEY);

            _parameterLiver        = _individual.EntityAt <IParameter>(Constants.ORGANISM, CoreConstants.Organ.LIVER, "PLiver");
            _parameterKidney       = _individual.EntityAt <IParameter>(Constants.ORGANISM, CoreConstants.Organ.KIDNEY, "PKidney");
            _parameterKidneyRelExp = DomainHelperForSpecs.ConstantParameterWithValue().WithName(CoreConstants.Parameters.REL_EXP);
            _parameterKidneyRelExp.DefaultValue = 10;
            kidney.Add(_parameterKidneyRelExp);

            _parameterLiver.ValueDiffersFromDefault().ShouldBeFalse();
            _parameterKidney.ValueDiffersFromDefault().ShouldBeFalse();

            _parameterKidney.Value = 40;
            _parameterKidney.ValueDiffersFromDefault().ShouldBeTrue();
            _parameterKidneyRelExp.Value = 50;
            _parameterKidneyRelExp.ValueDiffersFromDefault().ShouldBeTrue();

            _expressionProfile1 = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>(moleculeName: "Enz");
            _expressionProfile2 = DomainHelperForSpecs.CreateExpressionProfile <IndividualTransporter>(moleculeName: "Trans");
            _individual.AddExpressionProfile(_expressionProfile1);
            _individual.AddExpressionProfile(_expressionProfile2);


            _originDataSnapshot = new OriginData();
            A.CallTo(() => _originDataMapper.MapToSnapshot(_individual.OriginData)).Returns(_originDataSnapshot);

            _localizedParameterKidney = new LocalizedParameter {
                Path = "Organism|Kidney|PKidney"
            };
            A.CallTo(() => _parameterMapper.LocalizedParametersFrom(A <IEnumerable <IParameter> > ._))
            .Invokes(x => _mappedParameters = x.GetArgument <IEnumerable <IParameter> >(0).ToList())
            .Returns(new[] { _localizedParameterKidney });

            return(_completed);
        }
        protected override Task Context()
        {
            _parameterMapper           = A.Fake <ParameterMapper>();
            _expressionContainerMapper = A.Fake <ExpressionContainerMapper>();
            _expressionProfileFactory  = A.Fake <IExpressionProfileFactory>();
            _ontogenyMapper            = A.Fake <OntogenyMapper>();
            _ontogenyTask           = A.Fake <IOntogenyTask>();
            _moleculeExpressionTask = A.Fake <IMoleculeExpressionTask <Individual> >();
            _moleculeParameterTask  = A.Fake <IMoleculeParameterTask>();
            sut = new ExpressionProfileMapper(
                _parameterMapper,
                _expressionContainerMapper,
                _ontogenyMapper,
                _ontogenyTask,
                _moleculeExpressionTask,
                _expressionProfileFactory,
                _moleculeParameterTask);

            _ontogeny = new DatabaseOntogeny
            {
                Name = "Ontogeny"
            };

            _expressionProfileEnzyme = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>("Enzyme");
            _expressionProfileEnzyme.Molecule.Ontogeny = _ontogeny;
            _expressionProfileEnzyme.Description       = "Help";

            _expressionProfileTransporter             = DomainHelperForSpecs.CreateExpressionProfile <IndividualTransporter>("Transporter");
            _expressionProfileTransporter.Description = "Help";

            _expressionProfileOtherProtein = DomainHelperForSpecs.CreateExpressionProfile <IndividualOtherProtein>("OtherProtein");

            _enzymeGlobalParameter = DomainHelperForSpecs.ConstantParameterWithValue(5, isDefault: true)
                                     .WithName(CoreConstants.Parameters.HALF_LIFE_LIVER);
            _enzymeGlobalParameterSnapshot = new Parameter();

            A.CallTo(() => _parameterMapper.MapToSnapshot(_enzymeGlobalParameter)).Returns(_enzymeGlobalParameterSnapshot);

            _expressionContainer1 = new MoleculeExpressionContainer {
                Name = "Exp Container1"
            };
            _expressionContainer2 = new MoleculeExpressionContainer {
                Name = "Exp Container2"
            };
            _expressionProfileEnzyme.Individual.AddChildren(_expressionContainer1, _expressionContainer2, _enzymeGlobalParameter);
            _expressionProfileEnzyme.Molecule.DowncastTo <IndividualEnzyme>().Localization = Localization.Intracellular | Localization.BloodCellsMembrane;

            _relativeExpressionParameter1 = DomainHelperForSpecs.ConstantParameterWithValue(0.5).WithName(CoreConstants.Parameters.REL_EXP);
            _expressionContainer1.Add(_relativeExpressionParameter1);

            _relativeExpressionParameterNotSet = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.REL_EXP);
            _expressionContainer2.Add(_relativeExpressionParameterNotSet);

            _relativeExpressionContainerSnapshot1 = new ExpressionContainer();
            _relativeExpressionContainerSnapshot2 = new ExpressionContainer();

            A.CallTo(() => _expressionContainerMapper.MapToSnapshot(_expressionContainer1)).Returns(_relativeExpressionContainerSnapshot1);
            A.CallTo(() => _expressionContainerMapper.MapToSnapshot(_expressionContainer2)).Returns(_relativeExpressionContainerSnapshot2);

            _snapshotOntogeny = new Snapshots.Ontogeny();
            A.CallTo(() => _ontogenyMapper.MapToSnapshot(_ontogeny)).Returns(_snapshotOntogeny);
            _individual = new Individual();

            return(_completed);
        }
Esempio n. 8
0
        protected override Task Context()
        {
            _classificationMapper          = A.Fake <ClassificationMapper>();
            _snapshotMapper                = A.Fake <ISnapshotMapper>();
            _executionContext              = A.Fake <IExecutionContext>();
            _lazyLoadTask                  = A.Fake <ILazyLoadTask>();
            _simulationMapper              = A.Fake <SimulationMapper>();
            _simulationComparisonMapper    = A.Fake <SimulationComparisonMapper>();
            _parameterIdentificationMapper = A.Fake <ParameterIdentificationMapper>();
            _classificationSnapshotTask    = A.Fake <IClassificationSnapshotTask>();
            _qualificationPlanMapper       = A.Fake <QualificationPlanMapper>();
            _creationMetaDataFactory       = A.Fake <ICreationMetaDataFactory>();
            _logger = A.Fake <IOSPSuiteLogger>();

            sut = new ProjectMapper(
                _simulationMapper,
                _simulationComparisonMapper,
                _parameterIdentificationMapper,
                _qualificationPlanMapper,
                _executionContext,
                _classificationSnapshotTask,
                _lazyLoadTask,
                _creationMetaDataFactory,
                _logger);


            A.CallTo(() => _executionContext.Resolve <ISnapshotMapper>()).Returns(_snapshotMapper);
            _individual               = new Individual().WithName("IND");
            _compound                 = new Compound().WithName("COMP");
            _event                    = new PKSimEvent().WithName("EVENT");
            _formulation              = new Formulation().WithName("FORM");
            _protocol                 = new SimpleProtocol().WithName("PROTO");
            _population               = new RandomPopulation().WithName("POP");
            _observerSet              = new ObserverSet().WithName("OBS_SET");
            _observedData             = new DataRepository().WithName("OD");
            _expressionProfile        = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>();
            _parameterIdentification  = new OSPSuite.Core.Domain.ParameterIdentifications.ParameterIdentification().WithName("PI").WithId("PI_ID");
            _classifiableObservedData = new ClassifiableObservedData {
                Subject = _observedData
            };
            _classification = new Classification {
                ClassificationType = ClassificationType.ObservedData
            }.WithName("OD Classification");
            _simulationComparison = new IndividualSimulationComparison().WithName("COMP").WithId("SimComp");
            _simulation           = new IndividualSimulation().WithName("IND_SIM").WithId("IndSim");
            _qualificationPlan    = new QualificationPlan().WithName("QP").WithId("QP_ID");
            _project = new PKSimProject();
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_formulation);
            _project.AddBuildingBlock(_protocol);
            _project.AddBuildingBlock(_population);
            _project.AddBuildingBlock(_observerSet);
            _project.AddObservedData(_observedData);
            _project.AddBuildingBlock(_simulation);
            _project.AddBuildingBlock(_expressionProfile);
            _project.AddClassifiable(_classifiableObservedData);
            _project.AddClassification(_classification);
            _project.AddSimulationComparison(_simulationComparison);
            _project.AddParameterIdentification(_parameterIdentification);
            _project.AddQualificationPlan(_qualificationPlan);

            _compoundSnapshot                              = new Snapshots.Compound();
            _individualSnapshot                            = new Snapshots.Individual();
            _eventSnapshot                                 = new Event();
            _observerSetSnapshot                           = new Snapshots.ObserverSet();
            _formulationSnapshot                           = new Snapshots.Formulation();
            _protocolSnapshot                              = new Snapshots.Protocol();
            _populationSnapshot                            = new Snapshots.Population();
            _observedDataSnapshot                          = new Snapshots.DataRepository();
            _parameterIdentificationSnapshot               = new ParameterIdentification();
            _observedDataClassificationSnapshot            = new Snapshots.Classification();
            _simulationComparisonSnapshot                  = new SimulationComparison();
            _simulationClassificationSnapshot              = new Snapshots.Classification();
            _comparisonClassificationSnapshot              = new Snapshots.Classification();
            _parameterIdentificationClassificationSnapshot = new Snapshots.Classification();
            _qualificationPlanClassificationSnapshot       = new Snapshots.Classification();
            _qualificationPlanSnapshot                     = new Snapshots.QualificationPlan();
            _expressionProfileSnapshot                     = new Snapshots.ExpressionProfile();
            _simulationSnapshot                            = new Simulation();


            A.CallTo(() => _snapshotMapper.MapToSnapshot(_compound)).Returns(_compoundSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_individual)).Returns(_individualSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_event)).Returns(_eventSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_formulation)).Returns(_formulationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_protocol)).Returns(_protocolSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_population)).Returns(_populationSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_observedData)).Returns(_observedDataSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_observerSet)).Returns(_observerSetSnapshot);
            A.CallTo(() => _snapshotMapper.MapToSnapshot(_expressionProfile)).Returns(_expressionProfileSnapshot);
            A.CallTo(() => _simulationMapper.MapToSnapshot(_simulation, _project)).Returns(_simulationSnapshot);
            A.CallTo(() => _simulationComparisonMapper.MapToSnapshot(_simulationComparison)).Returns(_simulationComparisonSnapshot);
            A.CallTo(() => _parameterIdentificationMapper.MapToSnapshot(_parameterIdentification)).Returns(_parameterIdentificationSnapshot);
            A.CallTo(() => _qualificationPlanMapper.MapToSnapshot(_qualificationPlan)).Returns(_qualificationPlanSnapshot);

            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableObservedData>(_project)).Returns(new[] { _observedDataClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableSimulation>(_project)).Returns(new[] { _simulationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableComparison>(_project)).Returns(new[] { _comparisonClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableParameterIdentification>(_project)).Returns(new[] { _parameterIdentificationClassificationSnapshot });
            A.CallTo(() => _classificationSnapshotTask.MapClassificationsToSnapshots <ClassifiableQualificationPlan>(_project)).Returns(new[] { _qualificationPlanClassificationSnapshot });

            return(_completed);
        }