コード例 #1
0
        private static float convertToAxisBaseValue(IDimension yAxisDimension, IDimension columnDimension, float valueInColumnBaseUnit)
        {
            if (!columnDimension.HasUnit(yAxisDimension.BaseUnit.Name))
            {
                return(valueInColumnBaseUnit);
            }

            return(columnDimension.BaseUnitValueToUnitValue(yAxisDimension.BaseUnit, valueInColumnBaseUnit).ToFloat());
        }
コード例 #2
0
        /// <summary>
        ///    Returns the display unit defined for the given <paramref name="dimension" /> or <c>null</c>
        ///    if to mapping was defined for this specific <paramref name="dimension" />.
        ///    It also ensures that the returned unit actually belongs in the <paramref name="dimension" />.
        /// </summary>
        public virtual Unit DisplayUnitFor(IDimension dimension)
        {
            var defaultMap = retrieveDisplayUnitMapFor(dimension);

            if (defaultMap?.DisplayUnit == null)
            {
                return(null);
            }

            var unitName = defaultMap.DisplayUnit.Name;

            return(dimension.HasUnit(unitName) ? dimension.Unit(unitName) : null);
        }
コード例 #3
0
 public void SelectDimension(string dimensionName)
 {
     this.DoWithinExceptionHandler(() =>
     {
         Dimension = _dimensions.FirstOrDefault(d => string.Equals(d.Name, dimensionName)) ??
                     _dimensions.FirstOrDefault() ??
                     Constants.Dimension.NO_DIMENSION;
         //checking whether _selectedUnit is not supported by the current dimension, meaning that the user
         //has selected a new dimension and the unit must be reset to the default unit of this dimension
         if (_view.SelectedUnit == null || !Dimension.HasUnit(_view.SelectedUnit))
         {
             fillUnits(Dimension.DefaultUnitName);
         }
     });
 }
コード例 #4
0
ファイル: ImporterSpecs.cs プロジェクト: Yuri05/OSPSuite.Core
        public override void GlobalContext()
        {
            base.GlobalContext();
            _fakedTimeDimension          = A.Fake <IDimension>();
            _fakedConcentrationDimension = A.Fake <IDimension>();
            _fakedErrorDimension         = A.Fake <IDimension>();
            _fakedDimensionFactory       = A.Fake <IDimensionFactory>();
            _basicFormat   = A.Fake <DataSheet>();
            _container     = A.Fake <IContainer>();
            _dialogCreator = A.Fake <IDialogCreator>();
            var dataFormat = A.Fake <IDataFormat>();

            _columnInfos = new ColumnInfoCache
            {
                new ColumnInfo()
                {
                    DisplayName = "Time"
                },
                new ColumnInfo()
                {
                    DisplayName = "Concentration"
                },
                new ColumnInfo()
                {
                    DisplayName = "Error"
                }
            };

            _columnInfos["Time"].SupportedDimensions.Add(_fakedTimeDimension);
            _columnInfos["Concentration"].SupportedDimensions.Add(_fakedConcentrationDimension);
            _columnInfos["Error"].SupportedDimensions.Add(_fakedErrorDimension);

            A.CallTo(() => dataFormat.SetParameters(_basicFormat, _columnInfos, null)).Returns(1);
            A.CallTo(() => _container.ResolveAll <IDataFormat>()).Returns(new List <IDataFormat>()
            {
                dataFormat
            });
            _parser = A.Fake <IDataSourceFileParser>();
            _dataRepositoryMapper = A.Fake <IDataSetToDataRepositoryMapper>();
            A.CallTo(() => _container.Resolve <IDataSourceFileParser>()).Returns(_parser);
            A.CallTo(() => _fakedTimeDimension.HasUnit("min")).Returns(true);
            A.CallTo(() => _fakedConcentrationDimension.HasUnit("pmol/l")).Returns(true);
            A.CallTo(() => _fakedErrorDimension.HasUnit("pmol/l")).Returns(true);
            sut = new OSPSuite.Infrastructure.Import.Services.Importer(_container, _parser, _dataRepositoryMapper, _fakedDimensionFactory);
        }
