当前位置: 首页>>代码示例>>C#>>正文


C# SrmDocument.ImportFasta方法代码示例

本文整理汇总了C#中SrmDocument.ImportFasta方法的典型用法代码示例。如果您正苦于以下问题:C# SrmDocument.ImportFasta方法的具体用法?C# SrmDocument.ImportFasta怎么用?C# SrmDocument.ImportFasta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SrmDocument的用法示例。


在下文中一共展示了SrmDocument.ImportFasta方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MultiLabelExplicitSerialTest

        public void MultiLabelExplicitSerialTest()
        {
            // Create a simple document and add two peptides
            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault());
            const string pepSequence1 = "QFVLSCVILR";
            const string pepSequence2 = "DIEVYCDGAITTK";
            var reader = new StringReader(string.Join("\n", new[] {">peptides1", pepSequence1, pepSequence2}));
            IdentityPath path;
            document = document.ImportFasta(reader, true, IdentityPath.ROOT, out path);
            Assert.AreEqual(2, document.PeptideCount);

            // Add some modifications in two new label types
            var modCarb = new StaticMod("Carbamidomethyl Cysteine", "C", null, "C2H3ON");
            var modOther = new StaticMod("Another Cysteine", "C", null, "CO8N2");
            var staticMods = new[] {modCarb, modOther};
            var mod15N = new StaticMod("All 15N", null, null, null, LabelAtoms.N15, null, null);
            var modK13C = new StaticMod("13C K", "K", ModTerminus.C, null, LabelAtoms.C13, null, null);
            var modR13C = new StaticMod("13C R", "R", ModTerminus.C, null, LabelAtoms.C13, null, null);
            var modV13C = new StaticMod("Heavy V", "V", null, null, LabelAtoms.C13 | LabelAtoms.N15, null, null);
            var heavyMods = new[] { mod15N, modK13C, modR13C, modV13C };
            var labelTypeAA = new IsotopeLabelType("heavy AA", IsotopeLabelType.FirstHeavy);
            var labelTypeAll = new IsotopeLabelType("heavy All", IsotopeLabelType.FirstHeavy + 1);

            var settings = document.Settings;
            settings = settings.ChangePeptideModifications(mods =>
                new PeptideModifications(mods.StaticModifications,
                    new[]
                        {
                            new TypedModifications(labelTypeAA, new[] {modK13C, modR13C}),
                            new TypedModifications(labelTypeAll, new[] {mod15N})
                        }));
            document = document.ChangeSettings(settings);
            Assert.AreEqual(6, document.PeptideTransitionGroupCount);

            // Add modifications to light and heavy AA in the first peptide
            path = document.GetPathTo((int) SrmDocument.Level.Molecules, 0);
            var nodePepMod = (PeptideDocNode) document.FindNode(path);
            var explicitMod = new ExplicitMods(nodePepMod.Peptide,
                new[] {new ExplicitMod(pepSequence1.IndexOf('C'), modOther)},
                new[] {new TypedExplicitModifications(nodePepMod.Peptide, labelTypeAA, new ExplicitMod[0])});
            document = document.ChangePeptideMods(path, explicitMod, staticMods, heavyMods);
            Assert.AreEqual(5, document.PeptideTransitionGroupCount);

            // Add a modification to heavy All in the second peptide
            path = document.GetPathTo((int)SrmDocument.Level.Molecules, 1);
            nodePepMod = (PeptideDocNode)document.FindNode(path);
            explicitMod = new ExplicitMods(nodePepMod.Peptide, null,
                new[] { new TypedExplicitModifications(nodePepMod.Peptide, labelTypeAll,
                            new[] {new ExplicitMod(pepSequence2.IndexOf('V'), modV13C)}) });
            document = document.ChangePeptideMods(path, explicitMod, staticMods, heavyMods);
            Assert.AreEqual(5, document.PeptideTransitionGroupCount);

            AssertEx.Serializable(document, 3, AssertEx.DocumentCloned);
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:54,代码来源:IsotypeModTest.cs

示例2: NeutralLossListTest

        public void NeutralLossListTest()
        {
            TestSmallMolecules = false; // No concept of neutral loss for small molecules

            var phosphoLossMod = new StaticMod("Phospho Loss", "S, T, Y", null, false, "HPO3",
                LabelAtoms.None, RelativeRT.Matching, null, null, new[] { new FragmentLoss("H3PO4"), });

            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault().ChangePeptideModifications(mods =>
                mods.ChangeStaticModifications(new List<StaticMod>(mods.StaticModifications) { phosphoLossMod })));
            IdentityPath path = IdentityPath.ROOT;
            SrmDocument docFasta = document.ImportFasta(new StringReader(TEXT_FASTA_YEAST_7), false, path, out path);

            Assert.AreEqual(0, GetLossCount(docFasta, 1));

            // Insert losses into the first transition group
            var pathPeptide = docFasta.GetPathTo((int) SrmDocument.Level.Molecules, 0);
            var nodePep = (PeptideDocNode) docFasta.FindNode(pathPeptide);
            var nodeGroup = (TransitionGroupDocNode) nodePep.Children[0];
            var listChildren = new List<DocNode>(nodeGroup.Children);
            foreach (var nodeTran in nodeGroup.GetTransitions(docFasta.Settings,
                nodePep.ExplicitMods, nodeGroup.PrecursorMz, null, null, null, false))
            {
                if (!nodeTran.HasLoss)
                    continue;

                var tran = nodeTran.Transition;
                int matchIndex = listChildren.IndexOf(node =>
                    Equals(tran, ((TransitionDocNode)node).Transition));
                if (matchIndex == -1)
                    continue;

                while (matchIndex < listChildren.Count &&
                    Equals(tran, ((TransitionDocNode)listChildren[matchIndex]).Transition))
                {
                    matchIndex++;
                }
                listChildren.Insert(matchIndex, nodeTran);
            }

            var docLosses = (SrmDocument) docFasta.ReplaceChild(pathPeptide,
                nodeGroup.ChangeChildren(listChildren));

            int lossCount = GetLossCount(docLosses, 1);
            Assert.IsTrue(lossCount > 0);
            var docRoundTripped = AssertEx.RoundTripTransitionList(new ThermoMassListExporter(docLosses));
            Assert.AreEqual(lossCount, GetLossCount(docRoundTripped, 1));
            docRoundTripped = AssertEx.RoundTripTransitionList(new AgilentMassListExporter(docLosses));
            Assert.AreEqual(lossCount, GetLossCount(docRoundTripped, 1));
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:49,代码来源:LossesTest.cs

