| 1 | # GenPerl module | ||
| 2 | # | ||
| 3 | |||
| 4 | # POD documentation - main docs before the code | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Genetics::Haplotype | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | $ht = new Genetics::Haplotype(name => '12pEA1.1', | ||
| 13 | importID => 268, | ||
| 14 | dateCreated => $today, | ||
| 15 | Keywords => [ {name => "Test Data", | ||
| 16 | dataType => "Boolean", | ||
| 17 | value => 1}, | ||
| 18 | ], | ||
| 19 | MarkerCollection => {name => "12pEA1", importID => 267}, | ||
| 20 | Alleles => [ {name => 2, type => "code"}, | ||
| 21 | {name => "C", type => "nucleotide"} ], | ||
| 22 | ) ; | ||
| 23 | |||
| 24 | See the GenPerl Tutorial for more information. | ||
| 25 | |||
| 26 | =head1 DESCRIPTION | ||
| 27 | |||
| 28 | Haplotype objects represent a specific combination of alleles that are known, or | ||
| 29 | predicted, to be segregating togehter. The alleles in a haplotype may be experimentally | ||
| 30 | determined or predicted statistically. | ||
| 31 | |||
| 32 | =head1 LICENSE | ||
| 33 | |||
| 34 | This program is free software; you can redistribute it and/or modify | ||
| 35 | it under the terms of the GNU General Public License as published by | ||
| 36 | the Free Software Foundation; either version 2 of the License, or | ||
| 37 | (at your option) any later version. | ||
| 38 | |||
| 39 | This program is distributed in the hope that it will be useful, | ||
| 40 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 41 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 42 | GNU General Public License for more details. | ||
| 43 | |||
| 44 | You should have received a copy of the GNU General Public License | ||
| 45 | along with this program; if not, write to the Free Software | ||
| 46 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 47 | |||
| 48 | =head1 FEEDBACK | ||
| 49 | |||
| 50 | Currently, all feedback should be sent directly to the author. | ||
| 51 | |||
| 52 | =head1 AUTHOR - Steve Mathias | ||
| 53 | |||
| 54 | Email: mathias@genomica.com | ||
| 55 | |||
| 56 | Phone: (720) 565-4029 | ||
| 57 | |||
| 58 | Address: Genomica Corporation | ||
| 59 | 1745 38th Street | ||
| 60 | Boulder, CO 80301 | ||
| 61 | |||
| 62 | =head1 DETAILS | ||
| 63 | |||
| 64 | The rest of the documentation describes each of the object variables and | ||
| 65 | methods. The names of internal variables and methods are preceded with an | ||
| 66 | underscore (_). | ||
| 67 | |||
| 68 | =cut | ||
| 69 | |||
| 70 | ################## | ||
| 71 | # # | ||
| 72 | # Begin the code # | ||
| 73 | # # | ||
| 74 | ################## | ||
| 75 | |||
| 76 | package Genetics::Haplotype ; | ||
| 77 | |||
| 78 | BEGIN { | ||
| 79 | $ID = "Genetics::Haplotype" ; | ||
| 80 | #$DEBUG = $main::DEBUG ; | ||
| 81 | $DEBUG = 0 ; | ||
| 82 | $DEBUG and warn "Debugging in $ID is on" ; | ||
| 83 | } | ||
| 84 | |||
| 85 | =head1 Imported Packages | ||
| 86 | |||
| 87 | Genetics::Object Superclass | ||
| 88 | strict Just to be anal | ||
| 89 | vars Global variables | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | use Genetics::Object ; | ||
| 94 | use strict ; | ||
| 95 | use vars qw(@ISA $ID $DEBUG @ATTRS @REQD_ATTRS %DEFAULTS) ; | ||
| 96 | |||
| 97 | require 5.004 ; | ||
| 98 | |||
| 99 | @ISA = qw(Genetics::Object) ; | ||
| 100 | |||
| 101 | @ATTRS = qw(MarkerCollection Alleles) ; | ||
| 102 | |||
| 103 | @REQD_ATTRS = qw(MarkerCollection Alleles) ; | ||
| 104 | |||
| 105 | %DEFAULTS = () ; | ||
| 106 | |||
| 107 | |||
| 108 | =head1 Public methods | ||
| 109 | |||
| 110 | =head2 printXML | ||
| 111 | |||
| 112 | Function : Print an XML representation of the object. | ||
| 113 | Argument : A Genetics::StudyVariable object and the XML::Writer object being | ||
| 114 | used to generate the XML. | ||
| 115 | Returns : String | ||
| 116 | Scope : Public Instance Method | ||
| 117 | Comments : Calls Genetics::Object->printGeneralXML to generate XML elements | ||
| 118 | common to all Genetics::Object objects. | ||
| 119 | |||
| 120 | =cut | ||
| 121 | |||
| 122 | sub printXML { | ||
| 123 | my($self, $writer) = @_ ; | ||
| 124 | my($class, $listPtr, $hashPtr) ; | ||
| 125 | |||
| 126 | $class = ref $self ; | ||
| 127 | $class =~ s/.*::// ; | ||
| 128 | |||
| 129 | ## Common Attributes/Elements | ||
| 130 | $self->printGeneralXML($writer) ; | ||
| 131 | |||
| 132 | ## Haplotype Elements | ||
| 133 | # HMCRef | ||
| 134 | $hashPtr = $self->field('HMC') ; | ||
| 135 | $writer->startTag('HMCRef') ; | ||
| 136 | $writer->dataElement('Name', $$hashPtr{name}) ; | ||
| 137 | $writer->dataElement('ID', $$hashPtr{id}) ; | ||
| 138 | $writer->endTag('HMCRef') ; | ||
| 139 | # HtAlleles | ||
| 140 | $listPtr = $self->field('HtAlleles') ; | ||
| 141 | $writer->startTag('HtAlleles') ; | ||
| 142 | foreach $hashPtr (@$listPtr) { | ||
| 143 | $writer->startTag('Allele') ; | ||
| 144 | $writer->dataElement('Name', $$hashPtr{name}) ; | ||
| 145 | $writer->dataElement('Type', $$hashPtr{type}) ; | ||
| 146 | $writer->endTag('Allele') ; | ||
| 147 | } | ||
| 148 | $writer->endTag('HtAlleles') ; | ||
| 149 | # HtRecombination | ||
| 150 | if (defined ($listPtr = $self->field('HtRecombination'))) { | ||
| 151 | $writer->startTag('HtRecombination') ; | ||
| 152 | foreach $hashPtr (@$listPtr) { | ||
| 153 | $writer->startTag('MarkerRef') ; | ||
| 154 | $writer->dataElement('Name', $$hashPtr{name}) ; | ||
| 155 | $writer->dataElement('ID', $$hashPtr{id}) ; | ||
| 156 | $writer->endTag('MarkerRef') ; | ||
| 157 | } | ||
| 158 | $writer->endTag('HtRecombination') ; | ||
| 159 | } | ||
| 160 | # SubjectRef | ||
| 161 | if (defined ($listPtr = $self->field('Subject'))) { | ||
| 162 | foreach $hashPtr (@$listPtr) { | ||
| 163 | $writer->startTag('SubjectRef') ; | ||
| 164 | $writer->dataElement('Name', $$hashPtr{name}) ; | ||
| 165 | $writer->dataElement('ID', $$hashPtr{id}) ; | ||
| 166 | $writer->endTag('SubjectRef') ; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | |||
| 170 | $writer->endTag($class) ; | ||
| 171 | |||
| 172 | return(1) ; | ||
| 173 | } | ||
| 174 | |||
| 175 | |||
| 176 | 1; | ||
| 177 |