本文整理汇总了C#中SrmDocument.GetPathTo方法的典型用法代码示例。如果您正苦于以下问题:C# SrmDocument.GetPathTo方法的具体用法?C# SrmDocument.GetPathTo怎么用?C# SrmDocument.GetPathTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SrmDocument
的用法示例。
在下文中一共展示了SrmDocument.GetPathTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: RemoveMissing
/// <summary>
/// Removes peaks and annotations that were in the document but not in the file, so that all peptide results that were not explicitly imported as part of this file are now blank
/// </summary>
/// <param name="docNew">SrmDocument for which missing peaks should be removed</param>
/// <param name="trackAdjustedResults">List of peaks that were in the imported file</param>
/// <param name="changePeaks">If true, remove both peaks and annotations. If false, only remove annotations</param>
/// <returns></returns>
private SrmDocument RemoveMissing(SrmDocument docNew, ICollection<ResultsKey> trackAdjustedResults, bool changePeaks)
{
var measuredResults = docNew.Settings.MeasuredResults;
var chromatogramSets = measuredResults.Chromatograms;
for (int i = 0; i < chromatogramSets.Count; ++i)
{
var set = chromatogramSets[i];
var nameSet = set.Name;
for (int k = 0; k < docNew.MoleculeCount; ++k)
{
IdentityPath pepPath = docNew.GetPathTo((int)SrmDocument.Level.Molecules, k);
var pepNode = (PeptideDocNode)Document.FindNode(pepPath);
if (pepNode.IsDecoy)
continue;
if (pepNode.GlobalStandardType != null)
continue;
foreach (var groupNode in pepNode.TransitionGroups)
{
var groupPath = new IdentityPath(pepPath, groupNode.Id);
var chromInfos = groupNode.Results[i];
if (chromInfos == null)
continue;
foreach (var groupChromInfo in chromInfos)
{
if (groupChromInfo == null)
continue;
var key = new ResultsKey(groupChromInfo.FileId.GlobalIndex, groupNode.Id);
if (!trackAdjustedResults.Contains(key))
{
CountMissing++;
var fileId = groupChromInfo.FileId;
var fileInfo = set.GetFileInfo(fileId);
var filePath = fileInfo.FilePath;
// Remove annotations for defs that were imported into the document and were on this peptide prior to import
var newAnnotationValues = groupChromInfo.Annotations.ListAnnotations().ToList();
newAnnotationValues = newAnnotationValues.Where(a => !AnnotationsAdded.Contains(a.Key)).ToList();
var newAnnotations = new Annotations(groupChromInfo.Annotations.Note, newAnnotationValues, groupChromInfo.Annotations.ColorIndex);
var newGroupNode = groupNode.ChangePrecursorAnnotations(fileId, newAnnotations);
if (!ReferenceEquals(groupNode, newGroupNode))
docNew = (SrmDocument) docNew.ReplaceChild(groupPath.Parent, newGroupNode);
// Adjust peaks to null if they weren't in the file
if (changePeaks)
{
docNew = docNew.ChangePeak(groupPath, nameSet, filePath,
null, null, null, UserSet.IMPORTED, null, false);
}
}
}
}
}
}
return docNew;
}
示例3: 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);
}