Exemple #1
0
        public static IdentityPath ToIdentityPath(IList <int> idPath, SrmDocument document)
        {
            IdentityPath identityPath = ROOT;
            DocNode      next         = document;

            foreach (int globalIndex in idPath)
            {
                DocNodeParent parent = next as DocNodeParent;
                if (null == parent)
                {
                    return(null);
                }
                next = null;
                foreach (var child in parent.Children)
                {
                    if (child.Id.GlobalIndex == globalIndex)
                    {
                        next = child;
                        break;
                    }
                }
                if (null == next)
                {
                    return(null);
                }
                identityPath = new IdentityPath(identityPath, next.Id);
            }
            return(identityPath);
        }
Exemple #2
0
        /// <summary>
        /// Creates a dictionary mapping from strings to list of peptide IdentityPaths.
        /// Peptides can be looked up by either their low precision or high precision modified sequence.
        /// </summary>
        private IDictionary <Tuple <string, bool>, IList <IdentityPath> > MakeSequenceDictionary(SrmDocument document)
        {
            var sequenceToNode = new Dictionary <Tuple <string, bool>, IList <IdentityPath> >();

            foreach (var moleculeGroup in document.MoleculeGroups)
            {
                foreach (var molecule in moleculeGroup.Molecules)
                {
                    IdentityPath peptidePath = new IdentityPath(moleculeGroup.PeptideGroup, molecule.Peptide);
                    foreach (var sequenceKey in ListSequenceKeys(molecule))
                    {
                        var peptidePair = Tuple.Create(sequenceKey, molecule.IsDecoy);
                        IList <IdentityPath> idPathList;
                        // Each (sequence, isDecoy) pair can be associated with more than one peptide,
                        // to handle the case of duplicate peptides in the doucment.
                        if (sequenceToNode.TryGetValue(peptidePair, out idPathList))
                        {
                            idPathList.Add(peptidePath);
                        }
                        else
                        {
                            idPathList = new List <IdentityPath> {
                                peptidePath
                            };
                            sequenceToNode.Add(peptidePair, idPathList);
                        }
                    }
                }
            }
            return(sequenceToNode);
        }
Exemple #3
0
        /// <summary>
        /// Constructs the path from an existing relative instance with one added
        /// <see cref="Identity"/>.
        /// </summary>
        /// <param name="parent">An <see cref="Identity"/> to add to the beginning</param>
        /// <param name="child">An existing partial path</param>
        public IdentityPath(Identity parent, IdentityPath child)
        {
            List <Identity> path = new List <Identity> {
                parent
            };

            path.AddRange(child._identities);
            _identities = path.ToArray();
        }
Exemple #4
0
        /// <summary>
        /// Constructs the path from an existing instance with one added final
        /// <see cref="Identity"/>.
        /// </summary>
        /// <param name="parent">Original path</param>
        /// <param name="child">An <see cref="Identity"/> to add to the end</param>
        public IdentityPath(IdentityPath parent, Identity child)
        {
            List <Identity> path = new List <Identity>(parent._identities)
            {
                child
            };

            _identities = path.ToArray();
        }
Exemple #5
0
        private List <DocNode> GetDocNodes(IdentityPath identityPath, SrmDocument document)
        {
            var result = new List <DocNode>();

            while (!identityPath.IsRoot)
            {
                result.Insert(0, document.FindNode(identityPath));
                identityPath = identityPath.Parent;
            }
            return(result);
        }
        public static SrmDocument ImportFasta(SrmDocument document, string fastaPath, IProgressMonitor monitor,
                                              IdentityPath to, out IdentityPath firstAdded, out IdentityPath nextAdd, out List <PeptideGroupDocNode> peptideGroupsNew)
        {
            var importer = new FastaImporter(document, false);

            using (TextReader reader = File.OpenText(fastaPath))
            {
                peptideGroupsNew = importer.Import(reader, monitor, Helpers.CountLinesInFile(fastaPath)).ToList();
                document         = document.AddPeptideGroups(peptideGroupsNew, false, to, out firstAdded, out nextAdd);
            }
            return(document);
        }
