MAGE::...eValue(3pm)

πŸ’– Bio::MAGE::HigherLevelAnalysis::NodeValue β€” from the MAGE-OM API πŸ’–

okay bestie, welcome to the perl docs for Bio::MAGE::HigherLevelAnalysis::NodeValue, which lives in the User Contributed Perl Documentation section of the manual (section 3pm). she's a whole class, she's part of the MAGE-OM API, and we're gonna get into it. grab a snack πŸ“


✨ NAME ✨

Bio::MAGE::HigherLevelAnalysis::NodeValue β€” a whole class for the MAGE-OM API. no cap, that's literally what she is.


🌸 SYNOPSIS 🌸

here's the vibe in code form, bestie:

use Bio::MAGE::HigherLevelAnalysis::NodeValue

# creating an empty instance
my $nodevalue = Bio::MAGE::HigherLevelAnalysis::NodeValue->new();

# creating an instance with existing data
my $nodevalue = Bio::MAGE::HigherLevelAnalysis::NodeValue->new(
      value=>$value_val,
      name=>$name_val,
      dataType=>$ontologyentry_ref,
      scale=>$ontologyentry_ref,
      type=>$ontologyentry_ref,
      propertySets=>\@namevaluetype_list,
);

# 'value' attribute
my $value_val = $nodevalue->value(); # getter
$nodevalue->value($value); # setter

# 'name' attribute
my $name_val = $nodevalue->name(); # getter
$nodevalue->name($value); # setter

# 'dataType' association
my $ontologyentry_ref = $nodevalue->dataType(); # getter
$nodevalue->dataType($ontologyentry_ref); # setter

# 'scale' association
my $ontologyentry_ref = $nodevalue->scale(); # getter
$nodevalue->scale($ontologyentry_ref); # setter

# 'type' association
my $ontologyentry_ref = $nodevalue->type(); # getter
$nodevalue->type($ontologyentry_ref); # setter

# 'propertySets' association
my $namevaluetype_array_ref = $nodevalue->propertySets(); # getter
$nodevalue->propertySets(\@namevaluetype_list); # setter

look at her go. getters AND setters? we love a versatile queen. πŸ‘‘


πŸ’… DESCRIPTION πŸ’…

straight from the MAGE-OM documentation for the NodeValue class, and I'm quoting her exactly:

A value associated with the Node that can rank it in relation to the other nodes produced by the clustering algorithm.

so basically she holds a value that lets a Node get ranked against all the other nodes that came out of the clustering algorithm. it's giving ranking energy. it's giving "who's the main character Node" energy. 🌈


πŸ¦‹ INHERITANCE πŸ¦‹

Bio::MAGE::HigherLevelAnalysis::NodeValue has exactly one superclass, and it's:

  • Bio::MAGE::Extendable

that's it, that's the whole family tree she's inheriting from. iconic lineage honestly. ✨


πŸŽ€ CLASS METHODS πŸŽ€

okay so here's the tea: all of these methods can be called without having an instance of the class first. you just hit her with the:

Bio::MAGE::HigherLevelAnalysis::NodeValue->methodname()

syntax. class methods, no instance needed, she doesn't gatekeep. πŸ’–


🧚 new()

🧚 new(%args)

the object constructor new() takes these optional named-value style arguments, bestie:

  • value β€” sets the value of the value attribute
  • name β€” sets the value of the name attribute
  • dataType β€” sets the value of the dataType association

the value must be of type: an instance of Bio::MAGE::Description::OntologyEntry.

  • scale β€” sets the value of the scale association

the value must be of type: an instance of Bio::MAGE::Description::OntologyEntry.

  • propertySets β€” sets the value of the propertySets association (and psst, this association was inherited from class Bio::MAGE::Extendable, so thank her ancestors for this one)

the value must be of type: an array of Bio::MAGE::NameValueType.

  • type β€” sets the value of the type association

the value must be of type: an instance of Bio::MAGE::Description::OntologyEntry.


πŸ’œ $obj = class->new(%parameters)

the new() method is the class constructor. the whole origin story.

Parameters: if you give her a list of name/value parameters, the corresponding slots, attributes, or associations will have their initial values set by the constructor. she's setting you up on arrival fr fr.

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 is how you retrieve the name of all slots defined in a given class.

NOTE: the list of names does not include attribute or association names. just so you know, bestie. πŸ™ˆ

Return value: a list of the names of all slots defined for this class.

Side effects: none. she's chill like that.


πŸ“ @name_list = get_attribute_names()

returns the list of attribute data members for this class. that's it, that's the whole thing. ✨


πŸ“ @name_list = get_association_names()

returns the list of association data members for this class. also that simple. πŸ’…


🌈 @class_list = get_superclasses()

returns the list of superclasses for this class. (remember, she's got exactly one, and it's Bio::MAGE::Extendable β€” go say hi to her.)


🌈 @class_list = get_subclasses()

returns the list of subclasses for this class.


