public BackgroundProteome(BackgroundProteomeSpec backgroundProteomeSpec, bool queryDigestions) : base(backgroundProteomeSpec.Name, backgroundProteomeSpec.DatabasePath) { DigestionNames = new HashSet <string>(); if (!IsNone) { try { using (var proteomeDb = OpenProteomeDb()) { if (queryDigestions) { DigestionNames.UnionWith(proteomeDb.ListDigestions().Select(digestion => digestion.Name)); } } } catch (Exception) { DatabaseInvalid = true; } } if (queryDigestions) { DatabaseValidated = true; } }
public override bool Equals(object obj) { if (this == obj) { return(true); } BackgroundProteomeSpec that = obj as BackgroundProteomeSpec; if (that == null) { return(false); } return(Name == that.Name && DatabasePath == that.DatabasePath); }
public BackgroundProteome(BackgroundProteomeSpec backgroundProteomeSpec) : base(backgroundProteomeSpec.Name, backgroundProteomeSpec.DatabasePath) { _cache = new BackgroundProteomeMetadataCache(this); if (!IsNone) { try { OpenProteomeDb(); } catch (Exception) { DatabaseInvalid = true; } } DatabaseValidated = true; }
public BackgroundProteome(BackgroundProteomeSpec backgroundProteomeSpec, bool queryDigestions) : base(backgroundProteomeSpec.Name, backgroundProteomeSpec.DatabasePath) { DigestionNames = new HashSet<string>(); if (!IsNone) { try { using (var proteomeDb = OpenProteomeDb()) { if (queryDigestions) DigestionNames.UnionWith(proteomeDb.ListDigestions().Select(digestion => digestion.Name)); } } catch (Exception) { DatabaseInvalid = true; } } if (queryDigestions) DatabaseValidated = true; }
private BackgroundProteomeSpec FindBackgroundProteome(string documentPath, BackgroundProteomeSpec backgroundProteomeSpec) { var result = Settings.Default.BackgroundProteomeList.GetBackgroundProteomeSpec(backgroundProteomeSpec.Name); if (result != null) { if (result.IsNone || File.Exists(result.DatabasePath)) return result; } string fileName = Path.GetFileName(backgroundProteomeSpec.DatabasePath); // First look for the file name in the document directory string pathBackgroundProteome = Path.Combine(Path.GetDirectoryName(documentPath) ?? string.Empty, fileName ?? string.Empty); if (File.Exists(pathBackgroundProteome)) return new BackgroundProteomeSpec(backgroundProteomeSpec.Name, pathBackgroundProteome); // In the user's default library directory pathBackgroundProteome = Path.Combine(Settings.Default.ProteomeDbDirectory, fileName ?? string.Empty); if (File.Exists(pathBackgroundProteome)) return new BackgroundProteomeSpec(backgroundProteomeSpec.Name, pathBackgroundProteome); _out.WriteLine(Resources.CommandLine_FindBackgroundProteome_Warning__Could_not_find_the_background_proteome_file__0__, Path.GetFileName(fileName)); return BackgroundProteomeList.GetDefault(); }
public bool EqualsSpec(BackgroundProteomeSpec other) { return(Name == other.Name && DatabasePath == other.DatabasePath); }
public void OkDialog() { if (!_messageBoxHelper.ValidateNameTextBox(textName, out _name)) { return; } if (_backgroundProteomeSpec == null || _name != _backgroundProteomeSpec.Name) { foreach (BackgroundProteomeSpec backgroundProteomeSpec in _existing) { if (_name == backgroundProteomeSpec.Name) { _messageBoxHelper.ShowTextBoxError(textName, Resources.BuildBackgroundProteomeDlg_OkDialog_The_background_proteome__0__already_exists, _name); return; } } } if (string.IsNullOrEmpty(textPath.Text)) { _messageBoxHelper.ShowTextBoxError(textPath, Resources.BuildBackgroundProteomeDlg_OkDialog_You_must_specify_a_proteome_file); return; } try { if (textPath.Text != Path.GetFullPath(textPath.Text)) { _messageBoxHelper.ShowTextBoxError(textPath, Resources.BuildBackgroundProteomeDlg_OkDialog_Please_specify_a_full_path_to_the_proteome_file); return; } else if (!File.Exists(textPath.Text)) { _messageBoxHelper.ShowTextBoxError(textPath, string.Format(Resources.BuildBackgroundProteomeDlg_OkDialog_The_proteome_file__0__does_not_exist, textPath.Text)); return; } ProteomeDb.OpenProteomeDb(textPath.Text); } catch (Exception x) { // In case exception is thrown opening protdb string message = TextUtil.LineSeparate(Resources.BuildBackgroundProteomeDlg_OkDialog_The_proteome_file_is_not_valid, Resources.BuildBackgroundProteomeDlg_OkDialog_Choose_a_valid_proteome_file__or_click_the__Create__button_to_create_a_new_one_from_FASTA_files); MessageDlg.ShowWithException(this, message, x); return; } _databasePath = textPath.Text; _name = textName.Text; _backgroundProteomeSpec = new BackgroundProteomeSpec(_name, _databasePath); DialogResult = DialogResult.OK; Close(); }
public BackgroundProteome(BackgroundProteomeSpec backgroundProteomeSpec) : this(backgroundProteomeSpec, false) { // We intentionally do not copy the _needsProteinMetadataSearch member }
private bool? _needsProteinMetadataSearch; // Nullable for lazy evaluation, for quicker ctor #endregion Fields #region Constructors public BackgroundProteome(BackgroundProteomeSpec backgroundProteomeSpec) : this(backgroundProteomeSpec, false) { // We intentionally do not copy the _needsProteinMetadataSearch member }
private BackgroundProteomeSpec FindBackgroundProteome(IWin32Window parent, string documentPath, BackgroundProteomeSpec backgroundProteomeSpec) { var result = Settings.Default.BackgroundProteomeList.GetBackgroundProteomeSpec(backgroundProteomeSpec.Name); if (result != null) { if (File.Exists(result.DatabasePath)) return result; } if (documentPath == null) return null; // Is the saved path correct? Then just use that. if (File.Exists(backgroundProteomeSpec.DatabasePath)) return new BackgroundProteomeSpec(backgroundProteomeSpec.Name, backgroundProteomeSpec.DatabasePath); string fileName = Path.GetFileName(backgroundProteomeSpec.DatabasePath); // First look for the file name in the document directory string pathBackgroundProteome = Path.Combine(Path.GetDirectoryName(documentPath) ?? string.Empty, fileName ?? string.Empty); if (File.Exists(pathBackgroundProteome)) return new BackgroundProteomeSpec(backgroundProteomeSpec.Name, pathBackgroundProteome); // In the user's default library directory pathBackgroundProteome = Path.Combine(Settings.Default.ProteomeDbDirectory ?? string.Empty, fileName ?? string.Empty); if (File.Exists(pathBackgroundProteome)) return new BackgroundProteomeSpec(backgroundProteomeSpec.Name, pathBackgroundProteome); using (var dlg = new MissingFileDlg { FileHint = fileName, ItemName = backgroundProteomeSpec.Name, ItemType = Resources.SkylineWindow_FindBackgroundProteome_Background_Proteome, Filter = TextUtil.FileDialogFilterAll(Resources.SkylineWindow_FindBackgroundProteome_Proteome_File, ProteomeDb.EXT_PROTDB), FileDlgInitialPath = Settings.Default.ProteomeDbDirectory, Title = Resources.SkylineWindow_FindBackgroundProteome_Find_Background_Proteome }) { if (dlg.ShowDialog(parent) == DialogResult.OK) { if (dlg.FilePath == null) { return BackgroundProteomeList.GetDefault(); } Settings.Default.ProteomeDbDirectory = Path.GetDirectoryName(dlg.FilePath); return new BackgroundProteomeSpec(backgroundProteomeSpec.Name, dlg.FilePath); } } return null; }
public BackgroundProteome(BackgroundProteomeSpec backgroundProteomeSpec) : this(backgroundProteomeSpec, false) { // We intentionally do not copy cache information }