/// <summary>
        /// This method is called when the user wants to run BLAST on a sequence
        /// </summary>
        private void OnBlastSequence()
        {
            // Get the full sequence, or the selected fragment
            ISequence sequence = !string.IsNullOrEmpty(SelectedSequenceFragment)
                ? new Sequence(SelectedSequence.RawSequence.Alphabet, SelectedSequenceFragment)
                : SelectedSequence.RawSequence;

            IBlastServiceHandler blastServiceHandler = SelectedBlastAlgorithm;

            BlastParameters bp = new BlastParameters();

            bp.Add("Program", "blastn");
            bp.Add("Database", "nr");
            bp.Add("Expect", "10.0");

            blastServiceHandler.RequestCompleted += new EventHandler <BlastRequestCompletedEventArgs>(BlastServiceHandlerRequestCompleted);

            try
            {
                IsRunning = blastServiceHandler.SubmitRequest(sequence, bp);
                if (string.IsNullOrEmpty(IsRunning))
                {
                    ShowError("Failed to execute Blast", "No results returned", null);
                }
            }
            catch (Exception ex)
            {
                ShowError("Failed to execute Blast", "Error occurred", ex);
                ResultHits = null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method is called when the user wants to run BLAST on a sequence
        /// </summary>
        private void OnBlastSequence()
        {
            // Get the full sequence, or the selected fragment
            ISequence sequence = !string.IsNullOrEmpty(SelectedSequenceFragment)
                ? new Sequence(SelectedSequence.RawSequence.Alphabet, SelectedSequenceFragment)
                : SelectedSequence.RawSequence;

            IBlastServiceHandler blastServiceHandler = SelectedBlastAlgorithm;

            BlastParameters bp = new BlastParameters();

            bp.Add("Program", "blastn");
            bp.Add("Database", "nr");
            bp.Add("Expect", "10.0");

            try
            {
                string resultKey = blastServiceHandler.SubmitRequest(sequence, bp);
                if (string.IsNullOrEmpty(resultKey))
                {
                    ShowError("Failed to execute Blast", "No results returned", null);
                }
                else
                {
                    IList <BlastResult> results =
                        blastServiceHandler.FetchResultsSync(resultKey, bp);
                    if (results == null || results.Count == 0)
                    {
                        MessageBox.Show("No Results returned.");
                        ResultHits = null;
                    }
                    else
                    {
                        ResultHits = results[0].Records[0].Hits;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError("Failed to execute Blast", "Error occurred", ex);
                ResultHits = null;
            }
        }
        /// <summary>
        /// This method is called when the user wants to run BLAST on a sequence
        /// </summary>
        private void OnBlastSequence()
        {
            // Get the full sequence, or the selected fragment
            ISequence sequence = !string.IsNullOrEmpty(SelectedSequenceFragment)
                ? new Sequence(SelectedSequence.RawSequence.Alphabet, SelectedSequenceFragment)
                : SelectedSequence.RawSequence;

            IBlastServiceHandler blastServiceHandler = SelectedBlastAlgorithm;

            BlastParameters bp = new BlastParameters();

            foreach (var item in BlastParameters.Where(kv => !string.IsNullOrEmpty(kv.Value)))
            {
                bp.Add(item.Key, item.Value);
            }

            if (!string.IsNullOrEmpty(Url))
            {
                blastServiceHandler.Configuration.Connection = new Uri(Url);
                if (Url.StartsWith("https"))
                {
                    blastServiceHandler.Configuration.UseHttps = true;
                }
            }
            blastServiceHandler.Configuration.UseBrowserProxy = UseBrowserProxy;

            blastServiceHandler.RequestCompleted += new EventHandler <BlastRequestCompletedEventArgs>(BlastServiceHandlerRequestCompleted);

            try
            {
                IsRunning = blastServiceHandler.SubmitRequest(sequence, bp);
                if (string.IsNullOrEmpty(IsRunning))
                {
                    ShowError("Failed to execute Blast", "No results returned", null);
                }
            }
            catch (Exception ex)
            {
                ShowError("Failed to execute Blast", "Error occurred", ex);
                ResultHits = null;
            }
        }