Example #1
0
        private void DoWork()
        {
            try
            {
                // just do the basic name+description parsing, no regex or web access - we don't use extended metadata here
                var fastaImporter = new WebEnabledFastaImporter(new WebEnabledFastaImporter.FakeWebSearchProvider());
                var proteins      = new Dictionary <string, ProteinData>();
                foreach (var path in FastaFilePaths)
                {
                    var statusText = "Reading FASTA file " + Path.GetFileName(path);
                    var fileInfo   = new FileInfo(path);
                    var reader     = File.OpenText(path);
                    foreach (var protein in fastaImporter.Import(File.OpenText(path)))
                    {
                        if (!UpdateProgress(statusText, (int)(reader.BaseStream.Position * 100 / fileInfo.Length)))
                        {
                            return;
                        }
                        ProteinData proteinData;
                        if (!proteins.TryGetValue(protein.Sequence, out proteinData))
                        {
                            proteinData = new ProteinData(protein.Sequence);
                            proteins.Add(protein.Sequence, proteinData);
                        }
                        foreach (var name in protein.Names)
                        {
                            proteinData.AddName(name.Name, name.Description);
                        }
                    }
                }
                UpdatePeptides(proteins);

                if (!IsDisposed)
                {
                    BeginInvoke(new Action(Close));
                }
            }
            finally
            {
                lock (this)
                {
                    _running = false;
                    Monitor.PulseAll(this);
                }
            }
        }
        private void DoWork()
        {
            try
            {
                // just do the basic name+description parsing, no regex or web access - we don't use extended metadata here
                var fastaImporter = new WebEnabledFastaImporter(new WebEnabledFastaImporter.FakeWebSearchProvider());
                var proteins = new Dictionary<string, ProteinData>();
                foreach (var path in FastaFilePaths)
                {
                    var statusText = "Reading FASTA file " + Path.GetFileName(path);
                    var fileInfo = new FileInfo(path);
                    var reader = File.OpenText(path);
                    foreach (var protein in fastaImporter.Import(File.OpenText(path)))
                    {
                        if (!UpdateProgress(statusText, (int) (reader.BaseStream.Position * 100 / fileInfo.Length)))
                        {
                            return;
                        }
                        ProteinData proteinData;
                        if (!proteins.TryGetValue(protein.Sequence, out proteinData))
                        {
                            proteinData = new ProteinData(protein.Sequence);
                            proteins.Add(protein.Sequence, proteinData);
                        }
                        foreach (var name in protein.Names)
                        {
                            proteinData.AddName(name.Name, name.Description);
                        }
                    }
                }
                UpdatePeptides(proteins);

                if (!IsDisposed)
                {
                    BeginInvoke(new Action(Close));
                }
            }
            finally
            {
                lock(this)
                {
                    _running = false;
                    Monitor.PulseAll(this);
                }
            }
        }