Creating a dynamic page which shows a selection of data from one of the Ensembl databases is fairly straightforward.
package EnsEMBL::Web::Configuration::Gene; use strict; sub modify_tree { my $self = shift; $self->create_node('MyViewName', 'My Possibly Long Title for this View', [], { 'availability' => 'gene', 'concise' => 'My Short Title' } ); } 1;
This will add your view to the bottom of the lefthand menu, and provides a framework to which HTML output components will be attached (see below).
The 'concise' parameter is optional, and is a way of configuring an alternative, short name for your view that will appear in links (e.g. in the lefthand menu).
package EnsEMBL::Mirror::Component::Gene::MyViewImage; use strict; use base qw(EnsEMBL::Web::Component::Gene); sub _init { my $self = shift; $self->cacheable(1); $self->ajaxable(1); $self->configurable(0); } sub content { my $self = shift; ## The web 'object' is a wrapper around the Ensembl API object ## which a) makes the object extensible via plugins and ## b) usually includes methods that munge data into a web-friendly format my $object = $self->object; my $html; # Write your content-generating code here! return $html; } 1;The easiest approach is to look at a page that has a similar display to the one you want, and modify a copy of that code.
$self->create_node('MyViewName', 'My Possibly Long Title for this View', [ myviewimg EnsEMBL::Mirror::Component::Gene::MyViewImage myviewtable EnsEMBL::Mirror::Component::Gene::MyViewTable ], { 'availability' => 'gene', 'concise' => 'My Short Title' } );
You will note that the example in stage 3 has the package name EnsEMBL::Web::Configuration::Gene, while the one in stage 4 is EnsEMBL::Mirror::Component::Gene::MyViewImage.
When writing a plugin for an existing module, use the EnsEMBL::Web namespace.
In this situation the only functions you need to write are ones which replace existing functions, using the same function name (overwriting), or completely new functions (extending).
You do not even need the use base statement.
When writing a plugin for a new module, as in stage 4, use the EnsEMBL::Mirror namespace (where "Mirror" is whatever you've chosen as your plugin's namespace). These modules must be written in their entirety.
If your new components need data that is not already available through the standard Object::Gene module, you can extend the module in the same way as Configuration and Component code:
package EnsEMBL::Web::Object::Gene; use strict; sub my_gene_info { my $self = shift; my $api_obj = $self->Obj; ## Bio::Ensembl::Gene object my $gene_info = {}; ## Make API calls here! foreach my $trans (@{$api_obj->get_all_Transcripts()}) { ... } return $gene_info; } 1;