/// <summary> /// Parse the mass list text, then show a status dialog if: /// errors are found, or /// errors are not found and "silentSuccess" arg is false /// Shows a special error message and forces the user to alter their entry if the list is missing Precursor m/z, Product m/z or Peptide Sequence. /// Return false if no errors found. /// </summary> /// <param name="silentSuccess">If true, don't show the confirmation dialog when there are no errors</param> /// <returns>True if list contains any errors and user does not elect to ignore them</returns> private bool CheckForErrors(bool silentSuccess) { IdentityPath testSelectPath = null; List <MeasuredRetentionTime> testIrtPeptides = null; List <SpectrumMzInfo> testLibrarySpectra = null; List <TransitionImportErrorInfo> testErrorList = null; List <PeptideGroupDocNode> testPeptideGroups = null; var columns = Importer.RowReader.Indices; MissingEssentialColumns = new List <string>(); CheckEssentialColumn(new Tuple <int, string>(columns.PeptideColumn, Resources.ImportTransitionListColumnSelectDlg_PopulateComboBoxes_Peptide_Modified_Sequence)); CheckEssentialColumn(new Tuple <int, string>(columns.PrecursorColumn, Resources.ImportTransitionListColumnSelectDlg_PopulateComboBoxes_Precursor_m_z)); CheckEssentialColumn(new Tuple <int, string>(columns.ProductColumn, Resources.ImportTransitionListColumnSelectDlg_PopulateComboBoxes_Product_m_z)); var docNew = _docCurrent.ImportMassList(_inputs, Importer, null, _insertPath, out testSelectPath, out testIrtPeptides, out testLibrarySpectra, out testErrorList, out testPeptideGroups); if (testErrorList.Any()) { // There are errors, show them to user var isErrorAll = ReferenceEquals(docNew, _docCurrent); DialogResult response; if (MissingEssentialColumns.Count != 0) { // If the transition list is missing essential columns, tell the user in a // readable way string errorMessage = Resources.ImportTransitionListErrorDlg_ImportTransitionListErrorDlg_This_transition_list_cannot_be_imported_as_it_does_not_provide_values_for_; for (var i = 0; i < MissingEssentialColumns.Count; i++) { errorMessage = errorMessage + @" " + MissingEssentialColumns[i]; } MessageDlg.Show(this, errorMessage); return(true); } else { using (var dlg = new ImportTransitionListErrorDlg(testErrorList, isErrorAll, silentSuccess)) { response = dlg.ShowDialog(this); } return(response == DialogResult.Cancel); // There are errors, and user does not want to ignore them } } else if (!silentSuccess) { // No errors, confirm this to user MessageDlg.Show(this, Resources.PasteDlg_ShowNoErrors_No_errors); } return(false); // No errors }
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 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 VariableModImportListTest() { // TODO: Deal with multiple variable modifications that produce the same // precursor mass but different product ion masses SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault()); var staticMods = new List<StaticMod>(document.Settings.PeptideSettings.Modifications.StaticModifications); staticMods.AddRange(new[] { new StaticMod("Met Sulfoxide", "M", null, true, "O", LabelAtoms.None, RelativeRT.Matching, null, null, new[] { new FragmentLoss("SOCH4") }), new StaticMod("Met Sulfone", "M", null, true, "O2", LabelAtoms.None, RelativeRT.Matching, null, null, null), new StaticMod("Phospho", "S,T,Y", null, true, "PO3H", LabelAtoms.None, RelativeRT.Matching, null, null, new[] {new FragmentLoss("PO4H3")}), new StaticMod("K(GlyGly)", "K", null, true, "N2H6C4O2", LabelAtoms.None, RelativeRT.Matching, null, null, null), }); document = document.ChangeSettings(document.Settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(staticMods))); IdentityPath pathTo; List<MeasuredRetentionTime> irtPeptides; List<SpectrumMzInfo> librarySpectra; List<TransitionImportErrorInfo> errorList; var inputsPhospho = new MassListInputs(TEXT_PHOSPHO_TRANSITION_LIST, CultureInfo.InvariantCulture, TextUtil.SEPARATOR_CSV); document.ImportMassList(inputsPhospho, null, out pathTo, out irtPeptides, out librarySpectra, out errorList); Assert.AreEqual(27, errorList.Count); 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(1, errorList[0].Column); Assert.AreEqual(40, errorList[0].Row); var docHighMax = document.ChangeSettings(document.Settings.ChangeTransitionInstrument(inst => inst.ChangeMaxMz(1800))); var docList = docHighMax.ImportMassList(inputsPhospho, null, out pathTo); AssertEx.Serializable(docList); AssertEx.IsDocumentState(docList, 3, 68, 134, 157, 481); foreach (var nodeTran in docList.PeptideTransitions) { var it = nodeTran.Transition.IonType; Assert.IsTrue(it == IonType.y || it == IonType.b || it == IonType.precursor, "Found unexpected non b, y or precursor ion type."); } var inputsMultiLoss = new MassListInputs(TEXT_PHOSPHO_MULTI_LOSS, CultureInfo.InvariantCulture, TextUtil.SEPARATOR_CSV); docHighMax.ImportMassList(inputsMultiLoss, null, out pathTo, out irtPeptides, out librarySpectra, out errorList); Assert.AreEqual(5, errorList.Count); AssertEx.AreComparableStrings(Resources.MassListRowReader_CalcTransitionExplanations_Product_m_z_value__0__in_peptide__1__has_no_matching_product_ion, errorList[0].ErrorMessage, 2); Assert.AreEqual(1, errorList[0].Column); Assert.AreEqual(2, errorList[0].Row); var docMultiLos = docHighMax.ChangeSettings(docHighMax.Settings.ChangePeptideModifications(mods => mods.ChangeMaxNeutralLosses(2))); docList = docMultiLos.ImportMassList(inputsMultiLoss, null, out pathTo); AssertEx.IsDocumentState(docList, 4, 4, 4, 12); }
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; }