Added to perldoc instructions about the use of the environment variables.
[cxgn-corelibs.git] / lib / Bio / SeqIO / sgn_genomic.pm
blob2f199b2963c89e216fa7a7d1aab09d2a6306193f
1 package Bio::SeqIO::sgn_genomic;
3 use strict;
4 use English;
6 # Object preamble - inherits from Bio::Root::Object
8 use Bio::SeqIO;
9 use Bio::Seq::SeqFactory;
10 use Bio::Seq::SeqFastaSpeedFactory;
11 use base 'Bio::SeqIO';
12 use Carp;
14 use Class::MethodMaker
15 [ scalar => [+{-type=>'CXGN::Genomic::Search::GSS::Query'}, 'query',
16 +{-type=>'CXGN::Genomic::Search::GSS::Result'}, 'result',
17 +{-type=>'CXGN::Genomic::Search::GSS'}, 'search',
22 sub _initialize {
23 my($self,@args) = @_;
25 my %a = @args; #bind em to a hash
27 $a{-query} or croak "Must provide search query via -query ($a{-query})";
28 $a{-dbconn} && UNIVERSAL::isa($a{-dbconn},'CXGN::DB::Connection')
29 or croak 'Must provide CXGN::DB::Connection object via -dbconn';
31 $self->query($a{-query});
32 $self->search( CXGN::Genomic::Search::GSS->new($self->query) );
34 $self->SUPER::_initialize(@args);
35 unless ( defined $self->sequence_factory ) {
36 $self->sequence_factory( Bio::Seq::SeqFactory->new( -type => 'Bio::Seq::CXGNGenomic' ) );
39 #set the results object to autopage through the results
40 $self->query->order_by(gss_id => 'asc');
41 $self->result($self->search->new_result);
42 $self->result->autopage($self->query,$self->search);
45 =head2 next_seq
47 Title : next_seq
48 Usage : $seq = $stream->next_seq()
49 Function: returns the next sequence in the stream
50 Returns : Bio::Seq object or undef if no more sequences
51 Args : NONE
53 =cut
55 sub next_seq {
56 my( $self ) = @_;
57 my $alphabet;
59 #note: initialize above put the result in autopage mode
60 my $gss = $self->result->next_result
61 or return undef;
63 ### at this point, $gss _must_ contain our new gss object ###
64 $gss->isa('CXGN::Genomic::GSS')
65 or die 'there is something wrong with this code';
67 # print 'try gss '.$gss->gss_id." ($gss)\n";
68 # my $seq =
69 # eval {
70 $gss->to_bio_seq( -factory => $self->sequence_factory );
71 # }; if($EVAL_ERROR) {
72 # use Data::Dumper;
73 # warn $EVAL_ERROR;
74 # die Dumper($gss);
75 # }
76 # print "got seq $seq\n";
77 # print "got gss ".$seq->gss_object."\n";
78 # return sequences$seq;
81 =head2 write_seq
83 Title : write_seq
84 Usage : this method is not implemented. writing to the
85 genomic database is not allowed through this interface
87 =cut
89 sub write_seq {
90 croak 'write_seq not implemented. Writing to the genomic database is not allowed through this interface';
93 =head2 result
95 Accessor for this seqIO GSS results object
97 =head2 query
99 Accessor for this seqIO GSS results object
101 =head2 search
103 Accessor for this seqIO GSS results object
105 =cut
108 1;#do not remove