Parameter/Results Blast WebService

Jul 16, 2013 at 3:14 PM
Edited Jul 16, 2013 at 3:15 PM
Hi,

I need know the all parameters of the NCI Blast WebService eg if there is only how to get results with Query cover = 100%.
Another point also needs to know the results of a query with, eg the e-value and Query cover obtained.
With the code snippet below, I do not get the results you need.
                            resultText.Text += "\r\n" + string.Join("\r\n", result.Hits.Select(h => string.Format(
                            "{0}: Accession={1} Def={2}, Hsps={3}, Length={4}.",
                            h.Id, h.Accession, h.Def, 
                            h.Hsps.Count, h.Length)));
thanks,
Coordinator
Jul 16, 2013 at 5:33 PM
For the first question, the parameter list depends on the service you call (blastp, blastx, etc.). You can go to the NCBI site to get a list of all the parameters. .NET Bio currently uses the SOAP variant for submission so check this site out for more info: http://www.ncbi.nlm.nih.gov/books/NBK55699/. Essentially, you just code the parameters and values into the dictionary prior to submission to configure the service. Let me know if that doesn't make sense and I'll send you a code fragment.

For the second part of your question, can you expand on what you are trying to receive? Perhaps it's something not exposed in the result model which means you might need to parse the returning XML directly but I need to know a little more to tell for sure.

mark
Jul 17, 2013 at 10:54 PM
Hi Mark,

Thanks for help me. I am using SOAP-based webservice ('http://www.ncbi.nlm.nih.gov/blast/Blast.cgi') that said BioPerl, but would like to use it with Bio.NET. Below is the output I get the BioPerl script, as it could have the same output with Bio.Net?

ALIGNMENTS
ref|XM_003237979.1| Trichophyton rubrum CBS 118892 hypothetical protein (TERG_00021)
mRNA, complete cds
Length=2658
Score = 46.4 bits (50), Expect = 0.002
Identities = 25/25 (100%), Gaps = 0/25 (0%)
Strand=Plus/Plus

Query 1 AAGGAGAAGAAGAAAGAAGAGGAAG 25

Sbjct 1855 AAGGAGAAGAAGAAAGAAGAGGAAG 1879

thanks,
Coordinator
Jul 23, 2013 at 9:03 PM
I think everything is in the BlastResponse packet. Here's an example which dumps out the information from NCBI:
using System;
using System.Threading;
using Bio;
using Bio.Web;
using Bio.Web.Blast;