コード例 #5
0
        protected override void Context()
        {
            _fakedTimeDimension = A.Fake <IDimension>();
            _fakedConcentrationDimensionMolar = A.Fake <IDimension>();
            _fakedConcentrationDimensionMass  = A.Fake <IDimension>();
            _fakedErrorDimension = A.Fake <IDimension>();
            _fakedImporter       = A.Fake <IImporter>();
            _fakeDataSet         = new DataSet();

            _columnInfos = new ColumnInfoCache
            {
                new ColumnInfo()
                {
                    DisplayName = "Time", Name = "Time"
                },
                new ColumnInfo()
                {
                    DisplayName = "Concentration", Name = "Concentration"
                },
                new ColumnInfo()
                {
                    DisplayName = "Error", Name = "Error", IsMandatory = false, RelatedColumnOf = "Concentration"
                }
            };

            _columnInfos["Time"].SupportedDimensions.Add(_fakedTimeDimension);
            _columnInfos["Concentration"].SupportedDimensions.Add(_fakedConcentrationDimensionMolar);
            _columnInfos["Concentration"].SupportedDimensions.Add(_fakedConcentrationDimensionMass);
            _columnInfos["Error"].SupportedDimensions.Add(_fakedErrorDimension);
            _columnInfos["Error"].SupportedDimensions.Add(_fakedConcentrationDimensionMass);
            var parsedData = new Dictionary <ExtendedColumn, IList <SimulationPoint> >()
            {
                {
                    new ExtendedColumn()
                    {
                        Column = new Column()
                        {
                            Name = "Time",
                            Unit = new UnitDescription("s")
                        },
                        ColumnInfo = _columnInfos["Time"]
                    },
                    new List <SimulationPoint>()
                    {
                        new SimulationPoint()
                        {
                            Unit        = "s",
                            Measurement = 0,
                            Lloq        = double.NaN
                        },
                        new SimulationPoint()
                        {
                            Unit        = "s",
                            Measurement = 1,
                            Lloq        = double.NaN
                        },
                        new SimulationPoint()
                        {
                            Unit        = "s",
                            Measurement = 2,
                            Lloq        = double.NaN
                        }
                    }
                },
                {
                    new ExtendedColumn()
                    {
                        Column = new Column()
                        {
                            Name = "Concentration",
                            Unit = new UnitDescription("pmol/l")
                        },
                        ColumnInfo = _columnInfos["Concentration"]
                    },
                    new List <SimulationPoint>()
                    {
                        new SimulationPoint()
                        {
                            Unit        = "pmol/l",
                            Measurement = 10,
                            Lloq        = 1
                        },
                        new SimulationPoint()
                        {
                            Unit        = "pmol/l",
                            Measurement = 0.1,
                            Lloq        = 1
                        },
                        new SimulationPoint()
                        {
                            Unit        = "pmol/l",
                            Measurement = double.NaN,
                            Lloq        = 1
                        }
                    }
                },
                {
                    new ExtendedColumn()
                    {
                        Column = new Column()
                        {
                            Name = "Error",
                            Unit = new UnitDescription("")
                        },
                        ColumnInfo = _columnInfos["Error"]
                    },
                    new List <SimulationPoint>()
                    {
                        new SimulationPoint()
                        {
                            Unit        = "",
                            Measurement = 10,
                            Lloq        = 1
                        },
                        new SimulationPoint()
                        {
                            Unit        = "",
                            Measurement = 0.1,
                            Lloq        = 1
                        },
                        new SimulationPoint()
                        {
                            Unit        = "",
                            Measurement = double.NaN,
                            Lloq        = 1
                        }
                    }
                }
            };

            A.CallTo(() => _fakedTimeDimension.HasUnit("min")).Returns(true);
            A.CallTo(() => _fakedTimeDimension.HasUnit("s")).Returns(true);
            A.CallTo(() => _fakedConcentrationDimensionMolar.HasUnit("pmol/l")).Returns(true);
            A.CallTo(() => _fakedConcentrationDimensionMass.HasUnit("ng/ml")).Returns(true);
            A.CallTo(() => _fakedErrorDimension.HasUnit("pmol/l")).Returns(true);

            A.CallTo(() => _fakedConcentrationDimensionMolar.FindUnit("no unit", true)).Returns(null);
            A.CallTo(() => _fakedConcentrationDimensionMass.FindUnit("no unit", true)).Returns(null);
            A.CallTo(() => _fakedErrorDimension.FindUnit("no unit", true)).Returns(null);
            A.CallTo(() => _fakedConcentrationDimensionMolar.FindUnit("ng/ml", true)).Returns(null);
            A.CallTo(() => _fakedConcentrationDimensionMass.FindUnit("pmol/l", true)).Returns(null);

            _fakeDataSet.AddData(new List <ParsedDataSet>()
            {
                new ParsedDataSet(new List <string>(), A.Fake <DataSheet>(), new List <UnformattedRow>(),
                                  parsedData)
            });


            sut = new DataSource(_fakedImporter);
            sut.DataSets.Add("sheet1", _fakeDataSet);
        }
