Skip to content

Commit

Permalink
[Freaky-dev] Added parsing of multiple data sources (SegmentProviders…
Browse files Browse the repository at this point in the history
…) from the .conf files, and added the use of the LocusLinkHugoNormalizer as a hacky replacement for the former _search_keywords method. Actually it can safely be thought of as complementary to that method.
  • Loading branch information
Paul Edlefsen committed Jul 3, 2003
1 parent 9aaab41 commit 720ea37
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 20 deletions.
60 changes: 48 additions & 12 deletions lib/Bio/Graphics/Browser.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Bio::Graphics::Browser;

# $Id: Browser.pm,v 1.51.2.9 2003-07-02 22:33:42 pedlefsen Exp $
# $Id: Browser.pm,v 1.51.2.10 2003-07-03 16:17:31 pedlefsen Exp $
# This package provides methods that support the Generic Genome Browser.
# Its main utility for plugin writers is to access the configuration file information

Expand Down Expand Up @@ -76,10 +76,16 @@ use CGI qw( :standard escape escapeHTML center expires *table *dl *TR *td );
use Cwd;
use vars qw( $SOURCES $DEFAULT_SOURCE );

## TODO: REMOVE. Testing Hugo normalizer.
use Bio::DB::LocusLinkHugoNormalizer;
use vars '$normalizer';
my $normalizer = Bio::DB::LocusLinkHugoNormalizer->new();


## TODO: Document this. Why?
#$ENV{ 'PATH' } = '/bin:/usr/bin:/usr/local/bin';

use constant DEBUG => 0;
use constant DEBUG => 1;
use constant DEBUG_PLUGINS => 0;

