예제 #1
0
        /// <summary>
        /// Updates the program's settings using the .ini settings file passed to the constructor
        /// </summary>
        public void UpdateSettings()
        {
            /*
             * Files Settings
             */
            var inputFilePath = GetValueForKey("Files", "InputFileName");

            if (!string.IsNullOrWhiteSpace(inputFilePath))
            {
                var directoryName = Path.GetDirectoryName(inputFilePath);
                if (directoryName != null && !directoryName.Equals(string.Empty))
                {
                    Settings.InputDirectory = Path.GetDirectoryName(inputFilePath) + "\\";
                }

                Settings.InputFileName = Path.GetFileName(inputFilePath);
            }

            var outputDirectory = GetValueForKey("Files", "OutputDirectory");

            if (!string.IsNullOrWhiteSpace(outputDirectory))
            {
                Settings.OutputDirectory = outputDirectory + "\\";
            }
            else
            {
                Settings.OutputDirectory = Settings.InputDirectory;
            }

            var deconToolsFilterFile = GetValueForKey("Files", "DeconToolsFilterFileName");

            if (!string.IsNullOrWhiteSpace(deconToolsFilterFile))
            {
                Settings.DeconToolsFilterFileName = deconToolsFilterFile;

                Console.WriteLine("Reading " + deconToolsFilterFile);
                var loader = new DeconToolsFilterLoader(deconToolsFilterFile);

                loader.DisplayFilters();

                Settings.DeconToolsFilterList = loader.DeconToolsFilterList;
            }
            else
            {
                Settings.DeconToolsFilterList = new List <DeconToolsFilter>();
            }

            /*
             * DataFilters Settings
             */
            var maxIsotopicFit = GetValueForKey("DataFilters", "MaxIsotopicFit");

            if (!string.IsNullOrWhiteSpace(maxIsotopicFit))
            {
                Settings.FitMax = float.Parse(maxIsotopicFit);
            }

            var maxIScore = GetValueForKey("DataFilters", "MaxIScore");

            if (!string.IsNullOrWhiteSpace(maxIScore))
            {
                Settings.InterferenceScoreMax = float.Parse(maxIScore);
            }

            var minimumIntensity = GetValueForKey("DataFilters", "MinimumIntensity");

            if (!string.IsNullOrWhiteSpace(minimumIntensity))
            {
                Settings.IntensityMin = float.Parse(minimumIntensity);
            }

            var useHardCodedFilters = GetValueForKey("DataFilters", "UseHardCodedFilters");

            if (!string.IsNullOrWhiteSpace(useHardCodedFilters))
            {
                Settings.FilterUsingHardCodedFilters = bool.Parse(useHardCodedFilters);
            }

            var filterFlaggedData = GetValueForKey("DataFilters", "FilterFlaggedData");

            if (!string.IsNullOrWhiteSpace(filterFlaggedData))
            {
                Settings.FilterFlaggedData = bool.Parse(filterFlaggedData);
            }

            var imsMinScan = GetValueForKey("DataFilters", "IMSMinScan");

            if (!string.IsNullOrWhiteSpace(imsMinScan))
            {
                Settings.ScanIMSMin = int.Parse(imsMinScan);
            }

            var imsMaxScan = GetValueForKey("DataFilters", "IMSMaxScan");

            if (!string.IsNullOrWhiteSpace(imsMaxScan))
            {
                Settings.ScanIMSMax = int.Parse(imsMaxScan);
                if (Settings.ScanIMSMax <= 0)
                {
                    Settings.ScanIMSMax = int.MaxValue;
                }
            }

            var lcMinScan = GetValueForKey("DataFilters", "LCMinScan");

            if (!string.IsNullOrWhiteSpace(lcMinScan))
            {
                Settings.ScanLCMin = int.Parse(lcMinScan);
            }

            var lcMaxScan = GetValueForKey("DataFilters", "LCMaxScan");

            if (!string.IsNullOrWhiteSpace(lcMaxScan))
            {
                Settings.ScanLCMax = int.Parse(lcMaxScan);
                if (Settings.ScanLCMax <= 0)
                {
                    Settings.ScanLCMax = int.MaxValue;
                }
            }

            var monoisotopicMassMin = GetValueForKey("DataFilters", "MonoMassStart");

            if (!string.IsNullOrWhiteSpace(monoisotopicMassMin))
            {
                Settings.MassMonoisotopicStart = float.Parse(monoisotopicMassMin);
            }

            var monoisotopicMassMax = GetValueForKey("DataFilters", "MonoMassEnd");

            if (!string.IsNullOrWhiteSpace(monoisotopicMassMax))
            {
                Settings.MassMonoisotopicEnd = float.Parse(monoisotopicMassMax);
            }

            var frameTypeFilter = GetValueForKey("DataFilters", "FrameType");

            if (!string.IsNullOrWhiteSpace(frameTypeFilter))
            {
                Settings.FrameTypeFilter = (UIMFData.FrameType) short.Parse(frameTypeFilter);
            }

            /*
             * UMCCreationOptions Settings
             */
            var ignoreImsDriftTime = GetValueForKey("UMCCreationOptions", "IgnoreIMSDriftTime");

            if (!string.IsNullOrWhiteSpace(ignoreImsDriftTime))
            {
                Settings.IgnoreIMSDriftTime = bool.Parse(ignoreImsDriftTime);
            }

            // Monoisotopic mass constraint, in ppm
            var monoMassConstraint = GetValueForKey("UMCCreationOptions", "MonoMassConstraint");

            if (!string.IsNullOrWhiteSpace(monoMassConstraint))
            {
                Settings.MassMonoisotopicConstraint = float.Parse(monoMassConstraint);
            }

            // Obsolete:
            // var monoMassConstraintIsPPM = GetValueForKey("UMCCreationOptions", "MonoMassConstraintIsPPM");

            // Obsolete:
            // var useGenericNET = GetValueForKey("UMCCreationOptions", "UseGenericNET");

            var useCharge = GetValueForKey("UMCCreationOptions", "UseCharge");

            if (!string.IsNullOrWhiteSpace(useCharge))
            {
                Settings.UseCharge = bool.Parse(useCharge);
            }

            var minFeatureLengthPoints = GetValueForKey("UMCCreationOptions", "MinFeatureLengthPoints");

            if (!string.IsNullOrWhiteSpace(minFeatureLengthPoints))
            {
                Settings.FeatureLengthMin = short.Parse(minFeatureLengthPoints);
            }

            var lcGapMaxSize = GetValueForKey("UMCCreationOptions", "LCGapMaxSize");

            if (!string.IsNullOrWhiteSpace(lcGapMaxSize))
            {
                Settings.LCGapSizeMax = short.Parse(lcGapMaxSize);
            }

            var imsMaxDaCorrection = GetValueForKey("UMCCreationOptions", "IMSMaxDaCorrection");

            if (!string.IsNullOrWhiteSpace(imsMaxDaCorrection))
            {
                int readValue = short.Parse(imsMaxDaCorrection);

                Settings.IMSDaCorrectionMax = readValue < 0 ? 0 : readValue;
            }

            // Obsolete:
            // var umcFitScoreMinimum = GetValueForKey("UMCCreationOptions", "UMCFitScoreMinimum");

            // Obsolete: splitting is always enabled when finding LC-IMS-MS features
            // umcSplittingEnabled = GetValueForKey("UMCSplittingOptions", "Split");

            // Obsolete (not implemented)
            // minimumDifferenceInMedianPpmMass = GetValueForKey("UMCSplittingOptions", "MinimumDifferenceInMedianPpmMassToSplit");

            /*
             * DriftProfile Settings
             */
            var useConformationDetection = GetValueForKey("DriftProfileOptions", "UseConformationDetection");

            if (!string.IsNullOrWhiteSpace(useConformationDetection))
            {
                Settings.UseConformationDetection = bool.Parse(useConformationDetection);
            }

            var smoothingStDev = GetValueForKey("DriftProfileOptions", "SmoothingStDev");

            if (!string.IsNullOrWhiteSpace(smoothingStDev))
            {
                Settings.SmoothingStDev = float.Parse(smoothingStDev);
            }

            /*
             * PostCreationFiltering Settings
             */
            var filterIsosToSinglePoint = GetValueForKey("PostCreationFilteringOptions", "FilterIsosToSinglePoint");

            if (!string.IsNullOrWhiteSpace(filterIsosToSinglePoint))
            {
                Settings.FilterIsosToSinglePoint = bool.Parse(filterIsosToSinglePoint);
            }
        }
