Esempio n. 1
0
        public void Normalize(IsobaricResult result)
        {
            if (result.Count == 0)
            {
                return;
            }

            if (ByIonInjectionTime && result.HasIonInjectionTime())
            {
                result.ForEach(m => m.MultiplyIntensityByInjectionTime());
            }

            var defs = result.First().Definition.Items;

            var sums = (from def in defs
                        select GetIonBase(result, m => m[def.Index])).ToArray();

            for (int i = 1; i < sums.Length; i++)
            {
                sums[i] = sums[0] / sums[i];
            }

            result.ForEach(m =>
            {
                for (int i = 1; i < defs.Length; i++)
                {
                    m[defs[i].Index] *= sums[i];
                }
            });

            if (ByIonInjectionTime && result.HasIonInjectionTime())
            {
                result.ForEach(m => m.DevideIntensityByInjectionTime());
            }
        }
Esempio n. 2
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);
        }