Пример #1
0
        public override IsobaricResult ReadFromFile(string fileName)
        {
            IsobaricResult result = new IsobaricResult()
            {
                Mode = ITraqResultXmlFormatReader.GetMode(fileName)
            };

            var reader = new ITraqResultXmlFormatReader()
            {
                Progress  = this.Progress,
                Accept    = this.Accept,
                ReadPeaks = this.ReadPeaks
            };

            reader.OpenFile(fileName);
            try
            {
                IsobaricItem item;
                while (null != (item = reader.Next()))
                {
                    result.Add(item);
                }
            }
            finally
            {
                reader.Close();
            }

            return(result);
        }
Пример #2
0
 public static String GetMode(string fileName)
 {
     using (var reader = new ITraqResultXmlFormatReader())
     {
         reader.OpenFile(fileName);
         while (reader._reader.MoveToElement("ITraqResult"))
         {
             if (reader._reader.HasAttributes)
             {
                 return(reader._reader.GetAttribute("Mode"));
             }
         }
     }
     return(string.Empty);
 }
Пример #3
0
        public void RunFormat(IITraqResultFileFormat format)
        {
            Setup();

            var tmpFilename = @TestContext.CurrentContext.TestDirectory + "/../../../data//temp.xml";

            format.WriteToFile(tmpFilename, tr);

            FileAssert.AreEqual(@TestContext.CurrentContext.TestDirectory + "/../../../data//ITraqResult.xml", tmpFilename);

            var newtr = format.ReadFromFile(tmpFilename);

            CheckExtension.CheckEquals(tr, newtr);

            format.ReadPeaks = false;
            var newstr2 = format.ReadFromFile(tmpFilename);

            Assert.IsEmpty(newstr2[0].RawPeaks);
            Assert.IsEmpty(newstr2[0].PeakInIsolationWindow);
            Assert.IsEmpty(newstr2[1].RawPeaks);
            Assert.IsEmpty(newstr2[1].PeakInIsolationWindow);

            format.Accept = (m => 355 == m.Scan.Scan);
            var newstr3 = format.ReadFromFile(tmpFilename);

            Assert.AreEqual(1, newstr3.Count);
            Assert.AreEqual(355, newstr3[0].Scan.Scan);

            var lines = File.ReadAllText(tmpFilename);
            ITraqResultXmlFormatReader reader = new ITraqResultXmlFormatReader();

            reader.OpenByContent(lines);
            var item = reader.Next();

            CheckExtension.CheckEquals(tr[0], item);
            item = reader.Next();
            CheckExtension.CheckEquals(tr[1], item);

            File.Delete(tmpFilename);
            if (File.Exists(tmpFilename + ".index"))
            {
                File.Delete(tmpFilename + ".index");
            }
        }