3 # BioPerl module for Bio::Seq::SeqFastaSpeedFactory
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::SeqFastaSpeedFactory - Rapid instantiation of new Bio::SeqI objects through a factory using FASTA files.
21 use Bio::Seq::SeqFastaSpeedFactory;
22 my $factory = Bio::Seq::SeqFastaSpeedFactory->new();
23 my $seq = $factory->create(-seq => 'WYRAVLC',
26 # If you want the factory to create Bio::PrimarySeq objects instead
27 # of the default Bio::Seq objects, use the -type parameter:
28 my $factory = Bio::Seq::SeqFactory->new(-type => 'Bio::PrimarySeq');
32 This factory is quick at building simple L<Bio::PrimarySeqI> and L<Bio::SeqI>
33 objects generically derived from FASTA files (no annotations).
39 User feedback is an integral part of the evolution of this and other
40 Bioperl modules. Send your comments and suggestions preferably to
41 the Bioperl mailing list. Your participation is much appreciated.
43 bioperl-l@bioperl.org - General discussion
44 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
48 Please direct usage questions or support issues to the mailing list:
50 I<bioperl-l@bioperl.org>
52 rather than to the module maintainer directly. Many experienced and
53 reponsive experts will be able look at the problem and quickly
54 address it. Please include a thorough description of the problem
55 with code and data examples if at all possible.
59 Report bugs to the Bioperl bug tracking system to help us keep track
60 of the bugs and their resolution. Bug reports can be submitted via the
63 http://bugzilla.open-bio.org/
65 =head1 AUTHOR - Jason Stajich
67 Email jason@bioperl.org
71 The rest of the documentation details each of the object methods.
72 Internal methods are usually preceded with a _
77 # Let the code begin...
80 package Bio
::Seq
::SeqFastaSpeedFactory
;
86 use base
qw(Bio::Root::Root Bio::Seq::SeqFactory);
87 # a Bio::Seq::SeqFactory is also a Bio::Factory::SequenceFactoryI
93 Usage : my $obj = Bio::Seq::SeqFastaSpeedFactory->new();
94 Function: Builds a new Bio::Seq::SeqFastaSpeedFactory object
95 Returns : Bio::Seq::SeqFastaSpeedFactory
96 Args : -type => string, name of a PrimarySeqI derived class
97 This is optional. Default=Bio::Seq.
102 my($class,@args) = @_;
103 my $self = $class->SUPER::new
(@args);
104 my ($type) = $self->_rearrange([qw(TYPE)], @args);
113 Usage : my $seq = $seqbuilder->create(-seq => 'CAGT', -id => 'name');
114 Function: Instantiates new Bio::SeqI (or one of its child classes)
115 This object allows us to genericize the instantiation of sequence
117 Returns : Bio::Seq object (default)
118 The return type is configurable using new(-type =>"...").
119 Args : initialization parameters specific to the type of sequence
120 object we want. Typically
126 # Overloading the 'create' method of Bio::Seq::SeqFactory
128 my ($self,@args) = @_;
131 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
133 my $sequence = $param{'-seq'};
134 my $fulldesc = $param{'-desc'};
135 my $id = defined $param{'-id'} ?
$param{'-id'} : $param{'-primary_id'};
136 my $alphabet = $param{'-alphabet'};
138 # Constructing Bio::PrimarySeq object
139 my $t_pseq = bless {}, 'Bio::PrimarySeq';
140 $t_pseq->{'seq'} = $sequence;
141 $t_pseq->{'desc'} = $fulldesc;
142 $t_pseq->{'display_id'} = $id;
143 if( $sequence and !$alphabet ) {
144 $t_pseq->_guess_alphabet();
145 } elsif ( $sequence and $alphabet ) {
146 $t_pseq->{'alphabet'} = $alphabet;
150 my $type = $self->type;
151 if ($type eq 'Bio::Seq') {
152 # Constructing Bio::Seq object
153 $seq = bless {}, 'Bio::Seq';
154 $seq->{'primary_seq'} = $t_pseq;
155 } elsif ($type eq 'Bio::PrimarySeq') {
156 # Nothing more to do for a Bio::PrimarySeq
159 # Should not have any other sequence type
160 $self->warn("Expected sequence type Bio::Seq or Bio::PrimarySeq. Got ".
161 "$type. Defaulting to Bio::PrimarySeq\n");
162 $self->type('Bio::PrimarySeq');
173 Usage : $obj->type($newval)
175 Returns : value of type
176 Args : newvalue (optional)
180 # Using the 'type' method from Bio::Seq::SeqFactory