MAGE::...Element(3pm)

# πŸŽ€ MAGE::...Element πŸŽ€

bestie, welcome to MAGE::...Element(3pm) β€” straight out of the User Contributed Perl Documentation section. pull up a chair, we're doing MAGE today. πŸ’–


# ✨ NAME ✨

Bio::MAGE::DesignElement β€” the container module for the classes in the MAGE package: DesignElement. it's giving "one module to hold them all" energy. πŸ‘‘


# ✨ SYNOPSIS ✨

use Bio::MAGE::DesignElement;

that's it. that's the whole synopsis. iconic minimalism. πŸ’…


# ✨ DESCRIPTION ✨

so this is a package module β€” a lil container β€” that encapsulates a whole bunch of classes in the Bio::MAGE hierarchy. 🫢

and those classes? they all belong to the DesignElement package of the MAGE-OM object model. no cap. that's the whole description. periodt. 🌸


# ✨ CLASSES ✨

the Bio::MAGE::DesignElement module is home to the following Bio::MAGE classes, and bestie there are thirteen of them, she's thriving:

  • DesignElement
  • Position
  • Reporter
  • ReporterPosition
  • CompositePosition
  • CompositeSequence
  • Feature
  • MismatchInformation
  • FeatureInformation
  • CompositeCompositeMap
  • FeatureReporterMap
  • ReporterCompositeMap
  • FeatureLocation

# ✨ CLASS METHODS ✨

these are the ones you call on the class itself. let's get into it. ✨

  • @class_list = Bio::MAGE::DesignElement::classes(); β€” hands you back a list of the non-fully qualified class names in this package, meaning they do not have 'Bio::MAGE::' glued on the front. lowkey cleaner that way.
  • $obj = class->new(%parameters) β€” this is the class constructor, the birth of an object, main character origin story. 🌈
    • Parameters: if you feed it a list of name/value parameters, the matching slots, attributes, or associations get their initial values set by the constructor.
    • Return value: a reference to an object of the class.
    • Side effects: it invokes the initialize() method, but only if the class actually defines one.
  • @names = class->get_slot_names() β€” used to retrieve the name of all the slots defined in a given class.
    • NOTE: the list of names does not include attribute or association names. just slots. 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.
  • @name_list = get_association_names() β€” returns the list of association data members for this class.
  • @class_list = get_superclasses() β€” returns the list of superclasses for this class.
  • @class_list = get_subclasses() β€” returns the list of subclasses for this class.
  • $name = class_name() β€” returns the full class name for this class. the whole thing, no abbreviations. 😀
  • $package_name = package_name() β€” returns the base package name of the package that contains this class β€” i.e. no 'namespace::' prefix. just the base.
  • %assns = associations() β€” returns the association meta-information in a hash, where the keys are the association names and the values are Association objects that carry the meta-information for that association. 🧚

# ✨ INSTANCE METHODS ✨

