Bioperl Training Exercise 8

From BITS wiki
Jump to: navigation, search
  1. To create a class, build a package
  2. To create a method, write a subroutine
  3. To create an object, bless a referent
  • In other words: create the primer class BITS::Training::Primer with the following methods:
    • new (constructor accepting 1 argument: the primer sequence): returns a reference to the blessed referent. Remark: most say that the constructor returns an object; this is actually a kind of 'shortcut' expression;
    • getSequence: returns the primer nucleotide stretch
    • getLength: return the length of the primer
    • isDegenerate: returns true if the primer contains ambiguous residus.
    • numberOf (takes a single nucleotide as argument; e.g. you should be able to call $primer->numberOf('A').
    • as already mentioned above, use the arrow operator to call a method instead of the 'normal' subroutine call. Remember the Blah->make_noise($noise) call in Bioperl Training Exercise 5 ? The thingy left of the error becomes the first argument ! This thingy might be a package name (aka class) or an object (reference).
  • Make the primer.pl script 'consume' your class. Use the Data::Dumper module to dump the primer container (@primer) to STDERR