示例3: CreateMixedDoc

 private static SrmDocument CreateMixedDoc()
 {
     SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault0_6());
     IdentityPath path;
     // Add fasta sequences
     SrmDocument docFasta = document.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST),
         false, IdentityPath.ROOT, out path);
     AssertEx.IsDocumentState(docFasta, 1, 2, 98, 311);
     // Insert peptide list at beginnning
     SrmDocument docMixed = docFasta.ImportFasta(new StringReader(SrmDocEditTest.TEXT_BOVINE_PEPTIDES1),
         true, docFasta.GetPathTo(0), out path);
     AssertEx.IsDocumentState(docMixed, 2, 3, 111, 352);
     return docMixed;
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:14,代码来源:SrmSettingsChangeTest.cs

示例4: TestPaste

        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);

//.........这里部分代码省略.........
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:PasteTest.cs

示例5: VariableModBasicTest

        public void VariableModBasicTest()
        {
            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault0_6());

            // Make sure default document produces no variable modifications
            IdentityPath path = IdentityPath.ROOT;
            var docYeast = document.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST), false, path, out path);
            Assert.AreEqual(0, GetVariableModCount(docYeast));

            // Add a single variable modification
            var settings = document.Settings;
            var modsDefault = settings.PeptideSettings.Modifications;
            var listStaticMods = new List<StaticMod>(modsDefault.StaticModifications) {VAR_MET_OXIDIZED};
            var docMetOxidized = document.ChangeSettings(settings.ChangePeptideModifications(mods =>
                mods.ChangeStaticModifications(listStaticMods.ToArray())));

            // Make sure variable modifications are added as expected to imported FASTA
            path = IdentityPath.ROOT;
            var docMoYeast = docMetOxidized.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST), false, path, out path);
            Assert.AreEqual(21, GetVariableModCount(docMoYeast));
            AssertEx.IsDocumentState(docMoYeast, 2, 2, 119, 374);

            // Exclude unmodified peptides
            var docNoMoExclude = docMoYeast.ChangeSettings(docMoYeast.Settings.ChangePeptideFilter(f =>
                f.ChangeExclusions(new[] { new PeptideExcludeRegex("Non-Oxidized Meth", "M\\[", true, true) })));
            Assert.AreEqual(GetVariableModCount(docMoYeast), GetVariableModCount(docNoMoExclude));
            Assert.AreEqual(docNoMoExclude.PeptideCount, GetVariableModCount(docNoMoExclude));
            AssertEx.IsDocumentState(docNoMoExclude, 3, 2, 21, 63);

            // Exclude multiply modified peptides
            var docMultMoExclude = docNoMoExclude.ChangeSettings(docNoMoExclude.Settings.ChangePeptideFilter(f =>
                f.ChangeExclusions(new List<PeptideExcludeRegex>(f.Exclusions) { new PeptideExcludeRegex("Multi-Oxidized Meth", "M\\[.*M\\[", false, true) })));
            Assert.AreEqual(docMultMoExclude.PeptideCount, GetVariableModCount(docMultMoExclude));
            AssertEx.IsDocumentState(docMultMoExclude, 4, 2, 18, 56);

            // And that removing the variable modification removes the variably modifide peptides
            var docYeast2 = docMoYeast.ChangeSettings(docMoYeast.Settings.ChangePeptideModifications(mods => modsDefault));
            Assert.AreEqual(0, GetVariableModCount(docYeast2));
            Assert.AreEqual(docYeast, docYeast2);
            Assert.AreNotSame(docYeast, docYeast2);

            // Even when automanage children is turned off
            var docNoAuto = (SrmDocument)docMoYeast.ChangeChildren((from node in docYeast2.MoleculeGroups
                                                                   select node.ChangeAutoManageChildren(false)).ToArray());
            var docYeastNoAuto = docNoAuto.ChangeSettings(docYeast.Settings);
            Assert.AreEqual(0, GetVariableModCount(docYeastNoAuto));
            // Shouldn't come back, if the mods are restored
            var docMoNoAuto = docYeastNoAuto.ChangeSettings(docMetOxidized.Settings);
            Assert.AreEqual(0, GetVariableModCount(docMoNoAuto));
            Assert.AreSame(docYeastNoAuto.Children, docMoNoAuto.Children);

            // Make sure loss modification result in smaller m/z values
            var listModsLoss = new List<StaticMod>(modsDefault.StaticModifications) { VAR_ASP_WATER_LOSS };
            var docAspLoss = docYeast2.ChangeSettings(docYeast2.Settings.ChangePeptideModifications(mods =>
                mods.ChangeStaticModifications(listModsLoss.ToArray())));
            Assert.AreEqual(145, GetVariableModCount(docAspLoss));
            VerifyModificationOrder(docAspLoss, false);

            // Add multiple variable modifications
            listStaticMods.Add(VAR_ASP_WATER_ADD);
            var docVarMulti = docYeast2.ChangeSettings(docYeast2.Settings.ChangePeptideModifications(mods =>
                mods.ChangeStaticModifications(listStaticMods.ToArray())));
            Assert.AreEqual(220, GetVariableModCount(docVarMulti));
            int maxModifiableMulti = GetMaxModifiableCount(docVarMulti);
            Assert.IsTrue(maxModifiableMulti > GetMaxModifiedCount(docVarMulti));
            VerifyModificationOrder(docVarMulti, true);

            // Repeat with a single variable modification on multiple amino acids
            // and verify that this creates the same number of variably modified peptides
            var listModsMultiAA = new List<StaticMod>(modsDefault.StaticModifications) { VAR_MET_ASP_OXIDIZED };
            var docVarMultiAA = docYeast2.ChangeSettings(docYeast2.Settings.ChangePeptideModifications(mods =>
                mods.ChangeStaticModifications(listModsMultiAA.ToArray())));
            Assert.AreEqual(220, GetVariableModCount(docVarMultiAA));
            VerifyModificationOrder(docVarMultiAA, true);

            // And also multiple modifications on the same amino acid residue
            listStaticMods.Add(VAR_MET_AMONIA_ADD);
            var docVarAaMulti = docVarMulti.ChangeSettings(docVarMulti.Settings.ChangePeptideModifications(mods =>
                mods.ChangeStaticModifications(listStaticMods.ToArray())));
            Assert.AreEqual(315, GetVariableModCount(docVarAaMulti));
            int maxModifiableAaMulti = GetMaxModifiableCount(docVarAaMulti);
            Assert.AreEqual(maxModifiableMulti, maxModifiableAaMulti,
                "Unexptected change in the maximum number of modifiable amino acids");
            Assert.IsTrue(maxModifiableAaMulti > GetMaxModifiedCount(docVarAaMulti));
            VerifyModificationOrder(docVarAaMulti, true);

            // Reduce the maximum number of variable modifications allowed
            var docVar2AaMulti = docVarAaMulti.ChangeSettings(docVarAaMulti.Settings.ChangePeptideModifications(mods =>
                mods.ChangeMaxVariableMods(2)));
            Assert.AreEqual(242, GetVariableModCount(docVar2AaMulti));
            Assert.AreEqual(2, GetMaxModifiedCount(docVar2AaMulti));
            VerifyModificationOrder(docVar2AaMulti, true);

            var docVar1AaMulti = docVar2AaMulti.ChangeSettings(docVar2AaMulti.Settings.ChangePeptideModifications(mods =>
                mods.ChangeMaxVariableMods(1)));
            Assert.AreEqual(128, GetVariableModCount(docVar1AaMulti));
            Assert.AreEqual(1, GetMaxModifiedCount(docVar1AaMulti));
            VerifyModificationOrder(docVar1AaMulti, true);

            var docVarAaMultiReset = docVar1AaMulti.ChangeSettings(docVarAaMulti.Settings);