コード例 #6
0
ファイル: ImporterSpecs.cs プロジェクト: Yuri05/OSPSuite.Core
        public override void GlobalContext()
        {
            base.GlobalContext();
            _fakedTimeDimension          = A.Fake <IDimension>();
            _fakedConcentrationDimension = A.Fake <IDimension>();
            _fakedErrorDimension         = A.Fake <IDimension>();
            _container             = A.Fake <IContainer>();
            _dialogCreator         = A.Fake <IDialogCreator>();
            _fakedDimensionFactory = A.Fake <IDimensionFactory>();
            var dataFormat = A.Fake <IDataFormat>();

            _columnInfos = new ColumnInfoCache()
            {
                new ColumnInfo()
                {
                    DisplayName = "Time"
                },
                new ColumnInfo()
                {
                    DisplayName = "Concentration"
                },
                new ColumnInfo()
                {
                    DisplayName = "Error"
                }
            };
            _metaDataCategories = new List <MetaDataCategory>()
            {
                new MetaDataCategory()
                {
                    Name = "Organ"
                },
                new MetaDataCategory()
                {
                    Name = "Compartment"
                },
                new MetaDataCategory()
                {
                    Name = "Species"
                },
                new MetaDataCategory()
                {
                    Name = "Dose"
                },
                new MetaDataCategory()
                {
                    Name = "Molecule"
                },
                new MetaDataCategory()
                {
                    Name = "Route"
                }
            };

            _columnInfos["Time"].SupportedDimensions.Add(_fakedTimeDimension);
            _columnInfos["Concentration"].SupportedDimensions.Add(_fakedConcentrationDimension);
            _columnInfos["Error"].SupportedDimensions.Add(_fakedErrorDimension);

            A.CallTo(() => _fakedTimeDimension.HasUnit("min")).Returns(true);
            A.CallTo(() => _fakedConcentrationDimension.HasUnit("pmol/l")).Returns(true);
            A.CallTo(() => _fakedErrorDimension.HasUnit("pmol/l")).Returns(true);
            A.CallTo(() => _container.ResolveAll <IDataFormat>()).Returns(new List <IDataFormat>()
            {
                new DataFormatHeadersWithUnits(), new DataFormatNonmem(), new MixColumnsDataFormat()
            });
            _parser = A.Fake <IDataSourceFileParser>();
            _dataRepositoryMapper = A.Fake <IDataSetToDataRepositoryMapper>();
            A.CallTo(() => _container.Resolve <IDataSourceFileParser>()).Returns(_parser);
            sut = new OSPSuite.Infrastructure.Import.Services.Importer(_container, _parser, _dataRepositoryMapper, _fakedDimensionFactory);
        }
