3 # BioPerl module for Bio::Seq::SeqFactory
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Jason Stajich <jason@bioperl.org>
9 # Copyright Jason Stajich
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Seq::SeqFactory - Instantiates a new Bio::PrimarySeqI (or derived class) through a factory
21 use Bio::Seq::SeqFactory;
22 my $factory = Bio::Seq::SeqFactory->new();
23 my $seq = $factory->create(-seq => 'WYRAVLC',
26 # If you want the factory to create Bio::Seq objects instead
27 # of the default Bio::PrimarySeq objects, use the -type parameter:
29 my $factory = Bio::Seq::SeqFactory->new(-type => 'Bio::Seq');
34 This object will build L<Bio::PrimarySeqI> and L<Bio::SeqI> objects
41 User feedback is an integral part of the evolution of this and other
42 Bioperl modules. Send your comments and suggestions preferably to
43 the Bioperl mailing list. Your participation is much appreciated.
45 bioperl-l@bioperl.org - General discussion
46 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
50 Please direct usage questions or support issues to the mailing list:
52 I<bioperl-l@bioperl.org>
54 rather than to the module maintainer directly. Many experienced and
55 reponsive experts will be able look at the problem and quickly
56 address it. Please include a thorough description of the problem
57 with code and data examples if at all possible.
61 Report bugs to the Bioperl bug tracking system to help us keep track
62 of the bugs and their resolution. Bug reports can be submitted via the
65 http://bugzilla.open-bio.org/
67 =head1 AUTHOR - Jason Stajich
69 Email jason@bioperl.org
73 The rest of the documentation details each of the object methods.
74 Internal methods are usually preceded with a _
79 # Let the code begin...
82 package Bio
::Seq
::SeqFactory
;
86 use base
qw(Bio::Root::Root Bio::Factory::SequenceFactoryI);
91 Usage : my $obj = Bio::Seq::SeqFactory->new();
92 Function: Builds a new Bio::Seq::SeqFactory object
93 Returns : Bio::Seq::SeqFactory
94 Args : -type => string, name of a PrimarySeqI derived class
95 This is optional. Default=Bio::PrimarySeq.
100 my($class,@args) = @_;
101 my $self = $class->SUPER::new
(@args);
102 my ($type) = $self->_rearrange([qw(TYPE)], @args);
103 if( ! defined $type ) {
104 $type = 'Bio::PrimarySeq';
114 Usage : my $seq = $seqbuilder->create(-seq => 'CAGT', -id => 'name');
115 Function: Instantiates new Bio::SeqI (or one of its child classes)
116 This object allows us to genericize the instantiation of sequence
118 Returns : Bio::PrimarySeq object (default)
119 The return type is configurable using new(-type =>"...").
120 Args : initialization parameters specific to the type of sequence
121 object we want. Typically
128 my ($self,@args) = @_;
129 return $self->type->new(-verbose
=> $self->verbose, @args);
135 Usage : $obj->type($newval)
137 Returns : value of type
138 Args : newvalue (optional)
144 my ($self,$value) = @_;
145 if( defined $value) {
146 eval "require $value";
147 if( $@
) { $self->throw("$@: Unrecognized Sequence type for SeqFactory '$value'");}
149 my $a = bless {},$value;
150 unless( $a->isa('Bio::PrimarySeqI') ||
151 $a->isa('Bio::Seq::QualI') ) {
152 $self->throw("Must provide a valid Bio::PrimarySeqI or Bio::Seq::QualI or child class to SeqFactory Not $value");
154 $self->{'type'} = $value;
156 return $self->{'type'};