コード例 #1
0
        public void TestBuild()
        {
            var indexFile = new ITraqResultXmlIndexBuilder(true).Process(dataFile).First();

            FileAssert.AreEqual(expectFile, indexFile);

            File.Delete(indexFile);
        }
        public void Open(string fileName)
        {
            var indexFile = ITraqResultXmlIndexBuilder.GetTargetFile(fileName);

            if (!File.Exists(indexFile))
            {
                new ITraqResultXmlIndexBuilder()
                {
                    Progress = this.Progress
                }.Process(fileName);
            }

            Progress.SetMessage("Reading index from " + indexFile + " ...");
            this._indexItems = new FileIndexFormat().ReadFromFile(indexFile).ToDictionary(m => m.Key);
            Progress.SetMessage("Reading index from " + indexFile + " finished.");

            this._stream = FileUtils.OpenReadFile(fileName);
        }
コード例 #3
0
        public override void WriteToFile(string fileName, IsobaricResult t)
        {
            using (XmlTextWriter w = XmlUtils.CreateWriter(fileName, Encoding.ASCII))
            {
                StartWriteDocument(w, t.Mode);

                foreach (var item in t)
                {
                    WriteIsobaricItem(w, item);
                }

                EndWriteDocument(w);
            }

            var indexBuilder = new ITraqResultXmlIndexBuilder(true)
            {
                Progress = this.Progress
            };

            indexBuilder.Process(fileName);
        }
        public override IEnumerable <string> Process(string targetFileName)
        {
            this.reader.Progress = this.Progress;

            List <string>       resultFile = new List <string>();
            List <IsobaricItem> result     = new List <IsobaricItem>();

            ITraqResultXmlFormatFast format = new ITraqResultXmlFormatFast();

            XmlTextWriter sw = null;

            if (!individual)
            {
                sw = XmlUtils.CreateWriter(targetFileName, Encoding.ASCII);
                ITraqResultXmlFormatFast.StartWriteDocument(sw, reader.ToString());
            }

            try
            {
                for (int i = 0; i < rawFiles.Count(); i++)
                {
                    if (Progress.IsCancellationPending())
                    {
                        throw new UserTerminatedException();
                    }

                    Progress.SetMessage(1, MyConvert.Format("Processing {0}/{1} ...", i + 1, rawFiles.Count()));
                    using (var rawreader = RawFileFactory.GetRawFileReader(rawFiles[i]))
                    {
                        reader.RawReader = rawreader;

                        ITraqResultFileDistiller distiller = new ITraqResultFileDistiller(reader, minPeakCount, plexType, isotopeImpurityCorrectionTableFileName, precursorPPMTolearnce)
                        {
                            Progress             = this.Progress,
                            NormalizationBuilder = this.builder
                        };

                        if (individual)
                        {
                            string itraqFile = distiller.Process(rawFiles[i]).First();
                            resultFile.Add(itraqFile);
                        }
                        else
                        {
                            var curResult = distiller.GetTraqResult(rawFiles[i]);

                            foreach (var item in curResult)
                            {
                                ITraqResultXmlFormatFast.WriteIsobaricItem(sw, item);
                            }

                            curResult = null;
                        }

                        GC.Collect();
                        GC.WaitForFullGCComplete();
                    }
                }

                Progress.SetMessage(0, "");
            }
            finally
            {
                if (!individual)
                {
                    sw.Close();
                }
            }

            if (!individual)
            {
                var indexBuilder = new ITraqResultXmlIndexBuilder(true)
                {
                    Progress = this.Progress
                };
                indexBuilder.Process(targetFileName);
                resultFile.Add(targetFileName);
            }

            Progress.SetMessage(1, "Finished!");

            return(resultFile);
        }