changes all issue tracking in preparation for switch to github issues
[bioperl-live.git] / Bio / Seq / SeqFastaSpeedFactory.pm
blob0f1f0be26f6e714a5ad5181d253b233e80c9e4c9
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
14 =head1 NAME
16 Bio::Seq::SeqFastaSpeedFactory - Rapid creation of Bio::Seq objects through a factory
18 =head1 SYNOPSIS
20 use Bio::Seq::SeqFastaSpeedFactory;
21 my $factory = Bio::Seq::SeqFastaSpeedFactory->new();
22 my $seq = $factory->create( -seq => 'WYRAVLC',
23 -id => 'name' );
25 =head1 DESCRIPTION
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
30 factory.
32 =head1 FEEDBACK
34 =head2 Mailing Lists
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
43 =head2 Support
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.
54 =head2 Reporting Bugs
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
58 web:
60 https://github.com/bioperl/bioperl-live/issues
62 =head1 AUTHOR - Jason Stajich
64 Email jason@bioperl.org
66 =head1 APPENDIX
68 The rest of the documentation details each of the object methods.
69 Internal methods are usually preceded with a _
71 =cut
74 # Let the code begin...
77 package Bio::Seq::SeqFastaSpeedFactory;
78 use strict;
80 use Bio::Seq;
81 use Bio::PrimarySeq;
83 use base qw(Bio::Root::Root Bio::Factory::SequenceFactoryI);
86 =head2 new
88 Title : new
89 Usage : my $obj = Bio::Seq::SeqFastaSpeedFactory->new();
90 Function: Builds a new Bio::Seq::SeqFastaSpeedFactory object
91 Returns : Bio::Seq::SeqFastaSpeedFactory
92 Args : None
94 =cut
96 sub new {
97 my($class,@args) = @_;
98 my $self = $class->SUPER::new(@args);
99 return $self;
103 =head2 create
105 Title : create
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:
112 -primary_id
113 -display_id
114 -desc
115 -seq
116 -alphabet
118 =cut
120 sub create {
121 my ($self,@args) = @_;
123 my %param = @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;
145 return $seq;