🌸 $name = class_name()

returns the full class name for this class. like, the whole entire thing, namespace and all.


🌸 $package_name = package_name()

returns the base package name (i.e. no 'namespace::' in it) 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. meta-information about meta-information? we love layers. πŸŽ€


πŸ’– INSTANCE METHODS πŸ’–

okay bestie, this is the part where the object actually does stuff. every method here is called on an actual instance, so you need a $nodevalue (or whatever class) already living in a variable. let's go one by one, no skipping, i promise 🫢


$obj_copy = $obj->new()

so when you call new() on an existing object reference instead of on a class name, it flips into copy constructor mode β€” the brand new object starts out with initial values that are literally the ones from the existing object. it's giving "twin but make it fresh" πŸ‘―

  • Parameters: none, bestie. no input parameters are used in the copy constructor, because 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's defined by the class.

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

set_slots() is the "set a whole bunch of slots at once" girlie. she has two different invocation methods:

  1. the first one takes a named parameter list, i.e. %parameters
  2. the second one takes two array references, i.e. \@name_list and \@value_list
  • Return value: none 😢
  • Side effects: will call croak() if a slot_name is used that the class does not define.
like, if you make up a slot that doesn't exist? she WILL yell at you. croak() says hi. πŸ’€

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

get_slots() grabs the values of a bunch of slots all at the same time. one call, many slots, maximum efficiency, we love a multitasker ✨

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

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

set_slot() sets the slot $name to the value $val. simple, clean, iconic πŸ’…

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

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