Exemple #7
0
 public bool Equals(IdentityPath obj)
 {
     if (ReferenceEquals(null, obj))
     {
         return(false);
     }
     if (ReferenceEquals(this, obj))
     {
         return(true);
     }
     return(GlobalIndexes.SequenceEqual(obj.GlobalIndexes));
 }
        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);
        }
Exemple #9
0
        public static SrmDocument ImportFasta(SrmDocument document, string fastaPath, IProgressMonitor monitor,
                                              IdentityPath to, out IdentityPath firstAdded, out IdentityPath nextAdd, out int emptyProteinCount)
        {
            var importer = new FastaImporter(document, false);

            using (TextReader reader = File.OpenText(fastaPath))
            {
                document = document.AddPeptideGroups(importer.Import(reader, monitor, Helpers.CountLinesInFile(fastaPath)),
                                                     false, null, out firstAdded, out nextAdd);
            }
            emptyProteinCount = importer.EmptyPeptideGroupCount;
            return(document);
        }
Exemple #10
0
            public SrmDocument ChangePeak(SrmDocument doc, SrmTreeNode nodePepTree, TransitionGroupDocNode nodeTranGroup, string nameSet, MsDataFileUri filePath)
            {
                if ((_retentionTime ?? StartTime) == null)
                {
                    return(doc);
                }

                var groupPath = new IdentityPath(nodePepTree.Path, nodeTranGroup.Id);

                doc = _retentionTime.HasValue
                    ? doc.ChangePeak(groupPath, nameSet, filePath, null, _retentionTime.Value, UserSet.TRUE)
                    : doc.ChangePeak(groupPath, nameSet, filePath, null, StartTime, EndTime, UserSet.TRUE, null, false);

                var activeTransitionGroup = (TransitionGroupDocNode)doc.FindNode(groupPath);

                if (activeTransitionGroup.RelativeRT != RelativeRT.Matching)
                {
                    return(doc);
                }

                var activeChromInfo = SkylineWindow.FindChromInfo(doc, activeTransitionGroup, nameSet, filePath);
                var peptide         = (PeptideDocNode)doc.FindNode(groupPath.Parent);

                // See if there are any other transition groups that should have their peak bounds set to the same value
                foreach (var tranGroup in peptide.TransitionGroups.Where(tranGroup => tranGroup.RelativeRT == RelativeRT.Matching))
                {
                    var otherGroupPath = new IdentityPath(groupPath.Parent, tranGroup.TransitionGroup);
                    if (Equals(groupPath, otherGroupPath) || SkylineWindow.FindChromInfo(doc, tranGroup, nameSet, filePath) == null)
                    {
                        continue;
                    }

                    doc = doc.ChangePeak(otherGroupPath, nameSet, filePath, null,
                                         activeChromInfo.StartRetentionTime, activeChromInfo.EndRetentionTime, UserSet.TRUE, activeChromInfo.Identified, false);
                }
                return(doc);
            }
Exemple #11
0
        /// <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.IsEmpty)
                        {
                            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);
        }
