MAGE::Extendable(3pm)

πŸ’– MAGE::Extendable β€” User Contributed Perl Documentation πŸ’–

okay so bestie, we're doing MAGE::Extendable(3pm) today and honestly? it's giving abstract base class royalty πŸ‘‘βœ¨. This is the perl documentation for it, and it's a whole journey, so grab a lil snack πŸ“ and let's get into it.


πŸ¦‹ NAME πŸ¦‹

Bio::MAGE::Extendable β€” the class for the MAGE-OM API. that's it, that's the name πŸ’…


✨ SYNOPSIS ✨

here's the vibe, straight up:

use Bio::MAGE::Extendable

# Bio::MAGE::Extendable is an abstract base class and should not
# be directly instantiated. These examples indicate how subclass
# objects will behave

# 'propertySets' association
my $namevaluetype_array_ref = $extendable->propertySets(); # getter
$extendable->propertySets(\@namevaluetype_list); # setter
🚨 real talk: Bio::MAGE::Extendable is an abstract base class and should not be directly instantiated. the examples up there are just showing you how subclass objects will behave. do not come for me if you try to instantiate it, i warned you 😭

🌸 DESCRIPTION 🌸

okay so, direct from the MAGE-OM documentation for the Extendable class, no cap:

Abstract class that specifies for subclasses an association to NameValueTypes. These can be used, for instance, to specify proprietary properties and in-house processing hints.

and like, in case that wasn't clear: Bio::MAGE::Extendable is an abstract base class and should not be directly instantiated. instead, it serves as an interface definition for its subclasses. it's the blueprint bestie, not the building πŸ—οΈβœ¨


πŸ‘‘ INHERITANCE πŸ‘‘

