Exemplo n.º 1
0
        /// <summary>
        /// Handle a single SpectrumIdentificationResult element and child nodes
        /// Called by ReadSpectrumIdentificationList (xml hierarchy)
        /// </summary>
        /// <param name="result">PSM result</param>
        /// <param name="psmResults"></param>
        private void ProcessSpectrumIdentificationResult(SimpleMZIdentMLReader.SpectrumIdItem result, ICollection <IdentData> psmResults)
        {
            var data = new IdentData
            {
                NativeId        = result.NativeId,
                ScanId          = (ulong)result.ScanNum,
                ScanTimeSeconds = result.ScanTimeMinutes * 60,
                CalcMz          = result.CalMz,
                ExperMz         = result.ExperimentalMz,
                Charge          = result.Charge,
                ThresholdValue  = result.SpecEv // MS-GF:SpecEValue
            };

            //data.MassError = data.ExperMz - data.CalcMz;
            //data.PpmError = (data.MassError / data.CalcMz) * 1.0e6;

            if (IdentProg == IdentProgramType.MyriMatch &&
                result.AllParamsDict.TryGetValue("MyriMatch:MVH", out var valueText) &&
                double.TryParse(valueText, out var value))
            {
                data.ThresholdValue = value;
            }

            if (PassesThreshold(data) && PassesWindows(data))
            {
                psmResults.Add(data);
            }

            if (data.ScanTimeSeconds > 0)
            {
                HaveScanTimes = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read results from tsv file into group of objects from PSI_Interface
        /// </summary>
        /// <param name="idFilePath"></param>
        /// <returns></returns>
        public static SimpleMZIdentMLReader.SimpleMZIdentMLData ReadResultsFromFileToMzIdData(string idFilePath)
        {
            var databaseSearchResultData = ReadResultsFromFile(idFilePath);

            var simpleMzIdentMLData = new SimpleMZIdentMLReader.SimpleMZIdentMLData(idFilePath);

            foreach (var databaseSearchResult in databaseSearchResultData)
            {
                var peptide = new SimpleMZIdentMLReader.PeptideRef
                {
                    Sequence = databaseSearchResult.Sequence
                };

                var identification = new SimpleMZIdentMLReader.SpectrumIdItem
                {
                    Peptide = peptide,
                    Charge  = databaseSearchResult.Charge,
                    ScanNum = databaseSearchResult.ScanNum,
                    SpecEv  = databaseSearchResult.SpecEValue,
                };

                // Parse modification
                var modParts = databaseSearchResult.Modifications.Split(',');
                if (modParts.Length > 0)
                {
                    foreach (var part in modParts)
                    {
                        var mod = part.Split(' ');
                        if (mod.Length < 2)
                        {
                            continue;
                        }

                        var modName  = mod[0];
                        var modIndex = Convert.ToInt32(mod[1]);
                        var ipMod    = Modification.Get(modName);

                        var modification = new SimpleMZIdentMLReader.Modification
                        {
                            Mass = ipMod.Mass,
                            Tag  = modName,
                        };

                        peptide.ModsAdd(modIndex, modification);
                    }
                }

                var proteinAccessions = databaseSearchResult.ProteinName.Split(',');
                foreach (var accession in proteinAccessions)
                {
                    var dbSequence = new SimpleMZIdentMLReader.DatabaseSequence
                    {
                        Accession          = accession.Trim(),
                        ProteinDescription = databaseSearchResult.ProteinDescription
                    };
                    var peptideEvidence = new SimpleMZIdentMLReader.PeptideEvidence
                    {
                        DbSeq      = dbSequence,
                        Pre        = databaseSearchResult.Pre,
                        Post       = databaseSearchResult.Post,
                        PeptideRef = identification.Peptide,
                        Start      = databaseSearchResult.Start,
                        End        = databaseSearchResult.End,
                    };

                    identification.PepEvidence.Add(peptideEvidence);
                }

                simpleMzIdentMLData.Identifications.Add(identification);
            }

            return(simpleMzIdentMLData);
        }