~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to Bio/Seq/SeqFastaSpeedFactory.pm

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
=head1 NAME
15
15
 
16
 
Bio::Seq::SeqFastaSpeedFactory - Instantiates a new Bio::PrimarySeqI (or derived class) through a factory
 
16
Bio::Seq::SeqFastaSpeedFactory - Rapid creation of Bio::Seq objects through a factory
17
17
 
18
18
=head1 SYNOPSIS
19
19
 
20
20
    use Bio::Seq::SeqFastaSpeedFactory;
21
21
    my $factory = Bio::Seq::SeqFastaSpeedFactory->new();
22
 
    my $seq = $factory->create(-seq => 'WYRAVLC',
23
 
                               -id  => 'name');
24
 
 
25
 
    # If you want the factory to create Bio::Seq objects instead
26
 
    # of the default Bio::PrimarySeq objects, use the -type parameter:
27
 
 
28
 
    my $factory = Bio::Seq::SeqFastaSpeedFactory->new(-type => 'Bio::Seq');
29
 
 
 
22
    my $seq = $factory->create( -seq => 'WYRAVLC',
 
23
                                -id  => 'name'     );
30
24
 
31
25
=head1 DESCRIPTION
32
26
 
33
 
This object will build Bio::Seq objects generically.
 
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.
34
31
 
35
32
=head1 FEEDBACK
36
33
 
85
82
 
86
83
use base qw(Bio::Root::Root Bio::Factory::SequenceFactoryI);
87
84
 
 
85
 
88
86
=head2 new
89
87
 
90
88
 Title   : new
91
89
 Usage   : my $obj = Bio::Seq::SeqFastaSpeedFactory->new();
92
90
 Function: Builds a new Bio::Seq::SeqFastaSpeedFactory object 
93
91
 Returns : Bio::Seq::SeqFastaSpeedFactory
94
 
 Args    : -type => string, name of a PrimarySeqI derived class
95
 
                    This is optional. Default=Bio::PrimarySeq.
 
92
 Args    : None
96
93
 
97
94
=cut
98
95
 
109
106
 Usage   : my $seq = $seqbuilder->create(-seq => 'CAGT', -id => 'name');
110
107
 Function: Instantiates a new Bio::Seq object, correctly built but very
111
108
           fast, knowing stuff about Bio::PrimarySeq and Bio::Seq
112
 
 Returns : Bio::Seq
113
 
 
114
 
 Args    : initialization parameters specific to the type of sequence
115
 
           object we want.  Typically 
116
 
           -seq        => $str,
117
 
           -id         => $name
 
109
 Returns : A Bio::Seq object
 
110
 Args    : Initialization parameters for the sequence object we want:
 
111
              -id
 
112
              -primary_id
 
113
              -display_id
 
114
              -desc
 
115
              -seq
 
116
              -alphabet
118
117
 
119
118
=cut
120
119
 
129
128
    my $id       = defined $param{'-id'} ? $param{'-id'} : $param{'-primary_id'};
130
129
    my $alphabet = $param{'-alphabet'};
131
130
 
132
 
    my $seq = bless {}, "Bio::Seq";
133
 
    my $t_pseq = $seq->{'primary_seq'} = bless {}, "Bio::PrimarySeq";
134
 
    $t_pseq->{'seq'}  = $sequence;
135
 
    $t_pseq->{'desc'} = $fulldesc;
 
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
136
    $t_pseq->{'display_id'} = $id;
137
137
    $t_pseq->{'primary_id'} = $id;
138
 
    $seq->{'primary_id'} = $id; # currently Bio::Seq does not delegate this
 
138
    $seq->{'primary_id'}    = $id; # currently Bio::Seq does not delegate this
139
139
    if( $sequence and !$alphabet ) {
140
 
        $t_pseq->_guess_alphabet();
 
140
        $t_pseq->_guess_alphabet();
141
141
    } elsif ( $sequence and $alphabet ) {
142
142
        $t_pseq->{'alphabet'} = $alphabet;
143
143
    }