Genetics/Map.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 69 CC 3 SCAR 17.5
CC
3
Cov
0%
printXML
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.8
1 # GenPerl module
2 #
3  
4 # POD documentation - main docs before the code
5  
6 =head1 NAME
7  
8 Genetics::Map
9  
10 =head1 SYNOPSIS
11  
12 $map = new Genetics::Map(name => 'Chr12 2 PO',
13 importID => 121,
14 dateCreated => $today,
15 comment => "Stupid 2-marker map.",
16 Keywords => [ {name => "Test Data",
17 dataType => "Boolean",
18 value => 1},
19 ],
20 chromosome => "12",
21 orderingMethod => "Relative",
22 distanceUnits => "cM",
23 Organism => {genusSpecies => "Pongo pongo"},
24 OrderedMapElements => [ {SeqObj => {name => "D12S91", importID => 1},
25 distance => 1.3},
26 {SeqObj => {name => "EAEx1.1", importID => 265}}
27 ],
28 ) ;
29
30 See the GenPerl Tutorial for more information.
31  
32 =head1 DESCRIPTION
33  
34 Map objects represent an ordered list of Markers and the distances
35 between them.
36  
37 =head1 LICENSE
38  
39 This program is free software; you can redistribute it and/or modify
40 it under the terms of the GNU General Public License as published by
41 the Free Software Foundation; either version 2 of the License, or
42 (at your option) any later version.
43  
44 This program is distributed in the hope that it will be useful,
45 but WITHOUT ANY WARRANTY; without even the implied warranty of
46 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 GNU General Public License for more details.
48  
49 You should have received a copy of the GNU General Public License
50 along with this program; if not, write to the Free Software
51 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
52  
53 =head1 FEEDBACK
54  
55 Currently, all feedback should be sent directly to the author.
56  
57 =head1 AUTHOR - Steve Mathias
58  
59 Email: mathias@genomica.com
60  
61 Phone: (720) 565-4029
62  
63 Address: Genomica Corporation
64 1745 38th Street
65 Boulder, CO 80301
66  
67 =head1 DETAILS
68  
69 The rest of the documentation describes each of the object variables and
70 methods. The names of internal variables and methods are preceded with an
71 underscore (_).
72  
73 =cut
74  
75 ##################
76 # #
77 # Begin the code #
78 # #
79 ##################
80  
81 package Genetics::Map ;
82  
83 BEGIN {
84 $ID = "Genetics::Map" ;
85 $DEBUG = 0 ;
86 #$DEBUG = $main::DEBUG ;
87 $DEBUG and warn "Debugging in $ID is on" ;
88 }
89  
90 =head1 Imported Packages
91  
92 Genetics::Object Superclass
93 strict Just to be anal
94 vars Global variables
95  
96 =cut
97  
98 use Genetics::Object ;
99 use strict ;
100 use vars qw(@ISA $ID $VERSION $DEBUG @ATTRS @REQD_ATTRS %DEFAULTS) ;
101  
102 require 5.004 ;
103  
104 @ISA = qw(Genetics::Object) ;
105  
106 @ATTRS = qw(chromosome orderingMethod distanceUnits
107 Organism OrderedMapElements) ;
108  
109 @REQD_ATTRS = qw(orderingMethod distanceUnits OrderedMapElements) ;
110  
111 %DEFAULTS = (orderingMethod => "Relative",
112 distanceUnits => "cM") ;
113  
114  
115 =head1 Public methods
116  
117 printXML Write an XML representation of an object
118  
119 =cut
120  
121 =head2 printXML
122  
123 Function : Print an XML representation of the object.
124 Argument : A XML::Writer object that will be used to generate the XML.
125 Returns : String
126 Scope : Public
127 Called by : Calls Genetics::Object->printGeneralXML to generate XML elements
128 common to all Genetics::Object objects.
129  
130 =cut
131  
132 sub printXML {
133 my($self, $writer) = @_ ;
134 my($class, $value, $genus, $species, $subjectID, $markerDistanceListRef,
135 $markerNameID, $distance, $markerName, $markerImportID, $elementID, $i) ;
136  
137 $class = ref $self ;
138 $class =~ s/.*::// ;
139  
140 # Initialize variable for MapElement id attributes
141 $i = 1 ;
142 $elementID = "MapElement" . $i ;
143  
144 # Scientific Object Attributes/Elements
145 $self->writeGeneralXML($writer) ;
146 # Organism
147 ($genus, $species) = split($self->field('Organism')) ;
148 $writer->startTag('Organism') ;
149 $writer->dataElement('Genus', $genus) ;
150 $writer->dataElement('Species', $species) ;
151 $writer->endTag('Organism') ;
152 # Chromosome
153 $writer->dataElement('Chromosome', $self->field('Chromosome')) ;
154 # Source
155 if (defined ($value = $self->field('Source'))) {
156 $writer->startTag('ContactSource') ;
157 $writer->dataElement('Name', $value) ;
158 $writer->endTag('ContactSource') ;
159 }
160 # Distance Units
161 $writer->dataElement('MapDistanceUnits', $self->field('DistanceUnits')) ;
162 # OrderedMapElements
163 if (defined ($markerDistanceListRef = $self->field('MarkersAndDistances'))) {
164 while (($markerNameID, $distance) = splice(@$markerDistanceListRef, 0, 2)) {
165 ($markerName, $markerImportID) = $markerNameID =~ /(\w+):(\w+)/ ;
166 $writer->startTag('OrderedMapElement', 'id' => $elementID) ;
167 $writer->dataElement('Name', $markerName) ;
168 $writer->startTag('SeqObjRef') ;
169 $writer->dataElement('Name', $markerName) ;
170 $writer->dataElement('ImportID', $markerImportID) ;
171 $writer->endTag('SeqObjRef') ;
172 $writer->dataElement('Type', "Framework") ;
173 $writer->dataElement('DistanceToNext', $distance) ;
174 $writer->endTag('OrderedMapElement') ;
175 $elementID = "MapElement" . ++$i ;
176 }
177 }
178 # MapFeatures
179 # MapCorrelations
180 # HomologousRegions
181 # MapFunction
182 # Gender
183 $writer->dataElement('Gender', $self->field('Gender')) ;
184 # Length
185 # MapLiklihood
186 # PopSample
187 # MappingPanel
188 $writer->endTag($class) ;
189  
190 return(1) ;
191 }
192  
193 1;
194