Homework 2
CS 5046 (Spring 2006)

Assigned on February 15, 2006
Due by 11AM, February 22, 2006
Submit by email to murali AT cs DOT vt DOT edu

Please include "CS 5046 Homework 2" in the subject of the email message.

The aim of this homework is to help you get comfortable with object-oriented programming in Perl. In class, we developed a Network.pm module that contains several methods to read in and process a network of molecular interactions. In Homework 1, you added extra functionality to this module. Start from the module you developed in Homework 1. In this homework, you will modify the module to work in an object-oriented manner. This module will operate on objects belonging to the Network class.
Problem 1
(10 points) Add a constructor called new for the Network class. All the constructor should do is to create an empty instance of the class.
Problem 2
(15 points) Modify the read subroutine so that it operates on an instance of the Network class.
Problem 3
(15 points) Modify all the other subroutines so that they operate on an instance of the Network class.
Problem 4
(25 points) You may have noticed that the version of get_num_interactions from Homework 1 runs much slower when given a scalar argument. The reason is that it has to loop over all the interactions in the network to compute the number of interactions of a particular type. Modify the read method so that for every interaction type, you store the number of interactions of that type with the instance of Network that the read method is operating on.
Problem 5
(35 points) In order to correctly maintain the information you just added in Problem 4, you have to modify other methods in the Network class. Make these modifications. Write comments at the location of these modifications indicating that these are for Problem 5 (so that I know what changes you made for this problem).
Submitting your Homework
  • You can submit one script named network.pl and the Network.pm module that solve all problems. The network.pl script should read in two networks and exercise all the subroutines you have implemented in this homework.
  • Create a directory called <YourName>-Homework2 and put network.pl in that directory. Place Network.pm in the CS5046 subdirectory.
  • Submit your homework by zipping (or tarring and gzipping) the directory and emailing the zipped file to me.
  • Last modified: Wed Apr 11 22:31:24 EDT 2007