Exemple #12
0
        public SrmDocument Import(TextReader reader, IProgressMonitor progressMonitor, long lineCount, bool isMinutes, bool removeMissing = false, bool changePeaks = true)
        {
            IProgressStatus status = new ProgressStatus(Resources.PeakBoundaryImporter_Import_Importing_Peak_Boundaries);
            double          timeConversionFactor = isMinutes ? 1.0 : 60.0;
            int             linesRead            = 0;
            int             progressPercent      = 0;
            var             docNew                = (SrmDocument)Document.ChangeIgnoreChangingChildren(true);
            var             docReference          = docNew;
            var             sequenceToNode        = MakeSequenceDictionary(Document);
            var             fileNameToFileMatch   = new Dictionary <string, ChromSetFileMatch>();
            var             trackAdjustedResults  = new HashSet <ResultsKey>();
            var             modMatcher            = new ModificationMatcher();
            var             canonicalSequenceDict = new Dictionary <string, string>();

            // Add annotations as possible columns
            var allFieldNames = new List <string[]>(FIELD_NAMES);

            allFieldNames.AddRange(from def in Document.Settings.DataSettings.AnnotationDefs
                                   where def.AnnotationTargets.Contains(AnnotationDef.AnnotationTarget.precursor_result)
                                   select new[] { def.Name });

            string line = reader.ReadLine();

            linesRead++;
            int[] fieldIndices;
            int   fieldsTotal;
            // If we aren't changing peaks, allow start and end time to be missing
            var  requiredFields   = changePeaks ? REQUIRED_FIELDS : REQUIRED_NO_CHROM;
            char correctSeparator = ReadFirstLine(line, allFieldNames, requiredFields, out fieldIndices, out fieldsTotal);

            while ((line = reader.ReadLine()) != null)
            {
                linesRead++;
                if (progressMonitor != null)
                {
                    if (progressMonitor.IsCanceled)
                    {
                        return(Document);
                    }
                    int progressNew = (int)(linesRead * 100 / lineCount);
                    if (progressPercent != progressNew)
                    {
                        progressMonitor.UpdateProgress(status = status.ChangePercentComplete(progressNew));
                        progressPercent = progressNew;
                    }
                }
                var dataFields = new DataFields(fieldIndices, line.ParseDsvFields(correctSeparator), allFieldNames);
                if (dataFields.Length != fieldsTotal)
                {
                    throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Line__0__field_count__1__differs_from_the_first_line__which_has__2_,
                                                        linesRead, dataFields.Length, fieldsTotal));
                }
                string modifiedPeptideString = dataFields.GetField(Field.modified_peptide);
                string fileName = dataFields.GetField(Field.filename);
                bool   isDecoy  = dataFields.IsDecoy(linesRead);
                IList <IdentityPath> pepPaths;

                if (!sequenceToNode.TryGetValue(Tuple.Create(modifiedPeptideString, isDecoy), out pepPaths))
                {
                    string canonicalSequence;
                    if (!canonicalSequenceDict.TryGetValue(modifiedPeptideString, out canonicalSequence))
                    {
                        if (modifiedPeptideString.Any(c => c < 'A' || c > 'Z'))
                        {
                            modMatcher.CreateMatches(Document.Settings,
                                                     new List <string> {
                                modifiedPeptideString
                            },
                                                     Settings.Default.StaticModList,
                                                     Settings.Default.HeavyModList);
                            var nodeForModPep = modMatcher.GetModifiedNode(modifiedPeptideString);
                            if (nodeForModPep == null)
                            {
                                throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Peptide_has_unrecognized_modifications__0__at_line__1_, modifiedPeptideString, linesRead));
                            }
                            nodeForModPep = nodeForModPep.ChangeSettings(Document.Settings, SrmSettingsDiff.ALL);
                            // Convert the modified peptide string into a standardized form that
                            // converts unimod, names, etc, into masses, eg [+57.0]
                            canonicalSequence = nodeForModPep.ModifiedTarget.Sequence;
                            canonicalSequenceDict.Add(modifiedPeptideString, canonicalSequence);
                        }
                    }
                    if (null != canonicalSequence)
                    {
                        sequenceToNode.TryGetValue(Tuple.Create(canonicalSequence, isDecoy), out pepPaths);
                    }
                }
                if (null == pepPaths)
                {
                    UnrecognizedPeptides.Add(modifiedPeptideString);
                    continue;
                }
                Adduct charge;
                bool   chargeSpecified = dataFields.TryGetCharge(linesRead, out charge);
                string sampleName      = dataFields.GetField(Field.sample_name);

                double?apexTime = dataFields.GetTime(Field.apex_time, timeConversionFactor,
                                                     Resources.PeakBoundaryImporter_Import_The_value___0___on_line__1__is_not_a_valid_time_, linesRead);
                double?startTime = dataFields.GetTime(Field.start_time, timeConversionFactor,
                                                      Resources.PeakBoundaryImporter_Import_The_value___0___on_line__1__is_not_a_valid_start_time_, linesRead);
                double?endTime = dataFields.GetTime(Field.end_time, timeConversionFactor,
                                                    Resources.PeakBoundaryImporter_Import_The_value___0___on_line__1__is_not_a_valid_end_time_, linesRead);

                // Error if only one of startTime and endTime is null
                if (startTime == null && endTime != null)
                {
                    if (changePeaks)
                    {
                        throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Missing_start_time_on_line__0_, linesRead));
                    }
                    endTime = null;
                }
                if (startTime != null && endTime == null)
                {
                    if (changePeaks)
                    {
                        throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Missing_end_time_on_line__0_, linesRead));
                    }
                    startTime = null;
                }
                // Add filename to second dictionary if not yet encountered
                ChromSetFileMatch fileMatch;
                if (!fileNameToFileMatch.TryGetValue(fileName, out fileMatch))
                {
                    fileMatch = Document.Settings.MeasuredResults.FindMatchingMSDataFile(MsDataFileUri.Parse(fileName));
                    fileNameToFileMatch.Add(fileName, fileMatch);
                }
                if (fileMatch == null)
                {
                    UnrecognizedFiles.Add(fileName);
                    continue;
                }
                var               chromSet = fileMatch.Chromatograms;
                string            nameSet  = chromSet.Name;
                ChromFileInfoId[] fileIds;
                if (sampleName == null)
                {
                    fileIds = chromSet.MSDataFileInfos.Select(x => x.FileId).ToArray();
                }
                else
                {
                    var sampleFile = chromSet.MSDataFileInfos.FirstOrDefault(info => Equals(sampleName, info.FilePath.GetSampleName()));
                    if (sampleFile == null)
                    {
                        throw new IOException(string.Format(Resources.PeakBoundaryImporter_Import_Sample__0__on_line__1__does_not_match_the_file__2__, sampleName, linesRead, fileName));
                    }
                    fileIds = new[] { sampleFile.FileId };
                }
                // Define the annotations to be added
                var annotations = dataFields.GetAnnotations();
                if (!changePeaks)
                {
                    if (apexTime.HasValue)
                    {
                        annotations.Add(ComparePeakBoundaries.APEX_ANNOTATION, dataFields.GetField(Field.apex_time));
                    }
                    if (startTime.HasValue && endTime.HasValue)
                    {
                        annotations.Add(ComparePeakBoundaries.START_TIME_ANNOTATION, dataFields.GetField(Field.start_time));
                        annotations.Add(ComparePeakBoundaries.END_TIME_ANNOTATION, dataFields.GetField(Field.end_time));
                    }
                }
                AnnotationsAdded = annotations.Keys.ToList();

                // Loop over all the transition groups in that peptide to find matching charge,
                // or use all transition groups if charge not specified
                bool foundSample = false;
                foreach (var pepPath in pepPaths)
                {
                    var nodePep = (PeptideDocNode)docNew.FindNode(pepPath);

                    foreach (TransitionGroupDocNode groupNode in nodePep.Children)
                    {
                        if (chargeSpecified && charge != groupNode.TransitionGroup.PrecursorAdduct)
                        {
                            continue;
                        }

                        // Loop over the files in this groupNode to find the correct sample
                        // Change peak boundaries for the transition group
                        foreach (var fileId in GetApplicableFiles(fileIds, groupNode))
                        {
                            var groupPath = new IdentityPath(pepPath, groupNode.Id);
                            // Attach annotations
                            if (annotations.Any())
                            {
                                docNew = docNew.AddPrecursorResultsAnnotations(groupPath, fileId, annotations);
                            }
                            // Change peak
                            var filePath = chromSet.GetFileInfo(fileId).FilePath;
                            if (changePeaks)
                            {
                                docNew = docNew.ChangePeak(groupPath, nameSet, filePath,
                                                           null, startTime, endTime, UserSet.IMPORTED, null, false);
                            }
                            // For removing peaks that are not in the file, if removeMissing = true
                            trackAdjustedResults.Add(new ResultsKey(fileId.GlobalIndex, groupNode.Id));
                            foundSample = true;
                        }
                    }
                }
                if (!foundSample)
                {
                    UnrecognizedChargeStates.Add(new UnrecognizedChargeState(charge, fileName, modifiedPeptideString));
                }
            }
            // Remove peaks from the document that weren't in the file.
            if (removeMissing)
            {
                docNew = RemoveMissing(docNew, trackAdjustedResults, changePeaks);
            }
            // If nothing has changed, return the old Document before ChangeIgnoreChangingChildren was turned off
            if (!ReferenceEquals(docNew, docReference))
            {
                Document = (SrmDocument)Document.ChangeIgnoreChangingChildren(false).ChangeChildrenChecked(docNew.Children);
            }
            return(Document);
        }
