/// <summary> /// Initializes a new instance of the <see cref="SearchSettingsViewModel"/> class. /// Initializes from <see cref="Models.MsPfParameters" />, MSPathFinder parameters. /// </summary> /// <param name="dialogService">Dialog service for opening dialogs from view model</param> /// <param name="mspfParameters">The MSPathFinder parameters.</param> public SearchSettingsViewModel(IMainDialogService dialogService, MsPfParameters mspfParameters) : this(dialogService) { if (mspfParameters == null) { return; } SearchModifications.AddRange( mspfParameters.Modifications.Select( searchMod => new SearchModificationViewModel(this.dialogService) { SearchModification = searchMod })); MinSequenceLength = mspfParameters.MinSequenceLength; MaxSequenceLength = mspfParameters.MaxSequenceLength; MinSequenceMass = mspfParameters.MinSequenceMass; MaxSequenceMass = mspfParameters.MaxSequenceMass; MinPrecursorIonCharge = mspfParameters.MinPrecursorIonCharge; MaxPrecursorIonCharge = mspfParameters.MaxPrecursorIonCharge; MinProductIonCharge = mspfParameters.MinProductIonCharge; MaxProductIonCharge = mspfParameters.MaxPrecursorIonCharge; PrecursorIonToleranceValue = mspfParameters.PrecursorTolerancePpm.GetValue(); ProductIonToleranceValue = mspfParameters.ProductIonTolerancePpm.GetValue(); MaxDynamicModificationsPerSequence = mspfParameters.MaxDynamicModificationsPerSequence; }
/// <summary> /// Opens parameter file from .PARAM file.. /// </summary> /// <param name="filePath">The path of the parameter file.</param> /// <returns> /// Parsed MSPathFinder parameters. Returns null if file does not exist. /// Throws exception if file is not formatted correctly. /// </returns> private static MsPfParameters ReadFromParameterFile(string filePath) { if (!File.Exists(filePath)) { return(null); } var file = File.ReadAllLines(filePath); var param = new MsPfParameters(); foreach (var line in file) { var parts = line.Split('\t'); if (parts.Length < 2) { continue; } switch (parts[0]) { case "SpecFile": param.PuSpecFile = parts[1]; break; case "DatabaseFile": param.DatabaseFile = parts[1]; break; case "FeatureFile": param.FeatureFile = parts[1]; break; case "SearchMode": param.SearchMode = Convert.ToInt32(parts[1]); break; case "Tda": param.Tda = parts[1]; break; case "PrecursorIonTolerancePpm": param.PrecursorTolerancePpm = new Tolerance(Convert.ToDouble(parts[1]), ToleranceUnit.Ppm); break; case "ProductIonTolerancePpm": param.ProductIonTolerancePpm = new Tolerance(Convert.ToDouble(parts[1]), ToleranceUnit.Ppm); break; case "MinSequenceLength": param.MinSequenceLength = Convert.ToInt32(parts[1]); break; case "MaxSequenceLength": param.MaxSequenceLength = Convert.ToInt32(parts[1]); break; case "MinPrecursorIonCharge": param.MinPrecursorIonCharge = Convert.ToInt32(parts[1]); break; case "MaxPrecursorIonCharge": param.MaxPrecursorIonCharge = Convert.ToInt32(parts[1]); break; case "MinProductIonCharge": param.MinProductIonCharge = Convert.ToInt32(parts[1]); break; case "MaxProductIonCharge": param.MaxProductIonCharge = Convert.ToInt32(parts[1]); break; case "MinSequenceMass": param.MinSequenceMass = Convert.ToDouble(parts[1]); break; case "MaxSequenceMass": param.MaxSequenceMass = Convert.ToDouble(parts[1]); break; case "MinFeatureProbability": param.MinFeatureProbablility = Convert.ToDouble(parts[1]); break; case "MaxDynamicModificationsPerSequence": param.MaxDynamicModificationsPerSequence = Convert.ToInt32(parts[1]); break; case "Modification": param.Modifications.Add(ParseModification(parts[1])); break; } } if (param.PrecursorTolerancePpm == null && param.ProductIonTolerancePpm != null) { param.PrecursorTolerancePpm = param.ProductIonTolerancePpm; } if (param.PrecursorTolerancePpm != null && param.ProductIonTolerancePpm == null) { param.ProductIonTolerancePpm = param.PrecursorTolerancePpm; } return(param); }