Bioperl Training Exercise 9

From BITS wiki
Jump to: navigation, search
  • add getTm() method to BITS::Training::Primer that calculates the Tm for primer less than 14.
    Tm= (wA+xT) * 2 + (yG+zC) * 4
    where w,x,y,z are the number of the bases A,T,G,C in the sequence, respectively (from Marmur,J., and Doty,P. (1962) J Mol Biol 5:109-118


  • create LongPrimer class that inherits from BITS::Training::Primer.
    Check perldoc base ! Do you understand why it is important to use modules with a single package AND have the same name ?
    Edit primer.pl so that the appropriate primer object is created depending on the length of the sequence.

At this moment the BITS::Training::LongPrimer class is not very useful: all methods (including the constructor) are inherited from the parental BITS::Training::Primer class. In other words, you can perfectly create objects of the BITS::Training::LongPrimer class, but they will currently behave exactly the same as BITS::Training::Primer objects.


  • Now, add some BITS::Training::LongPrimer specific functionality by overriding the getTm() method. In OOP this is known as polymorphism, a method with the same name can have different behaviors depending to what class the object belongs.
    For sequences longer than 13 nucleotides, the equation used is
    Tm= 64.9 +41*(yG+zC-16.4)/(wA+xT+yG+zC)
    See Wallace,R.B., Shaffer,J., Murphy,R.F., Bonner,J., Hirose,T., and Itakura,K. (1979) Nucleic Acids Res 6:3543-3557 (Abstract) and Sambrook,J., and Russell,D.W. (2001) Molecular Cloning: A Laboratory Manual. Cold Spring Harbor Laboratory Press; Cold Spring Harbor, NY. (CHSL Press)


  • Make the proper improvements so that the Tm is calculated only once, e.g. not at every call to getTm().


  • Advanced (try out at home). Now the primer object class consumer has to decide which primer class to use, depending on the primer length. This is a job that perfectly can be done with a so called builder pattern.