Genetics/Marker.pm untested

filter: Statementstmt 0.0% 0 / 101 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 23 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 175 CC 14 SCAR 43.5
CC
14
Cov
0%
printXML
132.0
asHTML
20.0
BEGIN
2.0
CRAP 77.1
1 # GenPerl module
2 #
3  
4 # POD documentation - main docs before the code
5  
6 =head1 NAME
7  
8 Genetics::Marker
9  
10 =head1 SYNOPSIS
11  
12 $marker = new Genetics::Marker(name => 'D12S91',
13 importID => 1,
14 dateCreated => $today,
15 comment => "Marker in EA critical region",
16 NameAliases => [ {name => "d12s6666"}
17 ],
18 Contact => {name => "Jean Weissenbach",
19 organization => "Genethon"},
20 DBXReferences => [ {accessionNumber => "NT_009758.3",
21 databaseName => "GenBank"}
22 ],
23 Keywords => [ {name => "Test Data",
24 dataType => "Boolean",
25 value => 1},
26 ],
27 chromosome => "12",
28 malePloidy => 2,
29 femalePloidy => 2,
30 polymorphismType => "Repeat",
31 polymorphismIndex1 => 7,
32 polymorphismIndex2 => 11,
33 repeatSequence => "CA",
34 Organism => {genusSpecies => "Homo sapiens"},
35 Alleles => [ {name => 1, type => "Code"},
36 {name => 2, type => "Code"},
37 {name => 3, type => "Code"},
38 {name => 4, type => "Code"},
39 {name => 5, type => "Code"},
40 {name => 6, type => "Code"} ],
41 ISCNMapLocations => [ {chrNumber => "12",
42 chrArm => "p",
43 band => "12.2.1",
44 bandingMethod => "Geimsa"}, ],
45 Sequence => {lengthUnits => "bp",
46 length => 17,
47 sequence => "ACGTUMRCACAWSYKVHDBXN"},
48 ) ;
49  
50 See the GenPerl Tutorial for more information.
51  
52 =head1 DESCRIPTION
53  
54 Marker objects represent polymorphic genetic markers.
55  
56 =head1 LICENSE
57  
58 This program is free software; you can redistribute it and/or modify
59 it under the terms of the GNU General Public License as published by
60 the Free Software Foundation; either version 2 of the License, or
61 (at your option) any later version.
62  
63 This program is distributed in the hope that it will be useful,
64 but WITHOUT ANY WARRANTY; without even the implied warranty of
65 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66 GNU General Public License for more details.
67  
68 You should have received a copy of the GNU General Public License
69 along with this program; if not, write to the Free Software
70 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
71  
72 =head1 FEEDBACK
73  
74 Currently, all feedback should be sent directly to the author.
75  
76 =head1 AUTHOR - Steve Mathias
77  
78 Email: mathias@genomica.com
79  
80 Phone: (720) 565-4029
81  
82 Address: Genomica Corporation
83 1745 38th Street
84 Boulder, CO 80301
85  
86 =head1 DETAILS
87  
88 The rest of the documentation describes each of the object variables and
89 methods. The names of internal variables and methods are preceded with an
90 underscore (_).
91  
92 =cut
93  
94 ##################
95 # #
96 # Begin the code #
97 # #
98 ##################
99  
100 package Genetics::Marker ;
101  
102 BEGIN {
103 $ID = "Genetics::Marker" ;
104 #$DEBUG = $main::DEBUG ;
105 $DEBUG = 0 ;
106 $DEBUG and warn "Debugging in $ID is on" ;
107 }
108  
109 =head1 Imported Packages
110  
111 Genetics::Object Superclass
112 strict Just to be anal
113 vars Global variables
114  
115 =cut
116  
117 use Genetics::Object ;
118 use strict ;
119 use vars qw(@ISA $ID $DEBUG @ATTRS @REQD_ATTRS %DEFAULTS) ;
120  
121 require 5.004 ;
122  
123 @ISA = qw(Genetics::Object) ;
124  
125 @ATTRS = qw(chromosome malePloidy femalePloidy polymorphismType
126 polymorphismIndex1 polymorphismIndex2 repeatSequence
127 Alleles Sequence ISCNMapLocations Organism
128 ) ;
129  
130 @REQD_ATTRS = qw(malePloidy femalePloidy) ;
131  
132 %DEFAULTS = (malePloidy => 2, femalePloidy => 2) ;
133  
134  
135 =head1 Public methods
136  
137 =head2 printXML
138  
139 Function : Print an XML representation of the object.
140 Argument : A Genetics::Subject object and the XML::Writer object being used
141 to generate the XML.
142 Returns : N/A
143 Scope : Public Instance Method
144 Comments : Calls Genetics::Object->printGeneralXML to generate XML elements
145 common to all Genetics::Object objects.
146  
147 =cut
148  
149 sub printXML {
150 my($self, $writer) = @_ ;
151 my($class, $value, $hashPtr, $hashPtr2) ;
152  
153 $class = ref $self ;
154 $class =~ s/.*::// ;
155
156 ## Common Attributes/Elements
157 $self->printGeneralXML($writer) ;
158
159 ## Marker Elements
160 # SeqAttributes
161 $hashPtr = $self->field('SeqAttributes') ;
162 $writer->startTag('SeqAttributes') ;
163 if (defined ($hashPtr2 = $$hashPtr{Organism})) {
164 $writer->startTag('Organism') ;
165 $writer->dataElement('Genus', $$hashPtr2{genus}) ;
166 $writer->dataElement('Species', $$hashPtr2{species}) ;
167 $writer->endTag('Organism') ;
168 }
169 if (defined ($hashPtr2 = $$hashPtr{Chromosome})) {
170 $writer->startTag('Chromosome') ;
171 $writer->dataElement('Name', $$hashPtr2{name}) ;
172 $writer->endTag('Chromosome') ;
173 }
174 if (defined ($hashPtr2 = $$hashPtr{NtSequence})) {
175 $writer->startTag('NucleotideSeq') ;
176 $writer->dataElement('LengthUnits', $$hashPtr2{lengthUnits}) ;
177 $writer->dataElement('Length', $$hashPtr2{length}) ;
178 $writer->dataElement('NtSequence', $$hashPtr2{ntSequence}) ;
179 $writer->endTag('NucleotideSeq') ;
180 }
181 if (defined ($hashPtr2 = $$hashPtr{Source})) {
182 $writer->startTag('ContactSource') ;
183 $writer->dataElement('Name', $$hashPtr2{name}) ;
184 $writer->dataElement('Comment', $$hashPtr2{comment}) ;
185 $writer->endTag('ContactSource') ;
186 }
187 $writer->endTag('SeqAttributes') ;
188 # ISCNMapLocation
189 if (defined ($hashPtr = $self->field('ISCNMapLocation'))) {
190 $writer->startTag('ISCNMapLocation') ;
191 $writer->dataElement('ChrNumber', $$hashPtr{chrNumber}) ;
192 $writer->dataElement('ChrArm', $$hashPtr{chrArm}) ;
193 $writer->dataElement('Band', $$hashPtr{band}) ;
194 $writer->dataElement('BandingMethod', $$hashPtr{bandingMethod}) ;
195 $writer->endTag('ISCNMapLocation') ;
196 }
197 # ProbeChar
198 if (defined ($hashPtr = $self->field('ProbeChar'))) {
199 $writer->startTag('ProbeChar') ;
200 $writer->dataElement('ProbeCharType', $$hashPtr{characteristic}) ;
201 $writer->dataElement('Comment', $$hashPtr{comment}) ;
202 $writer->endTag('ProbeChar') ;
203 }
204 # MalePloidy
205 $writer->dataElement('MalePloidy', $self->field('malePloidy')) ;
206 # FemalePloidy
207 $writer->dataElement('FemalePloidy', $self->field('femalePloidy')) ;
208 # Allele
209 if (defined ($value = $self->field('Allele'))) {
210 foreach $hashPtr (@$value) {
211 $writer->startTag('Allele') ;
212 $writer->dataElement('Name', $$hashPtr{name}) ;
213 $writer->dataElement('Type', $$hashPtr{type}) ;
214 $writer->endTag('Allele') ;
215 }
216 }
217 # PolymophismType
218 if (defined ($value = $self->field('polymorphismType'))) {
219 $writer->dataElement('PolymophismType', $value) ;
220 }
221 # NtRepeatUnit
222 if (defined ($value = $self->field('nucleotideRepeatUnit'))) {
223 $writer->dataElement('NtRepeatUnit', $value) ;
224 }
225 # RepeatSequence
226 if (defined ($value = $self->field('repeatSequence'))) {
227 $writer->dataElement('RepeatSequence', $value) ;
228 }
229 # GtAssayMethodTemplate
230  
231 $writer->endTag($class) ;
232  
233 return(1) ;
234 }
235  
236 =head2 asHTML
237  
238 Function : Generate an HTML representation of the object.
239 Argument : A Genetics::Marker object and a scalar containing the name of
240 the GenPerl database in which the object is stored.
241 Returns : Scalar containing the HTML text.
242 Scope : Public Instance Method
243 Comments : Calls Genetics::Object->_generalHTMLParam to generate HTML
244 elements common to all Genetics::Object objects. An
245 HTML::Template object is used to actually generate the HTML.
246  
247 =cut
248  
249 sub asHTML {
250 my($self, $db) = @_ ;
251 my $tmpl = new HTML::Template(filename => "/home/slm/work/GenPerl/templates/marker.tmpl") ;
252 my(%param, $alleleListPtr, $allelePtr, @alleles, $orgPtr, $seqPtr,
253 $iscnListPtr, $iscnPtr, @iscnLoc) ;
254  
255 %param = (DB => $db) ; # DB is the database the object is in. It is used
256 # to conscruct URL links to associated objects
257  
258 # Object data
259 $self->_generalHTMLParam(\%param) ;
260
261 # Marekr data
262 $alleleListPtr = $self->Alleles() ;
263 foreach $allelePtr (@$alleleListPtr) {
264 push @alleles, "$$allelePtr{name}($$allelePtr{type})" ;
265 }
266 $param{ALLELES} = join(", ", @alleles) ;
267 if ($orgPtr = $self->Organism()) {
268 $param{ORG} = $$orgPtr{genusSpecies} ;
269 }
270 $self->chromosome() and $param{CHR} = $self->chromosome() ;
271 $self->malePloidy() and $param{MPLOIDY} = $self->malePloidy() ;
272 $self->femalePloidy() and $param{FPLOIDY} = $self->femalePloidy() ;
273 $self->polymorphismType() and $param{POLYTYPE} = $self->polymorphismType() ;
274 $self->repeatSequence() and $param{RPTSEQ} = $self->repeatSequence() ;
275 $self->polymorphismIndex1() and $param{POLYIDX1} = $self->polymorphismIndex1() ;
276 $self->polymorphismIndex2() and $param{POLYIDX2} = $self->polymorphismIndex2() ;
277 if ($seqPtr = $self->Sequence()) {
278 $param{SEQUENCE} = $$seqPtr{sequence} ;
279 }
280 if ($iscnListPtr = $self->ISCNMapLocations()) {
281 foreach $iscnPtr (@$iscnListPtr) {
282 push @iscnLoc, "$$iscnPtr{chrNumber }$$iscnPtr{hrArm}$$iscnPtr{band}" ;
283 }
284 $param{ISCNLOC} = join(", ", @iscnLoc) ;
285 }
286 $tmpl->param( %param ) ;
287  
288 return $tmpl->output() ;
289 }
290  
291 1;
292