Bio::Tools::Analysis::Protein GOR4
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Bio::Tools::Analysis::Protein::GOR4 - a wrapper around GOR4 protein
secondary structure prediction server
Package variables
Privates (from "my" definitions)
$ANALYSIS_SPEC = {name => 'Gor4', type => 'Protein'}
$URL = ''
$INPUT_SPEC = [ {mandatory =>'true', type => 'Bio::PrimarySeqI', 'name' => 'seq', }, ]
$RESULT_SPEC = { '' => 'bulk', 'Bio::SeqFeatureI' => 'ARRAY of Bio::SeqFeature::Generic', raw => '[ {struc =>, helix=> ,sheet=>, coil=>}]', meta => 'Bio::Seq::Meta::Array object', }
Included modules
HTTP::Request::Common qw ( POST )
  use Bio::Tools::Analysis::Protein::GOR4;
#get a Bio::Seq or Bio::PrimarySeq
use Bio::PrimarySeq;
$seq = Bio::PrimarySeq->new
-primary_id=>'test'); # a Bio::PrimarySeqI object
my $gor4 = Bio::Tools::Analysis::Protein::GOR4->new (-seq=>$seq); $gor4->run; print $gor4->result;# #raw text to standard error
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 three different states (helix,
coil or sheet), e.g.,
  my $analysis_object = Bio::Tools::SimpleAnalysis::Protein::GOR4->
new(-seq => $seq);
creates a new object
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
    The raw text of the program output
  my $rawdata = $analysis_object->result;
    An 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";
    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. See for examples of how to add sequence
  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";
    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
single array of GOR4 prediction scores. e.g.,
  my $meta_sequence = $analysis_object->result('all');
print "helix scores from residues 10-20 are ",
$meta_sequence->named_submeta_text("GOR4_helix",10,20), "\n";
    Meta sequence names are : GOR4_helix, GOR4_sheet, GOR4_coil,
GOR4_struc, representing the scores for each residue.
    Many methods common to all analyses are inherited from
No description
No description
No description
Methods description
resultcode    nextTop
 Name    : result
Usage : $job->result (...)
Returns : a result created by running an analysis
Args : see keys of $RESULT_SPEC
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
   Returns the raw ASCII data stream but without HTML tags
   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 or
coil) "method" (GOR4).
   Array of hash references of { helix =>, sheet => , coil => , struc=>}.
   A Bio::Seq::Meta::Array object. Scores can be accessed using methods
from this class. Meta sequence names are GOR4_helix, GOR4_sheet,
GOR4_coil, GOR4_struc.
Methods code
sub result {
    my ($self,$value) = @_;

    my @scores;
    my @fts;

    if ($value ) {
        #parse into basic raw form, store this as well as '_result'
if (!exists($self->{'_parsed'}) ) { my $result = IO::String->new($self->{'_result'}); while (my $line = <$result>) { next unless $line =~ /^\w\s/; # or for sopma/hnn /^[A-Z]\s/
$line =~/(\w)\s+(\d+)\s+(\d+)\s+(\d+)/; # or for so
push @scores, { struc => $1, helix => $2, sheet => $3, coil => $4, }; } $self->{'_parsed'} =\@ scores; } if ($value eq 'Bio::SeqFeatureI') { $self->_get_2ary_coords(); for my $type (keys %{$self->{'_parsed_coords'}} ) { next if $type =~ /\w{2,}/; #if not H,C,E or T
for my $loc (@{$self->{'_parsed_coords'}{$type}} ) { push @fts, Bio::SeqFeature::Generic->new (-start => $loc->{'start'}, -end => $loc->{'end'}, -source => 'GOR4', -primary => 'Region', -tag => { type => $type, method => $self->analysis_name, }); } #end of array of strucs of type
} # end of all 2nd struc elements
delete $self->{'_parsed_coords'}; #remove temp data
return @fts; } #endif BioSeqFeature
elsif ($value eq 'meta') { #1st of all make 3 or 4 arrays of scores for each type from column data
my %type_scores; for my $aa (@{$self->{'_parsed'}}) { push @{$type_scores{'struc'}}, $aa->{'struc'}; push @{$type_scores{'helix'}}, $aa->{'helix'}; push @{$type_scores{'sheet'}}, $aa->{'sheet'}; push @{$type_scores{'coil'}}, $aa->{'coil'}; } ## bless if necessary ##
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 = 'GOR4_struc'; ## now make meta_Sequence
for my $struc_type (keys %type_scores) { my $meta_name = "GOR4". "_" . "$struc_type"; my @meta = map{$_->{$struc_type}} @{$self->{'_parsed'}}; if (grep{$_ eq $meta_name}$self->seq->meta_names ) { $self->warn ("$meta_name already exists , not overwriting!"); next; } $self->seq->named_meta($meta_name,\@meta ); } # return seq array object implementing meta sequence #
return $self->seq; } else { return $self->{'_parsed'}; } } #endif ($value)
#return raw result if no return fomrt stated
return $self->{'_result'};
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'.
#could be put into a secondary base class if need be
my ($self) = @_; my @prot = @{$self->{'_parsed'}}; my %Result; for (my $index = 0; $index <= $#prot; $index++) { my $type = $prot[$index]{'struc'}; next unless $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 _init {
    my $self = shift;
    $self->{'_INPUT_SPEC'} =$INPUT_SPEC;
    $self->{'_RESULT_SPEC'} =$RESULT_SPEC;
    return $self;
sub _run {
    my $self  = shift;
    # delay repeated calls by default by 3 sec, set delay() to change
$self->sleep; $self->status('TERMINATED_BY_ERROR'); my $request = POST $self->url, Content_Type => 'form-data', Content => [title => "", notice => $self->seq->seq, ali_width => 70, ]; my $content = $self->request($request); my $text = $content->content; return unless $text; my ($next) = $text =~ /Prediction.*?=(.*?)>/; return unless $next; my $out = ''.$next; my $req2 = HTTP::Request->new(GET=>$out); my $resp2 = $self->request($req2); $self->status('COMPLETED') if $resp2 ne ''; $self->{'_result'} = $resp2->content; } 1;
General documentation
Mailing ListsTop
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.                  - General discussion - About the mailing lists
Support Top
Please direct usage questions or support issues to the mailing list:
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.
Reporting BugsTop
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
Richard Adams,,
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _