1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
|
##############################
#
# Bio::MAGE::Tools::MGEDOntologyPropertyEntry
#
##############################
# C O P Y R I G H T N O T I C E
# Copyright (c) 2001-2002 by:
# * The MicroArray Gene Expression Database Society (MGED)
# * Rosetta Inpharmatics
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
package Bio::MAGE::Tools::MGEDOntologyPropertyEntry;
use strict;
use Carp;
use Bio::MAGE::Base;
use Bio::MAGE::Association;
use Bio::MAGE::Extendable;
use vars qw($VERSION $DEBUG);
# Inherit methods from superclass
use base qw(Bio::MAGE::Tools::MGEDOntologyEntry);
$VERSION = 2006_08_16.1;
=head1 Bio::MAGE::Tools::MGEDOntologyPropertyEntry
=head2 SYNOPSIS
Bio::MAGE::Tools::MGEDOntologyPropertyEntry is a concrete class.
Superclass is:
Bio::MAGE::Tools::MGEDOntologyEntry
Subclasses are:
none
=head2 DESCRIPTION
This provides functionaliy for an ontology-aware OntologyEntry class
for entries of type Property.
=cut
$DEBUG = 0;
###############################################################################
#
# Constructor
#
###############################################################################
sub new {
my $class = shift;
if (ref($class)) {
$class = ref($class);
}
my $self = bless {}, $class;
my %args = @_;
#### Create this entry and all possible children
$self->createEntry(%args);
return $self;
}
###############################################################################
#
# Getter and Setter methods for class attributes
#
###############################################################################
=head2 ATTRIBUTES
Attributes are simple data types that belong to a single instance of a
class. In the Perl implementation of the MAGE-OM classes, the
interface to attributes is implemented using separate setter and
getter methods for each attribute.
=over
=item propertyType
Store the type of the property
=cut
###############################################################################
# setPropertyType
###############################################################################
sub setPropertyType {
my $self = shift;
my $attributeName = 'propertyType';
my $methodName = 'set'.ucfirst($attributeName);
confess(__PACKAGE__ . "::$methodName: no arguments passed to setter")
unless @_;
confess(__PACKAGE__ . "::$methodName: too many arguments passed to setter")
if @_ > 1;
my $val = shift;
return $self->{"__$attributeName"} = $val;
}
###############################################################################
# getPropertyType
###############################################################################
sub getPropertyType {
my $self = shift;
my $attributeName = 'propertyType';
my $methodName = 'get'.ucfirst($attributeName);
confess(__PACKAGE__ . "::$methodName: arguments passed to getter")
if @_;
return $self->{"__$attributeName"};
}
=item mgedOntologyProperty
Stores the name of the equivalent class or property in the MGED
Ontology for this OntologyEntry
=cut
###############################################################################
# setMgedOntologyProperty
###############################################################################
sub setMgedOntologyProperty {
my $self = shift;
my $attributeName = 'mgedOntologyProperty';
my $methodName = 'set'.ucfirst($attributeName);
confess(__PACKAGE__ . "::$methodName: no arguments passed to setter")
unless @_;
confess(__PACKAGE__ . "::$methodName: too many arguments passed to setter")
if @_ > 1;
my $val = shift;
return $self->{"__$attributeName"} = $val;
}
###############################################################################
# getMgedOntologyProperty
###############################################################################
sub getMgedOntologyProperty {
my $self = shift;
my $attributeName = 'mgedOntologyProperty';
my $methodName = 'get'.ucfirst($attributeName);
confess(__PACKAGE__ . "::$methodName: arguments passed to getter")
if @_;
return $self->{"__$attributeName"};
}
###############################################################################
#
# Regular methods
#
###############################################################################
###############################################################################
# createEntry
###############################################################################
sub createEntry {
my $self = shift || die ("self not passed");
my %args = @_;
my $propertyName = $args{'propertyName'} || die "ERROR: propertyName not passed";
my $propertyType = $args{'propertyType'} || die "ERROR: propertyType not passed";
my $values = $args{'values'} || die("ERROR: values not passed");
my $usedValues = $args{'usedValues'};
my $ontology = $args{'ontology'} || die "ERROR: ontology not passed";
#### Store the parameters in the class attributes
$self->setMgedOntologyProperty($propertyName);
$self->setPropertyType($propertyType);
$DEBUG && print STDERR "DEBUG: Entering [MGEDOntologyPropertyEntry] $propertyName,$propertyType\n";
if ($ontology->classExists($propertyType)) {
## Filler is a MGED Ontology Class
#print " This is a class\n";
$self->setIsAssignable(0);
$self->setCategory($self->getMgedOntologyProperty());
$self->setValue($self->getMgedOntologyProperty());
$self->setOntologyReference($ontology->getOntologyReference($self->getMgedOntologyProperty()));
#$self->addToAssociations(new MGEDOntologyClassEntry($propertyType,$ontology));
$DEBUG && print STDERR " Create new ClassEntry of name $propertyType\n";
my $childObject = Bio::MAGE::Tools::MGEDOntologyClassEntry->new(
className => $propertyType,
values => $values,
usedValues => $usedValues,
ontology => $ontology,
);
$self->addAssociations($childObject);
$DEBUG && print STDERR " Add to parent\n";
} elsif ($propertyType eq "enum") {
## Filler is of the type one-of
$self->setIsAssignable(1);
$self->setCategory($self->getMgedOntologyProperty());
## need to be able to store possible choises
my @assignableValues = $ontology->getEnumValues($self->getMgedOntologyProperty());
$self->setAssignableValues(\@assignableValues);
#### Create all the structure below this using $ontology
$self->setOntologyReference($ontology->getOntologyReference("placeholder"));
} elsif ($propertyType eq "any" || $propertyType eq "?") {
## Filler is thing, int etc.
$self->setIsAssignable(0);
## adjust method names to prevailing style in class (jaw)
#$self->set_category($self->getMgedOntologyProperty());
#$self->set_value($self->getMgedOntologyProperty());
$self->setCategory($self->getMgedOntologyProperty());
# FIXME presumably we need to deal with potential subclasses here as well (string values only at the moment)...
$self->setValue($values->{$propertyName});
# $self->setOntologyReference($ontology->getOntologyReference($self->getMgedOntologyProperty()));
# $self->addToAssociations(Bio::MAGE::Tools::MGEDOntologyPropertyEntry($self->getMgedOntologyProperty(), "thingFiller",
# $ontology));
} elsif ($propertyType eq "thingFiller") {
## Thing filler
$self->setIsAssignable(1);
## Fix java style setter.(jaw)
$self->setCategory($self->getMgedOntologyProperty());
## Add missing call to set_value (jaw)
$self->setValue($self->getMgedOntologyProperty());
## No MO reference
}
return 1;
}
###############################################################################
# assignValue
###############################################################################
sub assignValue {
my $self = shift || die ("self not passed");
my $val = shift;
if ($self->getIsAssignable && !$self->getIsAssigned) {
if ($self->getPropertyType() eq "enum" && grep(/^$val$/,@{$self->getAssignableValues()})) {
$self->setValue($val);
## Correct the temporary MO DB reference
my $ontologyReference = $self->getOntologyReference();
$ontologyReference->setAccession("#$val");
my $URI = $ontologyReference->getURI();
$URI =~ s/placeholder/$val/;
$ontologyReference->setURI($URI);
} elsif ($self->getPropertyType() eq "thingFiller") {
$self->setValue($val);
}
$self->setIsAssigned(1);
}
}
=head1 BUGS
Please send bug reports to mged-mage@lists.sf.net
=head1 AUTHOR
Eric W. Deutsch (edeutsch@systemsbiology.org)
=head1 SEE ALSO
perl(1).
=cut
#
# End the module by returning a true value
#
1;
|