Esempio n. 1
0
            public override string ToString()
            {
                var annotation = !HasAnnotations ?
                                 string.Empty:
                                 string.Format(@" ({0})", string.Join(@"/", _mi.Annotations.Where(a => !SpectrumPeakAnnotation.IsNullOrEmpty(a))).Select(a => a.ToString()));

                return(string.Format(@"i={0}, mz={1}{2}", _mi.Intensity, _mi.Mz, annotation));
            }
Esempio n. 2
0
        private void ProcessTransitionGroup(IDictionary <LibKey, SpectrumMzInfo> spectra,
                                            PeptideGroupDocNode nodePepGroup, PeptideDocNode nodePep, TransitionGroupDocNode nodeTranGroup, int replicateIndex)
        {
            LibKey key;

            if (nodePep.IsProteomic)
            {
                var sequence = Document.Settings.GetPrecursorCalc(nodeTranGroup.TransitionGroup.LabelType, nodePep.ExplicitMods)
                               .GetModifiedSequence(nodePep.Peptide.Target, SequenceModFormatType.lib_precision, false);
                key = new LibKey(sequence, nodeTranGroup.PrecursorAdduct.AdductCharge);
            }
            else
            {
                // For small molecules, the "modification" is expressed in the adduct
                key = new LibKey(nodeTranGroup.CustomMolecule.GetSmallMoleculeLibraryAttributes(), nodeTranGroup.PrecursorAdduct);
            }
            var mi              = new List <SpectrumPeaksInfo.MI>();
            var rt              = 0.0;
            var im              = IonMobilityAndCCS.EMPTY;
            var imGroup         = TransitionGroupIonMobilityInfo.EMPTY; // CCS may be available only at group level
            var groupChromInfos = nodeTranGroup.GetSafeChromInfo(replicateIndex);

            if (!groupChromInfos.IsEmpty)
            {
                var chromInfo = groupChromInfos.First(info => info.OptimizationStep == 0);
                imGroup = chromInfo.IonMobilityInfo;
            }
            var    maxApex       = float.MinValue;
            var    maxApexMs1    = float.MinValue;
            string chromFileName = null;
            double?mobilityMs1   = null; // Track MS1 ion mobility in order to derive high energy ion mobility offset value

            foreach (var nodeTran in nodeTranGroup.Transitions)
            {
                var chromInfos = nodeTran.GetSafeChromInfo(replicateIndex);
                if (chromInfos.IsEmpty)
                {
                    continue;
                }
                var chromInfo = chromInfos.First(info => info.OptimizationStep == 0);
                if (chromInfo.Area == 0)
                {
                    continue;
                }
                if (nodeTran.IsMs1)
                {
                    // Track MS1 ion mobility in order to derive high energy ion mobility offset value
                    if (chromInfo.Height > maxApexMs1)
                    {
                        maxApexMs1  = chromInfo.Height;
                        mobilityMs1 = chromInfo.IonMobility.IonMobility.Mobility;
                    }
                    continue;
                }
                if (chromFileName == null)
                {
                    var chromFileInfo = Document.Settings.MeasuredResults.Chromatograms[replicateIndex].MSDataFileInfos.FirstOrDefault(file => ReferenceEquals(file.Id, chromInfo.FileId));
                    if (chromFileInfo != null)
                    {
                        chromFileName = chromFileInfo.FilePath.GetFileName();
                    }
                }
                List <SpectrumPeakAnnotation> annotations = null;
                if (nodeTran.Transition.IsNonReporterCustomIon()) // CONSIDER(bspratt) include annotation for all non-peptide-fragment transitions?
                {
                    var smallMoleculeLibraryAttributes = nodeTran.Transition.CustomIon.GetSmallMoleculeLibraryAttributes();
                    var ion = new CustomIon(smallMoleculeLibraryAttributes, nodeTran.Transition.Adduct, nodeTran.GetMoleculeMass());
                    annotations = new List <SpectrumPeakAnnotation> {
                        SpectrumPeakAnnotation.Create(ion, nodeTran.Annotations.Note)
                    };
                }
                mi.Add(new SpectrumPeaksInfo.MI {
                    Mz = nodeTran.Mz, Intensity = chromInfo.Area, Quantitative = nodeTran.ExplicitQuantitative, Annotations = annotations
                });
                if (chromInfo.Height > maxApex)
                {
                    maxApex = chromInfo.Height;
                    rt      = chromInfo.RetentionTime;
                    var mobility = chromInfo.IonMobility.IonMobility;
                    var mobilityHighEnergyOffset = 0.0;
                    if (mobilityMs1.HasValue && mobility.HasValue && mobility.Mobility != mobilityMs1)
                    {
                        // Note any difference in MS1 and MS2 ion mobilities - the "high energy ion mobility offset"
                        mobilityHighEnergyOffset = mobility.Mobility.Value - mobilityMs1.Value;
                        mobility = mobility.ChangeIonMobility(mobilityMs1);
                    }
                    im = IonMobilityAndCCS.GetIonMobilityAndCCS(mobility, chromInfo.IonMobility.CollisionalCrossSectionSqA ?? imGroup.CollisionalCrossSection, mobilityHighEnergyOffset);
                }
            }
            if (chromFileName == null)
            {
                return;
            }
            SpectrumMzInfo spectrumMzInfo;

            if (!spectra.TryGetValue(key, out spectrumMzInfo))
            {
                spectrumMzInfo = new SpectrumMzInfo
                {
                    SourceFile     = DocumentFilePath,
                    Key            = key,
                    PrecursorMz    = nodeTranGroup.PrecursorMz,
                    SpectrumPeaks  = new SpectrumPeaksInfo(mi.ToArray()),
                    RetentionTimes = new List <SpectrumMzInfo.IonMobilityAndRT>(),
                    IonMobility    = im,
                    Protein        = nodePepGroup.Name,
                    RetentionTime  = rt
                };
                spectra[key] = spectrumMzInfo;
            }
            var isBest = replicateIndex == nodePep.BestResult;

            if (isBest)
            {
                spectrumMzInfo.IonMobility   = im;
                spectrumMzInfo.RetentionTime = rt;
            }
            spectrumMzInfo.RetentionTimes.Add(new SpectrumMzInfo.IonMobilityAndRT(chromFileName, im, rt, isBest));
        }