Exemple #13
0
        public Chromatogram[] GetChromatograms(DocumentLocation documentLocation)
        {
            if (documentLocation == null)
            {
                return(new Chromatogram[0]);
            }
            var               result            = new List <Chromatogram>();
            SrmDocument       document          = Program.MainWindow.Document;
            Bookmark          bookmark          = Bookmark.ToBookmark(documentLocation, document);
            IdentityPath      identityPath      = bookmark.IdentityPath;
            var               nodeList          = GetDocNodes(identityPath, document);
            TransitionDocNode transitionDocNode = null;

            if (nodeList.Count > 3)
            {
                transitionDocNode = (TransitionDocNode)nodeList[3];
            }
            var measuredResults = document.Settings.MeasuredResults;
            var nodePep         = (PeptideDocNode)(nodeList.Count > 1 ? nodeList[1] : null);

            if (null == nodePep)
            {
                return(result.ToArray());
            }

            int iColor = 0;

            foreach (var chromatogramSet in measuredResults.Chromatograms)
            {
                foreach (var msDataFileInfo in chromatogramSet.MSDataFileInfos)
                {
                    if (bookmark.ChromFileInfoId != null && !ReferenceEquals(msDataFileInfo.FileId, bookmark.ChromFileInfoId))
                    {
                        continue;
                    }

                    foreach (var nodeGroup in nodePep.TransitionGroups)
                    {
                        if (nodeList.Count > 2 && !Equals(nodeGroup, nodeList[2]))
                        {
                            continue;
                        }
                        ChromatogramGroupInfo[] arrayChromInfo;
                        measuredResults.TryLoadChromatogram(
                            chromatogramSet,
                            nodePep,
                            nodeGroup,
                            (float)document.Settings.TransitionSettings.Instrument.MzMatchTolerance,
                            true,
                            out arrayChromInfo);
                        foreach (var transition in nodeGroup.Transitions)
                        {
                            if (transitionDocNode != null && !Equals(transitionDocNode, transition))
                            {
                                continue;
                            }
                            foreach (var chromatogramGroup in arrayChromInfo)
                            {
                                for (int iTransition = 0; iTransition < chromatogramGroup.NumTransitions; iTransition++)
                                {
                                    ChromatogramInfo transitionInfo = chromatogramGroup.GetTransitionInfo(iTransition);
                                    if (Math.Abs(transitionInfo.ProductMz - transition.Mz) >
                                        document.Settings.TransitionSettings.Instrument.MzMatchTolerance)
                                    {
                                        continue;
                                    }
                                    Color color = GraphChromatogram.COLORS_LIBRARY[iColor % GraphChromatogram.COLORS_LIBRARY.Count];
                                    iColor++;
                                    result.Add(new Chromatogram
                                    {
                                        Intensities = transitionInfo.Intensities.ToArray(),
                                        ProductMz   = transitionInfo.ProductMz.RawValue,      // For negative ion mode data this will be a negative value
                                        PrecursorMz = chromatogramGroup.PrecursorMz.RawValue, // For negative ion mode data this will be a negative value
                                        Times       = transitionInfo.Times.ToArray(),
                                        Color       = color
                                    });
                                }
                            }
                        }
                    }
                }
            }

            if (result.Count == 1)
            {
                result[0].Color = ChromGraphItem.ColorSelected;
            }


            return(result.ToArray());
        }
Exemple #14
0
 /// <summary>
 /// Constructs a traversal for a specific path
 /// </summary>
 /// <param name="path">The path to traverse</param>
 public IdentityPathTraversal(IdentityPath path)
 {
     _path = path;
 }