Genetics/Phenotype.pm untested

filter: Statementstmt 0.0% 0 / 65 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 87 CC 3 SCAR 16.7
CC
3
Cov
0%
printXML
12.0
BEGIN
2.0
asHTML
2.0
CRAP 5.3
1 # GenPerl module
2 #
3  
4 # POD documentation - main docs before the code
5  
6 =head1 NAME
7  
8 Genetics::Phenotype
9  
10 =head1 SYNOPSIS
11  
12 $pt = new Genetics::Phenotype(name => 'JXPed1-1-Age',
13 importID => 266,
14 dateCreated => $today,
15 dateCollected => "1987-03-17",
16 Keywords => [ {name => "Test Data",
17 dataType => "Boolean",
18 value => 1},
19 ],
20 Subject => {name => "JXPed1-1", importID => 12},
21 StudyVariable => {name => "Age", importID => 444},
22 AssayAttrs => [ {name => "Clinic Name",
23 dataType => "String",
24 value => "Sister of Gracious Mercy and Hope"},
25 ],
26 value => 12,
27 isActive => 1,
28 ) ;
29
30 See the GenPerl Tutorial for more information.
31  
32 =head1 DESCRIPTION
33  
34 Phenotype objects represent the experimentally determined value an
35 individual has for a trait, affection status, environmental exposure,
36 or drug treatment.
37  
38 =head1 LICENSE
39  
40 This program is free software; you can redistribute it and/or modify
41 it under the terms of the GNU General Public License as published by
42 the Free Software Foundation; either version 2 of the License, or
43 (at your option) any later version.
44  
45 This program is distributed in the hope that it will be useful,
46 but WITHOUT ANY WARRANTY; without even the implied warranty of
47 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 GNU General Public License for more details.
49  
50 You should have received a copy of the GNU General Public License
51 along with this program; if not, write to the Free Software
52 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
53  
54 =head1 FEEDBACK
55  
56 Currently, all feedback should be sent directly to the author.
57  
58 =head1 AUTHOR - Steve Mathias
59  
60 Email: mathias@genomica.com
61  
62 Phone: (720) 565-4029
63  
64 Address: Genomica Corporation
65 1745 38th Street
66 Boulder, CO 80301
67  
68 =head1 DETAILS
69  
70 The rest of the documentation describes each of the object variables and
71 methods. The names of internal variables and methods are preceded with an
72 underscore (_).
73  
74 =cut
75  
76 ##################
77 # #
78 # Begin the code #
79 # #
80 ##################
81  
82 package Genetics::Phenotype ;
83  
84 BEGIN {
85 $ID = "Genetics::Phenotype" ;
86 #$DEBUG = $main::DEBUG ;
87 $DEBUG = 0 ;
88 $DEBUG and warn "Debugging in $ID is on" ;
89 }
90  
91 =head1 Imported Packages
92  
93 Genetics::Object Superclass
94 strict Just to be anal
95 vars Global variables
96  
97 =cut
98  
99 use Genetics::Object ;
100 use strict ;
101 use vars qw(@ISA $ID $DEBUG @ATTRS @REQD_ATTRS %DEFAULTS) ;
102  
103 require 5.004 ;
104  
105 @ISA = qw(Genetics::Object) ;
106  
107 @ATTRS = qw(value isActive dateCollected
108 Subject StudyVariable AssayAttrs) ;
109  
110 @REQD_ATTRS = qw(isActive value
111 Subject StudyVariable) ;
112  
113 %DEFAULTS = () ;
114  
115  
116 =head1 Public methods
117  
118 printXML Print an XML representation of the object
119  
120 =cut
121  
122 =head2 printXML
123  
124 Function : Print an XML representation of the object.
125 Argument : A Genetics::Genotype object and the XML::Writer object being used
126 to generate the XML.
127 Returns : String
128 Scope : Public
129 Comments : Calls Genetics::Object->printGeneralXML to generate XML elements
130 common to all Genetics::Object objects.
131  
132 =cut
133  
134 sub printXML {
135 my($self, $writer) = @_ ;
136 my($class, $value, $hashPtr, $attrListPtr, $tag, $typeVal, $type, $val) ;
137  
138 $class = ref $self ;
139 $class =~ s/.*::// ;
140
141 ## Common Attributes/Elements
142 $self->printGeneralXML($writer) ;
143
144 ## Phenotype Elements
145 # SubjectRef
146 $hashPtr = $self->field('Subject') ;
147 $writer->startTag('SubjectRef') ;
148 $writer->dataElement('Name', $$hashPtr{name}) ;
149 $writer->dataElement('ID', $$hashPtr{id}) ;
150 $writer->endTag('SubjectRef') ;
151 # StudyVarRef
152 $hashPtr = $self->field('StudyVariable') ;
153 $writer->startTag('StudyVarRef') ;
154 $writer->dataElement('Name', $$hashPtr{name}) ;
155 $writer->dataElement('ID', $$hashPtr{id}) ;
156 $writer->endTag('StudyVarRef') ;
157 # IsActive
158 $writer->dataElement('IsActive', $self->field('isActive')) ;
159 # PhenotypetAssayMethod
160  
161 # PtValue
162 if (defined ($value = $self->field('value'))) {
163 $writer->startTag('PtValue') ;
164 $writer->dataElement('Value', $value) ;
165 if (defined ($attrListPtr = $self->field('Attr'))) {
166 foreach $hashPtr (@$attrListPtr) {
167 $writer->startTag('Attribute') ;
168 while (($tag, $typeVal) = each(%$hashPtr)) {
169 ($type, $val) = split(/\s*=\s*/, $typeVal) ;
170 $writer->dataElement('Name', $tag) ;
171 $writer->dataElement('DataType', $type) ;
172 $writer->dataElement('Value', $val) ;
173 }
174 $writer->endTag('Attribute') ;
175 }
176 }
177 $writer->endTag('PtValue') ;
178 }
179 $writer->endTag($class) ;
180  
181 return(1) ;
182 }
183  
184 =head2 asHTML
185  
186 Function : Generate an HTML representation of the object.
187 Argument : A Genetics::Phenotype object and a scalar containing the name
188 of the GenPerl database in which the object is stored.
189 Returns : Scalar containing the HTML text.
190 Scope : Public Instance Method
191 Comments : Calls Genetics::Object->_generalHTMLParam to generate HTML
192 elements common to all Genetics::Object objects. An
193 HTML::Template object is used to actually generate the HTML.
194  
195 =cut
196  
197 sub asHTML {
198 my($self, $db) = @_ ;
199 my $tmpl = new HTML::Template(filename => "/home/slm/work/GenPerl/templates/phenotype.tmpl") ;
200 my(%param) ;
201  
202 %param = (DB => $db) ; # DB is the database the object is in. It is used
203 # to conscruct URL links to associated objects
204  
205 # Object data
206 $self->_generalHTMLParam(\%param) ;
207  
208 # Phenotype data
209 $param{ISACTIVE} = $self->isActive() ;
210 $param{VALUE} = $self->value() ;
211 $self->dateCollected() and $param{DATECOLL} = $self->dateCollected() ;
212 $param{SUBJECT} = $self->Subject->{name} ;
213 $param{SUBJECTID} = $self->Subject->{id} ;
214 $param{STUDYVAR} = $self->StudyVariable->{name} ;
215 $param{STUDYVARID} = $self->StudyVariable->{id} ;
216  
217 $tmpl->param( %param ) ;
218  
219 return $tmpl->output() ;
220 }
221  
222 1;
223  
224