Bio::MAGE::Extendable has the following subclasses (yes, it's a whole friend group, we love a big family 🌈):

  • Bio::MAGE::HigherLevelAnalysis::NodeValue
  • Bio::MAGE::Description::DatabaseEntry
  • Bio::MAGE::ArrayDesign::ZoneLayout
  • Bio::MAGE::ArrayDesign::ZoneGroup
  • Bio::MAGE::Description::ExternalReference
  • Bio::MAGE::DesignElement::Position
  • Bio::MAGE::Description::OntologyEntry
  • Bio::MAGE::DesignElement::MismatchInformation
  • Bio::MAGE::Measurement::Measurement
  • Bio::MAGE::DesignElement::FeatureInformation
  • Bio::MAGE::Measurement::Unit
  • Bio::MAGE::BioAssayData::BioAssayMapping
  • Bio::MAGE::BioAssayData::BioAssayDatum
  • Bio::MAGE::Describable
  • Bio::MAGE::BioAssayData::QuantitationTypeMapping
  • Bio::MAGE::BioAssayData::DesignElementMapping
  • Bio::MAGE::DesignElement::FeatureLocation
  • Bio::MAGE::Array::FeatureDefect
  • Bio::MAGE::BioAssayData::BioDataValues
  • Bio::MAGE::Array::ArrayManufactureDeviation
  • Bio::MAGE::Array::PositionDelta
  • Bio::MAGE::Array::ZoneDefect
  • Bio::MAGE::Protocol::ParameterValue
  • Bio::MAGE::BioSequence::SeqFeatureLocation
  • Bio::MAGE::BioMaterial::CompoundMeasurement
  • Bio::MAGE::BioMaterial::BioMaterialMeasurement
  • Bio::MAGE::BioSequence::SequencePosition

πŸ’œ CLASS METHODS πŸ’œ

these are the methods you can call without even having an instance of the class first, using the Bio::MAGE::Extendable->methodname() syntax. iconic, honestly 🫢

new()

new(%args)

so Bio::MAGE::Extendable is an abstract base class and should not be directly instantiated using the new() constructor. it's listed here purely to show you what arguments its subclasses will accept, iykyk.

the object constructor new() accepts the following optional named-value style arguments:

  • propertySets β€” sets the value of the propertySets association. the value must be of type: array of Bio::MAGE::NameValueType.

$obj = class->new(%parameters)

this one right here is the class constructor, the main character πŸ”₯

  • Parameters: if you give it a list of name/value parameters, the corresponding slots, attributes, or associations will have their initial values set by the constructor.
  • Return value: it returns a reference to an object of the class.
  • Side effects: it invokes the initialize() method if it is defined by the class.

@names = class->get_slot_names()

the get_slot_names() method grabs the name of every slot defined in a given class.

⚠️ NOTE: the list of names does not include attribute or association names. don't get it twisted.
  • Return value: a list of the names of all slots defined for this class.
  • Side effects: none.

@name_list = get_attribute_names()

returns the list of attribute data members for this class. slay.

@name_list = get_association_names()

returns the list of association data members for this class. also slay.

@class_list = get_superclasses()

returns the list of superclasses for this class. look up β¬†οΈβœ¨

@class_list = get_subclasses()

returns the list of subclasses for this class. look down β¬‡οΈπŸŒˆ

$name = class_name()

returns the full class name for this class.

$package_name = package_name()

returns the base package name (i.e. no 'namespace::') of the package that contains this class.

%assns = associations()

returns the association meta-information in a hash where the keys are the association names and the values are Association objects that provide the meta-information for the association. very meta of it πŸ’…


🧚 INSTANCE METHODS 🧚

$obj_copy = $obj->new()

when you invoke this with an existing object reference and not a class name, new() acts as a copy constructor β€” the new object's initial values get set to be those of the existing object. it's giving clone energy πŸ‘―

  • Parameters: no input parameters are used in the copy constructor, the initial values are taken directly from the object to be copied.
  • Return value: it returns a reference to an object of the class.
  • Side effects: it invokes the initialize() method if it is defined by the class.

$obj->set_slots(%parameters)

$obj->set_slots(\@name_list, \@value_list)

the set_slots() method sets a bunch of slots all at once. it's got two different invocation methods: the first takes a named parameter list, and the second takes two array references. pick your fighter πŸ₯Š

  • Return value: none.
  • Side effects: will call croak() if a slot_name is used that the class does not define. so like, don't do that πŸ™ˆ

@obj_list = $obj->get_slots(@name_list)

the get_slots() method gets the values of a bunch of slots all at once. efficiency queen πŸ‘‘

  • Return value: a list of instance objects.
  • Side effects: none.

$val = $obj->set_slot($name,$val)

the set_slot() method sets the slot $name to the value $val.

  • Return value: the new value of the slot, i.e. $val.
  • Side effects: none.

$val = $obj->get_slot($name)

the get_slot() method is used to get the values of a number of slots at the same time.

  • Return value: a single slot value, or undef if the slot has not been initialized.
  • Side effects: none.

🌟 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.

Bio::MAGE::Extendable has the following attribute accessor methods:

(that's it. nothing here. the silence is loud πŸ’€ β€” but keep reading bestie, the associations are where it's at)


πŸ¦‹ ASSOCIATIONS πŸ¦‹

associations are references to other classes. associations in MAGE-OM have a cardinality that determines the minimum and maximum number of instances of the 'other' class that may be included in the association:

  1. there must be exactly one item in the association, i.e. this is a mandatory data field.
  2. 0..1 β€” there may be one item in the association, i.e. this is an optional data field.
  3. 1..N β€” there must be one or more items in the association, i.e. this is a mandatory data field, with list cardinality.
  4. 0..N β€” there may be one or more items in the association, i.e. this is an optional data field, with list cardinality.

Bio::MAGE::Extendable has the following association accessor methods:

propertySets

methods for the propertySets association.

from the MAGE-OM documentation:

Allows specification of name/value pairs. Meant to primarily help in-house, pipeline processing of instances by providing a place for values that aren't part of the specification proper.

$array_ref = $extendable->setPropertySets($array_ref)

  • the restricted setter method for the propertySets association.
  • Input parameters: the value to which the propertySets association will be set : a reference to an array of objects of type Bio::MAGE::NameValueType.
  • Return value: the current value of the propertySets association : a reference to an array of objects of type Bio::MAGE::NameValueType.
  • Side effects: none.
  • Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified, or if $array_ref is not a reference to an array class Bio::MAGE::NameValueType instances.

$array_ref = $extendable->getPropertySets()

  • the restricted getter method for the propertySets association.
  • Input parameters: none.
  • Return value: the current value of the propertySets association : a reference to an array of objects of type Bio::MAGE::NameValueType.
  • Side effects: none.
  • Exceptions: will call croak() if any input parameters are specified.

$val = $extendable->addPropertySets(@vals)

because the propertySets association has list cardinality, it may store more than one value. this method adds the current list of objects in the propertySets association. the more the merrier, honestly πŸ’–

  • Input parameters: the list of values @vals to add to the propertySets association. NOTE: submitting a single value is permitted.
  • Return value: the number of items stored in the slot after adding @vals.
  • Side effects: none.
  • Exceptions: will call croak() if no input parameters are specified, or if any of the objects in @vals is not an instance of class Bio::MAGE::NameValueType.

and finally, the lil code moment that lives here:

sub initialize {

  carp __PACKAGE__ . "::initialize: abstract base classes should not be instantiated";

}
🚨 like it literally says in the code: abstract base classes should not be instantiated. the carp is coming for you if you try. consider yourself warned bestie πŸ˜­πŸ’…

πŸ’« SLOTS, ATTRIBUTES, AND ASSOCIATIONS πŸ’«

okay bestie, so in the Perl implementation of MAGE-OM classes there are literally three flavors of class data members and you need to know the difference or you're gonna be lost: slots, attributes, and associations. Let's break them down πŸ’…


πŸŽ€ SLOTS

This API uses the term "slot" to mean a data member of the class that wasn't in the UML model at all, and it's used for mainly internal purposes. Like, mind your business energy. Use these only if you understand the inner workings of the API, fr fr. Most often, slots get used by generic methods β€” think the ones hanging out in the XML writing and reading classes ✨

Slots are implemented with unified getter/setter methods, here's the tea:

  • $var = $obj->slot_name(); β€” retrieves the current value of the slot. just a lil peek πŸ‘€
  • $new_var = $obj->slot_name($new_var); β€” stores $new_var in the slot, and the return value is also $new_var. she gives back what you gave her, iconic behavior πŸ’–
  • @names = $obj->get_slot_names() β€” returns the list of all slots in the class. the whole roster 🫢
DATA CHECKING: No data type checking is made for these methods. none. zero. she does not check, she just vibes 😭

πŸ¦‹ ATTRIBUTES AND ASSOCIATIONS

The terms "attribute" and "association" mean data members of the class that were specified directly from the UML model. So these ones actually came from the source, no cap.

In the Perl implementation of MAGE-OM classes, association and attribute accessors are implemented using three separate methods:

  • get* β€” retrieves the current value.
NOTE: For associations, if the association has list cardinality, an array reference is returned. DATA CHECKING: Ensure that no argument is provided. like, none. don't hand her anything πŸ™ˆ
  • set* β€” sets the current value, replacing any existing value. out with the old, in with the new ✨
NOTE: For associations, if the association has list cardinality, the argument must be an array reference. Because of this, you probably should be using the add* methods instead. DATA CHECKING: For attributes, ensure that a single value is provided as the argument. For associations, if the association has list cardinality, ensure that the argument is a reference to an array of instances of the correct MAGE-OM class; otherwise ensure that there is a single argument of the correct MAGE-OM class.
  • add* β€” appends a list of objects to any values that may already be stored in the association.
NOTE: Only present in associations with list cardinality. if you don't have list cardinality, she's simply not there, periodt. DATA CHECKING: Ensure that all arguments are of the correct MAGE-OM class.

πŸ‘‘ GENERIC METHODS

The unified base class of all MAGE-OM classes, Bio::MAGE::Base, provides a whole set of generic methods that will operate on slots, attributes, and associations. one class to rule them all, main character energy:

  • $val = $obj->get_slot($name)
  • \@list_ref = $obj->get_slots(@name_list);
  • $val = $obj->set_slot($name,$val)
  • $obj->set_slots(%parameters)
  • $obj->set_slots(\@name_list, \@value_list)

See elsewhere in this page for a detailed description of these methods β€” the deep dive lives over there, iykyk πŸ’œ


πŸ’€ BUGS

Found something cursed? Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net) πŸ›


🌸 AUTHOR

Jason E. Stewart (jasons 'at' cpan 'dot' org) β€” thank you for your service, king 🫢


🌈 SEE ALSO

perl(1).


🚨 POD ERRORS

Hey! The above document had some coding errors, which are explained below. not me exposing the doc's messy era 😭:

  • Around line 361:
    • '=item' outside of any '=over'
  • Around line 446:
    • You forgot a '=back' before '=head2'
  • Around line 474:
    • Expected '=item 2'
  • Around line 479:
    • Expected '=item 3'
  • Around line 484:
    • Expected '=item 4'

and that's the whole page, bestie!! πŸ’– this doc came to you courtesy of perl v5.32.0, dated 2020-11-27, and it's the MAGE::Extendable(3pm) page β€” go forth and be extendable, slay βœ¨πŸ’…πŸ¦‹