get_slot() is used to get the values of a number of slots at the same time. (yes, that's exactly what the docs say about the single slot getter, and no, we are not arguing with the docs today πŸ™ˆ)

  • 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 one 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 β€” so like, one setter, one getter, per attribute. no shared anything, she's exclusive 😌

Bio::MAGE::HigherLevelAnalysis::NodeValue has the following attribute accessor methods:


value

methods for the value attribute.

from the MAGE-OM documentation:

The value for this NodeValue.

$val = $nodevalue->setValue($val)

the restricted setter method for the value attribute.

  • Input parameters: the value to which the value attribute will be set
  • Return value: the current value of the value attribute
  • Side effects: none
  • Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified

$val = $nodevalue->getValue()

the restricted getter method for the value attribute.

  • Input parameters: none
  • Return value: the current value of the value attribute
  • Side effects: none
  • Exceptions: will call croak() if any input parameters are specified
"restricted" means she takes exactly the right amount of arguments and nothing else. extra args? croak(). zero args where one is needed? also croak(). she's strict but she's fair πŸŽ€

name

methods for the name attribute.

from the MAGE-OM documentation:

The name for this value.

$val = $nodevalue->setName($val)

the restricted setter method for the name attribute.

  • Input parameters: the value to which the name attribute will be set
  • Return value: the current value of the name attribute
  • Side effects: none
  • Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified

$val = $nodevalue->getName()

the restricted getter method for the name attribute.

  • Input parameters: none
  • Return value: the current value of the name attribute
  • Side effects: none
  • Exceptions: will call croak() if any input parameters are specified

πŸ¦‹ ASSOCIATIONS πŸ¦‹

associations are references to other classes. and because MAGE-OM is dramatic, associations have a cardinality that determines the minimum and maximum number of instances of the 'other' class that may be included in the association. here's the whole rundown, no cuts:

  1. exactly one β€” 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::HigherLevelAnalysis::NodeValue has the following association accessor methods:


dataType

methods for the dataType association.

from the MAGE-OM documentation:

The data type of the any element.

$val = $nodevalue->setDataType($val)

the restricted setter method for the dataType association.

  • Input parameters: the value to which the dataType association will be set : one of the accepted enumerated values.
  • Return value: the current value of the dataType association : one of the accepted enumerated values.
  • Side effects: none
  • Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified, or if $val is not an instance of class Bio::MAGE::Description::OntologyEntry

$val = $nodevalue->getDataType()

the restricted getter method for the dataType association.

  • Input parameters: none
  • Return value: the current value of the dataType association : an instance of type Bio::MAGE::Description::OntologyEntry.
  • Side effects: none
  • Exceptions: will call croak() if any input parameters are specified

scale

methods for the scale association.

from the MAGE-OM documentation:

The scale (linear, log10, ln, etc.) of the value.

$val = $nodevalue->setScale($val)

the restricted setter method for the scale association.

  • Input parameters: the value to which the scale association will be set : one of the accepted enumerated values.
  • Return value: the current value of the scale association : one of the accepted enumerated values.
  • Side effects: none
  • Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified, or if $val is not an instance of class Bio::MAGE::Description::OntologyEntry

$val = $nodevalue->getScale()

the restricted getter method for the scale association.

  • Input parameters: none
  • Return value: the current value of the scale association : an instance of type Bio::MAGE::Description::OntologyEntry.
  • Side effects: none
  • Exceptions: will call croak() if any input parameters are specified

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 = $nodevalue->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 = $nodevalue->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 = $nodevalue->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.

  • 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
note the NOTE up there bestie β€” one single value is permitted, she's flexible like that 🫢

type

methods for the type association.

from the MAGE-OM documentation:

The type of value, distance, etc.

$val = $nodevalue->setType($val)

the restricted setter method for the type association.

  • Input parameters: the value to which the type association will be set : one of the accepted enumerated values.
  • Return value: the current value of the type association : one of the accepted enumerated values.
  • Side effects: none
  • Exceptions: will call croak() if no input parameters are specified, or if too many input parameters are specified, or if $val is not an instance of class Bio::MAGE::Description::OntologyEntry

$val = $nodevalue->getType()

the restricted getter method for the type association.

  • Input parameters: none
  • Return value: the current value of the type association : an instance of type Bio::MAGE::Description::OntologyEntry.
  • Side effects: none
  • Exceptions: will call croak() if any input parameters are specified

and then the page just. ends with this lil guy, exactly as written:

sub initialize {

  my $self = shift;
  return 1;

}

main character energy honestly πŸ‘‘

🌸 SLOTS, ATTRIBUTES, AND ASSOCIATIONS 🌸

ok so in the Perl version of MAGE-OM classes, there are literally three flavours of class data members and you need to know which is which: slots, attributes, and associations. bestie, they are NOT the same thing, do not mix them up πŸ’…


✨ SLOTS ✨

So this API uses the word "slot" for a class data member that wasn't in the UML model at all. They're mostly there for internal stuff β€” so like, only touch them if you genuinely understand the inner workings of the API, okay? 🫢

Most of the time, slots get used by generic methods β€” think the ones hanging out in the XML writing and reading classes. they're the backstage crew of this whole operation ngl.

Slots are implemented with unified getter/setter methods, so it's one method doing both jobs:

  • $var = $obj->slot_name(); β€” grabs the current value of the slot, that's it, that's the whole vibe.
  • $new_var = $obj->slot_name($new_var); β€” stores $new_var in the slot, and the return value is also $new_var (yes, it gives you back what you gave it, iconic behaviour honestly).
  • @names = $obj->get_slot_names() β€” hands you the list of every slot in the class. all of them. the full roster πŸ‘‘
DATA CHECKING: nope. zero. none. No data type checking is made for these methods. it will not catch you. be your own adult 😭

πŸ¦‹ ATTRIBUTES AND ASSOCIATIONS πŸ¦‹

The words "attribute" and "association" are for data members that were specified directly from the UML model. so these are the official ones, the ones on the mood board.

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

  • get* β€” retrieves the current value.
    • NOTE: for associations, if the association has list cardinality, you get back an array reference. not the array. the reference. iykyk.
    • DATA CHECKING: ensures that no argument is provided. give it an argument and it will simply not be having it πŸ™ˆ
  • set* β€” sets the current value, replacing whatever was there before. out with the old, in with the new, no sentimental attachments.
    • NOTE: for associations, if the association has list cardinality, the argument must be an array reference. and because of that whole situation, you probably should be using the add* methods instead. like, genuinely, add* is the main character here πŸ’…
    • DATA CHECKING: for attributes, it ensures a single value is provided as the argument. for associations, if the association has list cardinality, it ensures the argument is a reference to an array of instances of the correct MAGE-OM class; otherwise it ensures there's a single argument of the correct MAGE-OM class. so yes, it is checking. respectfully.
  • add* β€” NOTE: only present in associations with list cardinality. if you don't have list cardinality, this method simply does not exist for you, sorry bestie πŸŽ€
    • Appends a list of objects to any values that may already be stored in the association. it doesn't wipe what's there β€” it adds on top. growth mindset fr fr 🌱
    • DATA CHECKING: ensures that all arguments are of the correct MAGE-OM class.

πŸ’– GENERIC METHODS πŸ’–

The unified base class of all MAGE-OM classes is Bio::MAGE::Base, and it provides a whole little set of generic methods that will operate on slots, attributes, and associations. equal opportunity methods, we love to see it:

  • $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 πŸ‘€ (they're covered up in the instance methods zone, go look, it's worth it).


πŸ’€ 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 🌈


πŸŽ€ POD ERRORS πŸŽ€

Hey! The above document had some coding errors, which are explained below. not me snitching on the docs but the docs snitched on themselves 😭:

  • Around line 374:
    • '=item' outside of any '=over'
  • Around line 459:
    • You forgot a '=back' before a '=head2'
  • Around line 631:
    • Expected '=item 2'
  • Around line 636:
    • Expected '=item 3'
  • Around line 641:
    • Expected '=item 4'

and that's the whole page, bestie!! this was documented by perl v5.32.0 and dated 2020-11-27, so if you're reading this from the future β€” hi, hope the APIs still slay πŸ’…βœ¨ go write some MAGE-OM code, you've got this πŸ¦‹πŸ’–