# $Id: AcidConfig.pm,v 1.1 2004/11/15 14:23:01 jari Exp $

use strict;

package AcidConfig;

# Change configuration parameters below to fit your needs.

# Set these 'use lib' statements to point to the location of the ACID
# Perl modules.
use lib "/path/to/acid/src";
use lib "/path/to/acid/src/web";

# Set this to 0 if you want to peform a production run, in contrast to
# a test run. The difference is that a production run will actually
# download the latest data from the appropriate servers on the
# Internet. A test run will use the datafiles found in the testdata
# directory in the acid CVS.
my $test_run=0;

# Points at the location of the test data set
my $test_data_dir="/path/to/acid/testdata/";

# Define the acid database to use in test runs.
my $test_acid_db="test_db_name";

# Define the acid database to use in production runs.
my $acid_db="db_name";

# You must set up acid database connection information depending on
# how you run the acid programs against the (acid) mysql
# engine. Connection to mysql can be done using ssh tunneling or
# without. So we start by defining whether ssh tunneling is used
# to connect to the acid database, set $acid_ssh to 1 if tunneling is
# used, 0 otherwise.
my $acid_ssh=1;
# You need to define ports used in ssh tunneling, if you are not using
# ssh tunneling you can leave the the next few lines untouched. Note,
# if the acid and genome engines (and you use ssh to connect to both
# databases) are running on different hosts you must use different
# ports for the tunneling since two separate ssh tunnels must be set
# up.
my $acid_ssh_localport="3307";
my $acid_ssh_remoteport="3306";
# Further setup is needed for ssh tunneling
my $acid_ssh_user="userid_here";

# Host name of the machine running the (acid) mysql engine. Use
# localhost for engines on the local machine.
my $acid_mysqlhost="hostname.domainname";

# The acid administrator user name. This user is created when the acid
# database is created and used later in when running database updates.
my $acid_adminid="userid_here";

# The acid user name. This user is created then the acid database is
# created and is later only allowed to do selects on the acid database
# tables, and has by default an empty password. If you prefer to use a
# password you can set it below.
my $acid_userid="userid_here";
my $acid_userpassword="password_here";

# You must set up genome database connection information depending on
# how you run the acid programs against the (genome) mysql engine.
# Connection to mysql can be done using ssh tunneling or without. So
# we start by defining whether ssh tunneling is used to connect to the
# genome database, set $genome_ssh to 1 if tunneling is used, 0
# otherwise.
my $genome_ssh=1;
# You need to define ports used in ssh tunneling, if you are not using
# ssh tunneling you can leave the the next few lines untouched. Note,
# if the acid and genome engines (and you use ssh to connect to both
# databases) are running on different hosts you must use different
# ports for the tunneling since two separate ssh tunnels must be set
# up.
my $genome_ssh_localport="3305";
my $genome_ssh_remoteport="3306";
# Further setup is needed if you use ssh tunneling
my $genome_ssh_user="userid_here";

# Host name of the machine running the (genome) mysql engine. Use
# localhost for engines on the local machine.
my $genome_mysqlhost="hostname.domainname";

# The UCSC genome browser database user name. This user only needs
# permission to do selects on the genome database tables. Note that
# this user is not created but rather should be setup ny the genome
# browser maintainer.
my $genome_userid="userid_here";
my $genome_userpassword="password_here";

# Change the hash to point at the genome database you want to use
my %genome_db=( Hs => 'hg17',
		Mm => 'mm5',
		Rn => 'rn3' );

# where to store [huge] temporary files
my $tmp_dir="/path/to/tmpdir/";

# ssh command to use
my $ssh_cmd="ssh";
# ssh options to use
my $ssh_options="-2 -N -f -L";

# Do not change anything below this line.

sub acid_adminid() {
    return $acid_adminid;
}

sub acid_connection() {
    return ( "DBI:mysql:" . ( test() ? $test_acid_db : $acid_db ) . ":" .
	     ( $acid_ssh ? "127.0.0.1:$acid_ssh_localport" : $acid_mysqlhost) );
}

sub acid_userpassword() {
    return $acid_userpassword;
}

sub acid_userid() {
    return $acid_userid;
}

sub genome_db_name($) {
    if (exists($genome_db{$_[1]})) {
	return $genome_db{$_[1]};
    }
    return "";
}

sub genome_connection($) {
    return ("DBI:mysql:" . AcidConfig->genome_db_name($_[1]) . ":" .
	    ($genome_ssh?"127.0.0.1:$genome_ssh_localport":$genome_mysqlhost));
}

sub genome_userid() {
    return $genome_userid;
}

sub genome_userpassword() {
    return $genome_userpassword;
}

sub ssh() {
    return ($acid_ssh || $genome_ssh);
}

sub ssh_cmd() {
    return "$ssh_cmd $ssh_options";
}

sub ssh_localport($) {
    my $db=$_[1];
    return (($db eq "acid") ? $acid_ssh_localport : $genome_ssh_localport);
}

sub mysqlhost($) {
    my $db=$_[1];
    return (($db eq "acid") ? $acid_mysqlhost : $genome_mysqlhost);
}

sub ssh_remoteport() {
    my $db=$_[1];
    return (($db eq "acid") ? $acid_ssh_remoteport : $genome_ssh_remoteport);
}

sub ssh_user() {
    my $db=$_[1];
    return (($db eq "acid") ? $acid_ssh_user : $genome_ssh_user);
}

sub test() {
    return $test_run;
}

sub test_data_dir() {
    return $test_data_dir;
}

sub tmp_dir() {
    return $tmp_dir;
}

1;
