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); }
private void UpdateMasses() { string formula = null; LabelAtoms labelAtoms = LabelAtoms.None; if (cbChemicalFormula.Checked) { formula = Formula; } else { labelAtoms = LabelAtoms; string aaString = comboAA.Text; if (!string.IsNullOrEmpty(aaString) && aaString.Length == 1 && AminoAcid.IsAA(aaString[0]) && labelAtoms != LabelAtoms.None) { formula = SequenceMassCalc.GetHeavyFormula(aaString[0], labelAtoms); } } if (string.IsNullOrEmpty(formula)) { // If the mass edit boxes are already enabled, don't clear what a user // may have typed in them. if (!_formulaBox.MassEnabled) { _formulaBox.MonoMass = null; _formulaBox.AverageMass = null; } _formulaBox.MassEnabled = (labelAtoms == LabelAtoms.None); } else { _formulaBox.Formula = formula; } }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(_editing ? (Control)textName : comboMod, out name)) { return; } // Allow updating the original modification if (!_editing || !Equals(name, Modification.Name)) { if (!ModNameAvailable(name)) { helper.ShowTextBoxError(_editing ? (Control)textName : comboMod, Resources.EditStaticModDlg_OkDialog_The_modification__0__already_exists, name); return; } } string aas = comboAA.Text; if (string.IsNullOrEmpty(aas)) { aas = null; } else { // Use the cleanest possible format. var sb = new StringBuilder(); foreach (string aaPart in aas.Split(SEPARATOR_AA)) { string aa = aaPart.Trim(); if (aa.Length == 0) { continue; } if (sb.Length > 0) { sb.Append(", "); // Not L10N } sb.Append(aa); } } string termString = comboTerm.SelectedItem.ToString(); ModTerminus?term = null; if (!string.IsNullOrEmpty(termString)) { term = (ModTerminus)Enum.Parse(typeof(ModTerminus), termString); } if (cbVariableMod.Checked && aas == null && term == null) { MessageDlg.Show(this, Resources.EditStaticModDlg_OkDialog_Variable_modifications_must_specify_amino_acid_or_terminus); comboAA.Focus(); return; } string formula = null; double? monoMass = null; double? avgMass = null; LabelAtoms labelAtoms = LabelAtoms.None; if (cbChemicalFormula.Checked) { formula = Formula; } else { labelAtoms = LabelAtoms; } // Get the losses to know whether any exist below IList <FragmentLoss> losses = null; if (listNeutralLosses.Items.Count > 0) { losses = Losses.ToArray(); } if (!string.IsNullOrEmpty(formula)) { try { SequenceMassCalc.FormulaMass(BioMassCalc.MONOISOTOPIC, formula, SequenceMassCalc.MassPrecision); } catch (ArgumentException x) { _formulaBox.ShowTextBoxErrorFormula(helper, x.Message); return; } } else if (labelAtoms == LabelAtoms.None) { formula = null; // Allow formula and both masses to be empty, if losses are present if (NotZero(_formulaBox.MonoMass) || NotZero(_formulaBox.AverageMass) || losses == null) { // TODO: Maximum and minimum masses should be formalized and applied everywhere double mass; if (!_formulaBox.ValidateMonoText(helper, -1500, 5000, out mass)) { return; } monoMass = mass; if (!_formulaBox.ValidateAverageText(helper, -1500, 5000, out mass)) { return; } avgMass = mass; } // Loss-only modifications may not be variable else if (cbVariableMod.Checked) { MessageDlg.Show(this, Resources.EditStaticModDlg_OkDialog_The_variable_checkbox_only_applies_to_precursor_modification_Product_ion_losses_are_inherently_variable); cbVariableMod.Focus(); return; } } else if (aas == null && term.HasValue) { MessageDlg.Show(this, Resources.EditStaticModDlg_OkDialog_Labeled_atoms_on_terminal_modification_are_not_valid); return; } RelativeRT relativeRT = RelativeRT.Matching; if (comboRelativeRT.Visible && comboRelativeRT.SelectedItem != null) { relativeRT = RelativeRTExtension.GetEnum(comboRelativeRT.SelectedItem.ToString()); } // Store state of the chemical formula checkbox for next use. if (cbChemicalFormula.Visible) { Settings.Default.ShowHeavyFormula = _formulaBox.FormulaVisible; } var newMod = new StaticMod(name, aas, term, cbVariableMod.Checked, formula, labelAtoms, relativeRT, monoMass, avgMass, losses); foreach (StaticMod mod in _existing) { if (newMod.Equivalent(mod) && !(_editing && mod.Equals(_originalModification))) { if (DialogResult.OK == MultiButtonMsgDlg.Show( this, TextUtil.LineSeparate(Resources.EditStaticModDlg_OkDialog_There_is_an_existing_modification_with_the_same_settings, string.Format("'{0}'.", mod.Name), // Not L10N string.Empty, Resources.EditStaticModDlg_OkDialog_Continue), MultiButtonMsgDlg.BUTTON_OK)) { Modification = newMod; DialogResult = DialogResult.OK; } return; } } var uniMod = UniMod.GetModification(name, IsStructural); // If the modification name is not found in Unimod, check if there exists a modification in Unimod that matches // the dialog modification, and prompt the user to to use the Unimod modification instead. if (uniMod == null) { var matchingMod = UniMod.FindMatchingStaticMod(newMod, IsStructural); if (matchingMod != null && (ModNameAvailable(matchingMod.Name) || (_editing && Equals(matchingMod.Name, Modification.Name)))) { var result = MultiButtonMsgDlg.Show( this, TextUtil.LineSeparate(Resources.EditStaticModDlg_OkDialog_There_is_a_Unimod_modification_with_the_same_settings, string.Empty, string.Format(Resources.EditStaticModDlg_OkDialog_Click__Unimod__to_use_the_name___0___, matchingMod.Name), string.Format(Resources.EditStaticModDlg_OkDialog_Click__Custom__to_use_the_name___0___, name)), Resources.EditStaticModDlg_OkDialog_Unimod, Resources.EditStaticModDlg_OkDialog_Custom, true); if (result == DialogResult.Yes) { newMod = matchingMod.MatchVariableAndLossInclusion(newMod); // Unimod } if (result == DialogResult.Cancel) { return; } } } else { // If the dialog modification matches the modification of the same name in Unimod, // use the UnimodId. if (newMod.Equivalent(uniMod)) { newMod = uniMod.MatchVariableAndLossInclusion(newMod); } else { // Finally, if the modification name is found in Unimod, but the modification in Unimod does not // match the dialog modification, prompt the user to use the Unimod modification definition instead. if (DialogResult.OK != MultiButtonMsgDlg.Show( this, TextUtil.LineSeparate(string.Format(Resources.EditStaticModDlg_OkDialog_This_modification_does_not_match_the_Unimod_specifications_for___0___, name), string.Empty, Resources.EditStaticModDlg_OkDialog_Use_non_standard_settings_for_this_name), MultiButtonMsgDlg.BUTTON_OK)) { return; } } } _modification = newMod; DialogResult = DialogResult.OK; }
private void MainTest() { // Clean-up before running the test RunUI(() => SkylineWindow.ModifyDocument("Set default settings", doc => doc.ChangeSettings(SrmSettingsList.GetDefault()))); // Check using libkey with small molecules var adduct = Adduct.FromStringAssumeProtonated("M+3Na"); var z = adduct.AdductCharge; const string caffeineFormula = "C8H10N4O2"; const string caffeineInChiKey = "RYYVLZVUVIJVGH-UHFFFAOYSA-N"; const string caffeineHMDB = "HMDB01847"; const string caffeineInChi = "InChI=1S/C8H10N4O2/c1-10-4-9-6-5(10)7(13)12(3)8(14)11(6)2/h4H,1-3H3"; const string caffeineCAS = "58-08-2"; const string caffeineSMILES = "Cn1cnc2n(C)c(=O)n(C)c(=O)c12"; const string caffeineKEGG = "C07481"; var mId = new MoleculeAccessionNumbers(string.Join("\t", MoleculeAccessionNumbers.TagHMDB + ":" + caffeineHMDB, MoleculeAccessionNumbers.TagInChI + ":" + caffeineInChi, MoleculeAccessionNumbers.TagCAS + ":" + caffeineCAS, MoleculeAccessionNumbers.TagInChiKey + ":" + caffeineInChiKey, MoleculeAccessionNumbers.TagSMILES + ":" + caffeineSMILES, MoleculeAccessionNumbers.TagKEGG + ":" + caffeineKEGG)); Assert.AreEqual(caffeineInChiKey, mId.GetInChiKey()); Assert.AreEqual(caffeineCAS, mId.GetCAS()); Assert.AreEqual(caffeineSMILES, mId.GetSMILES()); Assert.AreEqual(caffeineKEGG, mId.GetKEGG()); var moleculeName = "caffeine"; var smallMolAttributes = SmallMoleculeLibraryAttributes.Create(moleculeName, caffeineFormula, caffeineInChiKey, string.Join("\t", MoleculeAccessionNumbers.TagHMDB + ":" + caffeineHMDB, MoleculeAccessionNumbers.TagInChI + ":" + caffeineInChi, MoleculeAccessionNumbers.TagCAS + ":" + caffeineCAS, MoleculeAccessionNumbers.TagSMILES + ":" + caffeineSMILES, MoleculeAccessionNumbers.TagKEGG + ":" + caffeineKEGG)); LibKey key; for (var loop = 0; loop++ < 2;) { key = new LibKey(smallMolAttributes, adduct); Assert.IsFalse(key.IsPrecursorKey); Assert.IsFalse(key.IsProteomicKey); Assert.IsTrue(key.IsSmallMoleculeKey); Assert.IsFalse(key.IsModified); Assert.AreEqual(0, key.ModificationCount); Assert.AreEqual(z, key.Charge); Assert.AreEqual(adduct, key.Adduct); Assert.AreEqual(caffeineInChiKey, key.Target.ToString()); var viewLibPepInfo = new ViewLibraryPepInfo(key); Assert.AreEqual(key, viewLibPepInfo.Key); var smallMolInfo = viewLibPepInfo.GetSmallMoleculeLibraryAttributes(); Assert.AreEqual(moleculeName, smallMolInfo.MoleculeName); Assert.AreEqual(caffeineInChiKey, smallMolInfo.InChiKey); Assert.AreEqual(caffeineFormula, smallMolInfo.ChemicalFormula); Assert.IsTrue(smallMolInfo.OtherKeys.Contains(caffeineCAS)); Assert.IsTrue(smallMolInfo.OtherKeys.Contains(caffeineInChi)); Assert.IsTrue(smallMolInfo.OtherKeys.Contains(caffeineHMDB)); Assert.IsTrue(smallMolInfo.OtherKeys.Contains(caffeineSMILES)); Assert.IsTrue(smallMolInfo.OtherKeys.Contains(caffeineKEGG)); adduct = Adduct.FromString("M+3Si", Adduct.ADDUCT_TYPE.non_proteomic, z = -17); // Not realistic, but let's see if it's handled consistently } // Check general libkey operation var seq = "YTQSNSVC[+57.0]YAK"; key = new LibKey(seq, Adduct.DOUBLY_PROTONATED); Assert.IsFalse(key.IsPrecursorKey); Assert.IsTrue(key.IsProteomicKey); Assert.IsFalse(key.IsSmallMoleculeKey); Assert.IsTrue(key.IsModified); Assert.AreEqual(2, key.Charge); Assert.AreEqual(1, key.ModificationCount); Assert.AreEqual(Adduct.DOUBLY_PROTONATED, key.Adduct); Assert.AreEqual(seq, key.Target.ToString()); // Test error conditions BuildLibraryError("missing_charge.pep.XML", TestFilesDir.FullPath); BuildLibraryError("non_int_charge.pep.XML", null); BuildLibraryError("zero_charge.pep.XML", null); BuildLibraryError("truncated.pep.XML", null); BuildLibraryError("no_such_file.pep.XML", null, "Failed to open"); BuildLibraryError("missing_mzxml.pep.XML", null, "Could not find spectrum file"); // Check for proper handling of labeled addducts in small molecule files // (formerly this would throw on a null object, fixed with the use of ExplicitMods.EMPTY) BuildLibraryValid("heavy_adduct.ssl", true, false, false, 1); // Make sure explorer handles this adduct type var viewLibUI = ShowDialog <ViewLibraryDlg>(SkylineWindow.ViewSpectralLibraries); RunUI(() => AssertEx.IsTrue(viewLibUI.GraphItem.IonLabels.Any())); RunUI(viewLibUI.CancelDialog); // Barbara added code to ProteoWizard to rebuild a missing or invalid mzXML index // BuildLibraryError("bad_mzxml.pep.XML", "<index> not found"); BuildLibraryValid(TestFilesDir.GetTestPath("library_errors"), new[] { "bad_mzxml.pep.XML" }, false, false, false, 1); string libraryBaseName = _libraryName; // Test mascot parser _libraryName = libraryBaseName + "mascot"; string libraryMascot = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.GetTestPath("mascot"), new[] { "F027319.dat" }, true, false, false, 121, 4); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryMascot))); // Test successful builds _libraryName = libraryBaseName + "a"; string libraryA = _libraryName + BiblioSpecLiteSpec.EXT; string libraryARedundant = _libraryName + BiblioSpecLiteSpec.EXT_REDUNDANT; BuildLibraryValid("CPTAC_Set4_725_091509.pep.XML", true, false, false, 1); BuildLibraryValid("CPTAC_Set4_610_080509.pep.XML", true, false, true, 2); _libraryName = libraryBaseName + "b"; string libraryB = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid("CPTAC_Set4_624_072409.pep.XML", false, false, false, 6); _libraryName = libraryBaseName + "c"; string libraryC = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.FullPath, new[] { libraryA, libraryB }, false, false, false, 8); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryA))); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryARedundant))); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryB))); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryC))); // Test peptide filter const string filterList = "ACARPIISVYSEK\n" + // TODO: Having the modified sequence as the first line causes an error with European number formats "ADRDESSPYAAM[+{0:F01}]IAAQDVAQR\n" + "ADAIQAGASQFETSAAK"; PastePeptideList(string.Format(filterList, 16.0), true, 0, 3, true); _libraryName = libraryBaseName + "filter"; string libraryFilter = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.GetTestPath("maxquant"), new[] { "test.msms.txt" }, false, true, false, 2); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryFilter))); RunUI(SkylineWindow.Undo); RunUI(SkylineWindow.Undo); // Test AddPathsDlg (file not found) EnsurePeptideSettings(); var buildLibraryDlg = ShowDialog <BuildLibraryDlg>(PeptideSettingsUI.ShowBuildLibraryDlg); string[] invalidPaths = { Path.Combine(TestFilesDir.GetTestPath("maxquant"), "test.msms.xml"), Path.Combine(TestFilesDir.GetTestPath("library_valid"), "CPTAC_Set4_624_072409.pep.XML") }; TestAddPaths(buildLibraryDlg, invalidPaths, true); // Test AddPathsDlg (file invalid type) string[] invalidTypes = { Path.Combine(TestFilesDir.GetTestPath("maxquant"), "test.msms.txt"), Path.Combine(TestFilesDir.GetTestPath("maxquant"), "mqpar.xml") }; TestAddPaths(buildLibraryDlg, invalidTypes, true); // Test AddPathsDlg (valid files) string[] goodPaths = { Path.Combine(TestFilesDir.GetTestPath("maxquant"), "test.msms.txt"), Path.Combine(TestFilesDir.GetTestPath("library_valid"), "CPTAC_Set4_624_072409.pep.XML") }; TestAddPaths(buildLibraryDlg, goodPaths, false); OkDialog(buildLibraryDlg, buildLibraryDlg.CancelDialog); const string heavyRPeptide = "TPAQFDADELR"; const string oxidizedMPeptide = "LVGNMHGDETVSR"; const string peptideList = heavyRPeptide + "\n" + oxidizedMPeptide + "\n" + "ALSIGFETCR\n" + "GNMHGDETVSR\n" + "VGNMHGDETVSR"; PastePeptideList(peptideList, true, 0, 1); // Set modifications on peptides to verify they connect with library spectra. const LabelAtoms labelAtoms = LabelAtoms.C13 | LabelAtoms.N15; const string heavyR = "Heavy R"; Settings.Default.HeavyModList.Add(new StaticMod(heavyR, "R", ModTerminus.C, null, labelAtoms, null, null)); const string oMeth = "Oxidized Methionine"; Settings.Default.StaticModList.Add(new StaticMod(oMeth, "M", null, "O")); var sequenceTree = SkylineWindow.SequenceTree; var docCurrent = SkylineWindow.Document; // Select the heavyR peptide PeptideTreeNode nodePepTree = null; IdentityPath pathPep = docCurrent.GetPathTo((int)SrmDocument.Level.Molecules, 0); RunUI(() => { sequenceTree.SelectedPath = pathPep; nodePepTree = sequenceTree.SelectedNode as PeptideTreeNode; }); Assert.IsNotNull(nodePepTree); Assert.AreEqual(heavyRPeptide, nodePepTree.DocNode.Peptide.Sequence); // Set the Heavy R modification explicitly var editPepModsDlg = ShowDialog <EditPepModsDlg>(SkylineWindow.ModifyPeptide); RunUI(() => { editPepModsDlg.SetModification(heavyRPeptide.Length - 1, IsotopeLabelType.heavy, heavyR); editPepModsDlg.OkDialog(); }); WaitForCondition(() => (SkylineWindow.Document.Molecules.First().TransitionGroupCount == 2)); // The peptide should now match the spectrum in the library, and have // both heavy and light precursors, with ranked transitions PeptideDocNode nodePep = null; RunUI(() => nodePep = nodePepTree.DocNode); Assert.IsNotNull(nodePep); Debug.Assert(nodePep != null); Assert.AreEqual(2, nodePep.Children.Count, "Missing precursor for heavy R peptide."); docCurrent = SkylineWindow.Document; foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { AssertLibInfo(docCurrent, nodeGroup); } // Which means all transition groups should now have spectrum info foreach (var nodeGroup in docCurrent.PeptideTransitionGroups) { AssertLibInfo(docCurrent, nodeGroup); } // New document var docNew = new SrmDocument(SrmSettingsList.GetDefault()); var docNewCopy = docNew; RunUI(() => SkylineWindow.SwitchDocument(docNewCopy, null)); const string idpList3 = "FHYKTDQGIK\n" + "WCAIGHQER\n" + "WCTISTHEANK"; int idpCount3 = idpList3.Split('\n').Length; const string idpList = "ADVTLGGGAK\n" + "AGFAGDDAPR\n" + "ALEFAKK\n" + "CCTESLVNR\n" + "DSYVGDEAQSK\n" + "YICDNQDTISSK\n" + // charge 3 peptides all have 2 also idpList3; int idpCount = idpList.Split('\n').Length; _libraryName = libraryBaseName + "_idp"; string libraryIdp = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.GetTestPath("idp_xml"), new[] { "orbi-small-eg.idpXML" }, false, false, false, idpCount + idpCount3); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryIdp))); // Add peptides expected to have charge 2 spectra in the library PastePeptideList(idpList, true, 0, 0); // Undo the paste RunUI(SkylineWindow.Undo); // Try filtering for only charge 3 spectra var transitionSettingsUI = ShowDialog <TransitionSettingsUI>( SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { transitionSettingsUI.PrecursorCharges = "3"; transitionSettingsUI.OkDialog(); }); PastePeptideList(idpList, false, idpCount - idpCount3 + 1 /* missing cleavage*/, 0); // New document var docNewCopy2 = docNew; RunUI(() => SkylineWindow.SwitchDocument(docNewCopy2, null)); _libraryName = libraryBaseName + "_cpas1"; string libraryCpas1 = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.GetTestPath("cpas"), null, false, false, false, 3); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryCpas1))); // These are very poor searches, so repeat with no filter Settings.Default.LibraryResultCutOff = 0; _libraryName = libraryBaseName + "_cpas2"; BuildLibraryValid(TestFilesDir.GetTestPath("cpas"), null, false, false, false, 100, 100); // And, since the spectra are really poor, allow lots of // possibilities for fragment ions. var transitionSettingsCpas = ShowDialog <TransitionSettingsUI>( SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { transitionSettingsCpas.PrecursorCharges = transitionSettingsCpas.ProductCharges = "1,2,3"; transitionSettingsCpas.FragmentTypes = "y,b"; transitionSettingsCpas.InstrumentMaxMz = 2000; transitionSettingsCpas.OkDialog(); }); EnsurePeptideSettings(); RunUI(() => { // Turn off carbamidomethyl cys, since not in these searches PeptideSettingsUI.PickedStaticMods = new string[0]; PeptideSettingsUI.OkDialog(); }); // Get the set of peptides to paste from the library, since there // are a lot. var setPeptides = new HashSet <Target>(); var library = SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries[0]; foreach (var libKey in library.Keys) { if (!libKey.IsModified) { setPeptides.Add(libKey.Target); } } string cpasPeptides = string.Join("\n", setPeptides.Select(p => p.ToString()).ToArray()); var pasteFilteredPeptideDlg = ShowDialog <PasteFilteredPeptidesDlg>( () => SkylineWindow.Paste(cpasPeptides)); RunUI(pasteFilteredPeptideDlg.NoDialog); Assert.IsTrue(WaitForCondition(() => SkylineWindow.Document.PeptideCount == setPeptides.Count), string.Format("Expecting {0} peptides, found {1}.", setPeptides.Count, SkylineWindow.Document.PeptideCount)); Assert.AreEqual(setPeptides.Count, SkylineWindow.Document.PeptideTransitionGroupCount, "Expecting precursors for peptides matched to library spectrum."); // New document docNew = new SrmDocument(SrmSettingsList.GetDefault()); RunUI(() => SkylineWindow.SwitchDocument(docNew, null)); // Tests for adding iRTs to spectral library after building // 1. ask to recalibrate iRTs // 2. ask to add iRTs // 3. if added iRTs, ask to add RT predictor // no recalibrate, add iRTs, no add predictor _libraryName = libraryBaseName + "_irt1"; // library_test_irt1 BuildLibraryIrt(true, false, false); RunUI(() => Assert.IsTrue(PeptideSettingsUI.Prediction.RetentionTime == null)); // no recalibrate, add iRTs, add predictor _libraryName = libraryBaseName + "_irt2"; // library_test_irt2 BuildLibraryIrt(true, false, true); RunUI(() => Assert.IsTrue(PeptideSettingsUI.Prediction.RetentionTime.Name.Equals(_libraryName))); var editIrtDlg2 = ShowDialog <EditIrtCalcDlg>(PeptideSettingsUI.EditCalculator); RunUI(() => Assert.IsTrue(ReferenceEquals(editIrtDlg2.IrtStandards, IrtStandard.BIOGNOSYS_10))); OkDialog(editIrtDlg2, editIrtDlg2.CancelDialog); // recalibrate, add iRTs, no add predictor _libraryName = libraryBaseName + "_irt3"; // library_test_irt3 BuildLibraryIrt(true, true, false); RunUI(() => Assert.IsTrue(PeptideSettingsUI.Prediction.RetentionTime.Name.Equals(libraryBaseName + "_irt2"))); // recalibrate, add iRTs, add predictor _libraryName = libraryBaseName + "_irt4"; // library_test_irt4 BuildLibraryIrt(true, true, true); RunUI(() => Assert.IsTrue(PeptideSettingsUI.Prediction.RetentionTime.Name.Equals(_libraryName))); var editIrtDlg4 = ShowDialog <EditIrtCalcDlg>(PeptideSettingsUI.EditCalculator); RunUI(() => Assert.IsTrue(ReferenceEquals(editIrtDlg4.IrtStandards, IrtStandard.EMPTY))); OkDialog(editIrtDlg4, editIrtDlg4.CancelDialog); OkDialog(PeptideSettingsUI, PeptideSettingsUI.CancelDialog); }
public StaticMod ChangeLabelAtoms(LabelAtoms prop) { return ChangeProp(ImClone(this), im => im.LabelAtoms = prop); }
public static string GetHeavyFormula(char aa, LabelAtoms labelAtoms) { string formulaAA = AMINO_FORMULAS[aa]; if (string.IsNullOrEmpty(formulaAA)) throw new ArgumentOutOfRangeException(string.Format(Resources.SequenceMassCalc_GetHeavyFormula_No_formula_found_for_the_amino_acid___0__, aa)); string formulaHeavy = formulaAA; if ((labelAtoms & LabelAtoms.C13) != 0) formulaHeavy = formulaHeavy.Replace(BioMassCalc.C, BioMassCalc.C13); if ((labelAtoms & LabelAtoms.N15) != 0) formulaHeavy = formulaHeavy.Replace(BioMassCalc.N, BioMassCalc.N15); if ((labelAtoms & LabelAtoms.O18) != 0) formulaHeavy = formulaHeavy.Replace(BioMassCalc.O, BioMassCalc.O18); if ((labelAtoms & LabelAtoms.H2) != 0) formulaHeavy = formulaHeavy.Replace(BioMassCalc.H, BioMassCalc.H2); return formulaHeavy + " - " + formulaAA; // Not L10N }
public StaticMod(string name, string aas, ModTerminus? term, bool isVariable, string formula, LabelAtoms labelAtoms, RelativeRT relativeRT, double? monoMass, double? avgMass, IList<FragmentLoss> losses, int? uniModId, string shortName) : base(name) { AAs = aas; Terminus = term; IsVariable = IsExplicit = isVariable; // All variable mods are explicit Formula = formula; LabelAtoms = labelAtoms; RelativeRT = relativeRT; MonoisotopicMass = monoMass; AverageMass = avgMass; Losses = losses; UnimodId = uniModId; ShortName = shortName; Validate(); }
public StaticMod(string name, string aas, ModTerminus? term, bool isVariable, string formula, LabelAtoms labelAtoms, RelativeRT relativeRT, double? monoMass, double? avgMass, IList<FragmentLoss> losses) : this(name, aas, term, isVariable, formula, labelAtoms, relativeRT, monoMass, avgMass, losses, null, null) { }
public StaticMod(string name, string aas, ModTerminus? term, string formula, LabelAtoms labelAtoms, double? monoMass, double? avgMass) : this(name, aas, term, false, formula, labelAtoms, RelativeRT.Matching, monoMass, avgMass, null, null, null) { }
public StaticMod(string name, string aas, ModTerminus? term, LabelAtoms labelAtoms) : this(name, aas, term, null, labelAtoms, null, null) { }
protected override void DoTest() { // Clean-up before running the test RunUI(() => SkylineWindow.ModifyDocument("Set default settings", doc => doc.ChangeSettings(SrmSettingsList.GetDefault()))); // Test error conditions BuildLibraryError("missing_charge.pep.XML", TestFilesDir.FullPath, "uw.edu"); BuildLibraryError("non_int_charge.pep.XML"); BuildLibraryError("zero_charge.pep.XML"); BuildLibraryError("truncated.pep.XML"); BuildLibraryError("no_such_file.pep.XML", "Failed to open"); BuildLibraryError("missing_mzxml.pep.XML", "Could not find spectrum file"); // Barbara added code to ProteoWizard to rebuild a missing or invalid mzXML index // BuildLibraryError("bad_mzxml.pep.XML", "<index> not found"); BuildLibraryValid(TestFilesDir.GetTestPath("library_errors"), new[] { "bad_mzxml.pep.XML" }, false, false, false, 1); string libraryBaseName = _libraryName; // Test mascot parser _libraryName = libraryBaseName + "mascot"; string libraryMascot = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.GetTestPath("mascot"), new[] { "F027319.dat" }, true, false, false, 121, 4); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryMascot))); // Test successful builds _libraryName = libraryBaseName + "a"; string libraryA = _libraryName + BiblioSpecLiteSpec.EXT; string libraryARedundant = _libraryName + BiblioSpecLiteSpec.EXT_REDUNDANT; BuildLibraryValid("CPTAC_Set4_725_091509.pep.XML", true, false, false, 1); BuildLibraryValid("CPTAC_Set4_610_080509.pep.XML", true, false, true, 2); _libraryName = libraryBaseName + "b"; string libraryB = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid("CPTAC_Set4_624_072409.pep.XML", false, false, false, 6); _libraryName = libraryBaseName + "c"; string libraryC = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.FullPath, new[] { libraryA, libraryB }, false, false, false, 8); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryA))); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryARedundant))); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryB))); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryC))); // Test peptide filter const string filterList = "ACARPIISVYSEK\n" + // TODO: Having the modified sequence as the first line causes an error with European number formats "ADRDESSPYAAM[+{0:F01}]IAAQDVAQR\n" + "ADAIQAGASQFETSAAK"; PastePeptideList(string.Format(filterList, 16.0), true, 0, 3, true); _libraryName = libraryBaseName + "filter"; string libraryFilter = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.GetTestPath("maxquant"), new[] { "test.msms.txt" }, false, true, false, 2); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryFilter))); RunUI(SkylineWindow.Undo); RunUI(SkylineWindow.Undo); // Test AddPathsDlg (file not found) EnsurePeptideSettings(); var buildLibraryDlg = ShowDialog <BuildLibraryDlg>(PeptideSettingsUI.ShowBuildLibraryDlg); string[] invalidPaths = { Path.Combine(TestFilesDir.GetTestPath("maxquant"), "test.msms.xml"), Path.Combine(TestFilesDir.GetTestPath("library_valid"), "CPTAC_Set4_624_072409.pep.XML") }; TestAddPaths(buildLibraryDlg, invalidPaths, true); // Test AddPathsDlg (file invalid type) string[] invalidTypes = { Path.Combine(TestFilesDir.GetTestPath("maxquant"), "test.msms.txt"), Path.Combine(TestFilesDir.GetTestPath("maxquant"), "mqpar.xml") }; TestAddPaths(buildLibraryDlg, invalidTypes, true); // Test AddPathsDlg (valid files) string[] goodPaths = { Path.Combine(TestFilesDir.GetTestPath("maxquant"), "test.msms.txt"), Path.Combine(TestFilesDir.GetTestPath("library_valid"), "CPTAC_Set4_624_072409.pep.XML") }; TestAddPaths(buildLibraryDlg, goodPaths, false); OkDialog(buildLibraryDlg, buildLibraryDlg.CancelDialog); const string heavyRPeptide = "TPAQFDADELR"; const string oxidizedMPeptide = "LVGNMHGDETVSR"; const string peptideList = heavyRPeptide + "\n" + oxidizedMPeptide + "\n" + "ALSIGFETCR\n" + "GNMHGDETVSR\n" + "VGNMHGDETVSR"; PastePeptideList(peptideList, true, 0, 1); // Set modifications on peptides to verify they connect with library spectra. const LabelAtoms labelAtoms = LabelAtoms.C13 | LabelAtoms.N15; const string heavyR = "Heavy R"; Settings.Default.HeavyModList.Add(new StaticMod(heavyR, "R", ModTerminus.C, null, labelAtoms, null, null)); const string oMeth = "Oxidized Methionine"; Settings.Default.StaticModList.Add(new StaticMod(oMeth, "M", null, "O")); var sequenceTree = SkylineWindow.SequenceTree; var docCurrent = SkylineWindow.Document; // Select the heavyR peptide PeptideTreeNode nodePepTree = null; IdentityPath pathPep = docCurrent.GetPathTo((int)SrmDocument.Level.Molecules, 0); RunUI(() => { sequenceTree.SelectedPath = pathPep; nodePepTree = sequenceTree.SelectedNode as PeptideTreeNode; }); Assert.IsNotNull(nodePepTree); Assert.AreEqual(heavyRPeptide, nodePepTree.DocNode.Peptide.Sequence); // Set the Heavy R modification explicitly var editPepModsDlg = ShowDialog <EditPepModsDlg>(SkylineWindow.ModifyPeptide); RunUI(() => { editPepModsDlg.SetModification(heavyRPeptide.Length - 1, IsotopeLabelType.heavy, heavyR); editPepModsDlg.OkDialog(); }); WaitForCondition(() => (SkylineWindow.Document.Molecules.First().TransitionGroupCount == 2)); // The peptide should now match the spectrum in the library, and have // both heavy and light precursors, with ranked transitions PeptideDocNode nodePep = null; RunUI(() => nodePep = nodePepTree.DocNode); Assert.IsNotNull(nodePep); Debug.Assert(nodePep != null); Assert.AreEqual(2, nodePep.Children.Count, "Missing precursor for heavy R peptide."); docCurrent = SkylineWindow.Document; foreach (TransitionGroupDocNode nodeGroup in nodePep.Children) { AssertLibInfo(docCurrent, nodeGroup); } // Which means all transition groups should now have spectrum info foreach (var nodeGroup in docCurrent.PeptideTransitionGroups) { AssertLibInfo(docCurrent, nodeGroup); } // New document var docNew = new SrmDocument(SrmSettingsList.GetDefault()); RunUI(() => SkylineWindow.SwitchDocument(docNew, null)); const string idpList3 = "FHYKTDQGIK\n" + "WCAIGHQER\n" + "WCTISTHEANK"; int idpCount3 = idpList3.Split('\n').Length; const string idpList = "ADVTLGGGAK\n" + "AGFAGDDAPR\n" + "ALEFAKK\n" + "CCTESLVNR\n" + "DSYVGDEAQSK\n" + "YICDNQDTISSK\n" + // charge 3 peptides all have 2 also idpList3; int idpCount = idpList.Split('\n').Length; _libraryName = libraryBaseName + "_idp"; string libraryIdp = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.GetTestPath("idp_xml"), new[] { "orbi-small-eg.idpXML" }, false, false, false, idpCount + idpCount3); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryIdp))); // Add peptides expected to have charge 2 spectra in the library PastePeptideList(idpList, true, 0, 0); // Undo the paste RunUI(SkylineWindow.Undo); // Try filtering for only charge 3 spectra var transitionSettingsUI = ShowDialog <TransitionSettingsUI>( SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { transitionSettingsUI.PrecursorCharges = "3"; transitionSettingsUI.OkDialog(); }); PastePeptideList(idpList, false, idpCount - idpCount3 + 1 /* missing cleavage*/, 0); // New document RunUI(() => SkylineWindow.SwitchDocument(docNew, null)); _libraryName = libraryBaseName + "_cpas1"; string libraryCpas1 = _libraryName + BiblioSpecLiteSpec.EXT; BuildLibraryValid(TestFilesDir.GetTestPath("cpas"), null, false, false, false, 3); Assert.IsTrue(File.Exists(TestFilesDir.GetTestPath(libraryCpas1))); // These are very poor searches, so repeat with no filter Settings.Default.LibraryResultCutOff = 0; _libraryName = libraryBaseName + "_cpas2"; BuildLibraryValid(TestFilesDir.GetTestPath("cpas"), null, false, false, false, 100, 100); // And, since the spectra are really poor, allow lots of // possibilities for fragment ions. var transitionSettingsCpas = ShowDialog <TransitionSettingsUI>( SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { transitionSettingsCpas.PrecursorCharges = transitionSettingsCpas.ProductCharges = "1,2,3"; transitionSettingsCpas.FragmentTypes = "y,b"; transitionSettingsCpas.InstrumentMaxMz = 2000; transitionSettingsCpas.OkDialog(); }); EnsurePeptideSettings(); RunUI(() => { // Turn off carbamidomethyl cys, since not in these searches PeptideSettingsUI.PickedStaticMods = new string[0]; PeptideSettingsUI.OkDialog(); }); // Get the set of peptides to paste from the library, since there // are a lot. HashSet <string> setPeptides = new HashSet <string>(); var library = SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries[0]; foreach (var libKey in library.Keys) { if (!libKey.IsModified) { setPeptides.Add(libKey.Sequence); } } string cpasPeptides = string.Join("\n", setPeptides.ToArray()); var pasteFilteredPeptideDlg = ShowDialog <PasteFilteredPeptidesDlg>( () => SkylineWindow.Paste(cpasPeptides)); RunUI(pasteFilteredPeptideDlg.NoDialog); Assert.IsTrue(WaitForCondition(() => SkylineWindow.Document.PeptideCount == setPeptides.Count), string.Format("Expecting {0} peptides, found {1}.", setPeptides.Count, SkylineWindow.Document.PeptideCount)); Assert.AreEqual(setPeptides.Count, SkylineWindow.Document.PeptideTransitionGroupCount, "Expecting precursors for peptides matched to library spectrum."); }