# if true, turn on surrounding rectangles for debugging the image map
Expand Down Expand Up @@ -658,7 +664,8 @@ sub gbrowse {
} elsif( !@segments && $page_settings->{ 'name' } ) {
## TODO: Shouldn't this happen in _name2segments?
# try again
$self->_do_keyword_search( $page_settings, \@segments );
## TODO: Put this back.. For now we're using the Hugo normalizer...
#$self->_do_keyword_search( $page_settings, \@segments );
unless( @segments ) {
# last resort
$self->_do_plugin_autofind( $page_settings, $plugins, \@segments );
Expand Down Expand Up @@ -1200,7 +1207,9 @@ sub _html_main_display {
# It's bad if we don't have any segments, but only if they asked for one.
if( ( @$segments == 0 ) &&
( my $name = $settings->{ 'name' } ) ) {
$self->_html_error( $settings, $babelfish->tr( 'NOT_FOUND', $name ) );
unless( $settings->{ '__already_printed_not_found' } ) {
$self->_html_error( $settings, $babelfish->tr( 'NOT_FOUND', $name ) );
}
} elsif( @$segments == 1 ) {
$segment = $segments->[ 0 ];
## TODO: Didn't we already handle this one (segment length short), in gbrowse?
Expand Down Expand Up @@ -1800,7 +1809,21 @@ sub _get_plugins_table_html {
my $source_menu_html = $self->_get_source_menu_html( $settings );
my $plugin_menu_html = $self->_get_plugin_menu_html( $settings, $plugins );

return unless( $source_menu_html || $plugin_menu_html );
unless( $source_menu_html ) {
## We have to say something about the source or else nobody will
## ever know and the next time the user refreshes they'll be
## sorry, and then we'll be sorry, and then sorryness will reign
## supreme. We don't want that.
$source_menu_html =
hidden(
'-name' => 'source',
'-value' => $self->source(),
'-override' => 1
);
unless( $plugin_menu_html ) {
return $source_menu_html;
}
}
return
table(
{ '-border' => 0,
Expand Down Expand Up @@ -2406,7 +2429,7 @@ sub _lookup_segments {
## TODO: Doublecheck this hypothesis!
if( my $name = $settings->{ 'name' } ) {
warn "name = $name" if DEBUG;
@segments = $self->_name2segments( $name );
@segments = $self->_name2segments( $settings, $name );
} elsif( my $seq_id = $settings->{ 'seq_id' } ) {
my @argv = ( '-seq_id' => $seq_id );
if( defined $settings->{ 'start' } ) {
Expand Down Expand Up @@ -2702,6 +2725,7 @@ sub _get_overview_panel_html {
) .
hidden(
'-name' => 'seg_length',
## TODO: There's a problem here with the CompoundSegment returning the wrong abs_range if one of them can ground it on a real segment but others can't.
'-value' => $segment->abs_range()->length(),#$segment->length(),
'-override' => 1
);
Expand Down Expand Up @@ -2972,7 +2996,7 @@ sub _load_uploaded_files {
'-safe' => 1
)->read_config();
## TODO: Note the old parameters. rel2abs was from:
## my $rel2abs = $self->_coordinate_mapper( $segment ) if $segment;
## my $rel2abs = $self->_coordinate_mapper( $settings, $segment ) if $segment;
## and who knows about smart_features...
# my $feature_file = Bio::Graphics::FeatureFile->new(-file => $local_fh,
# -map_coords => $rel2abs,
Expand Down Expand Up @@ -3248,7 +3272,7 @@ sub _html_edit_uploaded_file {

sub _coordinate_mapper {
my $self = shift;
my ( $segment ) = @_;
my ( $settings, $segment ) = @_;

my $seq_id = $segment->seq_id();
my $start = $segment->start();
Expand All @@ -3265,7 +3289,7 @@ sub _coordinate_mapper {
( $_->abs_seq_id() eq $seq_id ) &&
( $_->abs_start() <= $end ) &&
( $_->abs_end() >= $start )
} $self->_name2segments( $refname );
} $self->_name2segments( $settings, $refname );
return unless @segments;
$segments{ $refname } = $segments[ 0 ];
}
Expand Down Expand Up @@ -4280,7 +4304,7 @@ sub _replace_vars_with_vals {
: $1 eq 'end' ? $feature->end()
: $1 eq 'segstart' ? $panel->start()
: $1 eq 'segend' ? $panel->end()
: $1 eq 'alias' ? ( $feature->get_tag_values( 'alias' ) ||
: $1 eq 'alias' ? ( ( $feature->has_tag( 'alias' ) ? $feature->get_tag_values( 'alias' ) : undef ) ||
$feature->display_name() )
: $1
/exg;
Expand Down Expand Up @@ -5162,12 +5186,24 @@ sub _overview_pad {

sub _name2segments {
my $self = shift;
my ( $name ) = @_;
my ( $settings, $name ) = @_;

my $toomany = $self->setting( 'too_many_segments' );
my $max_segment = $self->setting( 'max_segment' );

my ( @segments, $class, $start, $end );
unless( $name =~ /([\w._-]+):(-?[\dkKmM.]+),(-?[\dkKmM.]+)$/ or
$name =~ /([\w._-]+):(-?[\dkKmM,.]+)(?:-|\.\.)(-?[\dkKmM,.]+)$/ ) {
## TODO: REMOVE. Testing Hugo normalizer.
my $location = $normalizer->locate( $name );
if( $location eq 'none' ) {
## TODO: Use the babelfish. Something like 'NOT_FOUND', only, like, different n stuff.
$self->_html_error( $settings, "Gene $name does not have a known location." );
$settings->{ '__already_printed_not_found' } = 1;
} elsif( defined $location ) {
$name = $location;
}
}
if( $name =~ /([\w._-]+):(-?[\dkKmM.]+),(-?[\dkKmM.]+)$/ or
$name =~ /([\w._-]+):(-?[\dkKmM,.]+)(?:-|\.\.)(-?[\dkKmM,.]+)$/ ) {
$name = $1;
Expand Down Expand Up @@ -5430,7 +5466,7 @@ sub _merge_segments_low {

sub _html_error {
my $self = shift;
my $settings = shift;;
my $settings = shift;
my @msg = @_;

warn "@msg" if DEBUG;
Expand Down
14 changes: 9 additions & 5 deletions lib/Bio/Graphics/Browser/Config.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Bio::Graphics::Browser::Config;

# $Id: Config.pm,v 1.1.2.4 2003-07-02 22:33:43 pedlefsen Exp $
# $Id: Config.pm,v 1.1.2.5 2003-07-03 16:17:31 pedlefsen Exp $
# Configuration data for gbrowse.

=head1 NAME
Expand Down Expand Up @@ -441,10 +441,13 @@ sub initialize_segment_providers {
$db_args = $self->get_and_eval( $provider.'db_args' );
$db_user = $self->get_and_eval( $provider.'user' );
$db_pass = $self->get_and_eval( $provider.'pass' );
next unless $db_args;
unless( $db_args ) {
warn "Unable to instantiate $provider: There are no db_args as ${provider}db_args.";
next;
}

unless( eval "require $db_adaptor; 1" ) {
warn $@;
warn "Unable to instantiate $provider: Error in 'require $db_adaptor': $@";
next;
}
my @argv =
Expand Down Expand Up @@ -481,11 +484,12 @@ sub initialize_segment_providers {

my $segment_provider = eval{ $db_adaptor->new( @argv ) };
if( $@ ) {
warn $@;
warn "Unable to instantiate $provider: Error in '$db_adaptor->new( ".
join( ', ', @argv )." )': $@";
next;
}
## TODO: REMOVE
warn "Adding segment provider $segment_provider.\n";
#warn "Adding segment provider $segment_provider.\n";
$self->add_next_provider( $segment_provider );
} # End foreach provider, construct it and add it.
} # initialize_segment_providers(..)
Expand Down
6 changes: 3 additions & 3 deletions lib/Bio/Graphics/Browser/ConfigIO.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Bio::Graphics::Browser::ConfigIO;

# $Id: ConfigIO.pm,v 1.1.2.5 2003-07-02 22:33:43 pedlefsen Exp $
# $Id: ConfigIO.pm,v 1.1.2.6 2003-07-03 16:17:32 pedlefsen Exp $
# This package parses a simple tab-delimited format for features into
# a Config object. It is simpler than GFF, but still has a lot of
# expressive power.
Expand Down Expand Up @@ -443,7 +443,7 @@ sub _parse_line {
} # End if this is a continuation line

if( ( $current_section eq 'general' ) &&
( my ( $label ) = ( $_ =~ /^\s*\<([^\>]+)\>/ ) ) ) {
( my ( $label ) = ( $_ =~ /^\s*\<([^\/][^\>]*)\>/ ) ) ) {
# New segment provider
$label =~ s/\s/_/g; # No whitespace allowed.
## TODO: REMOVE
Expand All @@ -459,7 +459,7 @@ sub _parse_line {
$config->get( '#segment_providers' ) . ' ' . $current_segment_provider
);
}
$parse_state->current_segment_provider( $current_section );
$parse_state->current_segment_provider( $label );
return;
} # End if this is the beginning of a new segment provider definition

Expand Down

0 comments on commit 720ea37

Please sign in to comment.