private bool ProcessTransitionList() { if (!File.Exists(txtTransitionList.Text)) { MessageDlg.Show(this, Resources.ChooseIrtStandardPeptides_OkDialog_Transition_list_field_must_contain_a_path_to_a_valid_file_); txtTransitionList.Focus(); return(false); } try { var inputs = new MassListInputs(txtTransitionList.Text); Document = Document.ImportMassList(inputs, new IdentityPath(Document.PeptideGroups.First().Id), out _, out _irtAdd, out _librarySpectra, out var errorList); if (errorList.Any()) { throw new InvalidDataException(errorList[0].ErrorMessage); } IrtFile = txtTransitionList.Text; } catch (Exception x) { MessageDlg.ShowWithException(this, string.Format(Resources.CreateIrtCalculatorDlg_OkDialog_Error_reading_iRT_standards_transition_list___0_, x.Message), x); return(false); } return(true); }
public void OkDialog() { if (radioProtein.Checked) { if (comboProteins.SelectedIndex == -1) { MessageDlg.Show(this, Resources.ChooseIrtStandardPeptidesDlg_OkDialog_Please_select_a_protein_containing_the_list_of_standard_peptides_for_the_iRT_calculator_); comboProteins.Focus(); return; } var peptideGroupItem = comboProteins.SelectedItem as PeptideGroupItem; if (peptideGroupItem != null) { var protein = peptideGroupItem.PeptideGroup; _irtPeptideSequences = new HashSet <string>(); foreach (var peptide in protein.Peptides) { _irtPeptideSequences.Add(peptide.ModifiedSequence); } if (Document.PeptideGroupCount > 0) { var pathFrom = Document.GetPathTo(Document.FindNodeIndex(protein.Id)); var pathTo = Document.GetPathTo(Document.FindNodeIndex(Document.PeptideGroups.First().Id)); if (!Equals(pathFrom, pathTo)) { IdentityPath newLocation; Document = Document.MoveNode(pathFrom, pathTo, out newLocation); } } } } else { if (!File.Exists(txtTransitionList.Text)) { MessageDlg.Show(this, Resources.ChooseIrtStandardPeptides_OkDialog_Transition_list_field_must_contain_a_path_to_a_valid_file_); txtTransitionList.Focus(); return; } try { IdentityPath selectPath; List <TransitionImportErrorInfo> errorList; var inputs = new MassListInputs(txtTransitionList.Text); Document = Document.ImportMassList(inputs, new IdentityPath(Document.PeptideGroups.First().Id), out selectPath, out _irtPeptides, out _librarySpectra, out errorList); if (errorList.Any()) { throw new InvalidDataException(errorList[0].ErrorMessage); } IrtFile = txtTransitionList.Text; } catch (Exception x) { MessageDlg.ShowWithException(this, string.Format(Resources.CreateIrtCalculatorDlg_OkDialog_Error_reading_iRT_standards_transition_list___0_, x.Message), x); return; } } DialogResult = DialogResult.OK; }
private static SrmDocument InitWiffDocument(TestFilesDir testFilesDir) { const LabelAtoms labelAtoms = LabelAtoms.C13 | LabelAtoms.N15; List <StaticMod> heavyMods = new List <StaticMod> { new StaticMod("Heavy K", "K", ModTerminus.C, null, labelAtoms, null, null), new StaticMod("Heavy R", "R", ModTerminus.C, null, labelAtoms, null, null), }; SrmSettings settings = SrmSettingsList.GetDefault(); settings = settings.ChangePeptideModifications(mods => mods.ChangeHeavyModifications(heavyMods)); SrmDocument doc = new SrmDocument(settings); IdentityPath selectPath; string path = testFilesDir.GetTestPath("051309_transition list.csv"); // Product m/z out of range var docError = doc; List <MeasuredRetentionTime> irtPeptides; List <SpectrumMzInfo> librarySpectra; List <TransitionImportErrorInfo> errorList; var inputs = new MassListInputs(path) { FormatProvider = CultureInfo.InvariantCulture, Separator = TextUtil.SEPARATOR_CSV }; docError.ImportMassList(inputs, null, out selectPath, out irtPeptides, out librarySpectra, out errorList); Assert.AreEqual(errorList.Count, 1); AssertEx.AreComparableStrings(TextUtil.SpaceSeparate(Resources.MassListRowReader_CalcTransitionExplanations_The_product_m_z__0__is_out_of_range_for_the_instrument_settings__in_the_peptide_sequence__1_, Resources.MassListRowReader_CalcPrecursorExplanations_Check_the_Instrument_tab_in_the_Transition_Settings), errorList[0].ErrorMessage, 2); Assert.AreEqual(errorList[0].Column, 1); Assert.AreEqual(errorList[0].Row, 19); doc = doc.ChangeSettings(settings.ChangeTransitionInstrument(inst => inst.ChangeMaxMz(1800))); inputs = new MassListInputs(path) { FormatProvider = CultureInfo.InvariantCulture, Separator = TextUtil.SEPARATOR_CSV }; doc = doc.ImportMassList(inputs, null, out selectPath); AssertEx.IsDocumentState(doc, 2, 9, 9, 18, 54); return(doc); }
public ImportTransitionListColumnSelectDlg(MassListImporter importer, SrmDocument docCurrent, MassListInputs inputs, IdentityPath insertPath) { Importer = importer; _docCurrent = docCurrent; _inputs = inputs; _insertPath = insertPath; InitializeComponent(); fileLabel.Text = Importer.Inputs.InputFilename; InitializeComboBoxes(); DisplayData(); PopulateComboBoxes(); //dataGrid.Update(); ResizeComboBoxes(); }
public static SrmDocument RoundTripTransitionList(AbstractMassListExporter exporter) { exporter.Export(null); // Reverse the output lines and import into a new document var docExport = exporter.Document; var docImport = new SrmDocument(docExport.Settings); string transitionList = exporter.MemoryOutput.Values.ToArray()[0].ToString(); IdentityPath pathAdded; var inputs = new MassListInputs(DuplicateAndReverseLines(transitionList, exporter.HasHeaders), CultureInfo.InvariantCulture, TextUtil.SEPARATOR_CSV); docImport = docImport.ImportMassList(inputs, IdentityPath.ROOT, out pathAdded); IsDocumentState(docImport, 1, docExport.MoleculeGroupCount, docExport.MoleculeCount, docExport.MoleculeTransitionGroupCount, docExport.MoleculeTransitionCount); return(docImport); }
public void OkDialog() { IrtType irtType = GetIrtType(); if (textCalculatorName.Text.Length == 0) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_Calculator_name_cannot_be_empty); return; } if (_existing.Select(spec => spec.Name).Contains(textCalculatorName.Text)) { var replaceResult = MultiButtonMsgDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_A_calculator_with_that_name_already_exists___Do_you_want_to_replace_it_, MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false); if (replaceResult == DialogResult.No) { return; } } if (irtType == IrtType.existing) { try { if (!File.Exists(textOpenDatabase.Text)) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_iRT_database_field_must_contain_a_path_to_a_valid_file_); textOpenDatabase.Focus(); return; } var db = IrtDb.GetIrtDb(textOpenDatabase.Text, null); if (db == null) { throw new DatabaseOpeningException(string.Format(Resources.CreateIrtCalculatorDlg_OkDialog_Cannot_read_the_database_file__0_, textOpenDatabase.Text)); } } catch (Exception x) { MessageDlg.ShowWithException(this, string.Format(Resources.CreateIrtCalculatorDlg_OkDialog_Failed_to_open_the_database_file___0_, x.Message), x); return; } } else if (irtType == IrtType.separate_list) { if (textNewDatabase.Text.Length == 0) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_iRT_database_field_must_not_be_empty_); textNewDatabase.Focus(); return; } if (!CreateIrtDatabase(textNewDatabase.Text)) { return; } } else { if (textNewDatabaseProteins.Text.Length == 0) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_iRT_database_field_must_not_be_empty_); textNewDatabaseProteins.Focus(); return; } if (comboBoxProteins.SelectedIndex == -1) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_Please_select_a_protein_containing_the_list_of_standard_peptides_for_the_iRT_calculator_); comboBoxProteins.Focus(); return; } if (!CreateIrtDatabase(textNewDatabaseProteins.Text)) { return; } } // Make a version of the document with the new calculator in it var databaseFileName = irtType == IrtType.existing ? textOpenDatabase.Text : irtType == IrtType.separate_list ? textNewDatabase.Text : textNewDatabaseProteins.Text; var calculator = new RCalcIrt(textCalculatorName.Text, databaseFileName); // CONSIDER: Probably can't use just a static default like 10 below var retentionTimeRegression = new RetentionTimeRegression(calculator.Name, calculator, null, null, RetentionTimeRegression.DEFAULT_WINDOW, new List <MeasuredRetentionTime>()); var docNew = Document.ChangeSettings(Document.Settings.ChangePeptidePrediction(prediction => prediction.ChangeRetentionTime(retentionTimeRegression))); // Import transition list of standards, if applicable if (irtType == IrtType.separate_list) { try { if (!File.Exists(textImportText.Text)) { MessageDlg.Show(this, Resources.CreateIrtCalculatorDlg_OkDialog_Transition_list_field_must_contain_a_path_to_a_valid_file_); return; } IdentityPath selectPath; List <MeasuredRetentionTime> irtPeptides; List <TransitionImportErrorInfo> errorList; var inputs = new MassListInputs(textImportText.Text); docNew = docNew.ImportMassList(inputs, null, out selectPath, out irtPeptides, out _librarySpectra, out errorList); if (errorList.Any()) { throw new InvalidDataException(errorList[0].ErrorMessage); } _dbIrtPeptides = irtPeptides.Select(rt => new DbIrtPeptide(rt.PeptideSequence, rt.RetentionTime, true, TimeSource.scan)).ToList(); IrtFile = textImportText.Text; } catch (Exception x) { MessageDlg.ShowWithException(this, string.Format(Resources.CreateIrtCalculatorDlg_OkDialog_Error_reading_iRT_standards_transition_list___0_, x.Message), x); return; } } else if (irtType == IrtType.protein) { PeptideGroupDocNode selectedGroup = comboBoxProteins.SelectedItem as PeptideGroupDocNode; // ReSharper disable PossibleNullReferenceException _irtPeptideSequences = new HashSet <Target>(selectedGroup.Peptides.Select(pep => pep.ModifiedTarget)); // ReSharper restore PossibleNullReferenceException } Document = docNew; DialogResult = DialogResult.OK; }