Exemplo n.º 1
0
 public static string GetTitleSample(string fileName)
 {
     using (StreamReader sr = new StreamReader(new FileStream(fileName, FileMode.Open)))
     {
         var iter = new MascotGenericFormatIterator <Peak>(sr);
         return(iter.GetNextTitle(sr));
     }
 }
Exemplo n.º 2
0
        public override IEnumerable <string> Process()
        {
            var result = new List <string>();

            var titleParser = options.GetTitleParser();
            var writer      = new MascotGenericFormatWriter <Peak>();

            Progress.SetRange(0, options.InputFiles.Count);
            int count = 0;

            foreach (var file in options.InputFiles)
            {
                count++;

                string resultFilename = options.GetOutputFile(file);
                Progress.SetMessage("Processing {0}/{1} : {2} ...", count, options.InputFiles.Count, file);

                var tempFile = resultFilename + ".tmp";
                using (var sw = new StreamWriter(tempFile))
                {
                    sw.WriteLine("###ShiftMass={0:0.#}", options.ShiftMass);
                    sw.WriteLine("###ShiftScan={0}", options.ShiftScan);
                    sw.WriteLine();

                    using (var sr = new StreamReader(new FileStream(file, FileMode.Open)))
                    {
                        var iter = new MascotGenericFormatIterator <Peak>(sr);
                        while (iter.HasNext())
                        {
                            if (Progress.IsCancellationPending())
                            {
                                throw new UserTerminatedException();
                            }

                            var pkl = iter.Next();

                            UpdatePrecursor(titleParser, pkl, options.ShiftMass, options.ShiftScan);

                            writer.Write(sw, pkl);
                        }
                    }
                }

                if (File.Exists(resultFilename))
                {
                    File.Delete(resultFilename);
                }

                File.Move(tempFile, resultFilename);

                result.Add(resultFilename);
            }
            Progress.End();

            return(result);
        }
Exemplo n.º 3
0
        public List <PeakList <T> > ReadFromFile(string filename)
        {
            var fi = new FileInfo(filename);

            if (!fi.Exists)
            {
                throw new FileNotFoundException("Cannot find the file " + filename);
            }
            String experimental = FileUtils.ChangeExtension(fi.Name, "");

            var result = new List <PeakList <T> >();
            var sr     = new StreamReader(new FileStream(filename, FileMode.Open));

            try
            {
                var iter = new MascotGenericFormatIterator <T>(sr);

                while (iter.HasNext())
                {
                    if (Progress.IsCancellationPending())
                    {
                        throw new UserTerminatedException();
                    }

                    var pkl = iter.Next();
                    if (pkl.Experimental == null || pkl.Experimental.Length == 0)
                    {
                        pkl.Experimental = experimental;
                    }
                    result.Add(pkl);
                }
            }
            finally
            {
                sr.Close();
            }

            return(result);
        }
Exemplo n.º 4
0
 public bool HasNext()
 {
     return(MascotGenericFormatIterator <Peak> .CheckHasNext(this.reader));
 }