GMOD / GBrowse

the Generic Genome Browser

Home Page:http://gmod.org/wiki/GBrowse

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

only first occurrence of a match group parameter is replaced

tolot27 opened this issue · comments

GBrowse allows regular expressions in data source name configurations as described in Using Pipes in the GBrowse.conf Data Source Name

Unfortunately, only the first occurrence of a match group parameter is replaced in the path variable. Consider the following example (slightly modified from the wiki):

[=~modENCODE_preview_v(\d+)]
description = modENCODE preview database
path        = /usr/local/modencode/bin/preview.pl $1 $1 |

Even this case does not make much sense, it shows the problem quit well. If you then request the url http: //your.host/gb2/gbrowse/modENCODE_preview_v42, the path will be created as following:

/usr/local/modencode/bin/preview.pl 42 $1

The second parameter is not replaced by its value.

proposed patch:

diff --git a/lib/Bio/Graphics/Browser2.pm b/lib/Bio/Graphics/Browser2.pm
index d9ee9f7..8062365 100644
--- a/lib/Bio/Graphics/Browser2.pm
+++ b/lib/Bio/Graphics/Browser2.pm
@@ -363,7 +363,7 @@ sub data_source_path {
       my $path = $self->resolve_path($self->setting("=~".$regex_key=>'path'),'config');
       my @matches = ($dsn =~ /$regex_key/);
       for (my $i = 1; $i <= scalar(@matches); $i++) {
-         $path =~ s/\$$i/$matches[$i-1]/;
+         $path =~ s/\$$i/$matches[$i-1]/g;
       }
       return $self->resolve_path($path, 'config');
   }