Hi Experts Please help :: Problem in Bio-Parser....with XML-RPC call

Discussion in 'Perl Misc' started by deep, Jul 30, 2006.

  1. deep

    deep Guest

    Hi All,
    I have a bio-parser written in perl which separate outs the contents of
    the blast result file.
    I am using this module in an XML-RPC environment , where I have a CPP
    client which send the Blast-Result-file to perl XML-RPC server ...which
    calls the blast parser method
    when the perl server is started, the first request he is getting from
    the client is fullfilled ..that means I am getting expecting output
    say number of hit counts and score..etc.

    But the problem arises when client sends the next request..
    I checked that
    The client sends request with the blast_result input file
    perfectly...
    Even server accepts the new request call and sends the
    parameteried input file to the blast parser method..but second time the
    method does not execute perfectly...It accepts input file and give the
    blank output....without any error...
    I checked the logger files and I found that blast parser method is not
    executed completely..but when i tried to execute the method separately
    (Not in XML-RPC environment)I got the expected output.

    I don't know why this is happening...????
    I am giving the complete code here...If you ppl have time...please help
    me.I will be greateful to you always....

    Thanks
    Deepak




    use strict;
    use Bio::SearchIO;
    use Bio::SimpleAlign;
    use Bio::AlignIO;
    use Frontier::Daemon;

    use lib 'lib/perl5/site_perl/5.8.5/';
    use Config::Simple;
    use Log::Log4perl;

    Log::Log4perl::init('log4perl.conf');

    my $logger = Log::Log4perl->get_logger('rootLogger');
    $logger->debug("Logger Initialised");
    sub blastParser()
    {

    $logger->debug("\nNew Call");

    print "\n Inside blastParser";

    my $fileContent = shift;
    my $tempFileName = 'TEMP_BLAST_RESULT_FILE';

    $logger->debug("\nBlast File :::\n".$fileContent);

    open BLASTFILE, ">$tempFileName" or die "Can't create File...!";
    #writting file content into the tempBlastFile
    print BLASTFILE "$fileContent";
    #Closing fileName
    close BLASTFILE;

    #Destroying the fileContent
    $fileContent = undef;
    print "\n Copied Input File Succsefully..";

    my $hitCount = shift;
    $logger->debug("\nHitCount from client: $hitCount");
    my $in = new Bio::SearchIO(-format => 'blast',
    # comment out the next line to read STDIN
    -file => $tempFileName );

    my @outputArray;
    my $arrayCnt = 0;

    while ( my $result = $in->next_result )
    {
    print "\nAnalysing the result...";
    my @stats = $result->available_statistics;
    my @params = $result->available_parameters;

    # $logger->debug("\nBlast File :::\n".$fileContent);
    $logger->debug("\nNumber of Hits Found :".$result->num_hits);
    print "\nNumber of hits fount :".$result->num_hits;

    while ( my $hit = $result->next_hit and $hitCount)
    {
    $hitCount--;

    print "\nAnalysing Hit Count :".$hitCount;

    my $id = $hit->matches('id');
    my $cons = $hit->matches('cons');
    my @accs = $hit->each_accession_number;
    my @qidentical = $hit->seq_inds('query','identical');
    my @qconserved = $hit->seq_inds('query','conserved');
    my @hidentical = $hit->seq_inds('hit','identical');
    my @hconserved = $hit->seq_inds('hit','conserved');
    #return start
    $outputArray[$arrayCnt++] = $hit->name;
    $outputArray[$arrayCnt++] = $hit->accession;
    $outputArray[$arrayCnt++] = $hit->raw_score;
    $outputArray[$arrayCnt++] = $hit->bits;
    $outputArray[$arrayCnt++] = $hit->gaps;

    $logger->debug("\nHitName :".$hit->name);
    $logger->debug("\nAccession :".$hit->accession);
    $logger->debug("\nRaw Score :".$hit->raw_score);
    $logger->debug("\nBits :".$hit->bits);
    $logger->debug("\ngaps :".$hit->gaps);
    #return stop
    #return gaps

    while ( my $hsp = $hit->next_hsp )
    {
    my ($qid,$qcons) = $hsp->matches('hit');
    my ($id,$cons) = $hsp->matches('query');
    @qidentical = $hsp->seq_inds('query','identical');
    @qconserved = $hsp->seq_inds('query','conserved');
    @hidentical = $hsp->seq_inds('hit','identical');
    @hconserved = $hsp->seq_inds('hit','conserved');
    my @hrange = $hsp->range('hit');
    my @qrange = $hsp->range('query');
    my $aln = $hsp->get_aln;
    my $alnIO = Bio::AlignIO->new(-format=>"clustalw",
    -file=>">tempHitFile");

    #return evalue
    $logger->debug("\neValue :".$hsp->evalue);
    $logger->debug("\nPercent Identity
    :".$hsp->percent_identity);
    $outputArray[$arrayCnt++] = $hsp->evalue;
    #return gaps
    $outputArray[$arrayCnt++] = $hsp->percent_identity;
    #return alignment
    #write_aln function writes the sequence allignment to the
    #specified file (here tempHitFile)
    #so we are stoaring the actual hit allignment to the file
    #and again recollecting it into the a string
    $alnIO->write_aln($aln);
    open hitFile, "tempHitFile" or die "Can't read file";

    undef $/;
    #getting the whole file into the outputArray
    my $allignMent = <hitFile>;
    $outputArray[$arrayCnt++] = $allignMent;
    $logger->debug("\nAllignments :".$allignMent);
    close hitFile;
    $hsp = undef;
    }
    $hit = undef;
    }
    $result = undef;
    }
    # my $cmd = "rm $tempFileName";
    # system ($cmd);
    # print "\nDeleting input file...$tempFileName and returning
    # outputArray @outputArray";
    return \@outputArray;
    }

    my $methods = {'blastParser' => \&blastParser};
    $logger->debug("Starting XMLRPC Server...");
    Frontier::Daemon->new(LocalPort => 9011, methods => $methods) or die
    "Couldn't start HTTP server : $!";
     
    deep, Jul 30, 2006
    #1
    1. Advertising

  2. deep

    deep Guest

    Re:problem in Bio-Parser....with XML-RPC call

    Hi All,
    I Got the answer but with one problem....
    Now when I send the first request....
    I got the expected output but without executing
    return \@outputArray;
    statement..in the blastparser method...
    I don't know why...???
    but when I send the second request, It executes the return
    \@outputArray; statement..
    and then calls the blastParser Method.
    But as now outputArray is blank i m getting blank output at client end.

    But the problem still remain...!!! why it is not executing return
    statement in the request itself..?? And if return statement is not
    executing ?? Then how i m getting the data at client side..when i send
    the request first time...!!

    I have defiantely checked the things in logger file. And believe me
    ....its working same as I mentioned above,,,!

    Thanks
    Deepak

    deep wrote:
    > Hi All,
    > I have a bio-parser written in perl which separate outs the contents of
    > the blast result file.
    > I am using this module in an XML-RPC environment , where I have a CPP
    > client which send the Blast-Result-file to perl XML-RPC server ...which
    > calls the blast parser method
    > when the perl server is started, the first request he is getting from
    > the client is fullfilled ..that means I am getting expecting output
    > say number of hit counts and score..etc.
    >
    > But the problem arises when client sends the next request..
    > I checked that
    > The client sends request with the blast_result input file
    > perfectly...
    > Even server accepts the new request call and sends the
    > parameteried input file to the blast parser method..but second time the
    > method does not execute perfectly...It accepts input file and give the
    > blank output....without any error...
    > I checked the logger files and I found that blast parser method is not
    > executed completely..but when i tried to execute the method separately
    > (Not in XML-RPC environment)I got the expected output.
    >
    > I don't know why this is happening...????
    > I am giving the complete code here...If you ppl have time...please help
    > me.I will be greateful to you always....
    >
    > Thanks
    > Deepak
    >
    >
    >
    >
    > use strict;
    > use Bio::SearchIO;
    > use Bio::SimpleAlign;
    > use Bio::AlignIO;
    > use Frontier::Daemon;
    >
    > use lib 'lib/perl5/site_perl/5.8.5/';
    > use Config::Simple;
    > use Log::Log4perl;
    >
    > Log::Log4perl::init('log4perl.conf');
    >
    > my $logger = Log::Log4perl->get_logger('rootLogger');
    > $logger->debug("Logger Initialised");
    > sub blastParser()
    > {
    >
    > $logger->debug("\nNew Call");
    >
    > print "\n Inside blastParser";
    >
    > my $fileContent = shift;
    > my $tempFileName = 'TEMP_BLAST_RESULT_FILE';
    >
    > $logger->debug("\nBlast File :::\n".$fileContent);
    >
    > open BLASTFILE, ">$tempFileName" or die "Can't create File...!";
    > #writting file content into the tempBlastFile
    > print BLASTFILE "$fileContent";
    > #Closing fileName
    > close BLASTFILE;
    >
    > #Destroying the fileContent
    > $fileContent = undef;
    > print "\n Copied Input File Succsefully..";
    >
    > my $hitCount = shift;
    > $logger->debug("\nHitCount from client: $hitCount");
    > my $in = new Bio::SearchIO(-format => 'blast',
    > # comment out the next line to read STDIN
    > -file => $tempFileName );
    >
    > my @outputArray;
    > my $arrayCnt = 0;
    >
    > while ( my $result = $in->next_result )
    > {
    > print "\nAnalysing the result...";
    > my @stats = $result->available_statistics;
    > my @params = $result->available_parameters;
    >
    > # $logger->debug("\nBlast File :::\n".$fileContent);
    > $logger->debug("\nNumber of Hits Found :".$result->num_hits);
    > print "\nNumber of hits fount :".$result->num_hits;
    >
    > while ( my $hit = $result->next_hit and $hitCount)
    > {
    > $hitCount--;
    >
    > print "\nAnalysing Hit Count :".$hitCount;
    >
    > my $id = $hit->matches('id');
    > my $cons = $hit->matches('cons');
    > my @accs = $hit->each_accession_number;
    > my @qidentical = $hit->seq_inds('query','identical');
    > my @qconserved = $hit->seq_inds('query','conserved');
    > my @hidentical = $hit->seq_inds('hit','identical');
    > my @hconserved = $hit->seq_inds('hit','conserved');
    > #return start
    > $outputArray[$arrayCnt++] = $hit->name;
    > $outputArray[$arrayCnt++] = $hit->accession;
    > $outputArray[$arrayCnt++] = $hit->raw_score;
    > $outputArray[$arrayCnt++] = $hit->bits;
    > $outputArray[$arrayCnt++] = $hit->gaps;
    >
    > $logger->debug("\nHitName :".$hit->name);
    > $logger->debug("\nAccession :".$hit->accession);
    > $logger->debug("\nRaw Score :".$hit->raw_score);
    > $logger->debug("\nBits :".$hit->bits);
    > $logger->debug("\ngaps :".$hit->gaps);
    > #return stop
    > #return gaps
    >
    > while ( my $hsp = $hit->next_hsp )
    > {
    > my ($qid,$qcons) = $hsp->matches('hit');
    > my ($id,$cons) = $hsp->matches('query');
    > @qidentical = $hsp->seq_inds('query','identical');
    > @qconserved = $hsp->seq_inds('query','conserved');
    > @hidentical = $hsp->seq_inds('hit','identical');
    > @hconserved = $hsp->seq_inds('hit','conserved');
    > my @hrange = $hsp->range('hit');
    > my @qrange = $hsp->range('query');
    > my $aln = $hsp->get_aln;
    > my $alnIO = Bio::AlignIO->new(-format=>"clustalw",
    > -file=>">tempHitFile");
    >
    > #return evalue
    > $logger->debug("\neValue :".$hsp->evalue);
    > $logger->debug("\nPercent Identity
    > :".$hsp->percent_identity);
    > $outputArray[$arrayCnt++] = $hsp->evalue;
    > #return gaps
    > $outputArray[$arrayCnt++] = $hsp->percent_identity;
    > #return alignment
    > #write_aln function writes the sequence allignment to the
    > #specified file (here tempHitFile)
    > #so we are stoaring the actual hit allignment to the file
    > #and again recollecting it into the a string
    > $alnIO->write_aln($aln);
    > open hitFile, "tempHitFile" or die "Can't read file";
    >
    > undef $/;
    > #getting the whole file into the outputArray
    > my $allignMent = <hitFile>;
    > $outputArray[$arrayCnt++] = $allignMent;
    > $logger->debug("\nAllignments :".$allignMent);
    > close hitFile;
    > $hsp = undef;
    > }
    > $hit = undef;
    > }
    > $result = undef;
    > }
    > # my $cmd = "rm $tempFileName";
    > # system ($cmd);
    > # print "\nDeleting input file...$tempFileName and returning
    > # outputArray @outputArray";
    > return \@outputArray;
    > }
    >
    > my $methods = {'blastParser' => \&blastParser};
    > $logger->debug("Starting XMLRPC Server...");
    > Frontier::Daemon->new(LocalPort => 9011, methods => $methods) or die
    > "Couldn't start HTTP server : $!";
     
    deep, Jul 30, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pere Montolio

    XML RPC to ONC XDR RPC

    Pere Montolio, Aug 11, 2004, in forum: XML
    Replies:
    0
    Views:
    731
    Pere Montolio
    Aug 11, 2004
  2. Steven Bethard

    grouping subsequences with BIO tags

    Steven Bethard, Apr 21, 2005, in forum: Python
    Replies:
    6
    Views:
    327
    Bengt Richter
    Apr 23, 2005
  3. Ymtrader
    Replies:
    1
    Views:
    584
    Adam Tauno Williams
    Mar 15, 2011
  4. Replies:
    0
    Views:
    216
  5. Vladimir Konrad

    rpc (not xml-rpc)

    Vladimir Konrad, Sep 2, 2005, in forum: Ruby
    Replies:
    5
    Views:
    138
    Austin Ziegler
    Sep 3, 2005
Loading...

Share This Page