2 # BioPerl module for Bio::Seq::SeqFastaSpeedFactory
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason@bioperl.org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Seq::SeqFastaSpeedFactory - Rapid creation of Bio::Seq objects through a factory
20 use Bio::Seq::SeqFastaSpeedFactory;
21 my $factory = Bio::Seq::SeqFastaSpeedFactory->new();
22 my $seq = $factory->create( -seq => 'WYRAVLC',
27 This factory was designed to build Bio::Seq objects as quickly as possible, but
28 is not as generic as L<Bio::Seq::SeqFactory>. It can be used to create sequences
29 from non-rich file formats. The L<Bio::SeqIO::fasta> sequence parser uses this
36 User feedback is an integral part of the evolution of this and other
37 Bioperl modules. Send your comments and suggestions preferably to
38 the Bioperl mailing list. Your participation is much appreciated.
40 bioperl-l@bioperl.org - General discussion
41 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
45 Please direct usage questions or support issues to the mailing list:
47 I<bioperl-l@bioperl.org>
49 rather than to the module maintainer directly. Many experienced and
50 reponsive experts will be able look at the problem and quickly
51 address it. Please include a thorough description of the problem
52 with code and data examples if at all possible.
56 Report bugs to the Bioperl bug tracking system to help us keep track
57 of the bugs and their resolution. Bug reports can be submitted via the
60 https://github.com/bioperl/bioperl-live/issues
62 =head1 AUTHOR - Jason Stajich
64 Email jason@bioperl.org
68 The rest of the documentation details each of the object methods.
69 Internal methods are usually preceded with a _
74 # Let the code begin...
77 package Bio
::Seq
::SeqFastaSpeedFactory
;
83 use base
qw(Bio::Root::Root Bio::Factory::SequenceFactoryI);
89 Usage : my $obj = Bio::Seq::SeqFastaSpeedFactory->new();
90 Function: Builds a new Bio::Seq::SeqFastaSpeedFactory object
91 Returns : Bio::Seq::SeqFastaSpeedFactory
97 my($class,@args) = @_;
98 my $self = $class->SUPER::new
(@args);
106 Usage : my $seq = $seqbuilder->create(-seq => 'CAGT', -id => 'name');
107 Function: Instantiates a new Bio::Seq object, correctly built but very
108 fast, knowing stuff about Bio::PrimarySeq and Bio::Seq
109 Returns : A Bio::Seq object
110 Args : Initialization parameters for the sequence object we want:
121 my ($self,@args) = @_;
124 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
126 my $sequence = $param{'-seq'};
127 my $fulldesc = $param{'-desc'};
128 my $id = defined $param{'-id'} ?
$param{'-id'} : $param{'-primary_id'};
129 my $alphabet = $param{'-alphabet'};
131 my $seq = bless {}, 'Bio::Seq';
132 my $t_pseq = $seq->{'primary_seq'} = bless {}, 'Bio::PrimarySeq';
133 $t_pseq->{'seq'} = $sequence;
134 $t_pseq->{'length'} = CORE
::length($sequence);
135 $t_pseq->{'desc'} = $fulldesc;
136 $t_pseq->{'display_id'} = $id;
137 $t_pseq->{'primary_id'} = $id;
138 $seq->{'primary_id'} = $id; # currently Bio::Seq does not delegate this
139 if( $sequence and !$alphabet ) {
140 $t_pseq->_guess_alphabet();
141 } elsif ( $sequence and $alphabet ) {
142 $t_pseq->{'alphabet'} = $alphabet;