Thank you for the advice, I've put your piece of script into my getDisplayNames subroutine of my formatter, but unfortunately the main $option loop exists always on the first test (!$option->filter).

I've dive a little further into the BioMart code to see where my filters disappeared, and it seems that's in the /execute/ subroutine of the QueryRunner:

    $self->executionPlan($query);

    my $formatterName = $query->formatter() || 'TSV';
    my $module = "BioMart::Formatter::$formatterName";
    $self->loadModule($module);
    my $formatter = $module->new();

*    $query = $formatter->processQuery($query);

$self->executionPlan($query);# call again as formatter processQuery can
                             # change plan

    my $rtable = $self->_getResultTable($query);

*    if ($query->count){
        $self->set('count',$rtable);
    }
    else{
        $formatter->resultTable($rtable);
        $self->set('formatter',$formatter);
    }

   * they are still there when the processQuery of the formatter is called
   * still there too just after when the executionPlan is call again on
     the query
   * but once the _getResultTable has been called, nothing more ... I
     suspect something in the _processPath of the QueryRunner, but what ?

Thus, to make it works easily, I've modified my code and moved some parts into the processQuery where the filters are still well defined, and I store now values I need for the getDisplayNames into a formatter object attribute created for this purpose.

Thanks

Patrice

On 12/03/2010 10:34 PM, Syed Haider wrote:
Hey Patrice,

look at this piece of code, hope this helps:

foreach my $option(@{$filter->getAllOptions}){
    next if (!$option->filter);
    my $options = $option->filter->getAllOptions;
    my @vals;
    foreach (@$options){
        push @vals,$_->value;
    }
    my @filters = ($option->filter);
    foreach my $filt (@filters) {
        print $filt->name."\t".$filt->displayName;
    }
}




On 30/11/2010 14:26, Patrice Dehais wrote:
Hello

I've a filter which defines a chromosomal region, thus in the marteditor
it has no field, tableConstraint, nor key but a filterList with
appropriate filter list (chr,start,end).
It works fine when I use Web interface of BioMart.
However, I need to retrieve the value of this filter in a homemade
Formatter.
I can retrieve values of all other filters (except this one) using this
script in the getDisplayNames subroutine of the formatter :

      foreach my $f (@{$query->getAllFilters}) {
          foreach my $row (@{$f->getTable->getRows}){
printf STDERR "filter name: %s value= %s\n",$f->name,$row->[0];
          }
      }

Why doesn't it work for this special kind of filter ?

thanks

Patrice




--
Patrice Dehais : INRA - LCG - SIGENAE,
Chemin de Borde-Rouge - Auzeville - BP 52627
31326 Castanet-Tolosan cedex - FRANCE
tel:   +33(0)5.61.28.57.08 fax:   +33(0)5.61.28.53.08
http://www.sigenae.org

Reply via email to