//.........这里部分代码省略.........
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:VariableModTest.cs

示例6: MultiLabelTypeTest

        public void MultiLabelTypeTest()
        {
            int startRev = 0;
            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault().ChangeTransitionInstrument(inst => inst.ChangeMaxMz(1800)));

            // Add some FASTA
            IdentityPath path, pathRoot = IdentityPath.ROOT;
            SrmDocument docFasta = document.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST_LIB), false, pathRoot, out path);
            const int initProt = 2, initPep = 26, initTran = 89;
            AssertEx.IsDocumentState(docFasta, ++startRev, initProt, initPep, initTran);

            // Add multiple heavy types
            var settings = docFasta.Settings.ChangePeptideModifications(mods => new PeptideModifications(mods.StaticModifications,
                new[]
                    {
                        new TypedModifications(LABEL_TYPE13_C, HEAVY_MODS_13_C),
                        new TypedModifications(LABEL_TYPE15_N, HEAVY_MODS_15_N)
                    }));
            var docMulti = docFasta.ChangeSettings(settings);

            // Make sure the contents of the resulting document are as expected.
            int countProteinTermTran, countProteinTerm;
            VerifyMultiLabelContent(docFasta, docMulti, out countProteinTerm, out countProteinTermTran);
            int multiGroupCount = initPep*3 - countProteinTerm;
            int multiTranCount = initTran*3 - countProteinTermTran;
            AssertEx.IsDocumentState(docMulti, ++startRev, initProt, initPep,
                multiGroupCount, multiTranCount);

            // Turn off auto-manage children on all peptides
            var listPepGroups = new List<DocNode>();
            foreach (PeptideGroupDocNode nodePepGroup in docMulti.MoleculeGroups)
            {
                var listPeptides = new List<DocNode>();
                foreach (PeptideDocNode nodePep in nodePepGroup.Children)
                    listPeptides.Add(nodePep.ChangeAutoManageChildren(false));
                listPepGroups.Add(nodePepGroup.ChangeChildren(listPeptides));
            }
            var docNoAuto = (SrmDocument) docMulti.ChangeChildren(listPepGroups);
            startRev++;

            // Switch back to settings without isotope labels
            var docNoAutoLight = docNoAuto.ChangeSettings(docFasta.Settings);
            // The document should return to its initial state
            AssertEx.IsDocumentState(docNoAutoLight, ++startRev, initProt, initPep, initTran);

            // Switch back to Settings with isotope labels
            var docNoAutoLabeled = docNoAutoLight.ChangeSettings(docMulti.Settings);
            // The number of nodes should not change
            AssertEx.IsDocumentState(docNoAutoLabeled, ++startRev, initProt, initPep, initTran);

            // Remove all document nodes
            var docEmpty = (SrmDocument) docNoAutoLabeled.ChangeChildren(new PeptideGroupDocNode[0]);

            // Paste FASTA back in
            var docRePaste = docEmpty.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST_LIB), false, pathRoot, out path);
            // This should produce the same document as the original settings change
            Assert.AreEqual(docMulti, docRePaste);
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:58,代码来源:IsotypeModTest.cs

