Exemple #1
0
        public void should_be_able_to_read_all_files_and_run_the_most()
        {
            var directories = new DirectoryInfo(_directory).EnumerateDirectories();
            var messages    = new List <string>();

            foreach (var directory in directories)
            {
                _sbmlTask = IoC.Resolve <ISbmlTask>().DowncastTo <SbmlTask>();
                var caseName = directory.Name;
                Debug.Print(caseName);
                var fileName = Path.Combine(directory.FullName, $"{caseName}-sbml-l3v1.xml");
                var context  = IoC.Resolve <IMoBiContext>();
                context.NewProject();
                var          project = context.CurrentProject;
                IMoBiCommand command;
                try
                {
                    command = _sbmlTask.ImportModelFromSbml(fileName, project);
                }
                catch (Exception e)
                {
                    messages.Add($"Import: {caseName} {e.Message}:");
                    continue;
                }

                if (command.IsEmpty())
                {
                    messages.Add($"Import: {caseName}");
                    continue;
                }

                addjEmptyBBIfneeded(project);
                addSettings(project, Path.Combine(directory.FullName, $"{caseName}-settings.txt"));
                var buildConfigurtion = genreateBuildConfiguration(project);
                var result            = _modelConstructor.CreateModelFrom(buildConfigurtion, caseName);
                if (result.IsInvalid)
                {
                    messages.Add(caseName);
                    continue;
                }

                var simulation = new MoBiSimulation {
                    BuildConfiguration = buildConfigurtion, Model = result.Model
                };
                var simModelManager = new SimModelManager(_simModelExporter, new SimModelSimulationFactory(),
                                                          new DataFactory(IoC.Resolve <IMoBiDimensionFactory>(), new SBMLTestDataNamingService(), IoC.Resolve <IObjectPathFactory>(), IoC.Resolve <IDisplayUnitRetriever>(), IoC.Resolve <IDataRepositoryTask>()));
                var runResults = simModelManager.RunSimulation(simulation);
                if (!runResults.Success)
                {
                    messages.Add(caseName);
                    continue;
                }

                var dt = _dateRepositoryTask.ToDataTable(runResults.Results);
                dt.First().ExportToCSV(Path.Combine(directory.FullName, $"{caseName}-result_mobi.csv"));
                _sbmlTask = null;
            }

            messages.Count.ShouldBeEqualTo(0, messages.ToString("\n"));
        }
Exemple #2
0
        protected override void Context()
        {
            _editObservedDataTask = A.Fake <IEditObservedDataTask>();
            _view = A.Fake <IDataRepositoryDataView>();
            _dataRepositoryTask = A.Fake <IDataRepositoryTask>();
            _commandCollector   = A.Fake <ICommandCollector>();
            sut = new DataRepositoryDataPresenter(_view, _dataRepositoryTask, _editObservedDataTask);
            sut.InitializeWith(_commandCollector);

            //common setup
            _dataRepository = new DataRepository();
            _dataTable      = new DataTable();
            A.CallTo(() => _dataRepositoryTask.ToDataTable(_dataRepository, A <DataColumnExportOptions> ._)).Returns(new[] { _dataTable });

            var col = _dataTable.AddColumn <float>("test");

            col.ExtendedProperties.Add(Constants.DATA_REPOSITORY_COLUMN_ID, "col");
            _baseGrid = new BaseGrid("base", "base", Constants.Dimension.NO_DIMENSION)
            {
                Values = new ArraySegment <float>()
            };
            _dim = A.Fake <IDimension>();
            _col = new DataColumn("col", "col", _dim, _baseGrid)
            {
                Values = new ArraySegment <float>()
            };
            _dataRepository.Add(_baseGrid);
            _dataRepository.Add(_col);
        }
        public DataTable MapFrom(WeightedObservedData weightedObservedData)
        {
            var columns    = weightedObservedData.ObservedData.ToList();
            var dataColumn = createWeightColumn(weightedObservedData.ObservedData.BaseGrid, weightedObservedData);

            columns.Add(dataColumn);
            return(_dataRepositoryTask.ToDataTable(columns, forceColumnTypeAsObject: true).First());
        }
Exemple #4
0
        private void exportDataRepository(string fileName, IEnumerable <DataColumn> dataRepository)
        {
            var dataTables = _dataRepositoryTask.ToDataTable(dataRepository, new DataColumnExportOptions
            {
                ColumnNameRetriever = x => x.QuantityInfo.PathAsString,
                DimensionRetriever  = _dimensionFactory.MergedDimensionFor
            });

            _dataRepositoryTask.ExportToExcel(dataTables, fileName, true);
        }
