Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Seq/SeqFastaSpeedFactory.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
1 # $Id: SeqFastaSpeedFactory.pm,v 1.3 2002/11/07 23:54:23 lapp Exp $ | |
2 # | |
3 # BioPerl module for Bio::Seq::SeqFactory | |
4 # | |
5 # Cared for by Jason Stajich <jason@bioperl.org> | |
6 # | |
7 # Copyright Jason Stajich | |
8 # | |
9 # You may distribute this module under the same terms as perl itself | |
10 | |
11 # POD documentation - main docs before the code | |
12 | |
13 =head1 NAME | |
14 | |
15 Bio::Seq::SeqFactory - Instantiates a new Bio::PrimarySeqI (or derived class) through a factory | |
16 | |
17 =head1 SYNOPSIS | |
18 | |
19 use Bio::Seq::SeqFactory; | |
20 my $factory = new Bio::Seq::SeqFactory; | |
21 my $seq = $factory->create(-seq => 'WYRAVLC', | |
22 -id => 'name'); | |
23 | |
24 # If you want the factory to create Bio::Seq objects instead | |
25 # of the default Bio::PrimarySeq objects, use the -type parameter: | |
26 | |
27 my $factory = new Bio::Seq::SeqFactory(-type => 'Bio::Seq'); | |
28 | |
29 | |
30 =head1 DESCRIPTION | |
31 | |
32 This object will build Bio::Seq objects generically. | |
33 | |
34 =head1 FEEDBACK | |
35 | |
36 =head2 Mailing Lists | |
37 | |
38 User feedback is an integral part of the evolution of this and other | |
39 Bioperl modules. Send your comments and suggestions preferably to | |
40 the Bioperl mailing list. Your participation is much appreciated. | |
41 | |
42 bioperl-l@bioperl.org - General discussion | |
43 http://bioperl.org/MailList.shtml - About the mailing lists | |
44 | |
45 =head2 Reporting Bugs | |
46 | |
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: | |
50 | |
51 bioperl-bugs@bioperl.org | |
52 http://bugzilla.bioperl.org/ | |
53 | |
54 =head1 AUTHOR - Jason Stajich | |
55 | |
56 Email jason@bioperl.org | |
57 | |
58 Describe contact details here | |
59 | |
60 =head1 CONTRIBUTORS | |
61 | |
62 Additional contributors names and emails here | |
63 | |
64 =head1 APPENDIX | |
65 | |
66 The rest of the documentation details each of the object methods. | |
67 Internal methods are usually preceded with a _ | |
68 | |
69 =cut | |
70 | |
71 | |
72 # Let the code begin... | |
73 | |
74 | |
75 package Bio::Seq::SeqFastaSpeedFactory; | |
76 use vars qw(@ISA); | |
77 use strict; | |
78 | |
79 use Bio::Root::Root; | |
80 use Bio::Factory::SequenceFactoryI; | |
81 use Bio::Seq; | |
82 use Bio::PrimarySeq; | |
83 | |
84 @ISA = qw(Bio::Root::Root Bio::Factory::SequenceFactoryI); | |
85 | |
86 =head2 new | |
87 | |
88 Title : new | |
89 Usage : my $obj = new Bio::Seq::SeqFactory(); | |
90 Function: Builds a new Bio::Seq::SeqFactory object | |
91 Returns : Bio::Seq::SeqFactory | |
92 Args : -type => string, name of a PrimarySeqI derived class | |
93 This is optional. Default=Bio::PrimarySeq. | |
94 | |
95 =cut | |
96 | |
97 sub new { | |
98 my($class,@args) = @_; | |
99 my $self = $class->SUPER::new(@args); | |
100 return $self; | |
101 } | |
102 | |
103 | |
104 =head2 create | |
105 | |
106 Title : create | |
107 Usage : my $seq = $seqbuilder->create(-seq => 'CAGT', -id => 'name'); | |
108 Function: Instantiates a new Bio::Seq object, correctly built but very | |
109 fast, knowing stuff about Bio::PrimarySeq and Bio::Seq | |
110 Returns : Bio::Seq | |
111 | |
112 Args : initialization parameters specific to the type of sequence | |
113 object we want. Typically | |
114 -seq => $str, | |
115 -id => $name | |
116 | |
117 =cut | |
118 | |
119 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'}; | |
126 | |
127 my $seq = bless {}, "Bio::Seq"; | |
128 my $t_pseq = $seq->{'primary_seq'} = bless {}, "Bio::PrimarySeq"; | |
129 $t_pseq->{'seq'} = $sequence; | |
130 $t_pseq->{'desc'} = $fulldesc; | |
131 $t_pseq->{'display_id'} = $id; | |
132 $t_pseq->{'primary_id'} = $id; | |
133 $seq->{'primary_id'} = $id; # currently Bio::Seq does not delegate this | |
134 if( $sequence ) { | |
135 $t_pseq->_guess_alphabet(); | |
136 } | |
137 | |
138 return $seq; | |
139 } | |
140 | |
141 1; | |
142 |