Bioperl Training Exercise 15

From BITS wiki
Jump to: navigation, search

In this exercise we will refactor the processor modules we have up to now. The idea is make the classes inherit from Bio::Seq::BaseSeqProcessor which in turn is an implementation of Bio::Factory::SequenceProcessorI. Have a look at the docs of that latter module (perldoc or CPAN or bioperl web site). Basically, it allows to create a chain of processors (pipeline). As a result of that every sequence in the stream is processed by every processor in the pipeline. The processing is done in the process_seq() method of every node in the pipeline (and lucky us, we called the processing method in the different modules process_seq already ;-).

Steps to take:

  1. Make sure that the different processor modules BITS::Training::SeqProcessor::* inherit from Bio::Seq::BaseSeqProcessor (we did it before e.g. Bioperl Training Exercise 9)
  2. The constructor is inherited from Bio::Seq::BaseSeqProcessor (the so-called superclass) so in principle we do not need one. However, for some modules we want to pass arguments to the constructor. One solution is to override the constructor. However, you should make sure that the constructor of the superclass is called as well. Without hardcoding the superclass name, this is done by means of the pseudoclass SUPER as such:
my $self = $class->SUPER::new(@args);

The SUPER pseudoclass allows a method to redispatch a call to the next available method in one of its parent classes. This redispatch mechanism works by searching for an inherited method in any of the ancestors of the current package (but not necessarily the invocant's package). See also perldoc perltoot and look for 'superclass';

  1. Refactor the original process_all.pl processing script (Bioperl Training Exercise 14). Set up the processor pipeline.
  2. Remove all explicit process_seq() calls and sit back to watch what happens (it's magic !).