示例7: MultiLabelTypeListTest

        public void MultiLabelTypeListTest()
        {
            TestSmallMolecules = false; // we don't expect to roundtrip export/import of transition lists for non-proteomic molecules

            int startRev = 0;
            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault().ChangeTransitionInstrument(inst => inst.ChangeMaxMz(1800)));

            // Add some FASTA
            IdentityPath path, pathRoot = IdentityPath.ROOT;
            SrmDocument docFasta = document.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST_LIB), false, pathRoot, out path);
            const int initProt = 2, initPep = 26, initTran = 89;
            AssertEx.IsDocumentState(docFasta, ++startRev, initProt, initPep, initTran);

            // Add multiple heavy types
            var settings = docFasta.Settings.ChangePeptideModifications(mods => new PeptideModifications(mods.StaticModifications,
                new[]
                    {
                        new TypedModifications(LABEL_TYPE13_C, HEAVY_MODS_13_C),
                        new TypedModifications(LABEL_TYPE15_N, HEAVY_MODS_15_N)
                    }));
            var docMulti = docFasta.ChangeSettings(settings);

            // CONSIDER: make explicit S-Lens, cone voltage, CE etc roundtrip?
            // docMulti.MoleculeTransitionGroups.FirstOrDefault().ChangeExplicitValues(ExplicitTransitionGroupValues.TEST)

            // Make sure transition lists export to various formats and roundtrip
            VerifyExportRoundTrip(new ThermoMassListExporter(docMulti), docFasta);
            VerifyExportRoundTrip(new AbiMassListExporter(docMulti), docFasta);
            VerifyExportRoundTrip(new AgilentMassListExporter(docMulti), docFasta);
            VerifyExportRoundTrip(new WatersMassListExporter(docMulti), docFasta);
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:31,代码来源:IsotypeModTest.cs

