private SrmDocument DeleteProteins(SrmDocument document, HashSet <IdentityPath> identityPathsToDelete) { var newProteins = new List <PeptideGroupDocNode>(); foreach (var protein in document.PeptideGroups) { if (identityPathsToDelete.Contains(new IdentityPath(protein.Id))) { continue; } if (protein.Children.Count != 0) { var newProtein = DeletePeptides(protein, identityPathsToDelete); if (newProtein.Children.Count == 0) { continue; } newProteins.Add(newProtein); } else { newProteins.Add(protein); } } return((SrmDocument)document.ChangeChildren(newProteins.Cast <DocNode>().ToArray())); }
protected SrmDocument DeleteNodes(SrmDocument document, HashSet <IdentityPath> identityPathsToDelete) { var newDocument = (SrmDocument)DeleteChildren(document, IdentityPath.ROOT, identityPathsToDelete); if (newDocument != null) { return(newDocument); } return((SrmDocument)document.ChangeChildren(new DocNode[0])); }
private static SrmDocument DeleteNodes(SrmDocument document, HashSet <IdentityPath> identityPathsToDelete, out List <IdentityPath> deletedPaths) { var newDocument = (SrmDocument)DeleteChildren(document, IdentityPath.ROOT, identityPathsToDelete, out deletedPaths); if (newDocument != null) { return(newDocument); } return((SrmDocument)document.ChangeChildren(new DocNode[0])); }
private SrmDocument AddSmallMolecules(SrmDocument document) { var newChildren = new List <PeptideGroupDocNode>(document.MoleculeGroups); newChildren.AddRange(new RefinementSettings().ConvertToSmallMolecules(document, TestContext.TestRunDirectory, RefinementSettings.ConvertToSmallMoleculesMode.masses_and_names).MoleculeGroups); newChildren.AddRange(new RefinementSettings().ConvertToSmallMolecules(document, TestContext.TestRunDirectory, RefinementSettings.ConvertToSmallMoleculesMode.masses_only).MoleculeGroups); newChildren.AddRange(new RefinementSettings().ConvertToSmallMolecules(document, TestContext.TestRunDirectory).MoleculeGroups); // Do this last for fullest library translation document = (SrmDocument)document.ChangeChildren(newChildren.ToArray()); return(document); }
public PeptideDocNode PermuteModificationsOnPeptide(SrmDocument document, PeptideGroupDocNode peptideGroupDocNode, PeptideDocNode peptideDocNode, List <IsotopeLabelType> partialLabelTypes) { if (SkipPeptide(peptideDocNode)) { return(peptideDocNode); } var potentiallyModifiedResidues = PotentiallyModifiedResidues(peptideDocNode, IsotopeModification); if (potentiallyModifiedResidues.Count == 0) { return(peptideDocNode); } // Create a document containing only one peptide so that "ChangePeptideMods" does not have to walk // over a long list of peptides to see which modifications are in use. var smallDocument = (SrmDocument)document.ChangeChildren(new DocNode[] { peptideGroupDocNode.ChangeChildren(new DocNode[] { peptideDocNode }) }); var newTypedExplicitModifications = PermuteTypedExplicitModifications(partialLabelTypes, peptideDocNode, potentiallyModifiedResidues); var newExplicitMods = new ExplicitMods(peptideDocNode.Peptide, peptideDocNode.ExplicitMods?.StaticModifications, newTypedExplicitModifications); var identityPath = new IdentityPath(peptideGroupDocNode.PeptideGroup, peptideDocNode.Peptide); smallDocument = smallDocument.ChangePeptideMods(identityPath, newExplicitMods, false, GlobalStaticMods, GlobalIsotopeMods); peptideDocNode = (PeptideDocNode)smallDocument.FindPeptideGroup(peptideGroupDocNode.PeptideGroup).FindNode(peptideDocNode.Peptide); var lightChargeStates = peptideDocNode.TransitionGroups.Where(tg => tg.IsLight).Select(tg => tg.PrecursorCharge).Distinct().ToList(); var chargeStatesByLabel = peptideDocNode.TransitionGroups.ToLookup(tg => tg.LabelType, tg => tg.PrecursorCharge); var transitionGroupsToAdd = new List <TransitionGroupDocNode>(); foreach (var typedExplicitModifications in newExplicitMods.GetHeavyModifications()) { var labelType = typedExplicitModifications.LabelType; foreach (var chargeState in lightChargeStates.Except(chargeStatesByLabel[labelType])) { var tranGroup = new TransitionGroup(peptideDocNode.Peptide, Adduct.FromChargeProtonated(chargeState), labelType); TransitionDocNode[] transitions = peptideDocNode.GetMatchingTransitions(tranGroup, smallDocument.Settings, newExplicitMods); var nodeGroup = new TransitionGroupDocNode(tranGroup, transitions); nodeGroup = nodeGroup.ChangeSettings(smallDocument.Settings, peptideDocNode, newExplicitMods, SrmSettingsDiff.ALL); transitionGroupsToAdd.Add(nodeGroup); } } if (transitionGroupsToAdd.Any()) { var newChildren = peptideDocNode.TransitionGroups.Concat(transitionGroupsToAdd).ToList(); newChildren.Sort(Peptide.CompareGroups); peptideDocNode = (PeptideDocNode)peptideDocNode.ChangeChildren(newChildren.Cast <DocNode>().ToList()); } return(peptideDocNode); }
public SrmDocument UpdateDocument(SrmDocument document) { if (document.Settings.HasResults && _annotationUpdaters.ContainsKey(AnnotationDef.AnnotationTarget.replicate)) { var newMeasuredResults = UpdateReplicateAnnotations(document.MeasuredResults); document = document.ChangeMeasuredResults(newMeasuredResults); } var newChildren = document.MoleculeGroups.Select(UpdateMoleculeGroup).ToArray(); document = (SrmDocument)document.ChangeChildren(newChildren); return(document); }
public void ThermoMixedPeptidesTest() { var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE); string docPath; SrmDocument docMixed = InitMixedDocument(testFilesDir, out docPath); FileEx.SafeDelete(Path.ChangeExtension(docPath, ChromatogramCache.EXT)); SrmDocument docUnmixed = InitUnmixedDocument(testFilesDir, out docPath); FileEx.SafeDelete(Path.ChangeExtension(docPath, ChromatogramCache.EXT)); string extRaw = ExtensionTestContext.ExtThermoRaw; var listChromatograms = new List <ChromatogramSet> { new ChromatogramSet("rep03", new[] { MsDataFileUri.Parse(testFilesDir.GetTestPath( "Site20_STUDY9P_PHASEII_QC_03" + extRaw)) }), new ChromatogramSet("rep05", new[] { MsDataFileUri.Parse(testFilesDir.GetTestPath( "Site20_STUDY9P_PHASEII_QC_05" + extRaw)) }) }; var docResults = docMixed.ChangeMeasuredResults(new MeasuredResults(listChromatograms)); var docContainerMixed = new ResultsTestDocumentContainer(docMixed, docPath); Assert.IsTrue(docContainerMixed.SetDocument(docResults, docMixed, true)); docContainerMixed.AssertComplete(); docMixed = docContainerMixed.Document; SrmDocument docMixedUnmixed = (SrmDocument)docMixed.ChangeChildren(new DocNode[0]); IdentityPath tempPath; docMixedUnmixed = docMixedUnmixed.AddPeptideGroups(docUnmixed.PeptideGroups, true, IdentityPath.ROOT, out tempPath, out tempPath); docResults = docUnmixed.ChangeMeasuredResults(new MeasuredResults(listChromatograms)); var docContainerUnmixed = new ResultsTestDocumentContainer(docUnmixed, docPath); Assert.IsTrue(docContainerUnmixed.SetDocument(docResults, docUnmixed, true)); docContainerUnmixed.AssertComplete(); docUnmixed = docContainerUnmixed.Document; AssertEx.DocumentCloned(docMixedUnmixed, docUnmixed); docContainerMixed.Release(); docContainerUnmixed.Release(); }
public void TestSerializePeptides() { var srmDocument = new SrmDocument(SrmSettingsList.GetDefault()); string strProteinSequence = string.Join(string.Empty, "MSLSSKLSVQDLDLKDKRVFIRVDFNVPLDGKKITSNQRIVAALPTIKYVLEHHPRYVVL", "ASHLGRPNGERNEKYSLAPVAKELQSLLGKDVTFLNDCVGPEVEAAVKASAPGSVILLEN", "LRYHIEEEGSRKVDGQKVKASKEDVQKFRHELSSLADVYINDAFGTAHRAHSSMVGFDLP", "QRAAGFLLEKELKYFGKALENPTRPFLAILGGAKVADKIQLIDNLLDKVDSIIIGGGMAF", "TFKKVLENTEIGDSIFDKAGAEIVPKLMEKAKAKGVEVVLPVDFIIADAFSADANTKTVT", "DKEGIPAGWQGLDNGPESRKLFAATVAKAKTIVWNGPPGVFEFEKFAAGTKALLDEVVKS", "SAAGNTVIIGGGDTATVAKKYGVTDKISHVSTGGGASLELLEGKELPGVAFLSEKK"); var fastaSequence = new FastaSequence("YCR012W", "PGK1", null, strProteinSequence); var peptideGroup = new PeptideGroupDocNode(fastaSequence, fastaSequence.Name, fastaSequence.Description, new PeptideDocNode[0]); Assert.AreEqual(true, peptideGroup.AutoManageChildren); peptideGroup = peptideGroup.ChangeSettings(srmDocument.Settings, SrmSettingsDiff.ALL); srmDocument = (SrmDocument)srmDocument.ChangeChildren(new DocNode[] { peptideGroup }); Assert.AreNotEqual(0, srmDocument.PeptideCount); Assert.AreNotEqual(0, srmDocument.MoleculeTransitionCount); Assert.IsFalse(CompactFormatOption.NEVER.UseCompactFormat(srmDocument)); Assert.IsTrue(CompactFormatOption.ALWAYS.UseCompactFormat(srmDocument)); VerifyRoundTrips(srmDocument); VerifyRoundTrips(AddSmallMolecules(srmDocument)); }
private SrmDocument ReplaceTransitionGroups( SrmDocument document, Func <TransitionGroupDocNode, TransitionGroupDocNode> transitionGroupTransformFunc) { var newMoleculeGroups = new List <PeptideGroupDocNode>(); foreach (var moleculeGroup in document.MoleculeGroups) { var newMolecules = new List <PeptideDocNode>(); foreach (var molecule in moleculeGroup.Molecules) { var newTransitionGroups = new List <TransitionGroupDocNode>(); foreach (var transitionGroup in molecule.TransitionGroups) { var newTransitionGroup = transitionGroupTransformFunc(transitionGroup); newTransitionGroups.Add(newTransitionGroup); } var newMolecule = (PeptideDocNode)molecule.ChangeChildren( newTransitionGroups.ToArray()); newMolecules.Add(newMolecule); } newMoleculeGroups.Add((PeptideGroupDocNode)moleculeGroup.ChangeChildren(newMolecules.ToArray())); } return((SrmDocument)document.ChangeChildren(newMoleculeGroups.ToArray())); }
protected override void DoTest() { LinkPdf = "http://www.srmcourse.ch/tutorials2014/Tutorial-1_Settings.pdf"; //Tutorial 1 string fastaFile = GetTestPath("Tutorial-1_Settings/TubercuList_v2-6.fasta.txt"); WaitForCondition(() => File.Exists(fastaFile)); var pepSettings = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunUI(() => { SkylineWindow.Size = new Size(1600, 800); pepSettings.SelectedTab = PeptideSettingsUI.TABS.Digest; pepSettings.ComboEnzymeSelected = "Trypsin [KR | P]"; pepSettings.MaxMissedCleavages = 0; }); var backProteomeDlg = ShowDialog <BuildBackgroundProteomeDlg>(pepSettings.AddBackgroundProteome); RunUI(() => { backProteomeDlg.BackgroundProteomePath = GetTestPath("Skyline"); backProteomeDlg.BackgroundProteomeName = "TubercuList_v2-6"; backProteomeDlg.AddFastaFile(fastaFile); WaitForCondition(() => backProteomeDlg.StatusText.Length > 10); Assert.IsTrue(backProteomeDlg.StatusText.Contains("3982".ToString(CultureInfo.CurrentCulture))); }); OkDialog(backProteomeDlg, backProteomeDlg.OkDialog); RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Prediction); RunUI(() => { pepSettings.SelectedTab = PeptideSettingsUI.TABS.Filter; pepSettings.TextMinLength = 7; pepSettings.TextMaxLength = 25; pepSettings.TextExcludeAAs = 0; pepSettings.AutoSelectMatchingPeptides = true; }); RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Library); var editListDlg = ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(pepSettings.EditLibraryList); var editLibraryDlg = ShowDialog <EditLibraryDlg>(editListDlg.AddItem); RunUI(() => { editLibraryDlg.LibraryName = "Mtb_proteome_library"; editLibraryDlg.LibraryPath = GetTestPath("Skyline\\Mtb_DirtyPeptides_QT_filtered_cons.sptxt"); }); OkDialog(editLibraryDlg, editLibraryDlg.OkDialog); OkDialog(editListDlg, editListDlg.OkDialog); RunUI(() => pepSettings.SetLibraryChecked(0, true)); RunUI(() => { pepSettings.SelectedTab = PeptideSettingsUI.TABS.Modifications; }); var editHeavyModListDlg = ShowDialog <EditListDlg <SettingsListBase <StaticMod>, StaticMod> >(pepSettings.EditHeavyMods); var addDlgOne = ShowDialog <EditStaticModDlg>(editHeavyModListDlg.AddItem); RunUI(() => addDlgOne.SetModification("Label:13C(6)15N(2) (C-term K)")); PauseForScreenShot("Isotope modification 1", 3); OkDialog(addDlgOne, addDlgOne.OkDialog); var addDlgTwo = ShowDialog <EditStaticModDlg>(editHeavyModListDlg.AddItem); RunUI(() => addDlgTwo.SetModification("Label:13C(6)15N(4) (C-term R)")); PauseForScreenShot("Isotope modification 2", 3); OkDialog(addDlgTwo, addDlgTwo.OkDialog); OkDialog(editHeavyModListDlg, editHeavyModListDlg.OkDialog); RunUI(() => { pepSettings.SetIsotopeModifications(0, true); pepSettings.SetIsotopeModifications(1, true); }); RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Digest); PauseForScreenShot("Digestion tab", 4); RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Prediction); PauseForScreenShot("Prediction tab", 4); RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Filter); PauseForScreenShot("Filter tab", 4); RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Library); PauseForScreenShot("Library tab", 4); RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Modifications); PauseForScreenShot("Modifications tab", 4); OkDialog(pepSettings, pepSettings.OkDialog); WaitForCondition( () => SkylineWindow.Status.Contains(Resources.BackgroundProteomeSpec_Digest_Digesting__0__.Split('{').First()) && SkylineWindow.Status.Contains(Resources.BackgroundProteomeSpec_Digest_Digesting__0__.Split('}').Last())); WaitForCondition( () => SkylineWindow.Status.Contains(Resources.BackgroundProteomeManager_LoadBackground_Resolving_protein_details_for__0__proteome.Split('{').First()) && SkylineWindow.Status.Contains(Resources.BackgroundProteomeManager_LoadBackground_Resolving_protein_details_for__0__proteome.Split('}').Last())); WaitForCondition(() => SkylineWindow.Status.Contains(Resources.SkylineWindow_UpdateProgressUI_Ready)); WaitForDocumentLoaded(); var transitionDlg = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Prediction; transitionDlg.PrecursorMassType = MassType.Monoisotopic; transitionDlg.FragmentMassType = MassType.Monoisotopic; transitionDlg.RegressionCEName = "ABI 5500 QTrap"; }); RunUI(() => { transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Filter; transitionDlg.PrecursorCharges = "2,3".ToString(CultureInfo.CurrentCulture); transitionDlg.ProductCharges = "1,2".ToString(CultureInfo.CurrentCulture); transitionDlg.FragmentTypes = "y"; transitionDlg.RangeFrom = Resources.TransitionFilter_FragmentStartFinders_ion_1; transitionDlg.RangeTo = Resources.TransitionFilter_FragmentEndFinders_last_ion; transitionDlg.SetListAlwaysAdd(0, false); transitionDlg.ExclusionWindow = 5; transitionDlg.SetAutoSelect = true; }); RunUI(() => { transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Library; transitionDlg.IonMatchTolerance = 1.0; transitionDlg.UseLibraryPick = true; transitionDlg.IonCount = 5; transitionDlg.Filtered = true; }); RunUI(() => { transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Instrument; transitionDlg.MinMz = 300; transitionDlg.MaxMz = 1250; }); RunUI(() => transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Prediction); PauseForScreenShot("Prediction Tab", 7); RunUI(() => transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Filter); PauseForScreenShot("Filter Tab", 7); RunUI(() => transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Library); PauseForScreenShot("Library Tab", 7); RunUI(() => transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Instrument); PauseForScreenShot("Instrument Tab", 7); OkDialog(transitionDlg, transitionDlg.OkDialog); RunUI(() => SkylineWindow.SaveDocument(GetTestPath("Tutorial-1_Settings\\SRMcourse_20140210_Settings.sky"))); //Tutorial 2 LinkPdf = "http://www.srmcourse.ch/tutorials2014/Tutorial-2_TransitionList.pdf"; RunUI(() => { }); SetExcelFileClipboardText(GetTestPath(@"Tutorial-2_TransitionList\\target_peptides.xlsx"), "Sheet1", 1, false); var peptidePasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg); var matchingDlg = ShowDialog <FilterMatchedPeptidesDlg>(peptidePasteDlg.PastePeptides); PauseForScreenShot("Filter Peptides", 1); OkDialog(matchingDlg, matchingDlg.OkDialog); OkDialog(peptidePasteDlg, peptidePasteDlg.OkDialog); int expectedTrans = TransitionGroup.IsAvoidMismatchedIsotopeTransitions ? 306 : 313; AssertEx.IsDocumentState(SkylineWindow.Document, null, 10, 30, 68, expectedTrans); RunUI(() => { SkylineWindow.ExpandProteins(); SkylineWindow.ExpandPeptides(); SkylineWindow.ExpandPrecursors(); SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode; }); PauseForScreenShot("Skyline Window", 2); var exportDlg = ShowDialog <ExportMethodDlg>(SkylineWindow.ShowExportTransitionListDlg); RunUI(() => { exportDlg.InstrumentType = "AB SCIEX"; exportDlg.ExportStrategy = ExportStrategy.Single; exportDlg.DwellTime = 20; }); PauseForScreenShot("Export Transition List", 3); var declusteringWarningDlg = ShowDialog <MultiButtonMsgDlg>( () => exportDlg.OkDialog(GetTestPath("Tutorial-2_TransitionList\\SRMcourse_20140210_MtbProteomeLib_TransList.csv"))); PauseForScreenShot("Decluster Window", 3); OkDialog(declusteringWarningDlg, declusteringWarningDlg.Btn1Click); WaitForClosedForm(exportDlg); //Tutorial 3 LinkPdf = "http://www.srmcourse.ch/tutorials2014/Tutorial-3_Library.pdf"; var pepSettings2 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI); RunUI(() => pepSettings2.SelectedTab = PeptideSettingsUI.TABS.Library); var buildLibraryDlg = ShowDialog <BuildLibraryDlg>(pepSettings2.ShowBuildLibraryDlg); RunUI(() => { buildLibraryDlg.LibraryPath = GetTestPath("Skyline"); buildLibraryDlg.LibraryName = "Mtb_hDP_20140210"; buildLibraryDlg.LibraryCutoff = 0.9; buildLibraryDlg.LibraryAuthority = "SRMcourse"; }); PauseForScreenShot("Build Library Window", 2); RunUI(() => { buildLibraryDlg.OkWizardPage(); buildLibraryDlg.AddDirectory(GetTestPath("Tutorial-3_Library")); }); PauseForScreenShot("Build Library Window Next", 2); OkDialog(buildLibraryDlg, buildLibraryDlg.OkWizardPage); RunUI(() => { pepSettings2.SetLibraryChecked(0, true); pepSettings2.SetLibraryChecked(1, true); }); OkDialog(pepSettings2, pepSettings2.OkDialog); WaitForLibrary(20213); WaitForCondition(() => SkylineWindow.Document.PeptideTransitionCount != expectedTrans); int expectedTransAfter = TransitionGroup.IsAvoidMismatchedIsotopeTransitions ? 444 : 450; AssertEx.IsDocumentState(SkylineWindow.Document, null, 10, 30, 96, expectedTransAfter); var libraryExpl = ShowDialog <ViewLibraryDlg>(SkylineWindow.ViewSpectralLibraries); var messageWarning = WaitForOpenForm <MultiButtonMsgDlg>(); OkDialog(messageWarning, messageWarning.Btn1Click); PauseForScreenShot("Spectral Library Explorer Window", 3); OkDialog(libraryExpl, libraryExpl.Close); var exportDlg2 = ShowDialog <ExportMethodDlg>(SkylineWindow.ShowExportTransitionListDlg); RunUI(() => { exportDlg2.InstrumentType = "AB SCIEX"; exportDlg2.ExportStrategy = ExportStrategy.Buckets; exportDlg2.MaxTransitions = 150; exportDlg2.DwellTime = 20; exportDlg2.IgnoreProteins = true; }); var declusteringWarningDlg2 = ShowDialog <MultiButtonMsgDlg>(() => exportDlg2.OkDialog(GetTestPath("Tutorial-3_Library\\SRMcourse_20140210_MtbProteomeLib_hDP_TransList.csv"))); OkDialog(declusteringWarningDlg2, declusteringWarningDlg2.Btn1Click); WaitForClosedForm(exportDlg2); //Tutorial 4-A LinkPdf = "http://www.srmcourse.ch/tutorials2014/Tutorial-4_Parameters.pdf"; SrmDocument smallDocument = SkylineWindow.Document; PeptideGroupDocNode[] newProteins = smallDocument.PeptideGroups.Take(0).ToArray(); smallDocument = (SrmDocument)smallDocument.ChangeChildren(newProteins); Assert.IsTrue(SkylineWindow.SetDocument(smallDocument, SkylineWindow.Document)); // TODO: Must be a better way to do this var transitionSettings = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { transitionSettings.SelectedTab = TransitionSettingsUI.TABS.Prediction; transitionSettings.RegressionCEName = "ABI QTrap 4000"; }); var editCollisionEnergy = ShowDialog <EditCEDlg>(() => transitionSettings.RegressionCEName = Resources.SettingsListComboDriver_Edit_current); RunUI(() => { editCollisionEnergy.StepSize = 2; editCollisionEnergy.StepCount = 5; }); PauseForScreenShot("Edit Collision Energy Equation Window", 2); OkDialog(editCollisionEnergy, editCollisionEnergy.OkDialog); OkDialog(transitionSettings, transitionSettings.OkDialog); SetExcelFileClipboardText(GetTestPath("Tutorial-4_Parameters\\transition_list_for_CEO.xlsx"), "Sheet1", 3, false); var insertTransitionDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg); RunUI(() => insertTransitionDlg.IsMolecule = false); // Make sure it's ready to accept peptides, not small molecules RunUI(insertTransitionDlg.PasteTransitions); OkDialog(insertTransitionDlg, insertTransitionDlg.OkDialog); AssertEx.IsDocumentState(SkylineWindow.Document, null, 10, 30, 30, 143); var exportDlg3 = ShowDialog <ExportMethodDlg>(SkylineWindow.ShowExportTransitionListDlg); RunUI(() => { exportDlg3.InstrumentType = "AB SCIEX"; exportDlg3.ExportStrategy = ExportStrategy.Single; exportDlg3.OptimizeType = ExportOptimize.CE; exportDlg3.MethodType = ExportMethodType.Standard; exportDlg2.DwellTime = 20; }); PauseForScreenShot("Export Transition List", 3); var defaultWaringDlg = ShowDialog <MultiButtonMsgDlg>( () => exportDlg3.OkDialog(GetTestPath("Tutorial-4_Parameters\\SRMcourse_20140211_Parameters_CEO.csv"))); OkDialog(defaultWaringDlg, defaultWaringDlg.Btn1Click); WaitForClosedForm(exportDlg3); var paths = new string[4]; for (int i = 0; i < paths.Length; i++) { paths[i] = GetTestPath("Tutorial-4_Parameters\\CEO_" + (i + 1) + ".wiff"); } ImportResults("CEO", paths, ExportOptimize.CE); RestoreViewOnScreen(43); RunUI(() => SkylineWindow.ShowChromatogramLegends(false)); PauseForScreenShot("Skyline Window", 3); ImportResults("", new[] { GetTestPath("Tutorial-4_Parameters\\CE_plus10.wiff"), GetTestPath("Tutorial-4_Parameters\\CE_minus10.wiff") }, ExportOptimize.NONE, false); RunUI(() => { SkylineWindow.ShowAllTransitions(); SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_maximum_view); }); RestoreViewOnScreen(44); PauseForScreenShot("Skyline Window", 4); var transitionSettings2 = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI); RunUI(() => { transitionSettings2.SelectedTab = TransitionSettingsUI.TABS.Prediction; }); var addCollisionEnergyDlg = ShowDialog <EditCEDlg>(transitionSettings2.AddToCEList); RunUI(() => { addCollisionEnergyDlg.UseCurrentData(); addCollisionEnergyDlg.RegressionName = "SRMcourse_20140211_Parameters_custom-CE-equation"; }); var equationGraphDlg = ShowDialog <GraphRegression>(addCollisionEnergyDlg.ShowGraph); PauseForScreenShot("Collision Energy Equation Graph", 6); OkDialog(equationGraphDlg, equationGraphDlg.CloseDialog); OkDialog(addCollisionEnergyDlg, addCollisionEnergyDlg.OkDialog); RunUI(() => { transitionSettings2.RegressionCEName = "SRMcourse_20140211_Parameters_custom-CE-equation"; transitionSettings2.SelectedTab = TransitionSettingsUI.TABS.Instrument; transitionSettings2.MZMatchTolerance = 0.01; }); PauseForScreenShot("Instrument Tab", 7); OkDialog(transitionSettings2, transitionSettings2.OkDialog); //Tutorial 4-B var manageResultsDlg = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults); RunUI(manageResultsDlg.RemoveAllReplicates); OkDialog(manageResultsDlg, manageResultsDlg.OkDialog); string[] paths2 = { GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 10)), GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 20)), GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 40)), GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 60)), GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 100)) }; ImportResults("", paths2, null, false); RestoreViewOnScreen(48); RunUI(() => SkylineWindow.AutoZoomBestPeak()); PauseForScreenShot("Skyline Window", 8); }
public void TestPaste() { ClearDefaultModifications(); _yeastDoc = new SrmDocument(SrmSettingsList.GetDefault().ChangeTransitionInstrument(instrument => instrument.ChangeMaxMz(1600))); _yeastDoc = _yeastDoc.ChangeSettings(_yeastDoc.Settings.ChangeTransitionFilter(filter => filter.ChangeMeasuredIons(new MeasuredIon[0]))); IdentityPath path; _yeastDocReadOnly = _yeastDoc = _yeastDoc.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST_LIB), false, IdentityPath.ROOT, out path); _study7DocReadOnly = _study7Doc = CreateStudy7Doc(); IdentityPath pathRoot = IdentityPath.ROOT; // Test pasting into document with same implicit modifications does not create any extra explicit modifications. var study7EmptyDoc = (SrmDocument) _study7Doc.ChangeChildren(new DocNode[0]); var study7PasteDoc = CopyPaste(_study7Doc, null, study7EmptyDoc, pathRoot); var arrayPeptides = _study7Doc.Peptides.ToArray(); var arrayPastePeptides = study7PasteDoc.Peptides.ToArray(); Assert.AreEqual(arrayPeptides.Length, arrayPastePeptides.Length); AssertEx.DocsEqual(_study7Doc, study7PasteDoc); // DocsEqual gives a more verbose failure message using XML output // Test implicit mods in source document become explicit mods in target document. ResetDocuments(); _yeastDoc = (SrmDocument) _yeastDoc.ChangeChildren(new DocNode[0]); var settings = _yeastDoc.Settings; _yeastDoc = _yeastDoc.ChangeSettings(settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0]))); _yeastDoc = CopyPaste(_study7Doc, null, _yeastDoc, pathRoot); var pepMods = _yeastDoc.Settings.PeptideSettings.Modifications; Assert.IsTrue(pepMods.StaticModifications != null); Assert.IsTrue(pepMods.HasHeavyModifications); Assert.IsFalse(pepMods.StaticModifications.Contains(mod => !mod.IsExplicit)); Assert.IsFalse(pepMods.HeavyModifications.Contains(mod => !mod.IsExplicit)); // Test explicit mods are dropped if the target document has matching implicit modifications. study7PasteDoc = CopyPaste(_yeastDoc, null, study7EmptyDoc, pathRoot); Assert.AreEqual(_study7Doc, study7PasteDoc); // Add new label type to source document. ResetDocuments(); const string labelTypeName13C = "heavy 13C"; var labelType13C = new IsotopeLabelType(labelTypeName13C, IsotopeLabelType.light.SortOrder + 1); _yeastDoc = ChangePeptideModifications(_yeastDoc, new[] {new TypedModifications(labelType13C, HEAVY_MODS_13_C)}); Assert.IsTrue(_yeastDoc.PeptideTransitionGroups.Contains(nodeGroup => Equals(nodeGroup.TransitionGroup.LabelType, labelType13C))); // Test pasting into the same document with new label type. _yeastDoc = CopyPaste(_yeastDoc, null, _yeastDoc, pathRoot); // Check all transition have correct label type references. Assert.IsFalse(_yeastDoc.PeptideTransitionGroups.Contains(nodeGroup => { IsotopeLabelType labelType = nodeGroup.TransitionGroup.LabelType; return !ReferenceEquals(labelType, _yeastDoc.Settings.PeptideSettings.Modifications.GetModificationsByName(labelType.Name).LabelType); })); // Check new document still serializes correctly. AssertEx.Serializable(_yeastDoc, AssertEx.DocumentCloned); // Test pasting into new document drops label types from source document that are not found in the target document. _yeastDoc = CopyPaste(_yeastDoc, null, new SrmDocument(SrmSettingsList.GetDefault()), pathRoot); Assert.IsNull(_yeastDoc.Settings.PeptideSettings.Modifications.GetModificationsByName(labelTypeName13C)); // If only specific children are selected, test that only these children get copied. ResetDocuments(); var arrayTrans = _study7Doc.PeptideTransitions.ToArray(); IList<DocNode> selNodes = new List<DocNode>(); for (int i = 0; i < arrayTrans.Length; i += 2) { selNodes.Add(arrayTrans[i]); } _study7Doc = CopyPaste(_study7Doc, selNodes, _study7Doc, pathRoot); Assert.AreEqual(arrayTrans.Length + selNodes.Count, _study7Doc.PeptideTransitionCount); // Test after pasting to a peptide list, all children have been updated to point to the correct parent. ResetDocuments(); _study7Doc = CopyPaste(_yeastDoc, new[] { _yeastDoc.Peptides.ToArray()[0] }, _study7Doc, _study7Doc.GetPathTo((int) SrmDocument.Level.MoleculeGroups, 0)); Assert.AreEqual(_yeastDoc.Peptides.ToArray()[0].Peptide, _study7Doc.Peptides.ToArray()[0].Peptide); Assert.AreEqual(_study7Doc.Peptides.ToArray()[0].Peptide, _study7Doc.PeptideTransitionGroups.ToArray()[0].TransitionGroup.Peptide); Assert.AreEqual(_study7Doc.PeptideTransitionGroups.ToArray()[0].TransitionGroup, _study7Doc.PeptideTransitions.ToArray()[0].Transition.Group); // If only specific transition are selected for a peptide, but all transition groups are included, test AutoManageChildren is true. ResetDocuments(); selNodes = new List<DocNode>(); foreach (TransitionGroupDocNode transGroup in _study7Doc.PeptideTransitionGroups) { selNodes.Add(transGroup.Children[0]); } // TODO: Fix this and make it pass // var emptyDoc = (SrmDocument)_study7Doc.ChangeChildren(new List<DocNode>()); // _study7Doc = CopyPaste(_study7Doc, selNodes, emptyDoc, pathRoot); _study7Doc = (SrmDocument)_study7Doc.ChangeChildren(new List<DocNode>()); _study7Doc = CopyPaste(_study7Doc, selNodes, _study7Doc, pathRoot); foreach (PeptideDocNode peptide in _study7Doc.Peptides) Assert.IsTrue(peptide.AutoManageChildren); // Test pasting in modifications with the same name as but different definition from existing modifications not allowed. ResetDocuments(); _yeastDoc = ChangePeptideModifications(_yeastDoc, new[] { new TypedModifications(IsotopeLabelType.heavy, HEAVY_C_K_DIFDEF) }); SetDefaultModifications(_study7Doc); AssertEx.ThrowsException<Exception>(() => _yeastDoc.Settings.UpdateDefaultModifications(false)); // Test variable modifications kept if target document has matching variable modifications turned on. ResetDocuments(); settings = _yeastDoc.Settings; var modsDefault = settings.PeptideSettings.Modifications; var listVariableMods = new List<StaticMod>(modsDefault.StaticModifications) { VAR_MET_OXIDIZED }; _yeastDoc = _yeastDoc.ChangeSettings(settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(listVariableMods.ToArray()))); // Make sure there is an implicitly modified peptide in the yeast document Assert.IsTrue(_yeastDoc.Peptides.Contains(nodePep => nodePep.Peptide.Sequence.Contains("C"))); Assert.IsTrue(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasVariableMods)); _yeastDoc = CopyPaste(_yeastDoc, null, _yeastDoc, pathRoot); Assert.IsFalse(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasExplicitMods && !nodePep.HasVariableMods)); // Otherwise the variable modifications become only explicit modifications. var yeastDocVar = _yeastDoc; _yeastDoc = _yeastDoc.ChangeSettings(_yeastDoc.Settings.ChangePeptideModifications(mods => modsDefault)); _yeastDoc = CopyPaste(yeastDocVar, null, _yeastDoc, pathRoot); Assert.IsFalse(_yeastDoc.Settings.PeptideSettings.Modifications.HasVariableModifications); Assert.IsTrue(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasExplicitMods)); Assert.IsFalse(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasVariableMods)); }
public SrmDocument AddAnnotationTestValues(SrmDocument document) { _counter = 0; _elementCount = 0; document = document.ChangeSettings(document.Settings.ChangeDataSettings( document.Settings.DataSettings.ChangeAnnotationDefs(ImmutableList.ValueOf(GetTestAnnotations())))); var measuredResults = document.MeasuredResults; if (measuredResults != null) { var chromatograms = measuredResults.Chromatograms.ToArray(); for (int i = 0; i < chromatograms.Length; i++) { _elementCount++; chromatograms[i] = chromatograms[i].ChangeAnnotations( AddAnnotations(chromatograms[i].Annotations, AnnotationDef.AnnotationTarget.replicate)); } document = document.ChangeMeasuredResults(measuredResults.ChangeChromatograms(chromatograms)); } var proteins = document.MoleculeGroups.ToArray(); for (int iProtein = 0; iProtein < proteins.Length; iProtein++) { var protein = proteins[iProtein]; _elementCount++; protein = (PeptideGroupDocNode)protein.ChangeAnnotations(AddAnnotations(protein.Annotations, AnnotationDef.AnnotationTarget.protein)); var peptides = protein.Molecules.ToArray(); for (int iPeptide = 0; iPeptide < peptides.Length; iPeptide++) { var peptide = peptides[iPeptide]; _elementCount++; peptide = (PeptideDocNode)peptide.ChangeAnnotations(AddAnnotations(peptide.Annotations, AnnotationDef.AnnotationTarget.peptide)); var precursors = peptide.TransitionGroups.ToArray(); for (int iPrecursor = 0; iPrecursor < precursors.Length; iPrecursor++) { var precursor = precursors[iPrecursor]; precursor = (TransitionGroupDocNode)precursor.ChangeAnnotations( AddAnnotations(precursor.Annotations, AnnotationDef.AnnotationTarget.precursor)); _elementCount++; var transitions = precursor.Transitions.ToArray(); for (int iTransition = 0; iTransition < transitions.Length; iTransition++) { var transition = transitions[iTransition]; _elementCount++; transition = (TransitionDocNode)transition.ChangeAnnotations( AddAnnotations(transition.Annotations, AnnotationDef.AnnotationTarget.transition)); if (transition.Results != null) { var results = transition.Results.ToArray(); for (int replicateIndex = 0; replicateIndex < results.Length; replicateIndex++) { _elementCount += results[replicateIndex].Count; results[replicateIndex] = new ChromInfoList <TransitionChromInfo>( results[replicateIndex] .Select(chromInfo => chromInfo.ChangeAnnotations(AddAnnotations( chromInfo.Annotations, AnnotationDef.AnnotationTarget.transition_result)))); } transition = transition.ChangeResults(new Results <TransitionChromInfo>(results)); } transitions[iTransition] = transition; } if (precursor.Results != null) { var results = precursor.Results.ToArray(); for (int replicateIndex = 0; replicateIndex < results.Length; replicateIndex++) { _elementCount += results[replicateIndex].Count; results[replicateIndex] = new ChromInfoList <TransitionGroupChromInfo>( results[replicateIndex].Select(chromInfo => chromInfo.ChangeAnnotations(AddAnnotations(chromInfo.Annotations, AnnotationDef.AnnotationTarget.precursor_result)))); } precursor = precursor.ChangeResults(new Results <TransitionGroupChromInfo>(results)); } precursor = (TransitionGroupDocNode)precursor.ChangeChildren(transitions); precursors[iPrecursor] = precursor; } peptide = (PeptideDocNode)peptide.ChangeChildren(precursors); peptides[iPeptide] = peptide; } protein = (PeptideGroupDocNode)protein.ChangeChildren(peptides); proteins[iProtein] = protein; } return((SrmDocument)document.ChangeChildren(proteins)); }
public SrmDocument PermuteIsotopeModifications(IProgressMonitor progressMonitor, SrmDocument document) { var progressStatus = new ProgressStatus(Resources.IsotopeModificationPermuter_PermuteIsotopeModifications_Permuting_isotope_modifications); progressMonitor.UpdateProgress(progressStatus.ChangePercentComplete(0)); int maxPermutationCount = 0; foreach (var peptide in document.Peptides) { if (SkipPeptide(peptide)) { continue; } int residueCount = PotentiallyModifiedResidues(peptide, IsotopeModification).Count; int permutationCount = SimplePermutation ? residueCount + 1 : 1 << residueCount; maxPermutationCount = Math.Max(permutationCount, maxPermutationCount); } var partialLabelTypes = new List <IsotopeLabelType>(maxPermutationCount); document = EnsureLabelTypes(progressMonitor, document, maxPermutationCount, partialLabelTypes); int totalPeptideCount = document.PeptideCount; int processedPeptideCount = 0; var newMoleculeGroups = new List <PeptideGroupDocNode>(); foreach (var peptideGroup in document.MoleculeGroups) { if (!peptideGroup.IsProteomic) { newMoleculeGroups.Add(peptideGroup); continue; } var newPeptides = new List <PeptideDocNode>(); foreach (var peptideDocNode in peptideGroup.Peptides) { if (progressMonitor.IsCanceled) { throw new OperationCanceledException(); } progressMonitor.UpdateProgress( progressStatus.ChangePercentComplete(100 * processedPeptideCount++ / totalPeptideCount)); var newPeptide = PermuteModificationsOnPeptide(document, peptideGroup, peptideDocNode, partialLabelTypes); newPeptides.Add(newPeptide); } var newChildren = ImmutableList.ValueOf(newPeptides.Cast <DocNode>()); if (ArrayUtil.ReferencesEqual(newChildren, peptideGroup.Children)) { newMoleculeGroups.Add(peptideGroup); } else { newMoleculeGroups.Add((PeptideGroupDocNode)peptideGroup.ChangeChildren(newChildren)); } } document = (SrmDocument)document.ChangeChildren(ImmutableList.ValueOf(newMoleculeGroups.Cast <DocNode>())); var pepModsNew = document.Settings.PeptideSettings.Modifications; pepModsNew = pepModsNew.DeclareExplicitMods(document, GlobalStaticMods, GlobalIsotopeMods); if (!Equals(pepModsNew, document.Settings.PeptideSettings.Modifications)) { var newSettings = document.Settings.ChangePeptideModifications(m => pepModsNew); document = document.ChangeSettings(newSettings); } return(document); }
public string GenerateDocumentXml(SrmDocument doc, string oldXml) { if (doc == null) { return(null); } // Minimize document to only the peptides we need var minimalPeptides = StandardPeptides.ToHashSet(); var oldPeptides = new Dictionary <Target, PeptideDocNode>(); if (!string.IsNullOrEmpty(oldXml)) { try { using (var reader = new StringReader(oldXml)) { var oldDoc = (SrmDocument) new XmlSerializer(typeof(SrmDocument)).Deserialize(reader); oldPeptides = oldDoc.Molecules.Where(pep => minimalPeptides.Contains(pep.Target)).ToDictionary(pep => pep.Target, pep => pep); } } catch { // ignored } } var addPeptides = new List <PeptideDocNode>(); foreach (var nodePep in doc.Molecules.Where(pep => minimalPeptides.Contains(pep.Target))) { if (oldPeptides.TryGetValue(nodePep.Target, out var nodePepOld)) { addPeptides.Add(nodePep.Merge(nodePepOld)); oldPeptides.Remove(nodePep.Target); } else { addPeptides.Add(nodePep); } } addPeptides.AddRange(oldPeptides.Values); var peptides = new List <PeptideDocNode>(); foreach (var nodePep in addPeptides) { var precursors = new List <DocNode>(); foreach (TransitionGroupDocNode nodeTranGroup in nodePep.Children) { var transitions = nodeTranGroup.Transitions.Where(tran => tran.ResultsRank.HasValue).OrderBy(tran => tran.ResultsRank.Value).Cast <DocNode>().ToList(); if (transitions.Count > 0) { precursors.Add(nodeTranGroup.ChangeChildren(transitions)); } } if (precursors.Count > 0) { peptides.Add((PeptideDocNode)nodePep.ChangeChildren(precursors)); } } if (peptides.Count == 0) { return(null); } peptides.Sort((nodePep1, nodePep2) => nodePep1.ModifiedTarget.CompareTo(nodePep2.ModifiedTarget)); doc = (SrmDocument)doc.ChangeChildren(new[] { new PeptideGroupDocNode(new PeptideGroup(), Resources.IrtDb_MakeDocumentXml_iRT_standards, string.Empty, peptides.ToArray()) }); // Clear some settings to make the document smaller and so that they won't get imported into a document // TODO: Convert all modifications to explicit? doc = doc.ChangeMeasuredResults(null); doc = doc.ChangeSettings(doc.Settings.ChangePeptideLibraries(libs => libs.ChangeLibraries(new List <LibrarySpec>(), new List <Library>()))); using (var writer = new StringWriter()) using (var writer2 = new XmlTextWriter(writer)) { doc.Serialize(writer2, null, SkylineVersion.CURRENT, null); return(writer.ToString()); } }
public void TestPaste() { ClearDefaultModifications(); _yeastDoc = new SrmDocument(SrmSettingsList.GetDefault().ChangeTransitionInstrument(instrument => instrument.ChangeMaxMz(1600))); _yeastDoc = _yeastDoc.ChangeSettings(_yeastDoc.Settings.ChangeTransitionFilter(filter => filter.ChangeMeasuredIons(new MeasuredIon[0]))); IdentityPath path; _yeastDocReadOnly = _yeastDoc = _yeastDoc.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST_LIB), false, IdentityPath.ROOT, out path); _study7DocReadOnly = _study7Doc = CreateStudy7Doc(); IdentityPath pathRoot = IdentityPath.ROOT; // Test pasting into document with same implicit modifications does not create any extra explicit modifications. var study7EmptyDoc = (SrmDocument)_study7Doc.ChangeChildren(new DocNode[0]); var study7PasteDoc = CopyPaste(_study7Doc, null, study7EmptyDoc, pathRoot); var arrayPeptides = _study7Doc.Peptides.ToArray(); var arrayPastePeptides = study7PasteDoc.Peptides.ToArray(); Assert.AreEqual(arrayPeptides.Length, arrayPastePeptides.Length); AssertEx.DocsEqual(_study7Doc, study7PasteDoc); // DocsEqual gives a more verbose failure message using XML output // Test implicit mods in source document become explicit mods in target document. ResetDocuments(); _yeastDoc = (SrmDocument)_yeastDoc.ChangeChildren(new DocNode[0]); var settings = _yeastDoc.Settings; _yeastDoc = _yeastDoc.ChangeSettings(settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(new StaticMod[0]))); _yeastDoc = CopyPaste(_study7Doc, null, _yeastDoc, pathRoot); var pepMods = _yeastDoc.Settings.PeptideSettings.Modifications; Assert.IsTrue(pepMods.StaticModifications != null); Assert.IsTrue(pepMods.HasHeavyModifications); Assert.IsFalse(pepMods.StaticModifications.Contains(mod => !mod.IsExplicit)); Assert.IsFalse(pepMods.HeavyModifications.Contains(mod => !mod.IsExplicit)); // Test explicit mods are dropped if the target document has matching implicit modifications. study7PasteDoc = CopyPaste(_yeastDoc, null, study7EmptyDoc, pathRoot); Assert.AreEqual(_study7Doc, study7PasteDoc); // Add new label type to source document. ResetDocuments(); const string labelTypeName13C = "heavy 13C"; var labelType13C = new IsotopeLabelType(labelTypeName13C, IsotopeLabelType.light.SortOrder + 1); _yeastDoc = ChangePeptideModifications(_yeastDoc, new[] { new TypedModifications(labelType13C, HEAVY_MODS_13_C) }); Assert.IsTrue(_yeastDoc.PeptideTransitionGroups.Contains(nodeGroup => Equals(nodeGroup.TransitionGroup.LabelType, labelType13C))); // Test pasting into the same document with new label type. _yeastDoc = CopyPaste(_yeastDoc, null, _yeastDoc, pathRoot); // Check all transition have correct label type references. Assert.IsFalse(_yeastDoc.PeptideTransitionGroups.Contains(nodeGroup => { IsotopeLabelType labelType = nodeGroup.TransitionGroup.LabelType; return(!ReferenceEquals(labelType, _yeastDoc.Settings.PeptideSettings.Modifications.GetModificationsByName(labelType.Name).LabelType)); })); // Check new document still serializes correctly. AssertEx.Serializable(_yeastDoc, AssertEx.DocumentCloned); // Test pasting into new document drops label types from source document that are not found in the target document. _yeastDoc = CopyPaste(_yeastDoc, null, new SrmDocument(SrmSettingsList.GetDefault()), pathRoot); Assert.IsNull(_yeastDoc.Settings.PeptideSettings.Modifications.GetModificationsByName(labelTypeName13C)); // If only specific children are selected, test that only these children get copied. ResetDocuments(); var arrayTrans = _study7Doc.PeptideTransitions.ToArray(); IList <DocNode> selNodes = new List <DocNode>(); for (int i = 0; i < arrayTrans.Length; i += 2) { selNodes.Add(arrayTrans[i]); } _study7Doc = CopyPaste(_study7Doc, selNodes, _study7Doc, pathRoot); Assert.AreEqual(arrayTrans.Length + selNodes.Count, _study7Doc.PeptideTransitionCount); // Test after pasting to a peptide list, all children have been updated to point to the correct parent. ResetDocuments(); _study7Doc = CopyPaste(_yeastDoc, new[] { _yeastDoc.Peptides.ToArray()[0] }, _study7Doc, _study7Doc.GetPathTo((int)SrmDocument.Level.MoleculeGroups, 0)); Assert.AreEqual(_yeastDoc.Peptides.ToArray()[0].Peptide, _study7Doc.Peptides.ToArray()[0].Peptide); Assert.AreEqual(_study7Doc.Peptides.ToArray()[0].Peptide, _study7Doc.PeptideTransitionGroups.ToArray()[0].TransitionGroup.Peptide); Assert.AreEqual(_study7Doc.PeptideTransitionGroups.ToArray()[0].TransitionGroup, _study7Doc.PeptideTransitions.ToArray()[0].Transition.Group); // If only specific transition are selected for a peptide, but all transition groups are included, test AutoManageChildren is true. ResetDocuments(); selNodes = new List <DocNode>(); foreach (TransitionGroupDocNode transGroup in _study7Doc.PeptideTransitionGroups) { selNodes.Add(transGroup.Children[0]); } // TODO: Fix this and make it pass // var emptyDoc = (SrmDocument)_study7Doc.ChangeChildren(new List<DocNode>()); // _study7Doc = CopyPaste(_study7Doc, selNodes, emptyDoc, pathRoot); _study7Doc = (SrmDocument)_study7Doc.ChangeChildren(new List <DocNode>()); _study7Doc = CopyPaste(_study7Doc, selNodes, _study7Doc, pathRoot); foreach (PeptideDocNode peptide in _study7Doc.Peptides) { Assert.IsTrue(peptide.AutoManageChildren); } // Test pasting in modifications with the same name as but different definition from existing modifications not allowed. ResetDocuments(); _yeastDoc = ChangePeptideModifications(_yeastDoc, new[] { new TypedModifications(IsotopeLabelType.heavy, HEAVY_C_K_DIFDEF) }); SetDefaultModifications(_study7Doc); AssertEx.ThrowsException <Exception>(() => _yeastDoc.Settings.UpdateDefaultModifications(false)); // Test variable modifications kept if target document has matching variable modifications turned on. ResetDocuments(); settings = _yeastDoc.Settings; var modsDefault = settings.PeptideSettings.Modifications; var listVariableMods = new List <StaticMod>(modsDefault.StaticModifications) { VAR_MET_OXIDIZED }; _yeastDoc = _yeastDoc.ChangeSettings(settings.ChangePeptideModifications(mods => mods.ChangeStaticModifications(listVariableMods.ToArray()))); // Make sure there is an implicitly modified peptide in the yeast document Assert.IsTrue(_yeastDoc.Peptides.Contains(nodePep => nodePep.Peptide.Sequence.Contains("C"))); Assert.IsTrue(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasVariableMods)); _yeastDoc = CopyPaste(_yeastDoc, null, _yeastDoc, pathRoot); Assert.IsFalse(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasExplicitMods && !nodePep.HasVariableMods)); // Otherwise the variable modifications become only explicit modifications. var yeastDocVar = _yeastDoc; _yeastDoc = _yeastDoc.ChangeSettings(_yeastDoc.Settings.ChangePeptideModifications(mods => modsDefault)); _yeastDoc = CopyPaste(yeastDocVar, null, _yeastDoc, pathRoot); Assert.IsFalse(_yeastDoc.Settings.PeptideSettings.Modifications.HasVariableModifications); Assert.IsTrue(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasExplicitMods)); Assert.IsFalse(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasVariableMods)); }