GO::Model::Term(3pm)

πŸ“¦
version 0.15 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

NAME πŸ’–

GO::Model::Term β€” it's a term, it's a concept, it lives in an ontology. That's the whole vibe. 🧚

(this is the GO::Model::Term(3pm) page, from the User Contributed Perl Documentation, bestie 🫢)


SYNOPSIS ✨

okay so here's the tea, two whole ways to get yourself a Term πŸ‘‘

# From a file
use GO::Parser;
my $parser = new GO::Parser({handler=>'obj'}); # create parser object
$parser->parse("gene_ontology.obo"); # parse file -> objects
my $graph = $parser->handler->graph;  # get L<GO::Model::Graph> object
my $term = $graph->get_term("GO:0001303");   # fetch a term by ID
printf "Term %s %s\n", $term->name, $term->acc;

# From a GO Database (requires go-db-perl)
my apph = GO::AppHandle->connect(-dbname=>$dbname);
my $term = $apph->get_term({acc=>00003677});
printf "Term:%s (%s)\nDefinition:%s\nSynonyms:%s\n",
  $term->name,
  $term->public_acc,
  $term->definition,
  join(", ", @{$term->synonym_list});

lowkey iconic, honestly. like, file route or database route, pick your fighter πŸ’…


DESCRIPTION πŸ¦‹

So this class represents an Ontology term β€” and babes, the same class does process, compartment AND function. one class, three jobs, main character energy fr fr ✨

heads up tho: right now, a Term is not aware of its Relationships. nope. it doesn't know its own lore 😭. if you wanna find out how a term is related to other terms, you gotta go through a GO::Model::Graph object, and that will hand you the GO::Model::Relationship objects. for example:

$rels = $graph->get_parent_relationships($term->acc);

see? graph does the social networking, not the term. periodt πŸ’…


SEE ALSO 🌸

  • GO::Model::Relationship
  • GO::Model::Graph
  • GO::Model::Xref
  • GO::Model::Association

go read those too bestie, they're all in the same friend group 🫢


NOTES πŸ“

Okay so this is the important part, don't scroll past it πŸ™ˆ

Like all the GO::Model::* classes, this one uses accessor methods to get or set the attributes. the rules are simple:

  • call the accessor with no arguments β†’ you get the value
  • pass in an argument β†’ the attribute gets set to that argument

for single-valued attributes it looks like this:

# this sets the value of the attribute
$my_object->attribute_name("my value");

# this gets the value of the attribute
$my_value = $my_object->attribute_name();

and for lists, you pass a reference, bestie:

# this sets the values of the attribute
$my_object->attribute_name(\@my_values);

# this gets the values of the attribute
$my_values = $my_object->attribute_name();
⚠️ also, tiny thing: the original page spells it "attribuet" in that paragraph. we love a typo era πŸ’€ anyway, moving on.

acc πŸ”‘

  • Usage β€” print $term->acc()
  • Alias β€” public_acc
  • Returns β€”
  • Args β€”

accessor: gets/sets the GO ID/accession, as an integer

throws: an exception if you try to pass in a non-integer 🚨 (do NOT do that)

if you wanna use IDs in the format GO:0000nnn, then you use the method public_acc() instead. that's the whole point of the alias, slay πŸ’–


name 🏷️

  • Usage β€” print $term->name;
  • Returns β€”
  • Args β€”

accessor: gets/sets the "name" attribute


subset_list πŸŽ€

  • Usage β€” foreach (@{$term->subset_list || []}) { printf " $_\n" }
  • Returns β€” list of strings
  • Args β€” list of strings [optional]

This is your List of subset Accs for a term ✨

fun fact: Subsets are also known as GO Slims. iykyk 🌈


