package LocalDefs;

# $Id: LocalDefs.pm,v 1.4 2001/09/13 09:55:21 mng Exp $

use Exporter;
use vars qw(@ISA @EXPORT);

@ISA = qw(Exporter);
@EXPORT = qw(get_vector_file_fasta
	     get_vector_file_staden);

# Default file locations

my $root = "/usr/local/badger";
my $fasta_vector_dir = "$root/lib/seqs/fasta";
my $staden_vector_dir = "$root/lib/seqs/staden";


{
    my %vector_cache;
    sub get_vector_file {
	my ($vector, $dir) = @_;
	
	unless (%{$vector_cache{$dir}}) {
	    local *DIR;
	    opendir(DIR, $dir)
		|| die "Couldn't read $dir $!\n";
	    while (defined (my $file = readdir DIR)) {
		next unless (-f "$dir/$file");
		my $vec = uc($file);
		$vec =~ s/.SEQ$//;
		$fasta_vector_cache{$dir}->{$vec} = "$dir/$file";
	    }
	    closedir(DIR);
	}

	$vector = uc($vector);
	$vector =~ s/.SEQ$//;

	return $fasta_vector_cache{$dir}->{$vector};
    }
}

sub get_vector_file_fasta {
    my ($vector) = @_;

    return &get_vector_file($vector, $fasta_vector_dir);
}

sub get_vector_file_staden {
    my ($vector) = @_;

    return &get_vector_file($vector, $staden_vector_dir);
}

1;

__END__

=head1 NAME

LocalDefs.pm - Local definitions for caftools etc.

=head1 SYNOPSIS

 use LocalDefs.pm;

 my $puc18_fasta = get_vector_file_fasta("puc18");
 my $m13_staden = get_vector_file_staden("m13mp18");

=head1 DESCRIPTION

LocalDefs.pm is designed as a single place to keep site specific information
for perl caftools (and possibly other packages).  By keeping such information
in one place, porting should be made much easier.

=head2 get_vector_file_fasta($vector)

get_vector_file_fasta returns the location of the fasta representation of the
given vector file.

=head2 get_vector_file_staden($vector)

get_vector_file_staden returns the location of the staden representation of the
given vector file.

=head1 AUTHOR

Rob Davies

=head1 HISTORY

 # $Log: LocalDefs.pm,v $
# Revision 1.4  2001/09/13  09:55:21  mng
# *** empty log message ***
#
# Revision 1.3  2001/09/13  09:52:10  mng
# *** empty log message ***
#
# Revision 1.2  2001/09/13  09:44:52  mng
# Fixed readdir warning.
#
# Revision 1.1  1999/11/15  14:42:58  rmd
# Initial revision
#
