BioPerl
view release on metacpan or search on metacpan
Bio/Tools/Analysis/Protein/Sopma.pm view on Meta::CPAN
unless $value == 3 or $value ==4;
$self->{'_states'} = $value;
}
$self->{'_states'} ||= $self->input_spec->[3]{'default'};
return $self->{'_states'};
}
=head2 result
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:
=over 3
=item undef
Returns the raw ASCII data stream but without HTML tags
=item 'Bio::SeqFeatureI'
The argument string defines the type of bioperl objects returned in an
array. The objects are L<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)
=item 'parsed'
Array of hash references of scores/structure assignations
{ helix =E<gt> , sheet =E<gt> , coil =E<gt> , struc=E<gt>}.
=item '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), and Sopma_struc.
=back
=cut
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/; # or for sopma/hnn /^[A-Z]\s/
$line =~/^([A-Z])\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/; # or for so
push @score, { struc => $1,
helix => $2,
sheet => $3,
coil => $5,
};
#include turn if 4states are requested
$score[$#score]{'turn'} = $4 if $self->states == 4;
#can optimize by duplicating code here
}
$self->{'_parsed'} = \@score;
}
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
## these 2 are added to distinguish features on same
## sequence run with different params
my $tag_hash = {
type => $type,
method => $self->analysis_name,
};
$self->_add_params_to_result($tag_hash);
## now make feature object
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,
);
} #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'}}) {
for my $type (qw(struc helix sheet coil)) {
push @{$type_scores{$type}}, $aa->{$type};
}
push @{$type_scores{'turn'}}, $aa->{'turn'} if exists $aa->{'turn'};
}
## convert to meta sequence array ##
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) {
( run in 1.936 second using v1.01-cache-2.11-cpan-39bf76dae61 )