now the ones you call on an actual object you already have. buckle up. πŸ¦‹

  • $obj_copy = $obj->new() β€” plot twist: when you invoke new() on an existing object reference instead of a class name, it acts as a copy constructor, and the new object's initial values are set to be those of the existing object. clone era. πŸ‘―
    • Parameters: no input parameters are used in the copy constructor β€” the initial values are taken directly from the object being copied.
    • Return value: 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) β€” sets a bunch of slots all at once. it's got two different invocation methods: the first takes a named parameter list, the second takes two array references. versatile queen. πŸ’…
    • Return value: none.
    • Side effects: will call croak() if a slot_name is used that the class does not define. so don't try it. 😭
  • @obj_list = $obj->get_slots(@name_list) β€” gets the values of a bunch of slots all at once.
    • Return value: a list of instance objects.
    • Side effects: none.
  • $val = $obj->set_slot($name,$val) β€” 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) β€” 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.
  • $val = $designelement->xml_lists() $inval = $designelement->xml_lists($inval) β€” the unified setter/getter for the xml_lists slot.
    • if $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
    • Input parameters: the optional $inval will invoke the setter method.
    • Return value: for both setter and getter, the current value of the xml_lists slot.
    • Side effects: none.
    • Exceptions: none.
  • $val = $designelement->tagname() $inval = $designelement->tagname($inval) β€” the unified setter/getter for the tagname slot.
    • if $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
    • Input parameters: the optional $inval will invoke the setter method.
    • Return value: for both setter and getter, the current value of the tagname slot.
    • Side effects: none.
    • Exceptions: none.
  • $val = $designelement->compositesequence_list() $inval = $designelement->compositesequence_list($inval) β€” the unified setter/getter for the compositesequence_list slot.
    • if $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
    • Input parameters: the optional $inval will invoke the setter method.
    • Return value: for both setter and getter, the current value of the compositesequence_list slot.
    • Side effects: none.
    • Exceptions: none.
  • $val = $designelement->reporter_list() $inval = $designelement->reporter_list($inval) β€” the unified setter/getter for the reporter_list slot.
    • if $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
    • Input parameters: the optional $inval will invoke the setter method.
    • Return value: for both setter and getter, the current value of the reporter_list slot.
    • Side effects: none.
    • Exceptions: none.
  • $val = $designelement->compositecompositemap_list() $inval = $designelement->compositecompositemap_list($inval) β€” the unified setter/getter for the compositecompositemap_list slot.
    • if $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
    • Input parameters: the optional $inval will invoke the setter method.
    • Return value: for both setter and getter, the current value of the compositecompositemap_list slot.
    • Side effects: none.
    • Exceptions: none.
  • $val = $designelement->reportercompositemap_list() $inval = $designelement->reportercompositemap_list($inval) β€” the unified setter/getter for the reportercompositemap_list slot.
    • if $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
    • Input parameters: the optional $inval will invoke the setter method.
    • Return value: for both setter and getter, the current value of the reportercompositemap_list slot.
    • Side effects: none.
    • Exceptions: none.
  • $val = $designelement->featurereportermap_list() $inval = $designelement->featurereportermap_list($inval) β€” the unified setter/getter for the featurereportermap_list slot.
    • if $inval is specified, the setter method is invoked; with no parameters, the getter method is invoked.
    • Input parameters: the optional $inval will invoke the setter method.
    • Return value: for both setter and getter, the current value of the featurereportermap_list slot.
    • Side effects: none.
    • Exceptions: none.
  • $array_ref = $designelement->getCompositeSequence_list() β€” handles the list for the Bio::MAGE::DesignElement::CompositeSequence class. returns a reference to an array of the class objects that have been associated with the package instance. πŸ“
    • super handy when you're retrieving data from a parsed MAGE-ML file. iykyk.
  • $designelement->addCompositeSequence(@vals) β€” an interface for adding Bio::MAGE::DesignElement::CompositeSequence objects to the compositesequence_list list. it's generally used by generic methods, like the ones in the XMLWriter.
    • Input parameters: the list of values @vals to add to the owner association. NOTE: submitting a single value is permitted. πŸ™ˆ
    • Return value: none.
    • Side effects: none.
    • Exceptions: will call croak() if no input parameters are specified, or if any of the objects in @vals is not a subclass of class Bio::MAGE::DesignElement::CompositeSequence.
  • $array_ref = $designelement->getReporter_list() β€” handles the list for the Bio::MAGE::DesignElement::Reporter class. returns a reference to an array of the class objects that have been associated with the package instance.
    • again, useful when retrieving data from a parsed MAGE-ML file. 🧚
  • $designelement->addReporter(@vals) β€” an interface for adding Bio::MAGE::DesignElement::Reporter objects to the reporter_list list. generally used by generic methods such as those in the XMLWriter.
    • Input parameters: the list of values @vals to add to the owner association. NOTE: submitting a single value is permitted.
    • Return value: none.
    • Side effects: none.
    • Exceptions: will call croak() if no input parameters are specified, or if any of the objects in @vals is not a subclass of class Bio::MAGE::DesignElement::Reporter.
  • $array_ref = $designelement->getCompositeCompositeMap_list() β€” handles the list for the Bio::MAGE::DesignElement::CompositeCompositeMap class. returns a reference to an array of the class objects that have been associated with the package instance.
    • yes bestie, once again this is useful when retrieving data from a parsed MAGE-ML file. 🌈
  • $designelement->addCompositeCompositeMap(@vals) β€” an interface for adding Bio::MAGE::DesignElement::CompositeCompositeMap objects to the compositecompositemap_list list. generally used by generic methods such as those in the XMLWriter.
    • Input parameters: the list of values @vals to add to the owner association. NOTE: submitting a single value is permitted.
    • Return value: none.
    • Side effects: none.