namespace BlastExample
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            const string seq = "ACCTCCACTAGCTTTGTTTGTAGTGATGCTCTGTAGCACCACTGG" +
                "GAAGCCCTTTAATGAATGTGCCTTTCCGCAAATCACACACACACAAATACACTTATAGAAACAAGGTGATTTTCTTGAAA" +
                "TAATAAAACAAAATTTGGAAGAAGATTTTTACTGTCTTAGGAAAAGTAAGGCATTGGAAGGTGGCTAGGTATGACATATG" +
                "AAGTTGCATTTTAAAACTGGAATTGGACAACTGATATTCAGTGATATTTATGCTACTACCTTCTAGAATCGAGAGCATGC" +
                "ACCCCACTCTGTACTCTTGCCTGGAGAATCCATGATGAGAGCCTGGTAGGCTGCAGTCCATGGGGTCACACAGAGTCGGA" +
                "CATGACTGAGCGACTTCACTTTCACTTTTCAATTTCATGCATTGGAGCCGGAAATGGCAACCCACTCCAGTGTTCTTGCC" +
                "TGGAGAATCCCAGGGATGGGGAAGCCTGGTGGGCTGCTGTCTATGGGGTCGCAGAGAGTCAGACACGACTGAAGTGACTT" +
                "AGCAGCAACCTTCTGGAATAAACGCCTCAGGCTTTAAACTCTGGCTTGACCATTCACTAGCCATGGGATCCACTAGAGTC" +
                "GACCTGCAGGCATGCAAGC";
            ISequence sequence = new Sequence(Alphabets.DNA, seq);

            var blastService = new NCBIBlastHandler(new ConfigParameters { UseBrowserProxy = false, UseAsyncMode = true });

            // Set database and program to search.
            var searchParams = new BlastParameters();
            searchParams.Add("Program", "blastn");
            searchParams.Add("Database", "ecoli");

            string jobId;
            try
            {
                jobId = blastService.SubmitRequest(sequence, searchParams);
            }
            catch(Exception ex)
            {
                Console.WriteLine("Service is not available: " + ex.Message);
                return;
            }

            ServiceRequestInformation info = blastService.GetRequestStatus(jobId);
            if (info.Status != ServiceRequestStatus.Waiting
                && info.Status != ServiceRequestStatus.Ready)
            {
                Console.WriteLine("Service is not ready or waiting.");
                return;
            }

            for (int attempt = 0; attempt < 10; attempt++)
            {
                info = blastService.GetRequestStatus(jobId);

                if (info.Status == ServiceRequestStatus.Error || info.Status == ServiceRequestStatus.Canceled)
                {
                    Console.WriteLine("Requested failed, status is: {0} - {1}", info.Status, info.StatusInformation);
                    return;
                }

                if (info.Status != ServiceRequestStatus.Ready)
                {
                    Thread.Sleep(info.Status == ServiceRequestStatus.Waiting ||
                                 info.Status == ServiceRequestStatus.Queued
                        ? 5000*attempt
                        : 1);
                }
                else break;
            }

            var results = blastService.FetchResultsSync(jobId, searchParams);
            if (results == null)
            {
                Console.WriteLine("No results returned.");
                return;
            }

            foreach (var r in results)
            {
                var md = r.Metadata;
                if (md != null)
                {
                    Console.WriteLine("Metadata:");
                    Console.WriteLine("Database: {0}, Program: {1}, Version: {2}", md.Database, md.Program, md.Version);
                    Console.WriteLine("Query Sequence: {0}", md.QuerySequence);
                    Console.WriteLine("Parameter Query: {0}", md.ParameterEntrezQuery);
                    Console.WriteLine("Parameter Expect: {0}", md.ParameterExpect);
                    Console.WriteLine("Parameter Filter: {0}", md.ParameterFilter);
                    Console.WriteLine("Gap Extend: {0}, Open: {1}", md.ParameterGapExtend, md.ParameterGapOpen);
                    Console.WriteLine("Include: {0}, MatchScore: {1}, Mismatch Score: {2}", md.ParameterInclude, md.ParameterMatchScore, md.ParameterMismatchScore);
                    Console.WriteLine("Matrix: {0}, Pattern: {1}", md.ParameterMatrix, md.ParameterPattern);
                    Console.WriteLine("Def: {0}, Query Id: {1}, Query Len: {2}", md.QueryDefinition, md.QueryId, md.QueryLength);
                }
                foreach (var rec in r.Records)
                {
                    Console.WriteLine();
                    Console.WriteLine("Hits:");
                    foreach (var h in rec.Hits)
                    {
                        Console.WriteLine("Id: {0}, Length: {1}", h.Id, h.Length);
                        Console.WriteLine("Accession: {0}, Def: {1}", h.Accession, h.Def);
                        foreach (var hs in h.Hsps)
                        {
                            Console.WriteLine("  Alignment length: {0}", hs.AlignmentLength);
                            Console.WriteLine("  Bit Score: {0}, Density: {1}, EValue: {2}, Gaps: {3}", hs.BitScore, hs.Density, hs.EValue, hs.Gaps);
                            Console.WriteLine("  Hit Sequence: {0}\r\nStart: {1}, End: {2}, Frame: {3}", hs.HitSequence, hs.HitStart, hs.HitEnd, hs.HitFrame);
                        }
                    }
                }
            }
        }
    }
}
Coordinator
Jul 25, 2013 at 5:59 PM
Check out http://julmar.com/blog/mark/?p=312 for a slightly easier way to work with this under .NET 4.5.
Aug 7, 2013 at 3:34 PM
Hi Mark,

Thanks! One more question, which means the parameter Density (hs.Density)? Which parameter is equivalent to Identities (bioPerl)?

Thanks for help me.
Coordinator
Aug 8, 2013 at 8:46 PM
Edited Aug 8, 2013 at 8:49 PM
HSP identities is stored in hsp.IdentitiesCount

HSPs are "high-scoring segment pairs". Essentially these are just alignments which meet or exceed some known threshold (cutoff).

The density field is mapped to the score density coming back from the service (Hsp_density from NCBI). I think bioPerl ignores that right now (along with a handful of other HSP fields). Looking at the raw XML being returned from the service it doesn't appear that it's returned very often anyway so I would expect it to be zero most of the time. It's an optional field according to the DTD.

mark

Mark Smith [email removed] | @marksm | www.julmar.com/blog/mark