Exemple #5
0
        public Task ExportResultsToExcel(IndividualSimulation individualSimulation)
        {
            _buildingBlockTask.LoadResults(individualSimulation);
            if (!individualSimulation.HasResults)
            {
                throw new PKSimException(PKSimConstants.Error.CannotExportResultsPleaseRunSimulation(individualSimulation.Name));
            }

            return(exportToFileAsync(PKSimConstants.UI.ExportSimulationResultsToExcel, Constants.Filter.EXCEL_SAVE_FILE_FILTER, PKSimConstants.UI.DefaultResultsExportNameFor(individualSimulation.Name), async fileName =>
            {
                var dataTables = _dataRepositoryTask.ToDataTable(individualSimulation.DataRepository, x => _quantityDisplayPathMapper.DisplayPathAsStringFor(individualSimulation, x), x => x.Dimension);
                await Task.Run(() => _dataRepositoryTask.ExportToExcel(dataTables, fileName, launchExcel: true));
            }, Constants.DirectoryKey.REPORT));
        }
Exemple #6
0
        public IEnumerable <DataTable> ExportToDataTable(IEnumerable <DataColumn> dataColumns, GlobalPKAnalysis globalPKAnalysis, DataTable dataTable, IEnumerable <Simulation> simulations)
        {
            var allDataTables  = new List <DataTable>();
            var allSimulations = simulations.ToList();

            if (allSimulations.Any())
            {
                allDataTables.AddRange(_dataRepositoryTask.ToDataTable(dataColumns, x => _quantityDisplayPathMapper.DisplayPathAsStringFor(simulationForColumn(x, allSimulations), x)));
            }

            allDataTables.Add(_globalPKAnalysisToDataTableMapper.MapFrom(globalPKAnalysis));
            allDataTables.Add(dataTable);

            return(allDataTables);
        }
Exemple #7
0
        public IEnumerable <DataTable> ExportToDataTable(IEnumerable <DataColumn> dataColumns, GlobalPKAnalysis globalPKAnalysis, DataTable dataTable, IEnumerable <Simulation> simulations)
        {
            var allDataTables  = new List <DataTable>();
            var allSimulations = simulations.ToList();

            if (allSimulations.Any())
            {
                string ColumnNameRetriever(DataColumn dataColumn) => _quantityDisplayPathMapper.DisplayPathAsStringFor(simulationForColumn(dataColumn, allSimulations), dataColumn);

                allDataTables.AddRange(_dataRepositoryTask.ToDataTable(dataColumns, ColumnNameRetriever, _dimensionFactory.MergedDimensionFor));
            }

            allDataTables.Add(_globalPKAnalysisToDataTableMapper.MapFrom(globalPKAnalysis));
            allDataTables.Add(dataTable);

            return(allDataTables);
        }
Exemple #8
0
        protected override void Context()
        {
            _dataRepositoryTask = A.Fake <IDataRepositoryTask>();
            _dimensionFactory   = A.Fake <IDimensionFactory>();
            sut = new WeightedDataRepositoryToDataTableMapper(_dataRepositoryTask, _dimensionFactory);

            var baseGrid = new BaseGrid("name", _dimensionFactory.NoDimension)
            {
                Values = new[] { 0.0f }
            };
            var dataColumn = new DataColumn {
                Values = new[] { 0.0f }
            };

            _dataRepository = new DataRepository {
                baseGrid, dataColumn
            };

            _weightedObservedData = new WeightedObservedData(_dataRepository);

            A.CallTo(() => _dataRepositoryTask.ToDataTable(A <IEnumerable <DataColumn> > ._, A <bool> ._, A <bool> ._, A <bool> ._)).Returns(new[] { new DataTable() });
        }
 protected override DataTable MapDataTableFromColumns()
 {
     return(_dataRepositoryTask.ToDataTable(_observedData, forceColumnTypeAsObject: true).First());
 }
        public Task ExportToCsvAsync(ISimulation simulation, DataRepository results, string fileName)
        {
            var dataTable = _dataRepositoryTask.ToDataTable(results, x => _quantityDisplayPathMapper.DisplayPathAsStringFor(simulation, x), x => x.Dimension, useDisplayUnit: false).First();

            return(Task.Run(() => dataTable.ExportToCSV(fileName)));
        }
 protected override DataTable MapDataTableFromColumns()
 {
     return(_dataRepositoryTask.ToDataTable(_observedData, new DataColumnExportOptions {
         ForceColumnTypeAsObject = true
     }).First());
 }
 private DataTable tableFor(IEnumerable <DataColumn> observedData)
 {
     return(_dataRepositoryTask.ToDataTable(observedData).First());
 }
Exemple #13
0
 protected override DataTable MapDataTableFromColumns()
 {
     return(_dataRepositoryTask.ToDataTable(_observedData, formatOutput: false).First());
 }