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

« back to all changes in this revision

Viewing changes to Bio/Seq/SeqFactory.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::SeqFactory - Instantiates a new Bio::PrimarySeqI (or derived class) through a factory
 
16
Bio::Seq::SeqFactory - Instantiation of generic Bio::PrimarySeqI (or derived) objects through a factory
17
17
 
18
18
=head1 SYNOPSIS
19
19
 
20
20
    use Bio::Seq::SeqFactory;
21
21
    my $factory = Bio::Seq::SeqFactory->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::SeqFactory->new(-type => 'Bio::Seq');
 
22
    my $primaryseq = $factory->create( -seq => 'WYRAVLC',
 
23
                                       -id  => 'name'     );
 
24
 
 
25
    # Create Bio::Seq instead of Bio::PrimarySeq objects:
 
26
    my $factory = Bio::Seq::SeqFactory->new( -type => 'Bio::Seq' );
29
27
 
30
28
 
31
29
=head1 DESCRIPTION
139
137
 
140
138
=cut
141
139
 
142
 
sub type{
143
 
   my ($self,$value) = @_;
144
 
   if( defined $value) {
 
140
sub type {
 
141
   my ($self, $value) = @_;
 
142
   if (defined $value) {
145
143
       eval "require $value";
146
144
       if( $@ ) { $self->throw("$@: Unrecognized Sequence type for SeqFactory '$value'");}
147
145
       
148
146
       my $a = bless {},$value;
149
147
       unless( $a->isa('Bio::PrimarySeqI') ||
150
 
               $a->isa('Bio::Seq::QualI') ) {
151
 
           $self->throw("Must provide a valid Bio::PrimarySeqI or Bio::Seq::QualI or child class to SeqFactory Not $value");
 
148
               $a->isa('Bio::Seq::QualI' ) ) {
 
149
           $self->throw("Must provide a valid Bio::PrimarySeqI or Bio::Seq::QualI or child class to SeqFactory Not $value");
152
150
       }
153
 
      $self->{'type'} = $value;
 
151
       $self->{'type'} = $value;
154
152
    }
155
153
    return $self->{'type'};
156
154
}