Bio::Tools::Analysis::Protein
Sopma
Summary
Bio::Tools::Analysis::Protein::Sopma - a wrapper around
Sopma protein secondary structure prediction server
Package variables
Privates (from "my" definitions)
$ANALYSIS_SPEC = {name => 'Sopma', type => 'Protein'}
$URL = 'http://npsa-pbil.ibcp.fr/cgi-bin/secpred_sopma.pl'
$ANALYSIS_NAME = 'Sopma'
$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, }, ]
$RESULT_SPEC = { '' => 'bulk', raw => '[{struc=>, helix=>, turn=>, coil=>, sheet=>}]', meta => 'Bio::Seq::Meta::Array object', 'Bio::SeqFeatureI' => 'ARRAY of Bio::SeqFeature::Generic', }
Included modules
HTTP::Request::Common qw ( POST )
IO::String
Inherit
Synopsis
use Bio::Tools::Analysis::Protein::Sopma;
#get a Bio::Seq or Bio::PrimarySeq
my $seq;
my $sopma = Bio::Tools::Analysis::Protein::Sopma->new
(-seq=>$seq, states=>4);
$sopma->run;
print $sopma->result;# #raw text to standard error
Description
A module to remotely retrieve predictions of protein secondary
structure. Each residue in the protein receives a score representing
the likelihood of existing in each of four different states (helix,
coil, turn or sheet), e.g.,
my $analysis_object = Bio::Tools::SimpleAnalysis::Protein::Sopma->new
( -seq => $seq,
-states =>4,
-window_width =>15,
);
creates a new object. Compulsory arguments -seq. Optional arguments
-states, -window_width,-similarity_threshold. These values can also be
set by direct methods , e.g.,
$analysis_object->states(4);
$analysis_object->run ;
submits the query to the server and obtains raw text output Given an
amino acid sequence the results can be obtained in 4 formats,
determined by the argument to the result method
1
The raw text of the program output
my $rawdata = $analysis_object->result;
2
A reference to an array of hashes of scores for each state and the
assigned state.
my $data_ref = $analysis_object->result('parsed');
print "score for helix at residue 2 is $data_ref->[1]{'helix'}\n";
print "predicted struc at residue 2 is $data_ref->[1]{'struc}\n";
Hash keys are 'helix', 'struc', 'sheet', 'coil', 'turn'.
3
An array of Bio::SeqFeature::Generic objects where each feature is a
predicted unit of secondary structure. Only stretches of helix/sheet
predictions for longer than 4 residues are defined as helices/sheets.
my @fts = $analysis_object->result(Bio::SeqFeatureI);
for my $ft (@fts) {
print " From ", $ft->start, " to ",$ft->end, " struc: " ,
($ft->each_tag_value('type'))[0] ,"\n";
}
4
A Bio::Seq::Meta::Array implementing sequence.
This is a Bio::Seq object that can also hold data about each residue
in the sequence. In this case, the sequence can be associated with a
arrays of Sopma prediction scores. e.g.,
my $meta_sequence = $analysis_object->result('meta');
print "scores from residues 10 -20 are ",
$meta_sequence->named_submeta_text("Sopma_helix",10,20), "\n";
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.
Methods
Methods description
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. |
Useage : $job->window_width(...)
Returns : The window width used in the analysis
Args : None (retrieves value) or an integer (default = 17)
that sets the window width.
This method gets/sets the window width for the prediction, . If attempted to set longer than the sequence, warns of error. |
Useage : $job->states(...)
Returns : The number of secondary structure prediction states
Args : None (retrieves value) or either '3' or '4' to set
prior to running analysis.
This method gets/sets the number of states for the prediction, either 3 or 4 (includes turns). |
Usage : $job->result (...)
Returns : a result created by running an analysis
Args : various
The method returns a result of an executed job. If the job was terminated by an error the result may contain an error message instead of the real data. This implementation returns differently processed data depending on argument:
undef Returns the raw ASCII data stream but without HTML tags
'Bio::SeqFeatureI' The argument string defines the type of bioperl objects returned in an array. The objects are Bio::SeqFeature::Generic. Feature primary tag is "2ary". Feature tags are "type" (which can be helix, sheet coil, or turn if 4 state prediction requested) "method" (Sopma)
'parsed' Array of hash references of scores/structure assignations { helix =>, sheet => , coil => , struc=>}.
'all' A Bio::Seq::Meta::Array object. Scores can be accessed using methods from this class. Meta sequence names are Sopma_helix, Sopma_sheet, Sopma_coil, Sopma_turn (if defined) Sopma_struc.
|
Methods code
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'};
return $self->{'_similarity_threshold'};} |
sub window_width
{ my ($self, $value) = @_;
if ($value) {
$self->throw ("window_width must be integer")
unless $value =~ /^\d+$/;
$self->{'_window_width'} = $value;
}
$self->{'_window_width'} ||= $self->input_spec->[2]{'default'};
$self->warn ("window width longer than sequence!")
unless $self->{'_window_width'} < $self->seq->length;
return $self->{'_window_width'};} |
sub states
{ my ($self, $value) = @_;
if ($value) {
$self->throw ("number of states must be 3 or 4")
unless $value == 3 or $value ==4;
$self->{'_states'} = $value;
}
$self->{'_states'} ||= $self->input_spec->[3]{'default'};
return $self->{'_states'};} |
sub result
{ my ($self,$value, $run_id) = @_;
my @score;
my @fts;
if ($value ) {
if (!exists($self->{'_parsed'} )) {
my $result = IO::String->new($self->{'_result'});
while (my $line = <$result>) {
next unless $line =~ /^[HCET]\s/; $line =~/^([A-Z])\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/; push @score, { struc => $1,
helix => $2,
sheet => $3,
coil => $5,
};
$score[$#score]{'turn'} = $4 if $self->states == 4;
}
$self->{'_parsed'} =\@ score;
}
if ($value eq 'Bio::SeqFeatureI') {
$self->_get_2ary_coords();
for my $type (keys %{$self->{'_parsed_coords'}} ) {
next if $type =~ /\w{2,}/;
my $tag_hash = {
type => $type,
method => $self->analysis_name,
};
$self->_add_params_to_result($tag_hash);
for my $loc (@{$self->{'_parsed_coords'}{$type}} ) {
push @fts, Bio::SeqFeature::Generic->new
(-start => $loc->{'start'},
-end => $loc->{'end'},
-source => 'Sopma',
-primary => 'Domain',
-tag => $tag_hash,
);
} } delete $self->{'_parsed_coords'}; return @fts;
}
elsif ($value eq 'meta') {
my %type_scores;
for my $aa (@{$self->{'_parsed'}}) {
for my $type (qw(struc helix sheet coil)) {
push @{$type_scores{$type}}, $aa->{$type};
}
push @{$type_scores{'turn'}}, $aa->{'turn'} if exists $aa->{'turn'};
}
if (!$self->seq->isa("Bio::Seq::Meta::Array")) {
bless ($self->seq, "Bio::Seq::Meta::Array");
}
$self->seq->isa("Bio::Seq::MetaI")
|| $self->throw("$self is not a Bio::Seq::MetaI");
$Bio::Seq::Meta::Array::DEFAULT_NAME = 'Sopma_struc';
for my $struc_type (keys %type_scores) {
my $meta_name = "Sopma". "_" . "$struc_type";
if ($run_id) {
$meta_name .= "|$run_id";
}
my @meta = map{$_->{$struc_type}} @{$self->{'_parsed'}};
if (grep{$_ eq $meta_name}$self->seq->meta_names >0) {
$self->warn ("$meta_name already exists , not overwriting!");
next;
}
$self->seq->named_meta($meta_name,\@meta );
}
return $self->seq;
}
else {
return $self->{'_parsed'};
}
} return $self->{'_result'};} |
sub _init
{ my $self = shift;
$self->url($URL);
$self->{'_ANALYSIS_SPEC'} = $ANALYSIS_SPEC;
$self->{'_INPUT_SPEC'} = $INPUT_SPEC;
$self->{'_RESULT_SPEC'} = $RESULT_SPEC;
$self->{'_ANALYSIS_NAME'} = $ANALYSIS_NAME;
return $self;} |
sub _get_2ary_coords
{ 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;
} |
sub _run
{ my $self = shift;
$self->delay(1);
$self->sleep;
$self->status('TERMINATED_BY_ERROR');
my $request = POST 'http://npsa-pbil.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;
my ($next) = $text =~ /Prediction.*?=(.*?)>/;
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;} |
| _add_params_to_result | description | prev | next | Top |
sub _add_params_to_result
{ my ($self, $tag_hash) = @_;
my $hash;
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;
}
} } |
General documentation
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://bio.perl.org/MailList.html - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via email
or the web:
bioperl-bugs@bio.perl.org
http://bugzilla.bioperl.org/