view release on metacpan or search on metacpan
Bio/Prospect/CBT/Exception.pm view on Meta::CPAN
my @args = ();
local $Error::Debug = exists $ex{stacktrace} ? $ex{stacktrace}
: $show_stacktrace;
local $Error::Depth = $Error::Depth + 1;
$self->SUPER::new(%ex, @args);
}
## INTERNAL FUNCTIONS
sub stringify($)
{
my $self = shift;
my $r = "! " . (ref($self)||$self) . " occurred: " . $self->error() . "\n";
if ( $self->detail() )
{ $r .= "Detail:" . wrap("\t", "\t", $self->detail()) . "\n" }
if ( $show_advice and $self->advice() )
{ $r .= "Advice:" . wrap("\t", "\t", $self->advice()) . "\n" }
if ( $show_stacktrace )
{ $r .= "Trace:\t" . $self->stacktrace() . "\n"; }
return $r;
}
sub error($) { $_[0]->{error}; }
sub detail($) { $_[0]->{detail}; }
sub advice($) { $_[0]->{advice}; }
# backward compatibility
sub text($) { $_[0]->error(); }
1;
=pod
=head1 SEE ALSO
Bio/Prospect/LocalClient.pm view on Meta::CPAN
Name: new()
Purpose: constructor
Arguments: hash reference with following key/value pairs
options => Bio::Prospect::Options object (required)
Returns: Bio::Prospect::LocalClient
=cut
sub new(;%) {
my $self = shift->SUPER::new(@_);
$self->_setenv();
$self->_prepare_options();
$self->{'xmlCacheName'} = 'xmlCache'; # name of xml file cache
$self->{'sortCacheName'} = 'sortCache'; # name of sort file cache
return $self;
}
#-------------------------------------------------------------------------------
Bio/Prospect/LocalClient.pm view on Meta::CPAN
=head2 thread()
Name: thread()
Purpose: return a list of Thread objects
Arguments: scalar sequence or Bio::PrimarySeqI-derived object
Returns: list of Bio::Prospect::Thread objects
=cut
sub thread($$) {
my ($self,$s) = @_;
if ( not defined $s or (ref $s and not $s->isa('Bio::PrimarySeqI')) ) {
throw Bio::Prospect::BadUsage(
"Bio::Prospect::LocalClient::thread() requires one Bio::PrimarySeqI subclass or " .
"scalar sequence argument" );
}
my $seq = ref $s ? $s->seq() : $s;
my $xfn = $self->_thread_to_file( $seq );
Bio/Prospect/LocalClient.pm view on Meta::CPAN
=head2 thread_summary()
Name: thread_summary()
Purpose: return a list of ThreadSummary objects
Arguments: Bio::Seq object
Returns: list of rospect2::ThreadSummary objects
=cut
sub thread_summary($$) {
my ($self,$s) = @_;
my @summary;
foreach my $t ( $self->thread($s) ) {
push @summary, new Bio::Prospect::ThreadSummary( $t );
}
return( @summary );
}
Bio/Prospect/LocalClient.pm view on Meta::CPAN
=head2 xml()
Name: xml()
Purpose: return xml string
Arguments: Bio::Seq object
Returns: string
=cut
sub xml($$) {
my ($self,$s) = @_;
my $xfn = $self->_thread_to_file( $s );
my $in = new IO::File "<$xfn" or throw
Bio::Prospect::RuntimeError( "can't open $xfn for reading");
my $xml='';
while(<$in>){ $xml .= $_; }
return( $xml );
}
#-------------------------------------------------------------------------------
# DEPRECATED METHODS - will be removed in subsequent releases.
#-------------------------------------------------------------------------------
sub score_summary($$) {
cluck("This function is deprecated on Oct-23-2003:\n");
my ($self,$s) = @_;
my $xfn = $self->thread_to_file( $s );
return Bio::Prospect::utilities::score_summary( $xfn );
}
sub thread_to_file($$) {
cluck("This function is deprecated on Oct-23-2003:\n");
return _thread_to_file($_[0],$_[1]);
}
#-------------------------------------------------------------------------------
# INTERNAL METHODS: not intended for use outside this module
#-------------------------------------------------------------------------------
=pod
Bio/Prospect/LocalClient.pm view on Meta::CPAN
=head2 _get_svm_scores()
Name: _get_svm_scores()
Purpose: return a hash of svm scores from a prospect sort file
Arguments: sort filename
Returns: hash
=cut
sub _get_svm_scores($$) {
my ($self,$fn) = @_;
my %retval;
my $in = new IO::File $fn || throw Bio::Prospect::RuntimeError( "can't open $fn for reading" );
my @fld;
while(<$in>) {
next if m/^:Protein/;
@fld = split /\s+/;
$retval{$fld[0]} = $fld[3];
}
Bio/Prospect/LocalClient.pm view on Meta::CPAN
"The sort file for this sequence is empty. sortProspect likely failed!",
"Execute sortProspect on the command-line and check output messages. sortProspect " .
"can fail because of erroneous characters in the output xml file (e.g. null character)."
);
}
close($in);
return %retval;
}
sub _thread_to_file($$)
{
my ($self,$s) = @_;
my $xfn;
my $seq = ref $s ? $s->seq() : $s;
# check the cache for a cached file cooresponding to this sequence.
# if available then return it rather than running prospect
my $cached = $self->_get_cache_file( Digest::MD5::md5_hex( $seq ), $self->{'xmlCacheName'} );
if ( defined $cached and -e $cached ) {
Bio/Prospect/LocalClient.pm view on Meta::CPAN
ouptut filename is returned. Threading results are cached by sequence for
the lifetime of the LocalClient object. See also B<::thread>.
=back
=cut
}
sub _thread1($$)
{
my ($self,$ifn) = @_;
my $xfn = "$ifn.xml";
my @cl = @{$self->{commandline}};
$cl[1] = sprintf($cl[1],$ifn);
$cl[2] = sprintf($cl[2],$xfn);
print(STDERR "about to @cl\n") if $ENV{DEBUG};
if ( eval { system("@cl") } ) {
my $s = $?;
if ($s & 127) {
Bio/Prospect/LocalClient.pm view on Meta::CPAN
=head2 _sort1()
Name: _sort1()
Purpose: run sortProspect on threading file
Arguments: prospect xml file
Returns: filename of sortProspect results
=cut
sub _sort1($$) {
my ($self,$xfn) = @_;
my $sfn = "$xfn.sort";
my $cmd = "sortProspect $xfn 2>/dev/null 1>$sfn";
print(STDERR "about to $cmd\n") if $ENV{DEBUG};
if ( eval { system("$cmd") } )
{
my $s = $?;
if ($s & 127)
{
$s &= 127;
Bio/Prospect/LocalClient.pm view on Meta::CPAN
throw Bio::Prospect::Exception
( "PDB_PATH is not set correctly",
"PDB_PATH ($Bio::Prospect::Init::PDB_PATH) is not a valid directory",
"Check your prospect installation and set PDB_PATH in Bio::Prospect::Init or as an environment variable" );
} else {
$ENV{'PDB_PATH'} = $Bio::Prospect::Init::PDB_PATH;
}
}
sub _prepare_options($$) {
my $self = shift;
my $opts = $self->{options};
(ref $opts eq 'Bio::Prospect::Options')
|| throw Bio::Prospect::BadUsage('Bio::Prospect::Options argument is missing');
my @cl = ( "$Bio::Prospect::Init::PROSPECT_PATH/bin/prospect" );
if (exists $opts->{phd}) {
throw Exception::NotYetSupported
Bio/Prospect/LocalClient.pm view on Meta::CPAN
Prepares temporary files based on options (e.g., writes a temporary
`tfile') and generates an array of command line options in
@{$self->{commandline}}. Args 1 and 2 are input and output respectively
and MUST be sprintf'd before use. See thread_1_file().
=back
=cut
}
sub _write_seqfile($$)
{
my ($self,$seq) = @_;
throw Exception ('seq undefined') unless defined $seq;
my ($fh,$fn) = $self->_tempfile('fa');
$seq =~ s/\s//g;
my $len = length($seq);
$seq =~ s/.{60}/$&\n/g; # wrap at 60 cols
$fh->print( ">LocalClient /len=$len\n$seq\n");
$fh->close();
return $fn;
Bio/Prospect/SoapClient.pm view on Meta::CPAN
Name: new()
Purpose: constructor
Arguments: hash reference with following key/value pairs
options => Bio::Prospect::Options object (required)
host => hostname of SOAP server (optional)
port => port of SOAP server (optional)
Returns: Bio::Prospect::SoapClient
=cut
sub new() {
my $self = shift->SUPER::new(@_);
my $host = $self->{'host'} || $Bio::Prospect::Init::SOAP_SERVER_HOST;
my $port = $self->{'port'} || $Bio::Prospect::Init::SOAP_SERVER_PORT;
$self->{'xmlCacheName'} = 'xmlCache'; # name of xml file cache
# get SOAP client
$self->{'SoapLite'} = SOAP::Lite
-> uri('http://cavs/Prospect/SoapServer')
-> proxy("http://$host:$port", options => {compress_threshold =>0});
Bio/Prospect/SoapClient.pm view on Meta::CPAN
=head2 thread()
Name: thread()
Purpose: return a list of Thread objects
Arguments: Bio::Seq object
Returns: list of Bio::Prospect::Thread objects
=cut
sub thread($$) {
my ($self,$s) = @_;
throw Bio::Prospect::BadUsage( "Bio::Prospect::SoapClient::thread() missing Bio::Seq argument" ) if
( ! defined $s || ref $s ne 'Bio::Seq' );
# call xml() to get the Prospect xml results.
$self->xml( $s );
# get cached xml file
my $fn = $self->_get_cache_file( Digest::MD5::md5_hex( $s->seq() ), $self->{'xmlCacheName'} );
Bio/Prospect/SoapClient.pm view on Meta::CPAN
=head2 thread_summary()
Name: thread_summary()
Purpose: return a list of ThreadSummary objects
Arguments: Bio::Seq object
Returns: list of rospect2::ThreadSummary objects
=cut
sub thread_summary($$) {
my ($self,$s) = @_;
my @summary;
my $retval = $self->{'SoapLite'}->thread_summary( $self->_parseOptions($s) );
if ($retval->fault) {
throw Bio::Prospect::RuntimeError(
"Caught fault (code: " . $retval->faultcode . ", msg: " .
$retval->faultstring
);
}
Bio/Prospect/SoapClient.pm view on Meta::CPAN
=head2 xml()
Name: xml()
Purpose: return xml string
Arguments: Bio::Seq object
Returns: string
=cut
sub xml($$) {
my ($self,$s) = @_;
throw Bio::Prospect::BadUsage( "Bio::Prospect::SoapClient::xml() missing Bio::Seq argument" ) if
( ! defined $s || ref $s ne 'Bio::Seq' );
# check the cache if we've already run prospect on this sequence
# check the cache for a cached file cooresponding to this sequence.
# if available then return it rather than running prospect
my $cached = $self->_get_cache_file( Digest::MD5::md5_hex( $s->seq() ), $self->{'xmlCacheName'} );
if ( defined $cached and -e $cached ) {
Bio/Prospect/SoapServer.pm view on Meta::CPAN
use Bio::Prospect::Exceptions;
use Bio::Prospect::LocalClient;
use Bio::Prospect::Options;
use Bio::Seq;
use SOAP::Lite;
use vars qw( $VERSION );
$VERSION = sprintf( "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/ );
sub new() {
my $type = shift;
my $self = {};
return (bless $self,$type);
}
#-------------------------------------------------------------------------------
# thread_summary()
#-------------------------------------------------------------------------------
Bio/Prospect/SoapServer.pm view on Meta::CPAN
3 - string, one of 'scop', 'fssp', 'all' (or '' if templates is defined in #4)
to define a template set
4 - string, contains a space-separated list of templates (or '' if
template set is defined in #3)
5 - string, one of 'global' or 'global_local' for alignment type
6 - string, either '0' (false) or '1' (true) for calculating zscores
Returns: XML string containing prospect results
=cut
sub thread_summary($$) {
my ($self,$seqID,$s,$secondaryStructure,$templateSet,$templates,$alignmentType,$calculateZscores) = @_;
my $opts = &_parseOptions($templateSet,$templates,$alignmentType,$calculateZscores);
# use LocalClient to do the work
my $LocalClient = new Bio::Prospect::LocalClient( {options=>$opts} );
my $seq = new Bio::Seq( -display_id => $seqID, -seq => $s );
my @threads = $LocalClient->thread_summary( $seq );
return( \@threads );
Bio/Prospect/SoapServer.pm view on Meta::CPAN
3 - string, one of 'scop', 'fssp', 'all' (or '' if templates is defined in #4)
to define a template set
4 - string, contains a space-separated list of templates (or '' if
template set is defined in #3)
5 - string, one of 'global' or 'global_local' for alignment type
6 - string, either '0' (false) or '1' (true) for calculating zscores
Returns: XML string containing prospect results
=cut
sub xml($$) {
my ($self,$seqID,$s,$secondaryStructure,$templateSet,$templates,$alignmentType,$calculateZscores) = @_;
my $opts = &_parseOptions($templateSet,$templates,$alignmentType,$calculateZscores);
# use LocalClient to do the work
my $LocalClient = new Bio::Prospect::LocalClient( {options=>$opts} );
my $seq = new Bio::Seq( -display_id => $seqID, -seq => $s );
my $xml = $LocalClient->xml( $seq );
return( $xml );