Example #1
0
        private void AddTransition(Library library, string[] line, double mzLastPeptide, int transMzIndex, int intensityIndex, double precursorMz)
        {
            var transition = new Library.Transition();

            transition.Id          = line[transMzIndex].Replace(",", ".");
            transition.PeptideId   = precursorMz.ToString().Replace(",", ".");
            transition.PrecursorMz = precursorMz;
            if (line[2].Length > 1)
            {
                transition.ProductMz = double.Parse(line[transMzIndex].Replace(",", "."), CultureInfo.InvariantCulture);
            }
            else
            {
                transition.ProductMz = mzLastPeptide;
            }
            transition.ProductIonIntensity = double.Parse(line[intensityIndex].Replace(",", "."), CultureInfo.InvariantCulture);
            string keystring = transition.Id + "-" + transition.PrecursorMz;

            if (library.TransitionList.Contains(keystring))
            {
                logger.Warn("Two of the same peptide - transition combinations were detected. The second entry was not added as a valid transition. Please check your file for duplication.");
            }
            else
            {
                library.TransitionList.Add(keystring, transition);
                var correspondingPeptide = (Library.Peptide)(library.PeptideList[key : Convert.ToString(precursorMz).Replace(",", ".")]);
                correspondingPeptide.AssociatedTransitions.Add(transition);
            }
        }
Example #2
0
        private void AddTransition(Library library, XmlReader reader)
        {
            var transition = new Library.Transition();

            transition.PeptideId = reader.GetAttribute("peptideRef");
            transition.Id        = reader.GetAttribute("id");
            Enums.IonType?ionType      = null;
            bool          cvParamsRead = false;

            while (reader.Read() && !cvParamsRead)
            {
                if (reader.IsStartElement())
                {
                    if (reader.LocalName == "Precursor")
                    {
                        ionType = Enums.IonType.Precursor;
                    }
                    else if (reader.LocalName == "Product")
                    {
                        ionType = Enums.IonType.Product;
                    }

                    if (reader.LocalName == "cvParam")
                    {
                        switch (reader.GetAttribute("accession"))
                        {
                        case "MS:1000827":
                            if (ionType == Enums.IonType.Precursor)
                            {
                                transition.PrecursorMz = double.Parse(reader.GetAttribute("value"), System.Globalization.CultureInfo.InvariantCulture);
                            }
                            else if (ionType == Enums.IonType.Product)
                            {
                                transition.ProductMz = double.Parse(reader.GetAttribute("value"), System.Globalization.CultureInfo.InvariantCulture);
                            }
                            break;

                        case "MS:1000041":
                            transition.ProductIonChargeState = Convert.ToInt32(reader.GetAttribute("value"));
                            break;

                        case "MS:1000903":
                            transition.ProductIonSeriesOrdinal = Convert.ToInt32(reader.GetAttribute("value"));
                            break;

                        case "MS:1000926":
                            transition.ProductInterpretationRank = Convert.ToInt32(reader.GetAttribute("value"));
                            break;

                        case "MS:1001220":
                            transition.IonType = reader.GetAttribute("value");
                            break;

                        case "MS:1001226":
                            transition.ProductIonIntensity = double.Parse(reader.GetAttribute("value"), System.Globalization.CultureInfo.InvariantCulture);
                            break;
                        }
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "Transition")
                {
                    if (reader.LocalName == "Precursor" || reader.LocalName == "Product")
                    {
                        ionType = null;
                    }
                    if (reader.LocalName == "Transition")
                    {
                        cvParamsRead = true;
                    }
                }
            }

            library.TransitionList.Add(transition.Id, transition);
            var correspondingPeptide = (Library.Peptide)(library.PeptideList[transition.PeptideId]);

            correspondingPeptide.AssociatedTransitionIds.Add(transition.Id);
            correspondingPeptide.AssociatedTransitions.Add(transition);
        }