示例8: SpecialFragmentTest

        public void SpecialFragmentTest()
        {
            var docOriginal = new SrmDocument(SrmSettingsList.GetDefault());
            IdentityPath path;
            var docPeptide = docOriginal.ImportFasta(new StringReader(">peptide1\nPEPMCIDEPR"),
                true, IdentityPath.ROOT, out path);
            // One of the prolines should have caused an extra transition
            Assert.AreEqual(4, docPeptide.PeptideTransitionCount);
            Assert.IsTrue(docPeptide.PeptideTransitions.Contains(nodeTran => nodeTran.Transition.Ordinal == 8)); // y8

            // Switch to the legacy version of the proline fragment where min length is 1
            var docLegacyProline = docPeptide.ChangeSettings(docPeptide.Settings.ChangeTransitionFilter(filter =>
                filter.ChangeMeasuredIons(new[] { MeasuredIonList.NTERM_PROLINE_LEGACY })));
            Assert.AreEqual(5, docLegacyProline.PeptideTransitionCount);
            // Allow b-ions
            var docLegacyProlineB = docLegacyProline.ChangeSettings(docLegacyProline.Settings.ChangeTransitionFilter(filter =>
                filter.ChangeIonTypes(new[] { IonType.b, IonType.y })));
            Assert.AreEqual(9, docLegacyProlineB.PeptideTransitionCount);

            // Add C-terminal Glu and Asp to the original peptide document
            var docGluAsp = docPeptide.ChangeSettings(docPeptide.Settings.ChangeTransitionFilter(filter =>
                filter.ChangeMeasuredIons(new List<MeasuredIon>(filter.MeasuredIons) { MeasuredIonList.CTERM_GLU_ASP })));
            Assert.AreEqual(5, docGluAsp.PeptideTransitionCount);
            Assert.IsTrue(docGluAsp.PeptideTransitions.Contains(nodeTran => nodeTran.Transition.Ordinal == 3)); // y3

            // Use the legacy version instead
            var docGluAspLegacy = docPeptide.ChangeSettings(docPeptide.Settings.ChangeTransitionFilter(filter =>
                filter.ChangeMeasuredIons(new List<MeasuredIon>(filter.MeasuredIons) { MeasuredIonList.CTERM_GLU_ASP_LEGACY })));
            Assert.AreEqual(6, docGluAspLegacy.PeptideTransitionCount);
            Assert.IsTrue(docGluAspLegacy.PeptideTransitions.Contains(nodeTran => nodeTran.Transition.Ordinal == 2)); // y2

            // Add Proline to the C-terminal modification
            var docGluAspPro = docPeptide.ChangeSettings(docPeptide.Settings.ChangeTransitionFilter(filter =>
                filter.ChangeMeasuredIons(new[] { new MeasuredIon("C-term GAP", "EDP", null, SequenceTerminus.C, 1) })));
            Assert.AreEqual(8, docGluAspPro.PeptideTransitionCount);
            Assert.IsTrue(docGluAspPro.PeptideTransitions.Contains(nodeTran =>
                nodeTran.Transition.Ordinal == 2 || // y2
                nodeTran.Transition.Ordinal == 8)); // y8

            // Restrict
            var docGluAspProRestrict = docPeptide.ChangeSettings(docPeptide.Settings.ChangeTransitionFilter(filter =>
                filter.ChangeMeasuredIons(new[] { new MeasuredIon("C-term GAP", "EDP", "P", SequenceTerminus.C, 1) })));
            Assert.AreEqual(6, docGluAspProRestrict.PeptideTransitionCount);
            Assert.IsFalse(docGluAspProRestrict.PeptideTransitions.Contains(nodeTran =>
                nodeTran.Transition.Ordinal == 2 || // not y2
                nodeTran.Transition.Ordinal == 8)); // not y8
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:47,代码来源:TransitionSettings07Test.cs

示例9: ReporterIonTest

        public void ReporterIonTest()
        {
            // Test the code that updates old-style formulas
            Assert.AreEqual("C5C'H13N2", BioMassCalc.AddH("C5C'H12N2"));
            Assert.AreEqual("CO2H", BioMassCalc.AddH("CO2"));

            var docOriginal = new SrmDocument(SrmSettingsList.GetDefault().ChangeTransitionInstrument(instrument => instrument.ChangeMinMz(10)));  // H2O2 is not very heavy!
            IdentityPath path;
            SrmDocument docPeptide = docOriginal.ImportFasta(new StringReader(">peptide1\nPEPMCIDEPR"),
                true, IdentityPath.ROOT, out path);
            // One of the prolines should have caused an extra transition
            Assert.AreEqual(4, docPeptide.PeptideTransitionCount);
            Assert.IsTrue(docPeptide.PeptideTransitions.Contains(nodeTran => nodeTran.Transition.Ordinal == 8));

            const string formula = "H2O2";  // This was H2O, but that falls below mz=10 at z > 1
            const string hydrogenPeroxide = "Hydrogen Perxoide";
            var reporterIons = new[] { new MeasuredIon(hydrogenPeroxide, formula, null, null, 1), new MeasuredIon(hydrogenPeroxide, formula, null, null, 2), new MeasuredIon(hydrogenPeroxide, formula, null, null, 3), MeasuredIonList.NTERM_PROLINE };
            SrmDocument docReporterIon = docPeptide.ChangeSettings(docPeptide.Settings.ChangeTransitionFilter(filter =>
                filter.ChangeMeasuredIons(reporterIons)));
            AssertEx.IsDocumentTransitionCount(docReporterIon, 7);

            //Check With Monoisotopic
            double mass = BioMassCalc.MONOISOTOPIC.CalculateMassFromFormula(formula);
            for (int i = 0; i < 3; i ++)
            {
                TransitionDocNode tranNode = docReporterIon.MoleculeTransitions.ElementAt(i);
                Transition tran = tranNode.Transition;
                Assert.AreEqual(reporterIons[i].CustomIon, tran.CustomIon);
                Assert.AreEqual(tran.Charge, i + 1);
                Assert.AreEqual(BioMassCalc.MONOISOTOPIC.CalculateIonMz(formula, i + 1), tranNode.Mz, BioMassCalc.MassElectron/100);
                Assert.AreEqual(BioMassCalc.CalculateIonMz(mass, i + 1), tranNode.Mz, BioMassCalc.MassElectron / 100);
            }

            //Check with Average
            TransitionPrediction predSettings =
                docReporterIon.Settings.TransitionSettings.Prediction.ChangeFragmentMassType(MassType.Average);
            TransitionSettings tranSettings = docReporterIon.Settings.TransitionSettings.ChangePrediction(predSettings);
            SrmSettings srmSettings = docReporterIon.Settings.ChangeTransitionSettings(tranSettings);
            SrmDocument averageDocument = docReporterIon.ChangeSettings(srmSettings);
            mass = BioMassCalc.AVERAGE.CalculateMassFromFormula(formula);
            for (int i = 0; i < 3; i++)
            {
                TransitionDocNode tranNode = averageDocument.MoleculeTransitions.ElementAt(i);
                Transition tran = tranNode.Transition;
                Assert.AreEqual(reporterIons[i].CustomIon, tran.CustomIon);
                Assert.AreEqual(tran.Charge, i + 1);
                Assert.AreEqual(BioMassCalc.AVERAGE.CalculateIonMz(formula, i + 1), tranNode.Mz, BioMassCalc.MassElectron / 100);
                Assert.AreEqual(BioMassCalc.CalculateIonMz(mass, i + 1), tranNode.Mz, BioMassCalc.MassElectron / 100);
            }

            //Make sure the rest of the transitions aren't reporter ions
            for (int i = 3; i < 7; i ++)
            {
                Transition tran = docReporterIon.MoleculeTransitions.ElementAt(i).Transition;
                Assert.AreNotEqual(tran.CustomIon, reporterIons);
            }
            var optionalIon = new MeasuredIon(hydrogenPeroxide, formula, null, null,1, true);
            SrmDocument optionalDoc = docPeptide.ChangeSettings(docPeptide.Settings.ChangeTransitionFilter(filter =>
                filter.ChangeMeasuredIons(new[] {optionalIon})));
            Assert.AreEqual(3, optionalDoc.PeptideTransitionCount);
            optionalDoc = optionalDoc.ChangeSettings(optionalDoc.Settings.ChangeTransitionFilter(filter =>
                filter.ChangeMeasuredIons(new[] {optionalIon.ChangeIsOptional(false)})));
            AssertEx.IsDocumentTransitionCount(optionalDoc, 4);
            Assert.AreEqual(optionalIon.ChangeIsOptional(false).CustomIon,
                optionalDoc.MoleculeTransitions.ElementAt(0).Transition.CustomIon);
            optionalDoc =
                optionalDoc.ChangeSettings(
                    optionalDoc.Settings.ChangeTransitionFilter(
                        filter => filter.ChangeMeasuredIons(new[] {optionalIon.ChangeIsOptional(true)})));

            TransitionGroupDocNode nodeGroup = optionalDoc.MoleculeTransitionGroups.ElementAt(0);
            var filteredNodes =
                TransitionGroupTreeNode.GetChoices(nodeGroup, optionalDoc.Settings,
                    optionalDoc.Molecules.ElementAt(0).ExplicitMods, true)
                    .Cast<TransitionDocNode>()
                    .Where(node => Equals(node.Transition.CustomIon, optionalIon.CustomIon));

            var unfilteredNodes =
                TransitionGroupTreeNode.GetChoices(nodeGroup, optionalDoc.Settings,
                    optionalDoc.Molecules.ElementAt(0).ExplicitMods, false)
                    .Cast<TransitionDocNode>()
                    .Where(node => Equals(node.Transition.CustomIon, optionalIon.CustomIon));

            Assert.AreEqual(0,filteredNodes.Count());
            Assert.AreEqual(1,unfilteredNodes.Count());
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:86,代码来源:TransitionSettings07Test.cs

示例10: DynamicMinMzTest

        public void DynamicMinMzTest()
        {
            var revisionIndex = 1;
            var settings = SrmSettingsList.GetDefault().ChangeTransitionFilter(filter =>
                filter.ChangeIonTypes(new[] { IonType.y, IonType.b })
                      .ChangeFragmentRangeFirstName("ion 1")
                      .ChangeFragmentRangeLastName("last ion"));
            var docOriginal = new SrmDocument(settings);
            IdentityPath path;
            var docPeptides = docOriginal.ImportFasta(new StringReader(">peptides\nESTIGNSAFELLLEVAK\nTVYHAGTK"),
                true, IdentityPath.ROOT, out path);
            AssertEx.IsDocumentState(docPeptides, revisionIndex++, 1, 2, 2, 40);
            // Both precursors should contain 1 and 2 ions
            foreach (var nodeGroup in docPeptides.PeptideTransitionGroups)
            {
                Assert.IsTrue(nodeGroup.Children.Contains(node => ((TransitionDocNode)node).Transition.Ordinal == 1));
                Assert.IsTrue(nodeGroup.Children.Contains(node => ((TransitionDocNode)node).Transition.Ordinal == 2));
            }

            // Switch to using dynamic minimum for product ions
            settings = settings.ChangeTransitionInstrument(instrument => instrument.ChangeIsDynamicMin(true));
            var docDynamicMin = docPeptides.ChangeSettings(settings);
            AssertEx.IsDocumentState(docDynamicMin, revisionIndex++, 1, 2, 35);
            var arrayNodeGroups = docDynamicMin.PeptideTransitionGroups.ToArray();
            // The larger precursor should no longer have 1 or 2 ions
            Assert.IsFalse(arrayNodeGroups[0].Children.Contains(node =>
                ((TransitionDocNode)node).Transition.Ordinal == 1 ||
                ((TransitionDocNode)node).Transition.Ordinal == 2));
            // But the smaller precursor should retain at least one of both
            Assert.IsTrue(arrayNodeGroups[1].Children.Contains(node => ((TransitionDocNode)node).Transition.Ordinal == 1));
            Assert.IsTrue(arrayNodeGroups[1].Children.Contains(node => ((TransitionDocNode)node).Transition.Ordinal == 2));

            // Use a minimum that is high enough to exclude the smaller precursor
            settings = settings.ChangeTransitionInstrument(instrument => instrument.ChangeMinMz(500));
            var docHighMinDynamicMz = docDynamicMin.ChangeSettings(settings);
            AssertEx.IsDocumentState(docHighMinDynamicMz, revisionIndex++, 1, 2, 1, 22);
            // Because of the dynamic minimum for product ions, the remaining precursor should not have changed
            var nodeGroupHigh = docHighMinDynamicMz.PeptideTransitionGroups.ToArray()[0];
            Assert.AreSame(arrayNodeGroups[0], nodeGroupHigh);

            // Remove dynamic minimum, and verify that product ions are removed
            settings = settings.ChangeTransitionInstrument(instrument => instrument.ChangeIsDynamicMin(false));
            var docHighMinMz = docHighMinDynamicMz.ChangeSettings(settings);
            AssertEx.IsDocumentState(docHighMinMz, revisionIndex, 1, 2, 1, 17);

            // No library test, because it is hard to test.  Many of the library
            // spectra are likely gathered with LTQs which apply the same dynamic
            // minimum to the ms/ms peaks they measure.
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:49,代码来源:TransitionSettings07Test.cs

示例11: ImportFastaTest

        public void ImportFastaTest()
        {
            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault0_6());
            IdentityPath path = IdentityPath.ROOT;
            SrmDocument docFasta = document.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST), false, path, out path);
            AssertEx.IsDocumentState(docFasta, 1, 2, 98, 311);
            Assert.AreEqual("YAL001C", ((PeptideGroupDocNode)docFasta.Children[0]).Name);
            Assert.AreEqual("YAL002W", ((PeptideGroupDocNode)docFasta.Children[1]).Name);
            Assert.AreEqual(1, path.Length);
            Assert.IsInstanceOfType(path.GetIdentity(0), typeof(FastaSequence));
            Assert.AreEqual("YAL001C", ((FastaSequence) path.GetIdentity(0)).Name);
            int maxMz = docFasta.Settings.TransitionSettings.Instrument.MaxMz - 120;
            foreach (PeptideGroupDocNode nodeGroup in docFasta.Children)
            {
                if (SrmDocument.IsSpecialNonProteomicTestDocNode(nodeGroup))
                    continue;

                Assert.IsInstanceOfType(nodeGroup.Id, typeof(FastaSequence));

                int lastEnd = docFasta.Settings.PeptideSettings.Filter.ExcludeNTermAAs - 1;

                foreach (PeptideDocNode nodePeptide in nodeGroup.Children)
                {
                    Peptide peptide = nodePeptide.Peptide;
                    char prev = peptide.PrevAA;
                    if (prev != 'K' && prev != 'R')
                        Assert.Fail("Unexpected preceding cleavage at {0}", prev);
                    string seq = peptide.Sequence;
                    char last = seq[seq.Length - 1];
                    if (last != 'K' && last != 'R' && peptide.NextAA != '-')
                        Assert.Fail("Unexpected cleavage at {0}", last);
                    Assert.IsNotNull(peptide.Begin);
                    Assert.IsNotNull(peptide.End);

                    // Make sure peptides are ordered, and not overlapping
                    if (peptide.Begin.Value < lastEnd)
                        Assert.Fail("Begin {0} less than last end {1}.", peptide.Begin.Value, lastEnd);
                    lastEnd = peptide.End.Value;

                    IList<DocNode> nodesTrans = ((DocNodeParent) nodePeptide.Children[0]).Children;
                    int trans = nodesTrans.Count;
                    if (trans < 3)
                    {
                        // Might have been cut off by the instrument limit.
                        if ((trans == 0 && ((TransitionGroupDocNode)nodePeptide.Children[0]).PrecursorMz < maxMz) ||
                                (trans > 0 && ((TransitionDocNode)nodesTrans[0]).Mz < maxMz))
                            Assert.Fail("Found {0} transitions, expecting 3.", trans);
                    }
                    // Might have extra proline transitions
                    else if (trans > 3 && peptide.Sequence.IndexOf('P') == -1)
                        Assert.Fail("Found {0} transitions, expecting 3.", trans);

                    // Make sure transitions are ordered correctly
                    IonType lastType = IonType.a;
                    int lastOffset = -1;
                    foreach (TransitionDocNode nodeTran in nodesTrans)
                    {
                        Transition transition = nodeTran.Transition;
                        if (lastType == transition.IonType)
                            Assert.IsTrue(transition.CleavageOffset > lastOffset);
                        else
                            Assert.IsTrue(((int)transition.IonType) > ((int) lastType));
                        lastType = transition.IonType;
                        lastOffset = transition.CleavageOffset;
                    }
                }
            }

            // Make sure old document is unmodified.
            Assert.AreEqual(0, document.RevisionIndex);
            Assert.AreEqual(0, document.PeptideTransitionCount);

            // Re-paste of fasta should have no impact.
            // path = IdentityPath.ROOT; use null as substitute for Root
            SrmDocument docFasta2 = docFasta.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST), false, null, out path);
            // Returns the original document to avoid adding undo record in running app
            Assert.AreSame(docFasta, docFasta2);
            Assert.IsNull(path);

            // Discard double-insert document, and add peptides list into previous document
            path = IdentityPath.ROOT;
            SrmDocument docPeptides = docFasta.ImportFasta(new StringReader(TEXT_BOVINE_PEPTIDES1), true, path, out path);
            AssertEx.IsDocumentState(docPeptides, 2, 3, 111, 352);
            Assert.AreEqual(1, path.Length);
            Assert.IsNotInstanceOfType(path.GetIdentity(0), typeof(FastaSequence));
            Assert.AreEqual("Peptides1", ((PeptideGroupDocNode)docPeptides.FindNode(path)).Name);
            PeptideGroupDocNode nodePepList = (PeptideGroupDocNode) docPeptides.Children[2];
            Assert.IsNotInstanceOfType(nodePepList.Id, typeof(FastaSequence));
            // Make sure other two nodes are unchanged
            Assert.AreSame(docFasta.Children[0], docPeptides.Children[0]);
            Assert.AreSame(docFasta.Children[1], docPeptides.Children[1]);

            foreach (PeptideDocNode nodePeptide in nodePepList.Children)
            {
                if (SrmDocument.IsSpecialNonProteomicTestDocNode(nodePeptide))
                    continue;
                char prev = nodePeptide.Peptide.PrevAA;
                char next = nodePeptide.Peptide.NextAA;
                if (prev != 'X' || next != 'X')
                    Assert.Fail("Expected amino acids X, but found {0} or {1}", prev, next);
//.........这里部分代码省略.........
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:SrmDocEditTest.cs

示例12: RemoveDuplicatePeptidesTest

        public void RemoveDuplicatePeptidesTest()
        {
            // First try removals with no impact
            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault0_6());
            IdentityPath path;
            SrmDocument docFasta = document.ImportFasta(new StringReader(string.Format(TEXT_FASTA_YEAST_FRAGMENT, 1)),
                false, IdentityPath.ROOT, out path);
            AssertEx.IsDocumentState(docFasta, 1, 1, 11, 36);
            var refinementSettings = new RefinementSettings {RemoveDuplicatePeptides = true};
            SrmDocument docFasta2 = refinementSettings.Refine(docFasta);
            Assert.AreSame(docFasta, docFasta2);

            docFasta2 = docFasta.ImportFasta(new StringReader(string.Format(TEXT_FASTA_YEAST_FRAGMENT, 2)),
                false, IdentityPath.ROOT, out path);
            // Adding same sequence twice, even with different custom names is ignored
            Assert.AreSame(docFasta, docFasta2);

            // Try a successful removal of duplicates that leaves no peptides
            SrmDocument docPeptides = document.ImportFasta(new StringReader(TEXT_BOVINE_PEPTIDES1),
                true, IdentityPath.ROOT, out path);
            SrmDocument docPeptides2 = docPeptides.ImportFasta(new StringReader(TEXT_BOVINE_PEPTIDES1),
                true, IdentityPath.ROOT, out path);
            AssertEx.IsDocumentState(docPeptides2, 2, 2, 26, 82);
            SrmDocument docPeptides3 = refinementSettings.Refine(docPeptides2);
            Assert.AreNotSame(docPeptides2, docPeptides3);
            AssertEx.IsDocumentState(docPeptides3, 3, 2, 0, 0);

            // Try again leaving a single peptide
            docPeptides2 = docPeptides.ImportFasta(new StringReader(TEXT_BOVINE_PEPTIDES1 + "\n" + TEXT_BOVINE_SINGLE_PEPTIDE),
                true, IdentityPath.ROOT, out path);
            docPeptides3 = refinementSettings.Refine(docPeptides2);
            Assert.AreNotSame(docPeptides2, docPeptides3);
            AssertEx.IsDocumentState(docPeptides3, 3, 2, 1, 3);
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:34,代码来源:SrmDocEditTest.cs

示例13: MoveNodeTest

        public void MoveNodeTest()
        {
            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault());
            IdentityPath path = IdentityPath.ROOT;
            SrmDocument docFasta = document.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST), false, path, out path);
            // 1. From peptide group to root
            SrmDocument docMoved = docFasta.MoveNode(docFasta.GetPathTo(0), IdentityPath.ROOT, out path);
            Assert.AreEqual(1, docMoved.FindNodeIndex(path));
            Assert.AreSame(docFasta.Children[0], docMoved.Children[1]);
            Assert.AreSame(docFasta.Children[1], docMoved.Children[0]);
            // 2. From peptide group to before other peptide group
            docMoved = docFasta.MoveNode(docFasta.GetPathTo(1), docFasta.GetPathTo(0), out path);
            Assert.AreEqual(0, docMoved.FindNodeIndex(path));
            Assert.AreSame(docFasta.Children[0], docMoved.Children[1]);
            Assert.AreSame(docFasta.Children[1], docMoved.Children[0]);

            // Some peptide lists
            IdentityPath pathPeptides;
            SrmDocument docPeptides = docFasta.ImportFasta(new StringReader(TEXT_BOVINE_PEPTIDES2), true,
                                                           docFasta.GetPathTo(1), out pathPeptides);
            docPeptides = docPeptides.ImportFasta(new StringReader(TEXT_BOVINE_PEPTIDES1), true,
                                               IdentityPath.ROOT, out path);
            docPeptides = docPeptides.MoveNode(path, pathPeptides, out pathPeptides);
            Assert.AreEqual(1, docPeptides.FindNodeIndex(pathPeptides));

            // 3. Peptide from one group to another
            IdentityPath fromParent = docPeptides.GetPathTo(2);
            IdentityPath from = new IdentityPath(fromParent, ((DocNodeParent)docPeptides.FindNode(fromParent)).Children[0].Id);
            SrmDocument docPeptides2 = docPeptides.MoveNode(from, pathPeptides, out path);
            Assert.AreEqual(pathPeptides, path.Parent);
            Assert.AreEqual(((DocNodeParent)docPeptides.Children[1]).Children.Count,
                ((DocNodeParent)docPeptides2.Children[1]).Children.Count - 1);
            Assert.AreEqual(((DocNodeParent)docPeptides.Children[2]).Children.Count,
                ((DocNodeParent)docPeptides2.Children[2]).Children.Count + 1);
            // Though moved to a different group, this should not have changed the overall
            // peptide order, since it was moved from the beginning of one group to the end
            // of the group before it.
            Assert.AreEqual(docPeptides.FindNodeIndex(from), docPeptides2.FindNodeIndex(path));

            // 4. To before another peptide
            from = new IdentityPath(fromParent, ((DocNodeParent)docPeptides2.FindNode(fromParent)).Children[0].Id);
            IdentityPath path2;
            SrmDocument docPeptides3 = docPeptides2.MoveNode(from, path, out path2);
            Assert.AreEqual(pathPeptides, path.Parent);
            Assert.AreEqual(((DocNodeParent)docPeptides2.Children[1]).Children.Count,
                ((DocNodeParent)docPeptides3.Children[1]).Children.Count - 1);
            Assert.AreEqual(((DocNodeParent)docPeptides2.Children[2]).Children.Count,
                ((DocNodeParent)docPeptides3.Children[2]).Children.Count + 1);
            // Relative to all peptides, index should be 1 less than before
            Assert.AreEqual(docPeptides2.FindNodeIndex(from), docPeptides3.FindNodeIndex(path2) + 1);

            // 5. To within another peptide
            IdentityPath to = new IdentityPath(path, ((DocNodeParent)docPeptides3.FindNode(path)).Children[0].Id);
            SrmDocument docPeptides4 = docPeptides3.MoveNode(path2, to, out path);
            // Should not have changed to count in the group
            Assert.AreEqual(((DocNodeParent)docPeptides3.Children[1]).Children.Count,
                ((DocNodeParent)docPeptides4.Children[1]).Children.Count);
            // Relative to all peptides, should have been returned to original order
            Assert.AreEqual(docPeptides2.FindNodeIndex(from), docPeptides4.FindNodeIndex(path));

            // Make sure expected exceptions are thrown
            Assert.IsNull(docPeptides4.FindNode(from));
            AssertEx.ThrowsException<IdentityNotFoundException>(() =>
                docPeptides4.MoveNode(from, to, out path));
            AssertEx.ThrowsException<InvalidOperationException>(() =>
                docPeptides2.MoveNode(from, docPeptides2.GetPathTo(0), out path));
            AssertEx.ThrowsException<InvalidOperationException>(() =>
                docPeptides3.MoveNode(docPeptides2.GetPathTo((int) SrmDocument.Level.Molecules, 0), to, out path));
            AssertEx.ThrowsException<InvalidOperationException>(() =>
                docPeptides3.MoveNode(docPeptides2.GetPathTo((int)SrmDocument.Level.Transitions, 0), to, out path));
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:71,代码来源:SrmDocEditTest.cs


注:本文中的SrmDocument.ImportFasta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。