Exemple #1
0
        public override IEnumerable <string> Process(string rawFileName)
        {
            IsobaricResult result = GetTraqResult(rawFileName);

            string resultFileName = GetITraqFileName(rawFileName);

            ITraqResultFileFormatFactory.GetXmlFormat().WriteToFile(resultFileName, result);

            return(new[] { resultFileName });
        }
Exemple #2
0
        protected List <IIdentifiedSpectrum> GetSpectra(string fileName)
        {
            Progress.SetMessage("Reading peptides ...");
            List <IIdentifiedSpectrum> spectra = format.ReadFromFile(fileName);

            Progress.SetMessage("Reading itraq ...");
            IsobaricResult itraq = ITraqResultFileFormatFactory.GetXmlFormat().ReadFromFile(rawFileName);

            Progress.SetMessage("Matching peptide and itraq ...");

            ITraqItemUtils.MatchPeptideWithItraq(itraq, spectra);

            return(spectra);
        }
        /// <summary>
        /// 从itraqFile中读取spectra对应的iTRAQ信息。
        /// </summary>
        /// <param name="spectra"></param>
        /// <param name="itraqFile"></param>
        /// <param name="progress"></param>
        public static void LoadITraq(List <IIdentifiedSpectrum> spectra, string itraqFile, bool readPeaks = false, IProgressCallback progress = null)
        {
            if (progress == null)
            {
                progress = new EmptyProgressCallback();
            }

            var fileNames = new HashSet <string>(from s in spectra
                                                 let fs = s.Query.FileScan
                                                          select fs.Experimental + "," + fs.FirstScan.ToString());

            var reader = ITraqResultFileFormatFactory.GetXmlReader();

            reader.ReadPeaks = readPeaks;
            reader.Progress  = progress;

            reader.Open(itraqFile);

            progress.SetMessage("Reading iTRAQ from {0} ...", itraqFile);
            progress.SetRange(1, spectra.Count);

            foreach (var spectrum in spectra)
            {
                if (progress.IsCancellationPending())
                {
                    throw new UserTerminatedException();
                }

                progress.Increment(1);

                var fs = spectrum.Query.FileScan;
                if (reader.Has(fs.Experimental, fs.FirstScan))
                {
                    spectrum.SetIsobaricItem(reader.Read(fs.Experimental, fs.FirstScan));
                }
                else
                {
                    spectrum.SetIsobaricItem(null);
                }
            }
        }
Exemple #4
0
        public IsobaricResult GetTraqResult(string rawFileName)
        {
            Progress.SetMessage("Processing " + rawFileName + " ...");

            string experimental = FileUtils.ChangeExtension(new FileInfo(rawFileName).Name, "");

            string originalFileName = GetOriginalITraqFileName(rawFileName);

            string paramFileName = originalFileName + ".param";

            IsobaricResult result = null;

            ITraqFileBuilder builder = new ITraqFileBuilder(itraqReader.PlexType.GetDefinition());

            if (!CheckOriginalFile(originalFileName) || !File.Exists(paramFileName))
            {
                itraqReader.Progress = this.Progress;

                Progress.SetMessage("Reading isobaric tag channels from " + new FileInfo(rawFileName).Name + "...");
                List <IsobaricItem> pkls = itraqReader.ReadFromFile(rawFileName);
                Progress.SetMessage("Reading isobaric tag channels finished.");

                if (pkls.Count == 0)
                {
                    throw new Exception(MyConvert.Format("No isobaric tag information readed from file {0}, contact with author.", rawFileName));
                }

                var accs = builder.GetDistances(from pkl in pkls select pkl.RawPeaks);

                if (accs.Count == 0)
                {
                    throw new Exception(MyConvert.Format("No isobaric tag information readed from file {0}, contact with author.", rawFileName));
                }

                result      = builder.GetITraqResult(pkls, accs, SigmaFoldTolerance, 1);
                result.Mode = itraqReader.ToString();

                result.ForEach(m => m.Experimental = experimental);

                ITraqResultFileFormatFactory.GetXmlFormat().WriteToFile(originalFileName, result);

                using (StreamWriter sw = new StreamWriter(paramFileName))
                {
                    sw.WriteLine("Ion\tDetectedIon\tDeltaMass\tDeltaPPM\tDetectedSigma");
                    var ions = builder.Definition.Items;
                    for (int i = 0; i < ions.Length; i++)
                    {
                        sw.WriteLine("{0:0.00000}\t{1:0.00000}\t{2:0.00000}\t{3:0.00}\t{4:0.00000}", ions[i].Mass, ions[i].Mass + accs[i].Mean, accs[i].Mean, PrecursorUtils.mz2ppm(ions[i].Mass, accs[i].Mean), accs[i].StdDev);
                    }
                }
            }
            else
            {
                Progress.SetMessage("Read xml information from " + originalFileName + " ...");

                var format = ITraqResultFileFormatFactory.GetXmlFormat();
                format.Progress = this.Progress;

                result = format.ReadFromFile(originalFileName);
            }

            result.RemoveAll(m => m.PeakCount() < minPeakCount);

            result.ForEach(m => calc.Correct(m));

            result.RemoveAll(m => m.PeakCount() < minPeakCount);

            result.ForEach(m => m.PrecursorPercentage = m.PeakInIsolationWindow.GetPrecursorPercentage(this.precursorPPM));

            if (NormalizationBuilder != null)
            {
                NormalizationBuilder.Normalize(result);
            }
            return(result);
        }