Archive Ensembl HomeArchive Ensembl Home
Home > Help & Documentation

Installing and Running BioMart within Ensembl

Since the 0.6 version of BioMart, installation within external websites has become much harder as the code is not suited for such integrations without a number of post CVS checkout modifications. These you will find listed at the end.

Modifications to Ensembl code base

To enable BioMart in your checkout - include in your directory the following line (directly above the EnsEMBL::Ensembl plugin line:

'EnsEMBL::Mart' => $SiteDefs::ENSEMBL_SERVERROOT.'/public-plugins/mart',

Considerations when running BioMart within Ensembl

NOTE: We do not run the BioMart application within the same Apache instances as the rest of the Ensembl site AND we use a secondary MySQL server for the BioMart databases.

There are a number of reasons for this - mainly due to the size of the Apache processes Mart produces (these are all 0.5G) and the number of tables in the Mart database. These both have adverse effects on the performance of the Ensembl website, so we have ring-fenced hardware specifically for running BioMart.

One solution is to use a reverse proxy to dispatch in-bound network traffic to a set of servers, while presenting a single interface to the caller (see Apache's mod-proxy documentation), and mod_rewrite to redirect users to the separate Mart machine.

  RewriteEngine     on
  ProxyPreserveHost On

# requests going to the server
  RewriteRule  ^/biomart/(martview.*)      http://your.mart.server/biomart/$1  [P,L]
  RewriteRule  ^/biomart/(martservice.*)   http://your.mart.server/biomart/$1  [P,L]
  RewriteRule  ^/biomart/(martresults.*)   http://your.mart.server/biomart/$1  [P,L]

# requests coming back from server
  ProxyPassReverse  / http://your.mart.server/

If you decide to do this, you also need to:

  • Remove EnsEMBL::Mart from to remove Biomart from the Ensembl Webserver
  • Keep the changes as described below to achieve the Ensembl look'n'feel and temporary file management
  • Copy modules/EnsEMBL/Web/Document/HTML/ to your plugin and comment out the line:
    and the closing curly bracket two lines below it.

Changes to code post CVS checkout


  • Delete the line [TAG:lib] (currently line 16)
  • Replace the following (near line 35)
    foreach(keys %$hash) {
      if($_ eq "background") {
        foreach my $param (keys %{$hash->{$_}}) {
          if($param eq "resultsDir1") {
            $background_dir = $hash->{$_}->{$param};
    ## Let us do a nasty little hack (see to sensbily and
    ## in a working manner allow for heirarchical file saving to stop filesystems
    ## barfing really badly...
    $background_file =~ s/^[\.\\\/]+//;
    use Digest::MD5 qw(md5_hex);
    (my $background_directory = md5_hex($background_file) ) =~ s/^(\w)(\w\w).*$/$1\/$2/;
    my $background_dir = $hash->{'background'}{'resultsDir1'}.'/'.$background_directory.'/';


  • Delete the line [TAG:lib] (currently line 12)


  • Delete the line [TAG:lib] (currently line 26)


  • Replace the colour configuration with:
  • Set the exturl line to your server
  • Set an appropriate results dir: (resultsDir1 ), and set enable = yes
  • Set "subject" to "Your Ensembl BioMart results are ready" and "from" to "no-reply@your.domain.tld"
  • Set "expire" to "12h"


  • Replace
    my $background_file_hash = int(rand($background_file_dirCount)) + 1;
    my $background_file_hash = 1;
    ## Hack (see martresults.PLS) to allow for heirarchical file saving 
    ## to stop filesystems barfing really badly...
    use Digest::MD5 qw(md5_hex);
    use File::Path;
    (my $background_directory = md5_hex( $background_file )) =~ s/^(\w)(\w\w).*$/$1\/$2/;
    $background_file_dir .= $background_directory.'/';
    mkpath( $background_file_dir, 0, 0777 );


Copy the .tt files from public-plugins/mart/templates to biomart-perl/conf/templates/custom.