Assigned on March 13, 2007
Due by 11AM, March 20, 2007
Submit by email to murali AT cs DOT vt DOT edu
This homework will give you practice in automating class
creation using the Class::Struct package. We will do so in
the context of parsing an ``OBO'' file that specifies the terms
in the Gene Ontology and their relationships with each other.
Problem 1
(15 points) Add a method called definition
to the GO::Term class to store the definition of
each GO term. This information is provided in the file in the lines
starting with the string ``def''.
Problem 2
(40 points) Implement two
new methods called get_num_parents and get_parents in
the GO::Term class. A parent of a term
t is another term u such that tis_au (i.e., the line "is_a: u" appears in the definition of
t) or t is part_ofu (i.e., the line
"relationship: part_of u" appears in the definition of t). Note the word
``or'' in the definition of ``parent.'' The method
get_num_parents returns the number of parents of a term. The
method get_parents returns a reference to an array containing
the identifiers (and no other information) of the parents of the term.
Problem 3
(45 points) Implement a new class called GO::Ontology
that stores all the instances of GO::Term created.
(We have already created much of this class during the lectures.)
This class should contain the following methods:
terms
Use this method to store a term created by the read
method in a hash. The keys of the hash are GO identifiers (e.g., ``GO:0000001'')
and the values are references to instances of the CS5046::GO::Term
class.
read
This method takes a single parameter, which is a file specifying
the structure of the Gene Ontology (e.g., gene_ontology.obo),
and parses this file. The class should use the terms method
to store terms.
get_grandparents
This method takes a single parameter, which
is an identifier for a GO term. It returns a reference to an array
containing the identifiers of the grandparents of the term. A grandparent
of a term is any parent of a parent of a term. In a comment at the
beginning of the method, tell me whether you added any fields
to the definition of the GO::Term and the GO::Ontology
classes to solve this problem.
Write a test script called go.pl that uses these
methods and tests that they are working correctly.
Submitting your Homework
You should only use Class::Struct to implement classes.
You may modify the GO::Term and the GO::Ontology
classes we implemented during the lectures. Keep in mind that the
implementation may not parse lines correctly. You will have to fix the
parser, if necessary.
I will check your code for proper use of the principles of object
oriented programming. You should make sure that you invoke each method
using the arrow operator. I will penalise your solution if it does
not use the principles we have discussed in class.
Make sure the script is executable by changing its executable bit
(chmod u+x go.pl).
Create a directory called <YourName>-Homework3 and put go.pl
and the module in that directory. Make sure that the module is placed
in the correct sub-directories.
Submit your homework by zipping (or tarring and
gzipping) the directory and emailing the zipped file to me.