sync w/ main trunk
[bioperl-live.git] / Bio / Structure / Model.pm
blobaa6631b318bb4eb8c8bdf5630eed460569bea053
1 # $Id$
3 # bioperl module for Bio::Structure::Model
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Kris Boulez <kris.boulez@algonomics.com>
9 # Copyright Kris Boulez
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
15 =head1 NAME
17 Bio::Structure::Model - Bioperl structure Object, describes a Model
19 =head1 SYNOPSIS
21 #add synopsis here
23 =head1 DESCRIPTION
25 This object stores a Bio::Structure::Chain
27 =head1 FEEDBACK
29 =head2 Mailing Lists
31 User feedback is an integral part of the evolution of this and other
32 Bioperl modules. Send your comments and suggestions preferably to one
33 of the Bioperl mailing lists. Your participation is much appreciated.
35 bioperl-l@bioperl.org - General discussion
36 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
38 =head2 Support
40 Please direct usage questions or support issues to the mailing list:
42 L<bioperl-l@bioperl.org>
44 rather than to the module maintainer directly. Many experienced and
45 reponsive experts will be able look at the problem and quickly
46 address it. Please include a thorough description of the problem
47 with code and data examples if at all possible.
49 =head2 Reporting Bugs
51 Report bugs to the Bioperl bug tracking system to help us keep track
52 the bugs and their resolution. Bug reports can be submitted via the web:
54 http://bugzilla.open-bio.org/
56 =head1 AUTHOR - Kris Boulez
58 Email kris.boulez@algonomics.com
60 =head1 APPENDIX
62 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
64 =cut
67 # Let the code begin...
69 package Bio::Structure::Model;
70 use strict;
72 use Bio::Structure::Entry;
73 use Bio::Structure::Chain;
74 use base qw(Bio::Root::Root);
77 =head2 new()
79 Title : new()
80 Usage : $struc = Bio::Structure::Model->new(
81 -id => 'human_id',
84 Function: Returns a new Bio::Structure::Model object from basic
85 constructors. Probably most called from Bio::Structure::IO.
86 Returns : a new Bio::Structure::Model object
88 =cut
92 sub new {
93 my ($class, @args) = @_;
94 my $self = $class->SUPER::new(@args);
96 my($id, $chain, $residue ) =
97 $self->_rearrange([qw(
99 CHAIN
100 RESIDUE
102 @args);
104 $id && $self->id($id);
106 $chain && $self->throw("you have to add chain via an Entry object\n");
108 $residue && $self->throw("you have to add residues via an Entry object\n");
110 return $self;
115 =head2 chain()
117 Title : chain
118 Usage :
119 Function: will eventually allow parent/child navigation not via an Entry object
120 Returns :
121 Args :
123 =cut
125 sub chain {
126 my ($self,$value) = @_;
128 $self->throw("go via an Entry object\n");
132 =head2 add_chain()
134 Title : add_chain
135 Usage :
136 Function: will eventually allow parent/child navigation not via an Entry object
137 Returns :
138 Args :
140 =cut
142 sub add_chain {
143 my ($self,$value) = @_;
145 $self->throw("go via an Entry object for now\n");
148 =head2 entry()
150 Title : entry
151 Usage :
152 Function: will eventually allow parent/child navigation not via an Entry object
153 Returns :
154 Args :
156 =cut
158 sub entry {
159 my($self) = @_;
161 $self->throw("Model::entry go via an Entry object please\n");
165 =head2 id()
167 Title : id
168 Usage : $model->id("model 5")
169 Function: Gets/sets the ID for this model
170 Returns : the ID
171 Args : the ID
173 =cut
175 sub id {
176 my ($self, $value) = @_;;
177 if (defined $value) {
178 $self->{'id'} = $value;
180 return $self->{'id'};
183 =head2 residue()
185 Title : residue
186 Usage :
187 Function: will eventually allow parent/child navigation not via an Entry object
188 Returns :
189 Args :
191 =cut
193 sub residue {
194 my ($self, @args) = @_;
196 $self->throw("need to go via Entry object or learn symbolic refs\n");
200 =head2 add_residue()
202 Title : add_residue
203 Usage :
204 Function: will eventually allow parent/child navigation not via an Entry object
205 Returns :
206 Args :
208 =cut
210 sub add_residue {
211 my ($self, @args) = @_;
213 $self->throw("go via entry->add_residue(chain, residue)\n");
218 sub DESTROY {
219 my $self = shift;
221 # no specific DESTROY for now
225 # from here on only private methods
228 =head2 _remove_chains()
230 Title : _remove_chains
231 Usage :
232 Function: Removes the chains attached to a Model. Tells the chains they
233 don't belong to this Model any more
234 Returns :
235 Args :
237 =cut
239 sub _remove_chains {
240 my ($self) = shift;
242 $self->throw("use Entry methods pleae\n");
246 =head2 _remove_entry()
248 Title : _remove_entry
249 Usage :
250 Function: Removes the Entry this Model is atttached to.
251 Returns :
252 Args :
254 =cut
256 sub _remove_entry {
257 my ($self) = shift;
259 $self->throw("use a method based on an Entry object\n");
263 =head2 _create_default_chain()
265 Title : _create_default_chain
266 Usage :
267 Function: Creates a default Chain for this Model. Typical situation
268 in an X-ray structure where there is only one chain
269 Returns :
270 Args :
272 =cut
274 sub _create_default_chain {
275 my ($self) = shift;
277 my $chain = Bio::Structure::Chain->new(-id => "default");
281 =head2 _grandparent()
283 Title : _grandparent
284 Usage :
285 Function: get/set a symbolic reference to our grandparent
286 Returns :
287 Args :
289 =cut
291 sub _grandparent {
292 my($self,$symref) = @_;
294 if (ref($symref)) {
295 $self->throw("Thou shall only pass strings in here, no references $symref\n");
297 if (defined $symref) {
298 $self->{'grandparent'} = $symref;
300 return $self->{'grandparent'};