in_subset πŸ”

  • Usage β€” if ($term->in_subset('goslim_prok');
  • Returns β€” bool
  • Args β€” subset-name str

Tests if the term belongs to a subset. yes/no queen πŸ’…


definition πŸ“–

  • Usage β€” print $term->definition;
  • Returns β€”
  • Args β€”

accessor: gets/sets the "definition" attribute


primary_xref πŸ”—

  • Title β€” primary_xref
  • Usage β€”
  • Function β€”
  • Example β€”
  • Returns β€” GO::Model::Xref
  • Args β€”

The same as acc(), except the ID comes back as a GO::Model::Xref rather than a string. glow up edition ✨


comment πŸ’¬

  • Title β€” comment
  • Usage β€” $obj->comment($newval)
  • Function β€”
  • Example β€”
  • Returns β€” value of comment (a scalar)
  • Args β€” on set, new value (a scalar or undef, optional)

definition_dbxref_list πŸ—‚οΈ

  • Title β€” definition_dbxref_list
  • Usage β€” $obj->definition_dbxref(\@xrefs)
  • Function β€”
  • Example β€”
  • Returns β€” definition_dbxref_list hashlist (of GO::Model::Xref)
  • Args β€” on set, new values (GO::Model::Xref hashlist)

GO::Model::Xref πŸ’œ


add_definition_dbxref βž•

  • Usage : $term->add_definition_dbxref($xref);
  • Args : GO::Term::Xref

GO::Model::Xref πŸ’œ


has_synonym 🀝

  • Usage β€” if ($term->has_synonym("autotrophy") {...}
  • Returns β€” bool
  • Args β€” string

add_synonym πŸ“

  • Usage β€” $term->add_synonym("calcineurin");
  • Usage β€” $term->add_synonym(@synonym_strings);
  • Returns β€”
  • Args β€”

Adds a synonym; loses type information (the synonym type ends up blank). so like, it forgets what kind of synonym it was 😭 keep that in mind bestie.


synonym_list πŸ“‹

  • Usage β€” my $syn_l = $term->synonym_list;
  • Usage β€” $term->synonym_list([$syn1, $syn2]);
  • Returns β€” arrayref
  • Args β€” arrayref [optional]

accessor: gets/sets list of synonyms [array reference]

each synonym is represented as a string β€” so this method loses synonym typing information. If you use it as a setter, it will set the type for each synonym to null. πŸ’€


add_synonym_by_type 🏷️✨

  • Usage β€” $term->add_synonym_by_type('exact', $syn);
  • Returns β€”
  • Args β€”

synonyms_by_type πŸ”Ž

  • Usage β€” $synstrs = $term->synonyms_by_type('exact');
  • Usage β€” $term->synonyms_by_type('exact', \@exact_syns);
  • Returns β€” arrayref of strings
  • Args β€” type string, arrayref of strings [optional]

in getter mode, it gets you a list of synonyms of a particular type πŸ‘‘

in setter mode, it sets a list of synonyms for a particular type πŸ’…


alt_id_list 🧬

  • Usage β€” my $syn_l = $term->alt_id_list;
  • Usage β€” $term->alt_id_list([$syn1, $syn2]);
  • Returns β€” arrayref
  • Args β€” arrayref [optional]

accessor: gets/sets list of synonyms [array reference]

(yeah, the original says "synonyms" here even though it's the alt id list. we don't ask questions, we just report the facts πŸ™ˆ)


add_alt_id βž•πŸ§¬

  • Usage β€” $term->add_alt_id('GO:0000001');
  • Returns β€”
  • Args β€” id string, or list of id strings

namespace (INHERITED) 🧚

  • Usage β€” print $term->namespace(); # getting the type
  • Usage β€” $term->namespace("molecular_function"); # setting the type
  • Alias β€” type
  • Alias β€” term_type
  • Alias β€” category
  • Alias β€” ontology
  • Returns β€” string representing type
  • Args β€” string represnting type [optional]

The OBO namespace for the GO::Model::Term or GO::Model::Relationship ✨

This method is inherited from the superclass, so say thank you to your ancestors 🫢


set_namespace_by_code πŸ”€

  • Usage β€” $term->set_namespace_by_code("P");
  • Returns β€”
  • Args β€” String: M, P or C

Currently the mapping is hardcoded:

('F'=>'molecular_function',
 'P'=>'biological_process',
 'C'=>'cellular_component');

no cap, that's literally baked in πŸ”₯


get_code_from_namespace πŸ”‘

  • Usage β€” $code = $term->get_code_from_namespace;
  • Returns β€” String: M, P or F
  • Args β€” String (if omitted will use current namespace)

Returns the code for the current namespace (or any given namespace if supplied) πŸ’–


add_dbxref βž•πŸ”—

  • Usage : $term->add_dbxref($xref);
  • Args : GO::Term::Xref

GO::Model::Xref πŸ’œ


dbxref_list πŸ—„οΈ

  • Usage : $term->dbxref_list($xref);
  • Args : optional listref of GO::Term::Xref
  • Returns : listref of GO::Term::Xref

accessor: gets/sets list of dbxref [array reference]


is_obsolete πŸ’€

accessor: gets/set obsolete flag [boolean

(yeah the bracket never closes in the original. iconic honestly. it stays.)


is_root πŸ‘‘

accessor: gets/set is_root flag [boolean]


and that's part 1 bestie β€” hold on, there's more coming πŸ’–βœ¨

✨ TERM ASSOCIATION METHODS ✨

okay bestie, this is the part where your term gets a whole social circle πŸ’– every protein that ever said "yeah I'm associated with this" lives down here.


πŸŽ€ association_list

Usage   - $assoc_l = $term->association_list
Returns - arrayref of GO::Model::Association
Args    - arrayref of GO::Model::Association [optional]

accessor energy: gets / sets the list of associations. it's an array reference, obviously πŸ’…

and if this thing is undef, the datasource is gonna get queried for the associations. she goes and fetches. no shame in it.

πŸ’– selected_association_list

Usage   - $assoc_l = $term->selected_association_list
Returns - arrayref of GO::Model::Association
Args    - arrayref of GO::Model::Association [optional]

accessor: gets the list of SELECTED associations, again as an array reference.

heads up: this method is only of use if you're rocking it alongside GO::AppHandle in the go-db-perl distro 🫢

and no, this is not the total list of every association tied to the term. if the term got created via a query on products, then yeah, it'll include those associations. iykyk.

refs: GO::Model::Association ✨

πŸ¦‹ add_association

Usage   - $term->add_association($assoc);
Returns -
Args    - GO::Model::Association

you hand her an association, she adds it. that's the whole vibe.

refs: GO::Model::Association

🌸 add_selected_association

Usage   -
Returns -
Args    -

the docs are giving mystery, but the name is not subtle bestie. it adds a selected association πŸ’…

refs: GO::Model::Association

🧚 association_hash

returns associations as a listref of unique GeneProduct objects. no dupes, she said periodt.

refs: GO::Model::Association

πŸ‘‘ get_all_associations

Usage   - my $al = $term->get_all_associations
Returns - GO::Model::Association list
Args    -

returns all associations for the term and the terms beneath it in the GO DAG. it's giving generational.

same as $apph->get_all_associations($term) ⭐

refs: GO::Model::Association

πŸ”₯ n_associations

Usage   - my $n = $term->n_associations
Returns -
Args    -

it counts. that's it, that's the method πŸ’€

πŸ’œ product_list

Usage   - $prods = $term->product_list
Returns - L<GO::Model::GeneProduct> listref
Args    -

Returns a reference to an array of gene products that are attached directly to this term. direct only, no plus-ones.

(fr fr: if the products have not been fetched, this method will call $term->association_list, cache the results, and use the associations to build the product list. so the next calls of product_list on this term will be faster β€” she learned, she remembered, she slays ✨)

See GO::Model::GeneProduct

🌈 deep_product_list

Usage   -
Returns - GO::Model::GeneProduct listref
Args    -

finds all the products attached to this term and all terms below in the graph. the whole downline showed up to the party πŸŽ‰

refs: GO::Model::GeneProduct

πŸ’… n_deep_products

Usage   - my $count = $term->n_deep_products;
Returns - int
Args    - filter (hashref) - or string "recount"

gets the count for the distinct number of GO::Model::GeneProduct entries annotated at OR BELOW this level. if you already set the filters in GO::AppHandle, then those filters get used when figuring out the count.

Remember bestie: if you did not explicitly set the filters, then the default filter will be used, which is [!IEA] (i.e. curated associations only, see www.geneontology.org for a whole discussion on evidence codes πŸ‘€).

Note: currently only the speciesdb filter is respected. turns out it's very expensive to do the set arithmetic for distinct recursive gene counts with different evidence combinations. but because each product belongs to one speciesdb only, the speciesdb counts are mutually exclusive, which makes this way easier. thank u for your service πŸ™
  # get the number of gene products that have been annotated
  # as transcription factors in worm and fly discounting
  # uncurated automatic annotations
  $apph->filters({evcodes=>["!IEA"], speciesdbs=>["SGD", "FB"]});
  $term = $apph->get_term({name=>"transcription factor"});
  print $term->n_deep_products;

The count will be cached, so if you alter the filter parameters be sure to get a recount like this:

  my $count = $term->n_deep_products("recount");

TODO: make the recount automatic if the filter is changed (not me being patient about this, no ma'am 😭)

PERFORMANCE NOTE 1: When you ask the AppHandle to give you a list of GO::Model::Term objects, it may decide to populate this attribute while it's building the terms in a fast and efficient way. Therefore you should avoid setting the filters after you've created the objects, otherwise it'll have to refetch all these values and slow everything down. don't do that to yourself 🫢

PERFORMANCE NOTE 2: If you're using the SQL GO::AppHandle implementation, then this call will probably involve a query to the gene_produc_count table. and if you populated the database you're using yourself, make sure this table is filled, otherwise this is gonna be one expensive query πŸ’Έ

refs: GO::Model::GeneProduct

πŸ“ n_products

Usage   - as n_deep_products
Returns -
Args    -

see docs for n_deep_products ^^^

gets a count of products AT THIS LEVEL ONLY. no descendants invited, this one's intimate πŸ’…

refs: GO::Model::GeneProduct

🌟 loadtime

Title   : loadtime
Usage   :
Function:
Example :
Returns : time term was loaded into datasource
Args    : none

Returns the time the term was loaded into the datasource. no args, she just tells you when she arrived 🌸


and that's a wrap on the whole page, bestie!! go forth and associate πŸ’– this iconic piece of documentation came from the perl v5.36.0 release, dated 2023-12-18, and it's filed under GO::Model::Term(3pm) β€” give her a lil kiss on the forehead, she earned it πŸŽ€βœ¨

πŸ“¦ where this page comes from