use
vars
qw(@ISA $VERSION @EXPORT_OK %EXPORT_TAGS $__MAGEML_LISTS $__MAGEML_PACKAGES $__CLASS2FULLCLASS)
;
@ISA
=
qw(Bio::MAGE::Base Exporter)
;
$VERSION
=
q[$Id: MAGE.pm,v 1.10 2002/10/13 21:56:03 jason_e_stewart Exp $]
;
%EXPORT_TAGS
= (
ALL
=> [
''
]);
sub
import
{
my
(
$pkg
,
@tags
) =
@_
;
foreach
(
@tags
) {
if
(
$_
=~ /ALL/) {
import_all();
}
}
}
sub
import_all {
eval
qq[
require Bio::MAGE::AuditAndSecurity;
require Bio::MAGE::Description;
require Bio::MAGE::Measurement;
require Bio::MAGE::BQS;
require Bio::MAGE::BioEvent;
require Bio::MAGE::Protocol;
require Bio::MAGE::BioMaterial;
require Bio::MAGE::BioSequence;
require Bio::MAGE::DesignElement;
require Bio::MAGE::ArrayDesign;
require Bio::MAGE::Array;
require Bio::MAGE::BioAssay;
require Bio::MAGE::QuantitationType;
require Bio::MAGE::BioAssayData;
require Bio::MAGE::Experiment;
require Bio::MAGE::HigherLevelAnalysis;
]
;
if
($@) {
die
"MAGE load error: $@
";
}
}
sub
initialize {
my
(
$self
) =
shift
;
$self
->identifiers({});
$self
->packages({});
$self
->registered_objects({});
$self
->tagname(
'MAGE-ML'
)
unless
defined
$self
->tagname();
$self
->add_objects(
$self
->objects())
if
defined
$self
->objects();
return
1;
}
sub
classes {
return
(
'Extendable'
,
'Identifiable'
,
'Describable'
,
'NameValueType'
);
}
BEGIN {
$__MAGEML_PACKAGES
= [
'AuditAndSecurity'
,
'Description'
,
'Measurement'
,
'BQS'
,
'BioEvent'
,
'Protocol'
,
'BioMaterial'
,
'BioSequence'
,
'DesignElement'
,
'ArrayDesign'
,
'Array'
,
'BioAssay'
,
'QuantitationType'
,
'BioAssayData'
,
'Experiment'
,
'HigherLevelAnalysis'
]
;
}
sub
mageml_packages {
return
@{
$__MAGEML_PACKAGES
};
}
BEGIN {
$__CLASS2FULLCLASS
= {
'ReporterGroup'
=>
'Bio::MAGE::ArrayDesign::ReporterGroup'
,
'SeqFeatureLocation'
=>
'Bio::MAGE::BioSequence::SeqFeatureLocation'
,
'BibliographicReference'
=>
'Bio::MAGE::BQS::BibliographicReference'
,
'BioDataTuples'
=>
'Bio::MAGE::BioAssayData::BioDataTuples'
,
'ArrayGroup'
=>
'Bio::MAGE::Array::ArrayGroup'
,
'DistanceUnit'
=>
'Bio::MAGE::Measurement::DistanceUnit'
,
'ProtocolApplication'
=>
'Bio::MAGE::Protocol::ProtocolApplication'
,
'ManufactureLIMS'
=>
'Bio::MAGE::Array::ManufactureLIMS'
,
'Hybridization'
=>
'Bio::MAGE::BioAssay::Hybridization'
,
'Security'
=>
'Bio::MAGE::AuditAndSecurity::Security'
,
'FeatureReporterMap'
=>
'Bio::MAGE::DesignElement::FeatureReporterMap'
,
'PositionDelta'
=>
'Bio::MAGE::Array::PositionDelta'
,
'DerivedBioAssayData'
=>
'Bio::MAGE::BioAssayData::DerivedBioAssayData'
,
'Hardware'
=>
'Bio::MAGE::Protocol::Hardware'
,
'CompositePosition'
=>
'Bio::MAGE::DesignElement::CompositePosition'
,
'ParameterValue'
=>
'Bio::MAGE::Protocol::ParameterValue'
,
'CompositeCompositeMap'
=>
'Bio::MAGE::DesignElement::CompositeCompositeMap'
,
'Audit'
=>
'Bio::MAGE::AuditAndSecurity::Audit'
,
'BioAssay'
=>
'Bio::MAGE::BioAssay::BioAssay'
,
'HardwareApplication'
=>
'Bio::MAGE::Protocol::HardwareApplication'
,
'Unit'
=>
'Bio::MAGE::Measurement::Unit'
,
'BioSource'
=>
'Bio::MAGE::BioMaterial::BioSource'
,
'CompositeSequence'
=>
'Bio::MAGE::DesignElement::CompositeSequence'
,
'PValue'
=>
'Bio::MAGE::QuantitationType::PValue'
,
'BioAssayDimension'
=>
'Bio::MAGE::BioAssayData::BioAssayDimension'
,
'StandardQuantitationType'
=>
'Bio::MAGE::QuantitationType::StandardQuantitationType'
,
'MismatchInformation'
=>
'Bio::MAGE::DesignElement::MismatchInformation'
,
'DesignElementDimension'
=>
'Bio::MAGE::BioAssayData::DesignElementDimension'
,
'Parameter'
=>
'Bio::MAGE::Protocol::Parameter'
,
'Feature'
=>
'Bio::MAGE::DesignElement::Feature'
,
'FeatureGroup'
=>
'Bio::MAGE::ArrayDesign::FeatureGroup'
,
'QuantitationType'
=>
'Bio::MAGE::QuantitationType::QuantitationType'
,
'ExternalReference'
=>
'Bio::MAGE::Description::ExternalReference'
,
'SequencePosition'
=>
'Bio::MAGE::BioSequence::SequencePosition'
,
'BioEvent'
=>
'Bio::MAGE::BioEvent::BioEvent'
,
'BioAssayDatum'
=>
'Bio::MAGE::BioAssayData::BioAssayDatum'
,
'MeasuredBioAssay'
=>
'Bio::MAGE::BioAssay::MeasuredBioAssay'
,
'CompositeGroup'
=>
'Bio::MAGE::ArrayDesign::CompositeGroup'
,
'BioAssayTreatment'
=>
'Bio::MAGE::BioAssay::BioAssayTreatment'
,
'Extendable'
=>
'Bio::MAGE::Extendable'
,
'SoftwareApplication'
=>
'Bio::MAGE::Protocol::SoftwareApplication'
,
'Node'
=>
'Bio::MAGE::HigherLevelAnalysis::Node'
,
'NodeValue'
=>
'Bio::MAGE::HigherLevelAnalysis::NodeValue'
,
'DerivedBioAssay'
=>
'Bio::MAGE::BioAssay::DerivedBioAssay'
,
'DatabaseEntry'
=>
'Bio::MAGE::Description::DatabaseEntry'
,
'Compound'
=>
'Bio::MAGE::BioMaterial::Compound'
,
'ArrayDesign'
=>
'Bio::MAGE::ArrayDesign::ArrayDesign'
,
'BioMaterialMeasurement'
=>
'Bio::MAGE::BioMaterial::BioMaterialMeasurement'
,
'Transformation'
=>
'Bio::MAGE::BioAssayData::Transformation'
,
'ConcentrationUnit'
=>
'Bio::MAGE::Measurement::ConcentrationUnit'
,
'BioMaterial'
=>
'Bio::MAGE::BioMaterial::BioMaterial'
,
'Treatment'
=>
'Bio::MAGE::BioMaterial::Treatment'
,
'BioAssayData'
=>
'Bio::MAGE::BioAssayData::BioAssayData'
,
'BioAssayCreation'
=>
'Bio::MAGE::BioAssay::BioAssayCreation'
,
'ReporterDimension'
=>
'Bio::MAGE::BioAssayData::ReporterDimension'
,
'ConfidenceIndicator'
=>
'Bio::MAGE::QuantitationType::ConfidenceIndicator'
,
'Failed'
=>
'Bio::MAGE::QuantitationType::Failed'
,
'ArrayManufactureDeviation'
=>
'Bio::MAGE::Array::ArrayManufactureDeviation'
,
'SpecializedQuantitationType'
=>
'Bio::MAGE::QuantitationType::SpecializedQuantitationType'
,
'FeatureInformation'
=>
'Bio::MAGE::DesignElement::FeatureInformation'
,
'ExperimentDesign'
=>
'Bio::MAGE::Experiment::ExperimentDesign'
,
'PhysicalArrayDesign'
=>
'Bio::MAGE::ArrayDesign::PhysicalArrayDesign'
,
'PhysicalBioAssay'
=>
'Bio::MAGE::BioAssay::PhysicalBioAssay'
,
'Ratio'
=>
'Bio::MAGE::QuantitationType::Ratio'
,
'FeatureLocation'
=>
'Bio::MAGE::DesignElement::FeatureLocation'
,
'DesignElement'
=>
'Bio::MAGE::DesignElement::DesignElement'
,
'QuantitationTypeDimension'
=>
'Bio::MAGE::BioAssayData::QuantitationTypeDimension'
,
'DerivedSignal'
=>
'Bio::MAGE::QuantitationType::DerivedSignal'
,
'Fiducial'
=>
'Bio::MAGE::Array::Fiducial'
,
'BioSequence'
=>
'Bio::MAGE::BioSequence::BioSequence'
,
'ReporterPosition'
=>
'Bio::MAGE::DesignElement::ReporterPosition'
,
'QuantitationTypeMapping'
=>
'Bio::MAGE::BioAssayData::QuantitationTypeMapping'
,
'MeasuredBioAssayData'
=>
'Bio::MAGE::BioAssayData::MeasuredBioAssayData'
,
'Identifiable'
=>
'Bio::MAGE::Identifiable'
,
'Position'
=>
'Bio::MAGE::DesignElement::Position'
,
'ExperimentalFactor'
=>
'Bio::MAGE::Experiment::ExperimentalFactor'
,
'BioAssayMap'
=>
'Bio::MAGE::BioAssayData::BioAssayMap'
,
'Array'
=>
'Bio::MAGE::Array::Array'
,
'SeqFeature'
=>
'Bio::MAGE::BioSequence::SeqFeature'
,
'OntologyEntry'
=>
'Bio::MAGE::Description::OntologyEntry'
,
'ImageAcquisition'
=>
'Bio::MAGE::BioAssay::ImageAcquisition'
,
'FeatureExtraction'
=>
'Bio::MAGE::BioAssay::FeatureExtraction'
,
'Error'
=>
'Bio::MAGE::QuantitationType::Error'
,
'ArrayManufacture'
=>
'Bio::MAGE::Array::ArrayManufacture'
,
'Map'
=>
'Bio::MAGE::BioEvent::Map'
,
'Organization'
=>
'Bio::MAGE::AuditAndSecurity::Organization'
,
'Database'
=>
'Bio::MAGE::Description::Database'
,
'SecurityGroup'
=>
'Bio::MAGE::AuditAndSecurity::SecurityGroup'
,
'CompositeSequenceDimension'
=>
'Bio::MAGE::BioAssayData::CompositeSequenceDimension'
,
'Image'
=>
'Bio::MAGE::BioAssay::Image'
,
'Zone'
=>
'Bio::MAGE::ArrayDesign::Zone'
,
'NodeContents'
=>
'Bio::MAGE::HigherLevelAnalysis::NodeContents'
,
'Reporter'
=>
'Bio::MAGE::DesignElement::Reporter'
,
'FeatureDimension'
=>
'Bio::MAGE::BioAssayData::FeatureDimension'
,
'Protocol'
=>
'Bio::MAGE::Protocol::Protocol'
,
'Describable'
=>
'Bio::MAGE::Describable'
,
'ExpectedValue'
=>
'Bio::MAGE::QuantitationType::ExpectedValue'
,
'Contact'
=>
'Bio::MAGE::AuditAndSecurity::Contact'
,
'CompoundMeasurement'
=>
'Bio::MAGE::BioMaterial::CompoundMeasurement'
,
'MassUnit'
=>
'Bio::MAGE::Measurement::MassUnit'
,
'FactorValue'
=>
'Bio::MAGE::Experiment::FactorValue'
,
'ZoneDefect'
=>
'Bio::MAGE::Array::ZoneDefect'
,
'VolumeUnit'
=>
'Bio::MAGE::Measurement::VolumeUnit'
,
'DesignElementGroup'
=>
'Bio::MAGE::ArrayDesign::DesignElementGroup'
,
'ReporterCompositeMap'
=>
'Bio::MAGE::DesignElement::ReporterCompositeMap'
,
'LabeledExtract'
=>
'Bio::MAGE::BioMaterial::LabeledExtract'
,
'TimeUnit'
=>
'Bio::MAGE::Measurement::TimeUnit'
,
'FeatureDefect'
=>
'Bio::MAGE::Array::FeatureDefect'
,
'QuantityUnit'
=>
'Bio::MAGE::Measurement::QuantityUnit'
,
'BioAssayMapping'
=>
'Bio::MAGE::BioAssayData::BioAssayMapping'
,
'ZoneGroup'
=>
'Bio::MAGE::ArrayDesign::ZoneGroup'
,
'BioAssayDataCluster'
=>
'Bio::MAGE::HigherLevelAnalysis::BioAssayDataCluster'
,
'DesignElementMapping'
=>
'Bio::MAGE::BioAssayData::DesignElementMapping'
,
'Parameterizable'
=>
'Bio::MAGE::Protocol::Parameterizable'
,
'BioDataValues'
=>
'Bio::MAGE::BioAssayData::BioDataValues'
,
'DesignElementMap'
=>
'Bio::MAGE::BioAssayData::DesignElementMap'
,
'QuantitationTypeMap'
=>
'Bio::MAGE::BioAssayData::QuantitationTypeMap'
,
'Person'
=>
'Bio::MAGE::AuditAndSecurity::Person'
,
'ZoneLayout'
=>
'Bio::MAGE::ArrayDesign::ZoneLayout'
,
'ParameterizableApplication'
=>
'Bio::MAGE::Protocol::ParameterizableApplication'
,
'MeasuredSignal'
=>
'Bio::MAGE::QuantitationType::MeasuredSignal'
,
'Channel'
=>
'Bio::MAGE::BioAssay::Channel'
,
'BioDataCube'
=>
'Bio::MAGE::BioAssayData::BioDataCube'
,
'ManufactureLIMSBiomaterial'
=>
'Bio::MAGE::Array::ManufactureLIMSBiomaterial'
,
'BioSample'
=>
'Bio::MAGE::BioMaterial::BioSample'
,
'NameValueType'
=>
'Bio::MAGE::NameValueType'
,
'TemperatureUnit'
=>
'Bio::MAGE::Measurement::TemperatureUnit'
,
'PresentAbsent'
=>
'Bio::MAGE::QuantitationType::PresentAbsent'
,
'Software'
=>
'Bio::MAGE::Protocol::Software'
,
'Experiment'
=>
'Bio::MAGE::Experiment::Experiment'
,
'Description'
=>
'Bio::MAGE::Description::Description'
,
'Measurement'
=>
'Bio::MAGE::Measurement::Measurement'
}
;
}
sub
class2fullclass {
return
%{
$__CLASS2FULLCLASS
};
}
sub
add_objects {
my
(
$self
,
$list_ref
) =
@_
;
croak
"Bio::MAGE::add_objects: Expected array reference but got $list_ref"
unless
UNIVERSAL::isa(
$list_ref
,
'ARRAY'
);
foreach
my
$object
(@{
$list_ref
}) {
$self
->register(
$object
,1);
}
}
sub
getAuditAndSecurity_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'AuditAndSecurity'
}) {
eval
"require Bio::MAGE::AuditAndSecurity"
;
die
"Couldn't require Bio::MAGE::AuditAndSecurity"
if
$@;
$self
->{__PACKAGES}{
'AuditAndSecurity'
} = Bio::MAGE::AuditAndSecurity->new();
}
return
$self
->{__PACKAGES}{
'AuditAndSecurity'
};
}
sub
getDescription_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'Description'
}) {
eval
"require Bio::MAGE::Description"
;
die
"Couldn't require Bio::MAGE::Description"
if
$@;
$self
->{__PACKAGES}{
'Description'
} = Bio::MAGE::Description->new();
}
return
$self
->{__PACKAGES}{
'Description'
};
}
sub
getMeasurement_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'Measurement'
}) {
eval
"require Bio::MAGE::Measurement"
;
die
"Couldn't require Bio::MAGE::Measurement"
if
$@;
$self
->{__PACKAGES}{
'Measurement'
} = Bio::MAGE::Measurement->new();
}
return
$self
->{__PACKAGES}{
'Measurement'
};
}
sub
getBQS_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'BQS'
}) {
eval
"require Bio::MAGE::BQS"
;
die
"Couldn't require Bio::MAGE::BQS"
if
$@;
$self
->{__PACKAGES}{
'BQS'
} = Bio::MAGE::BQS->new();
}
return
$self
->{__PACKAGES}{
'BQS'
};
}
sub
getBioEvent_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'BioEvent'
}) {
eval
"require Bio::MAGE::BioEvent"
;
die
"Couldn't require Bio::MAGE::BioEvent"
if
$@;
$self
->{__PACKAGES}{
'BioEvent'
} = Bio::MAGE::BioEvent->new();
}
return
$self
->{__PACKAGES}{
'BioEvent'
};
}
sub
getProtocol_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'Protocol'
}) {
eval
"require Bio::MAGE::Protocol"
;
die
"Couldn't require Bio::MAGE::Protocol"
if
$@;
$self
->{__PACKAGES}{
'Protocol'
} = Bio::MAGE::Protocol->new();
}
return
$self
->{__PACKAGES}{
'Protocol'
};
}
sub
getBioMaterial_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'BioMaterial'
}) {
eval
"require Bio::MAGE::BioMaterial"
;
die
"Couldn't require Bio::MAGE::BioMaterial"
if
$@;
$self
->{__PACKAGES}{
'BioMaterial'
} = Bio::MAGE::BioMaterial->new();
}
return
$self
->{__PACKAGES}{
'BioMaterial'
};
}
sub
getBioSequence_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'BioSequence'
}) {
eval
"require Bio::MAGE::BioSequence"
;
die
"Couldn't require Bio::MAGE::BioSequence"
if
$@;
$self
->{__PACKAGES}{
'BioSequence'
} = Bio::MAGE::BioSequence->new();
}
return
$self
->{__PACKAGES}{
'BioSequence'
};
}
sub
getDesignElement_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'DesignElement'
}) {
eval
"require Bio::MAGE::DesignElement"
;
die
"Couldn't require Bio::MAGE::DesignElement"
if
$@;
$self
->{__PACKAGES}{
'DesignElement'
} = Bio::MAGE::DesignElement->new();
}
return
$self
->{__PACKAGES}{
'DesignElement'
};
}
sub
getArrayDesign_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'ArrayDesign'
}) {
eval
"require Bio::MAGE::ArrayDesign"
;
die
"Couldn't require Bio::MAGE::ArrayDesign"
if
$@;
$self
->{__PACKAGES}{
'ArrayDesign'
} = Bio::MAGE::ArrayDesign->new();
}
return
$self
->{__PACKAGES}{
'ArrayDesign'
};
}
sub
getArray_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'Array'
}) {
eval
"require Bio::MAGE::Array"
;
die
"Couldn't require Bio::MAGE::Array"
if
$@;
$self
->{__PACKAGES}{
'Array'
} = Bio::MAGE::Array->new();
}
return
$self
->{__PACKAGES}{
'Array'
};
}
sub
getBioAssay_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'BioAssay'
}) {
eval
"require Bio::MAGE::BioAssay"
;
die
"Couldn't require Bio::MAGE::BioAssay"
if
$@;
$self
->{__PACKAGES}{
'BioAssay'
} = Bio::MAGE::BioAssay->new();
}
return
$self
->{__PACKAGES}{
'BioAssay'
};
}
sub
getQuantitationType_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'QuantitationType'
}) {
eval
"require Bio::MAGE::QuantitationType"
;
die
"Couldn't require Bio::MAGE::QuantitationType"
if
$@;
$self
->{__PACKAGES}{
'QuantitationType'
} = Bio::MAGE::QuantitationType->new();
}
return
$self
->{__PACKAGES}{
'QuantitationType'
};
}
sub
getBioAssayData_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'BioAssayData'
}) {
eval
"require Bio::MAGE::BioAssayData"
;
die
"Couldn't require Bio::MAGE::BioAssayData"
if
$@;
$self
->{__PACKAGES}{
'BioAssayData'
} = Bio::MAGE::BioAssayData->new();
}
return
$self
->{__PACKAGES}{
'BioAssayData'
};
}
sub
getExperiment_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'Experiment'
}) {
eval
"require Bio::MAGE::Experiment"
;
die
"Couldn't require Bio::MAGE::Experiment"
if
$@;
$self
->{__PACKAGES}{
'Experiment'
} = Bio::MAGE::Experiment->new();
}
return
$self
->{__PACKAGES}{
'Experiment'
};
}
sub
getHigherLevelAnalysis_package {
my
$self
=
shift
;
if
(not
exists
$self
->{__PACKAGES}{
'HigherLevelAnalysis'
}) {
eval
"require Bio::MAGE::HigherLevelAnalysis"
;
die
"Couldn't require Bio::MAGE::HigherLevelAnalysis"
if
$@;
$self
->{__PACKAGES}{
'HigherLevelAnalysis'
} = Bio::MAGE::HigherLevelAnalysis->new();
}
return
$self
->{__PACKAGES}{
'HigherLevelAnalysis'
};
}
sub
objects {
my
$self
=
shift
;
if
(
@_
) {
$self
->{__OBJECTS} =
shift
;
}
return
$self
->{__OBJECTS};
}
sub
tagname {
my
$self
=
shift
;
if
(
@_
) {
$self
->{__TAGNAME} =
shift
;
}
return
$self
->{__TAGNAME};
}
sub
identifier {
my
$self
=
shift
;
if
(
@_
) {
$self
->{__IDENTIFIER} =
shift
;
}
return
$self
->{__IDENTIFIER};
}
sub
registered_objects {
my
$self
=
shift
;
if
(
@_
) {
$self
->{__REGISTERED_OBJECTS} =
shift
;
}
return
$self
->{__REGISTERED_OBJECTS};
}
sub
identifiers {
my
$self
=
shift
;
if
(
@_
) {
$self
->{__IDENTIFIERS} =
shift
;
}
return
$self
->{__IDENTIFIERS};
}
sub
packages {
my
$self
=
shift
;
if
(
@_
) {
$self
->{__PACKAGES} =
shift
;
}
return
$self
->{__PACKAGES};
}
sub
obj2mageml {
my
(
$self
,
$writer
) =
@_
;
my
$identifier
=
$self
->identifier();
croak
"Bio::MAGE::obj2mageml: Identifier not specified for topmost level object"
unless
defined
$identifier
;
my
@attrs
;
if
(
defined
$identifier
) {
push
(
@attrs
,
identifier
=>
$identifier
);
}
my
$empty
= 0;
my
$tag
=
$self
->tagname();
$writer
->write_start_tag(
$tag
,
$empty
,
@attrs
);
my
%packages
= %{
$self
->packages()};
foreach
my
$package
(
$self
->mageml_packages()) {
next
unless
exists
$packages
{
$package
};
my
$pkg_obj
=
$packages
{
$package
};
$pkg_obj
->obj2mageml(
$writer
);
}
$writer
->write_end_tag(
$tag
);
}
sub
obj2database {
my
(
$self
,
$writer
) =
@_
;
my
$identifier
=
$self
->identifier();
die
"Bio::MAGE: Identifier not specified"
unless
defined
$identifier
;
my
@attrs
;
if
(
defined
$identifier
) {
push
(
@attrs
,
identifier
=>
$identifier
);
}
my
$empty
= 0;
my
$tag
=
$self
->tagname();
my
%packages
= %{
$self
->packages()};
foreach
my
$package
(
$self
->mageml_packages()) {
next
unless
exists
$packages
{
$package
};
my
$pkg_obj
=
$packages
{
$package
};
$pkg_obj
->obj2database(
$writer
);
}
}
sub
register {
my
(
$self
,
$obj
,
$register
) =
@_
;
my
$registered
=
$self
->registered_objects();
return
if
$registered
->{
$obj
};
$registered
->{
$obj
}++;
my
$known_identifiers
=
$self
->identifiers();
if
(
$register
and
$obj
->isa(
'Bio::MAGE::Identifiable'
)) {
die
"Object must have identifier: $obj"
unless
$obj
->getIdentifier();
unless
(
exists
$known_identifiers
->{
$obj
->getIdentifier}) {
my
$packages
=
$self
->packages();
my
$package_name
=
$obj
->
package
();
my
$pkg_obj
=
$packages
->{
$package_name
};
unless
(
defined
$pkg_obj
) {
my
$class
=
"Bio::MAGE::$package_name"
;
$pkg_obj
=
$class
->new();
$packages
->{
$package_name
} =
$pkg_obj
;
}
$pkg_obj
->register(
$obj
);
$known_identifiers
->{
$obj
->getIdentifier}++;
}
}
foreach
my
$association
(
$obj
->association_methods()) {
my
%assns_hash
=
$obj
->associations();
my
$association_obj
;
{
no
strict
'refs'
;
my
$assoc_name
=
'get'
.
ucfirst
(
$association
);
$association_obj
=
$obj
->
$assoc_name
();
}
next
unless
defined
$association_obj
;
my
$register
=
$assns_hash
{
$association
}->is_ref();
if
(
$assns_hash
{
$association
}->cardinality() eq
"0..N"
or
$assns_hash
{
$association
}->cardinality() eq
"1..N"
) {
if
(
ref
(
$association_obj
) =~ /ARRAY/) {
foreach
my
$element
(
@$association_obj
) {
$self
->register(
$element
,
$register
)
if
defined
$element
;
}
}
else
{
die
"Expected array ref: $obj, association: $association, got $association_obj\n"
;
}
}
else
{
$self
->register(
$association_obj
,
$register
)
if
defined
$association_obj
;
}
}
}
1;