コード例 #7
0
        protected override void Context()
        {
            _fakedTimeDimension          = A.Fake <IDimension>();
            _fakedConcentrationDimension = A.Fake <IDimension>();
            _fakedErrorDimension         = A.Fake <IDimension>();

            _columnInfos = new ColumnInfoCache
            {
                new ColumnInfo()
                {
                    DisplayName = "Time", Name = "Time", IsMandatory = true
                },
                new ColumnInfo()
                {
                    DisplayName = "Concentration", Name = "Concentration", IsMandatory = true
                },
                new ColumnInfo()
                {
                    DisplayName = "Error", Name = "Error", IsMandatory = false, RelatedColumnOf = "Concentration"
                }
            };

            _columnInfos["Time"].SupportedDimensions.Add(_fakedTimeDimension);
            _columnInfos["Concentration"].SupportedDimensions.Add(_fakedConcentrationDimension);
            _columnInfos["Error"].SupportedDimensions.Add(_fakedErrorDimension);
            _metaDataCategories = new List <MetaDataCategory>()
            {
                new MetaDataCategory()
                {
                    Name = "Organ"
                },
                new MetaDataCategory()
                {
                    Name = "Compartment"
                },
                new MetaDataCategory()
                {
                    Name = "Species"
                },
                new MetaDataCategory()
                {
                    Name = "Dose"
                },
                new MetaDataCategory()
                {
                    Name = "Molecule"
                },
                new MetaDataCategory()
                {
                    Name = "Route"
                }
            };

            A.CallTo(() => _fakedTimeDimension.HasUnit("min")).Returns(true);
            A.CallTo(() => _fakedConcentrationDimension.HasUnit("pmol/l")).Returns(true);
            A.CallTo(() => _fakedErrorDimension.HasUnit("pmol/l")).Returns(true);
            sut          = new DataFormatHeadersWithUnits();
            _basicFormat = new TestDataSheet
                           (
                new Cache <string, ColumnDescription>()
            {
                {
                    "Organ",
                    new ColumnDescription(0, new List <string>()
                    {
                        "PeripheralVenousBlood"
                    }, ColumnDescription.MeasurementLevel.Discrete)
                },
                {
                    "Compartment",
                    new ColumnDescription(1, new List <string>()
                    {
                        "Arterialized"
                    }, ColumnDescription.MeasurementLevel.Discrete)
                },
                {
                    "Species",
                    new ColumnDescription(2, new List <string>()
                    {
                        "Human"
                    }, ColumnDescription.MeasurementLevel.Discrete)
                },
                {
                    "Dose",
                    new ColumnDescription(3, new List <string>()
                    {
                        "75 [g] glucose"
                    }, ColumnDescription.MeasurementLevel.Discrete)
                },
                {
                    "Molecule",
                    new ColumnDescription(4, new List <string>()
                    {
                        "GLP-1_7-36 total", "Glucose", "Insuline", "GIP_total", "Glucagon"
                    }, ColumnDescription.MeasurementLevel.Discrete)
                },
                {
                    "Time [min]",
                    new ColumnDescription(5, null, ColumnDescription.MeasurementLevel.Numeric)
                },
                {
                    "Concentration (molar) [pmol/l]",
                    new ColumnDescription(6, null, ColumnDescription.MeasurementLevel.Numeric)
                },
                {
                    "Error [pmol/l]",
                    new ColumnDescription(7, null, ColumnDescription.MeasurementLevel.Numeric)
                },
                {
                    "Route",
                    new ColumnDescription(8, new List <string>()
                    {
                        "po"
                    }, ColumnDescription.MeasurementLevel.Discrete)
                },
                {
                    "Groupe Id",
                    new ColumnDescription(9, new List <string>()
                    {
                        "H", "T2DM"
                    }, ColumnDescription.MeasurementLevel.Discrete)
                }
            }
                           );
        }
コード例 #8
0
 private bool haveCommonUnits(IDimension sourceDimension, Unit importedUnit)
 {
     return(sourceDimension.HasUnit(importedUnit.Name));
 }
コード例 #9
0
 private Unit defaultUnitForDimension(IDimension dimension, Unit defaultUnit)
 {
     return(dimension.HasUnit(defaultUnit)
     ? defaultUnit
     : dimension.DefaultUnit);
 }