BioPerl-Run

 view release on metacpan or  search on metacpan

lib/Bio/DB/SoapEUtilities/FetchAdaptor.pm  view on Meta::CPAN

    my ($result, $type) = $self->_rearrange([qw( RESULT TYPE )], @args);
    $self->throw("Bio::DB::SoapEUtilities::Result argument required") unless $result;
    $self->throw("RESULT argument must be a Bio::DB::SoapEUtilities::Result object") unless
	ref($result) eq 'Bio::DB::SoapEUtilities::Result';
    $self->{'_type'} = $type || $result->fetch_type;
    $self->{'_result'} = $result;
    1;
}

=head2 _load_adaptor()

 Title   : _load_adaptor
 Usage   : 
 Function: loads a FetchAdaptor subclass
 Returns : 
 Args    : adaptor type (subclass name)

=cut

sub _load_adaptor {
    my ($class, $type, $result) = @_;
    return unless $type;
    # specials
    for ($result->fetch_type) {
	$_ eq 'seq' && do {
	    $_[1] = $type = 'species' if $result->fetch_db and 
		$result->fetch_db eq 'taxonomy';
	    last;
	};
	# else, leave $type alone
    }
    my $module = "Bio::DB::SoapEUtilities::FetchAdaptor::".$type;
    my $ok;
    eval {
	$ok = $class->_load_module($module);
    };
    for ($@) {
	/^$/ && do {
	    return $ok;
	};
	/Can't locate/ && do {
	    $class->throw("Fetch adaptor for '$type' not found");
	};
	do { # else 
	    $class->throw("Error in fetch adaptor for '$type' : $@");
	};
    }
}

=head2 obj_class()

 Title   : obj_class
 Usage   : $adaptor->obj_class
 Function: Returns the fully qualified BioPerl classname
           of the objects returned by next_obj()
 Returns : scalar string (class name)
 Args    : none

=cut

sub obj_class { shift->throw_not_implemented }

=head2 next_obj()

 Title   : next_obj
 Usage   : $obj = $adaptor->next_obj
 Function: Returns the next parsed BioPerl object from the 
           adaptor
 Returns : object of class obj_class()
 Args    : none

=cut

sub next_obj { shift->throw_not_implemented }

=head2 rewind()

 Title   : rewind
 Usage   : 
 Function: Rewind the adaptor's iterator
 Returns : 
 Args    : none

=cut

sub rewind { shift->throw_not_implemented }

=head2 result()

 Title   : result
 Usage   : 
 Function: contains the SoapEUtilities::Result object
 Returns : Bio::DB::SoapEUtilities::Result object
 Args    : none

=cut

sub result { shift->{'_result'} }

=head2 type()

 Title   : type
 Usage   : 
 Function: contains the fetch type of this adaptor
 Returns : 
 Args    : 

=cut

sub type { shift->{'_type'} }
1;



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