Exceptions: (yeah this is the tail end of that last method's whole deal, keep scrolling bestie πŸ’…) will call croak() if no input parameters are specified, or if any of the objects in @vals is not a subclass of class Bio::MAGE::DesignElement::CompositeCompositeMap


🌸 $array_ref = $designelement->getReporterCompositeMap_list()

This one handles the list for the Bio::MAGE::DesignElement::ReporterCompositeMap class. It hands you back a reference to an array of the class objects that have been associated with the package instance.

Lowkey so useful when you're retrieving data from a parsed MAGE-ML file. 🧚

πŸ¦‹ $designelement->addReporterCompositeMap(@vals)

This method is the interface for adding Bio::MAGE::DesignElement::ReporterCompositeMap objects to the reportercompositemap_list list. It's generally used by generic methods, like the ones hanging out in the XMLWriter.

  • Input parameters: the list of values @vals to add to the owner association. NOTE: submitting a single value is permitted.
  • Return value: none
  • Side effects: none
  • Exceptions: will call croak() if no input parameters are specified, or if any of the objects in @vals is not a subclass of class Bio::MAGE::DesignElement::ReporterCompositeMap

πŸ’œ $array_ref = $designelement->getFeatureReporterMap_list()

Handles the list for the Bio::MAGE::DesignElement::FeatureReporterMap class. Returns a reference to an array of the class objects that have been associated with the package instance.

Again β€” chef's kiss when you're pulling data out of a parsed MAGE-ML file. ✨

πŸŽ€ $designelement->addFeatureReporterMap(@vals)

The interface for adding Bio::MAGE::DesignElement::FeatureReporterMap objects to the featurereportermap_list list. Generally used by generic methods such as those in the XMLWriter.

  • Input parameters: the list of values @vals to add to the owner association. NOTE: submitting a single value is permitted.
  • Return value: none
  • Side effects: none
  • Exceptions: will call croak() if no input parameters are specified, or if any of the objects in @vals is not a subclass of class Bio::MAGE::DesignElement::FeatureReporterMap

πŸ”₯ $designelement->obj2xml($writer)

Writes out this object, and all its sub-objects, as XML β€” using the $writer you hand it to actually do the XML formatting. Main character does the object, the writer does the glow-up. πŸ‘‘

  • Input parameters: $writer must be an XML writer, e.g. an instance of Bio::MAGE::XML::Writer. It must have methods: write_start_tag(), write_end_tag(), and obj2xml().
  • Return value: none
  • Side effects: all writing is delegated to the $writer β€” its write_start_tag() and write_end_tag() methods are invoked with the appropriate data, and all class sub-objects of the Bio::MAGE::DesignElement instance will have their obj2xml() methods invoked in turn. By allowing the $writer to do the actual formatting of the output XML, it enables the user to precisely control the format.
  • Exceptions: will call croak() if no identifier has been set for the Bio::MAGE::DesignElement instance.
bestie. set your identifier. don't make it croak. 😭

πŸ“ $designelement->register($obj)

Stores an object for later writing as XML. Save it for the group chat, basically.

  • Input parameters: object to be added to the list of registered objects.
  • Return value: none
  • Side effects: if $obj needs to be stored by this class, a reference will be stored in the correct XML list for this class.
  • Exceptions: none

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

okay so in the Perl implementation of MAGE-OM classes, there are exactly three types of class data members, and you will be learning all of them: "slots", "attributes", and "associations". Sit down, hydrate, let's go. 🫢

πŸ”’ SLOTS

This API uses the term "slot" to mean a data member of the class that was not present in the UML model, and it's used for mainly internal purposes β€” so only touch it if you genuinely understand the inner workings of the API. No cap. Most often, slots get used by generic methods, like the ones in the XML writing and reading classes.

Slots are implemented using unified getter/setter methods:

  • $var = $obj->slot_name(); β€” retrieves the current value of the slot.
  • $new_var = $obj->slot_name($new_var); β€” stores $new_var in the slot; the return value is also $new_var.
  • @names = $obj->get_slot_names() β€” returns the list of all slots in the class.

DATA CHECKING: No data type checking is made for these methods. None. Zero. It simply does not check. πŸ™ˆ

🌈 ATTRIBUTES AND ASSOCIATIONS

The terms "attribute" and "association" mean data members of the class that were specified directly from the UML model. (Yes, that's the difference. That's it. That's the tea. β˜•)

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.
  • set* β€” sets the current value, replacing any existing value.
    • 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.
    • 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* β€” NOTE: only present in associations with list cardinality.
    • Appends a list of objects to any values that may already be stored in the association.
    • 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 set of generic methods that will operate on slots, attributes, and associations:

$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. πŸ‘€


πŸ’€ BUGS πŸ’€

Please send bug reports to the project mailing list: (mged-mage 'at' lists 'dot' sf 'dot' net)

not me begging you to actually report the bugs instead of just yelling about them in your own terminal πŸ™

πŸ‘‘ AUTHOR πŸ‘‘

Jason E. Stewart (jasons 'at' cpan 'dot' org)


πŸ”— SEE ALSO πŸ”—

perl(1).


and that's the whole page, bestie β€” this one's perl v5.32.0, dated 2020-11-27, and yeah it's literally titled MAGE::...Element(3pm). go forth and parse your MAGE-ML, you absolute icon πŸ’–βœ¨πŸ¦‹