Added to perldoc instructions about the use of the environment variables.
[cxgn-corelibs.git] / lib / Bio / SeqIO / xform.pm
blobffa0a5edd9d5ec67dc1bbc60aacb3ca3b3165931
1 package Bio::SeqIO::xform;
3 use strict;
4 # Object preamble - inherits from Bio::Root::Object
6 use Bio::SeqIO;
7 use Bio::Seq::SeqFactory;
8 use Bio::Seq::SeqFastaSpeedFactory;
9 use UNIVERSAL qw/isa/;
10 use base 'Bio::SeqIO';
11 use Carp;
13 sub _initialize {
14 my($self,@args) = @_;
16 my %a = @args; #bind em to a hash
18 ### check input ###
19 $a{-enclose} && isa($a{-enclose},'Bio::SeqIO')
20 or croak "Must provide SeqIO to map via -enclose";
22 ref $a{-map_next} eq 'CODE'
23 or croak '-map_next must be a subroutine reference'
24 if($a{-map_next});
26 ref $a{-map_write} eq 'CODE'
27 or croak '-map_write must be a subroutine reference'
28 if($a{-map_write});
30 @{$self}{qw/_seqio _next _write /} =
31 @a{qw/ -enclose -map_next -map_write/};
33 $self->SUPER::_initialize(@args);
37 =head2 enclosed
39 Ret : the enclosed SeqIO object, or undef if none set
41 =cut
43 sub enclosed {
44 my $this = shift;
45 UNIVERSAL::isa($this,__PACKAGE__)
46 or croak 'improper use of enclosed(), which is a method of '.__PACKAGE__;
47 $this->{_seqio};
51 #ret: new page number
52 # sub _params_nextpage {
53 # my $self = shift;
54 # if ( defined $self->{_sgn_pagenum} ) {
55 # $self->{_sgn_pagenum}++;
56 # } else {
57 # $self->{_sgn_pagenum} = 0;
58 # }
59 # $self->params->page($self->{_sgn_pagenum});
60 # }
62 =head2 next_seq
64 Title : next_seq
65 Usage :
66 Function: returns the next sequence in the stream
67 Returns : Bio::Seq object
68 Args : NONE
70 =cut
72 sub next_seq {
74 my( $self ) = @_;
76 my $nextseq = $self->{_seqio}->next_seq;
77 return $nextseq unless $nextseq;
79 $self->{_next} ? $self->{_next}->($nextseq) : $nextseq;
82 =head2 write_seq
84 Title : write_seq
85 Usage :
87 =cut
89 sub write_seq {
90 my $self = shift;
91 my @seqs = @_;
93 $self->{_seqio}->write_seq(
94 $self->{_write} ?
95 $self->{_write}->(@seqs) :
96 @seqs
101 1;#do not remove