BioPerl

 view release on metacpan or  search on metacpan

Bio/Tools/Analysis/Protein/Sopma.pm  view on Meta::CPAN


Meta sequence names are : Sopma_helix, Sopma_sheet, Sopma_turn,
Sopma_coil, Sopma_struc, representing the scores for each residue.

Many methods common to all analyses are inherited from
Bio::Tools::Analysis::SimpleAnalysisBase.

=back

=head1 SEE ALSO

L<Bio::SimpleAnalysisI>, 
L<Bio::Tools::Analysis::SimpleAnalysisBase>
L<Bio::Seq::Meta::Array>, 
L<Bio::WebAgent>

=head1 FEEDBACK

=head2 Mailing Lists

User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists.  Your participation is much appreciated.

  bioperl-l@bioperl.org                  - General discussion
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

=head2 Support 

Please direct usage questions or support issues to the mailing list:

I<bioperl-l@bioperl.org>

rather than to the module maintainer directly. Many experienced and 
reponsive experts will be able look at the problem and quickly 
address it. Please include a thorough description of the problem 
with code and data examples if at all possible.

=head2 Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution.  Bug reports can be submitted via the
web:

  https://github.com/bioperl/bioperl-live/issues

=head1 AUTHORS

Richard Adams, Richard.Adams@ed.ac.uk, 

=head1 APPENDIX

=cut

use strict;

package Bio::Tools::Analysis::Protein::Sopma;

use IO::String;
use Bio::SeqIO;
use HTTP::Request::Common qw (POST);
use Bio::SeqFeature::Generic;
use Bio::Seq::Meta::Array;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;

use base qw(Bio::Tools::Analysis::SimpleAnalysisBase);

#extends array for 2struc.
my $URL = 'https://npsa-prabi.ibcp.fr/cgi-bin/secpred_sopma.pl';
my $ANALYSIS_NAME= 'Sopma';
my $ANALYSIS_SPEC= {name => 'Sopma', type => 'Protein'};
my $INPUT_SPEC = [
                  {mandatory=>'true',
                   type     => 'Bio::PrimarySeqI',
                   'name'   => 'seq',
                  },
                  {mandatory =>'false',
                   type      => 'integer',
                   name      => 'similarity_threshold',
                   default   => 8,
                  },
                  {mandatory  =>'false',
                   type       => 'integer',
                   name       => 'window_width',
                   default    => 17,
                  },
                  {mandatory  =>'false',
                   type       => 'integer',
                   name       => 'states',
                   default    => 4,
                  },
                 ];
my  $RESULT_SPEC =
    {
     ''   => 'bulk',              # same as undef
     raw  => '[{struc=>, helix=>, turn=>, coil=>, sheet=>}]',
     meta => 'Bio::Seq::Meta::Array object',
     'Bio::SeqFeatureI' => 'ARRAY of Bio::SeqFeature::Generic',
    };
use constant MIN_STRUC_LEN => 3; 


=head2  similarity_threshold

  Useage  : $job->similarity_threshold(...)
  Returns : The  similarity threshold used in the analysis
  Args    : None (retrieves value) or  an integer (default = 8) 
            that sets the similarity threshold .

This method gets/sets the  similarity threshold for the prediction.

=cut

sub similarity_threshold {
    my ($self, $value) = @_;
    if ($value) {
        $self->throw ("similarity_threshold must be integer")
            unless $value =~ /^\d+$/;
        $self->{'_similarity_threshold'} = $value;
    }
    $self->{'_similarity_threshold'} ||= $self->input_spec->[1]{'default'};

Bio/Tools/Analysis/Protein/Sopma.pm  view on Meta::CPAN

    $self->{'_RESULT_SPEC'}   = $RESULT_SPEC;
    $self->{'_ANALYSIS_NAME'} = $ANALYSIS_NAME;
    return $self;
}

sub _get_2ary_coords {
    #helper sub for result;
    ##extracts runs of structure > MIN_STRUC_LENresidues or less if Turn:
    #i.e., helical prediction for 1 residue isn't very meaningful...
    ## and poulates array of hashes with start/end values.
    ##keys of $Result are 'H' 'T' 'C' 'E'. 
    my ($self) = @_;
    my @prot = @{$self->{'_parsed'}};
    my %Result;
    for (my $index = 0; $index <= $#prot; $index++) {

        my $type        = $prot[$index]{'struc'};
        next unless $type && $type =~ /[HTCE]/;
        my $length = 1;
        for (my $j = $index + 1; $j <= $#prot; $j++) {
            my $test = $prot[$j];
            if ($test->{'struc'} eq $type) {
                $length++;
            } elsif (  $length > MIN_STRUC_LEN  ||
                       ($length <= MIN_STRUC_LEN && $type eq 'T') ) {
                push @{$Result{$type}}, {start => $index + 1 ,  end => $j};
                $index += $length -1;
                last;
            } else {
                $index += $length - 1;
                last;
            }
        }
    }
    $self->{'_parsed_coords'} = \%Result; #temp assignment
}

sub  _run {
    my $self  = shift;
    $self->delay(1);
    # delay repeated calls by default by 3 sec, set delay() to change
    $self->sleep;
    $self->status('TERMINATED_BY_ERROR');
    my $request = POST 'https://npsa-prabi.ibcp.fr/cgi-bin/secpred_sopma.pl',
        Content_Type => 'form-data',
            Content  => [title     => "",
                         notice    => $self->seq->seq,
                         ali_width => 70,
                         states    => $self->states,
                         threshold => $self->similarity_threshold ,
                         width     => $self->window_width,
                        ];

    my $text = $self->request($request)->content;
    return $self unless $text;

    #### get text only version of results ## 
    my ($next) = $text =~ /Prediction.*?=(.*?)>/;
    return $self unless $next;
    my $out    = "http://npsa-pbil.ibcp.fr/". "$next";
    my $req2   = HTTP::Request->new(GET=>$out);
    my $resp2  = $self->request ($req2);
    $self->{'_result'} = $resp2->content;
    $self->status('COMPLETED') if $resp2 ne '';
    return $self;
}

sub _add_params_to_result{
	## called when making Seqfeature objects
	my ($self, $tag_hash) = @_;
	my $hash;
	## adds input parameter values to SeqFeatureI results where multiple
    ##  parameter values are possible. Only adds value if not default. 
	map{$hash->{$_->{'name'}} = $_}@{$self->input_spec()};

	for my $p (keys %$hash) {
		if (!ref($self->$p) && $self->$p ne $hash->{$p}{'default'}) {
			$tag_hash->{$p} = $self->$p;
		}
	}
				 
}


1;



( run in 0.666 second using v1.01-cache-2.11-cpan-39bf76dae61 )