예제 #2
0
        public void CreateSettings()
        {
            /*
             * Files Settings
             */
            var value = IniReadValue("Files", "InputFileName");

            if (!string.IsNullOrWhiteSpace(value))
            {
                var directoryName = Path.GetDirectoryName(value);
                if (directoryName != null && !directoryName.Equals(string.Empty))
                {
                    Settings.InputDirectory = Path.GetDirectoryName(value) + "\\";
                }

                Settings.InputFileName = Path.GetFileName(value);
            }

            value = IniReadValue("Files", "OutputDirectory");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.OutputDirectory = value + "\\";
            }
            else
            {
                Settings.OutputDirectory = Settings.InputDirectory;
            }

            value = IniReadValue("Files", "DeconToolsFilterFileName");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.DeconToolsFilterFileName = value;
                var loader = new DeconToolsFilterLoader(value);
                Settings.DeconToolsFilterList = loader.DeconToolsFilterList;
            }
            else
            {
                Settings.DeconToolsFilterList = new System.Collections.Generic.List <DeconToolsFilter>();
            }

            /*
             * DataFilters Settings
             */
            value = IniReadValue("DataFilters", "MaxIsotopicFit");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.FitMax = float.Parse(value);
            }

            value = IniReadValue("DataFilters", "MaxIScore");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.InterferenceScoreMax = float.Parse(value);
            }

            value = IniReadValue("DataFilters", "MinimumIntensity");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.IntensityMin = float.Parse(value);
            }

            value = IniReadValue("DataFilters", "UseHardCodedFilters");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.FilterUsingHardCodedFilters = bool.Parse(value);
            }

            value = IniReadValue("DataFilters", "FilterFlaggedData");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.FilterFlaggedData = bool.Parse(value);
            }

            value = IniReadValue("DataFilters", "IMSMinScan");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.ScanIMSMin = int.Parse(value);
            }

            value = IniReadValue("DataFilters", "IMSMaxScan");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.ScanIMSMax = int.Parse(value);
                if (Settings.ScanIMSMax <= 0)
                {
                    Settings.ScanIMSMax = int.MaxValue;
                }
            }

            value = IniReadValue("DataFilters", "LCMinScan");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.ScanLCMin = int.Parse(value);
            }

            value = IniReadValue("DataFilters", "LCMaxScan");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.ScanLCMax = int.Parse(value);
                if (Settings.ScanLCMax <= 0)
                {
                    Settings.ScanLCMax = int.MaxValue;
                }
            }

            value = IniReadValue("DataFilters", "MonoMassStart");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.MassMonoisotopicStart = float.Parse(value);
            }

            value = IniReadValue("DataFilters", "MonoMassEnd");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.MassMonoisotopicEnd = float.Parse(value);
            }

            value = IniReadValue("DataFilters", "FrameType");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.FrameTypeFilter = (DataReader.FrameType) short.Parse(value);
            }

            /*
             * UMCCreationOptions Settings
             */
            value = IniReadValue("UMCCreationOptions", "IgnoreIMSDriftTime");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.IgnoreIMSDriftTime = bool.Parse(value);
            }

            value = IniReadValue("UMCCreationOptions", "MonoMassConstraint");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.MassMonoisotopicConstraint = float.Parse(value);
            }

            value = IniReadValue("UMCCreationOptions", "MonoMassConstraintIsPPM");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.MassMonoisotopicConstraintIsPPM = bool.Parse(value);
            }

            value = IniReadValue("UMCCreationOptions", "UseGenericNET");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.UseGenericNET = bool.Parse(value);
            }

            value = IniReadValue("UMCCreationOptions", "UseCharge");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.UseCharge = bool.Parse(value);
            }

            value = IniReadValue("UMCCreationOptions", "MinFeatureLengthPoints");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.FeatureLengthMin = short.Parse(value);
            }

            value = IniReadValue("UMCCreationOptions", "LCGapMaxSize");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.LCGapSizeMax = short.Parse(value);
            }

            value = IniReadValue("UMCCreationOptions", "IMSMaxDaCorrection");
            if (!string.IsNullOrWhiteSpace(value))
            {
                int readValue = short.Parse(value);

                Settings.IMSDaCorrectionMax = readValue < 0 ? 0 : readValue;
            }

            value = IniReadValue("UMCCreationOptions", "UMCFitScoreMinimum");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.UMCFitScoreMinimum = float.Parse(value);
            }

            /*
             * UMCSplittingOptions Settings
             */
            value = IniReadValue("UMCSplittingOptions", "Split");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.Split = bool.Parse(value);
            }

            value = IniReadValue("UMCSplittingOptions", "MinimumDifferenceInMedianPpmMassToSplit");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.MinimumDifferenceInMedianPpmMassToSplit = short.Parse(value);
            }

            /*
             * DriftProfile Settings
             */
            value = IniReadValue("DriftProfileOptions", "UseConformationDetection");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.UseConformationDetection = bool.Parse(value);
            }

            value = IniReadValue("DriftProfileOptions", "SmoothingStDev");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.SmoothingStDev = float.Parse(value);
            }

            /*
             * PostCreationFiltering Settings
             */
            value = IniReadValue("PostCreationFilteringOptions", "FilterIsosToSinglePoint");
            if (!string.IsNullOrWhiteSpace(value))
            {
                Settings.FilterIsosToSinglePoint = bool.Parse(value);
            }
        }