~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to Bio/Seq/SeqFastaSpeedFactory.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: SeqFastaSpeedFactory.pm,v 1.3 2002/11/07 23:54:23 lapp Exp $
 
1
# $Id: SeqFastaSpeedFactory.pm,v 1.7.4.1 2006/10/02 23:10:27 sendu Exp $
2
2
#
3
 
# BioPerl module for Bio::Seq::SeqFactory
 
3
# BioPerl module for Bio::Seq::SeqFastaSpeedFactory
4
4
#
5
5
# Cared for by Jason Stajich <jason@bioperl.org>
6
6
#
12
12
 
13
13
=head1 NAME
14
14
 
15
 
Bio::Seq::SeqFactory - Instantiates a new Bio::PrimarySeqI (or derived class) through a factory
 
15
Bio::Seq::SeqFastaSpeedFactory - Instantiates a new Bio::PrimarySeqI (or derived class) through a factory
16
16
 
17
17
=head1 SYNOPSIS
18
18
 
19
 
    use Bio::Seq::SeqFactory;
20
 
    my $factory = new Bio::Seq::SeqFactory;
 
19
    use Bio::Seq::SeqFastaSpeedFactory;
 
20
    my $factory = new Bio::Seq::SeqFastaSpeedFactory;
21
21
    my $seq = $factory->create(-seq => 'WYRAVLC',
22
22
                               -id  => 'name');
23
23
 
24
24
    # If you want the factory to create Bio::Seq objects instead
25
25
    # of the default Bio::PrimarySeq objects, use the -type parameter:
26
26
 
27
 
    my $factory = new Bio::Seq::SeqFactory(-type => 'Bio::Seq');
 
27
    my $factory = new Bio::Seq::SeqFastaSpeedFactory(-type => 'Bio::Seq');
28
28
 
29
29
 
30
30
=head1 DESCRIPTION
39
39
Bioperl modules. Send your comments and suggestions preferably to
40
40
the Bioperl mailing list.  Your participation is much appreciated.
41
41
 
42
 
  bioperl-l@bioperl.org              - General discussion
43
 
  http://bioperl.org/MailList.shtml  - About the mailing lists
 
42
  bioperl-l@bioperl.org                  - General discussion
 
43
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
44
44
 
45
45
=head2 Reporting Bugs
46
46
 
47
47
Report bugs to the Bioperl bug tracking system to help us keep track
48
 
of the bugs and their resolution. Bug reports can be submitted via
49
 
email or the web:
 
48
of the bugs and their resolution. Bug reports can be submitted via the
 
49
web:
50
50
 
51
 
  bioperl-bugs@bioperl.org
52
 
  http://bugzilla.bioperl.org/
 
51
  http://bugzilla.open-bio.org/
53
52
 
54
53
=head1 AUTHOR - Jason Stajich
55
54
 
56
55
Email jason@bioperl.org
57
56
 
58
 
Describe contact details here
59
 
 
60
 
=head1 CONTRIBUTORS
61
 
 
62
 
Additional contributors names and emails here
63
 
 
64
57
=head1 APPENDIX
65
58
 
66
59
The rest of the documentation details each of the object methods.
73
66
 
74
67
 
75
68
package Bio::Seq::SeqFastaSpeedFactory;
76
 
use vars qw(@ISA);
77
69
use strict;
78
70
 
79
 
use Bio::Root::Root;
80
 
use Bio::Factory::SequenceFactoryI;
81
71
use Bio::Seq;
82
72
use Bio::PrimarySeq;
83
73
 
84
 
@ISA = qw(Bio::Root::Root Bio::Factory::SequenceFactoryI);
 
74
use base qw(Bio::Root::Root Bio::Factory::SequenceFactoryI);
85
75
 
86
76
=head2 new
87
77
 
88
78
 Title   : new
89
 
 Usage   : my $obj = new Bio::Seq::SeqFactory();
90
 
 Function: Builds a new Bio::Seq::SeqFactory object 
91
 
 Returns : Bio::Seq::SeqFactory
 
79
 Usage   : my $obj = new Bio::Seq::SeqFastaSpeedFactory();
 
80
 Function: Builds a new Bio::Seq::SeqFastaSpeedFactory object 
 
81
 Returns : Bio::Seq::SeqFastaSpeedFactory
92
82
 Args    : -type => string, name of a PrimarySeqI derived class
93
83
                    This is optional. Default=Bio::PrimarySeq.
94
84
 
117
107
=cut
118
108
 
119
109
sub create {
120
 
    my ($self,%param) = @_;
121
 
 
122
 
    my $sequence = $param{'-seq'}  || $param{'-SEQ'};
123
 
    my $fulldesc = $param{'-desc'} || $param{'-DESC'};
124
 
    my $id       = $param{'-id'}   || $param{'-ID'} ||
125
 
                   $param{'-primary_id'}   || $param{'-PRIMARY_ID'};
 
110
    my ($self,@args) = @_;
 
111
    
 
112
    my %param = @args;
 
113
    @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
 
114
    
 
115
    my $sequence = $param{'-seq'};
 
116
    my $fulldesc = $param{'-desc'};
 
117
    my $id       = $param{'-id'} || $param{'-primary_id'};
 
118
    my $alphabet = $param{'-alphabet'};
126
119
 
127
120
    my $seq = bless {}, "Bio::Seq";
128
121
    my $t_pseq = $seq->{'primary_seq'} = bless {}, "Bio::PrimarySeq";
131
124
    $t_pseq->{'display_id'} = $id;
132
125
    $t_pseq->{'primary_id'} = $id;
133
126
    $seq->{'primary_id'} = $id; # currently Bio::Seq does not delegate this
134
 
    if( $sequence ) {
 
127
    if( $sequence and !$alphabet ) {
135
128
        $t_pseq->_guess_alphabet();
 
129
    } elsif ( $sequence and $alphabet ) {
 
130
        $t_pseq->{'alphabet'} = $alphabet;
136
131
    }
137
132
 
138
133
    return $seq;