GBrowse

 view release on metacpan or  search on metacpan

bin/gbrowse_import_ucsc_db.pl  view on Meta::CPAN

sub create_database_dir {
    my ($data_dir,$dsn) = @_;
    my $uid   = $<;
    my ($gid) = $( =~ /^(\d+)/;
    my $dir = "$data_dir/$dsn";
    unless (-d $dir) {
	print STDERR "Creating database directory for $dsn. You may be prompted for your password.\n";
	system "sudo mkdir -p $dir";
    }
    unless (-w $dir) {
	system "sudo chown $uid $dir";
	system "sudo chgrp $gid $dir";
    }
    return $dir;
}

sub create_scaffold_db {
    my ($dir,$dsn) = @_;
    my $path = "$dir/chromosomes";
    mkdir $path unless -e $path;
    open my $db,">$path/chrom_sizes.gff3" or die "$path: $!";

bin/gbrowse_import_ucsc_db.pl  view on Meta::CPAN

	    unless -e "$path/$chr.fa" && -M "$path/chromosomes.fa" > -M "$path/$prefix$chr.fa.gz";
	system $command;
    }
    print STDERR "done\n";

    print STDERR "Creating FASTA index...";
    my $index = Bio::DB::Fasta->new($path) or die "Couldn't create index";
    print "done\n";

    my $wwwuser = GBrowse::ConfigData->config('wwwuser');
    system "sudo chown -R $wwwuser $path";
    return $path;
}

sub create_gene_db {
    my ($dir,$dsn) = @_;
    my $path = "$dir/refGenes";
    mkdir $path unless -e $path;

    my $src_path = "$path/genes.gff3";
    my $db_path = "$path/genes.sqlite";

bin/gbrowse_import_ucsc_db.pl  view on Meta::CPAN

    close $fh2;
}

sub create_writable_file {
    my $file = shift;
    return if -e $file && -w $file;

    my $uid   = $<;
    my ($gid) = $( =~ /^(\d+)/;
    system "sudo touch $file";
    system "sudo chown $uid $file";
    system "sudo chgrp $gid $file";
    system "chmod +w $file";
}

package GFFWriter;

sub new {
    my $class = shift;
    my ($fh,$dsn)  = @_;
    return bless {

bin/gbrowse_metadb_config.pl  view on Meta::CPAN

	$database->do("GRANT ALL PRIVILEGES on $db_name.* TO '$db_user'\@'%' IDENTIFIED BY '$db_pass'")
	    or die DBI->errstr;
    }
}

sub fix_session_permissions {
    print STDERR "Fixing permissions in sessions directory\n";
    my $globals     = Bio::Graphics::Browser2->open_globals;
    my $session_dir = $globals->session_dir;
    my $webuser     = GBrowse::ConfigData->config('wwwuser');
    system "sudo chown -R $webuser $session_dir";
}

sub fix_sqlite_permissions {
    my (undef, $db_name) = $dsn =~ /.*:(database=)?([^;]+)/;
    $db_name ||= "gbrowse_login";

    my ($path) = $dsn =~ /dbname=([^;]+)/i;
    ($path) = $dsn =~ /DBI:SQLite:([^;]+)/i unless $path;
    die "Couldn't figure out location of database index from $dsn" unless $path;

bin/gbrowse_metadb_config.pl  view on Meta::CPAN


    # Check if we need to, to avoid unnecessary printing/sudos.
    unless ($group) {
	print STDERR "Unable to look up group for $user. Will not change ownerships on $path.\n";
	print STDERR "You should do this manually to give the Apache web server read/write access to $path.\n";
	return;
    }

    if (-e $path && $user ne $file_owner) {
	print STDERR "Using sudo to set $path ownership to $user:$group. You may be prompted for your login password now.\n";
	system "sudo chown $user $path" ;
	system "sudo chgrp $group $path";
	system "sudo chmod 0644 $path";
    }
    if (-e $dir && $user ne $dir_owner) {
	print STDERR "Using sudo to set $dir ownership to $user:$group. You may be prompted for your login password now.\n";
	system "sudo chown $user $dir";
	system "sudo chgrp $group $dir";
	system "sudo chmod 0755 $dir";
    }
}

# Create Database() - Creates the database specified (or the default gbrowse_login database).
sub create_mysql_database {
    my (undef, $db_name) = $dsn =~ /.*:(database=)?([^;]+)/;
    $db_name ||= "gbrowse_login";
    unless (DBI->connect($dsn)) {

docs/pod/INSTALL.MacOSX.pod  view on Meta::CPAN

                  --with-unix-socket-path=/usr/local/mysql/run/mysql_socket \
                  --with-mysqld-user=mysql \
                  --with-comment
    % make
    % sudo make install
    % sudo mkdir /usr/local/mysql/run

=item 3. Configure the installation

    % sudo /usr/local/mysql/bin/mysql_install_db --force # create var/ for DBs
    % sudo chown -R mysql /usr/local/mysql/var /usr/local/mysql/run
    % sudo chgrp -R mysql /usr/local/mysql

=back

=item Installing MySQL from a precompiled package

=over 4

=item 1. Download the package from mysql.com

    http://www.mysql.com/downloads/

Find the "standard" release in pkg/dmg form and download it from a
nearby mirror.  Double click the .dmg file and follow the typical
installer instructions.  The package places everything in standard
paths (ie the mysql.sock is found in /etc/).

=item 2. Configure the installation

    % sudo chown -R mysql /usr/local/mysql/data
    % sudo chgrp -R mysql /usr/local/mysql
    % cd /usr/local/mysql
    % sudo ./configure # installs the appropriate databases

=back

=back

=item 4. Starting MySQL

etc/init.d/gbrowse-aws-balancer  view on Meta::CPAN

VERBOSITY=3
NICE=0

COMMAND=$1

if [ -f /etc/default/gbrowse-aws-balancer ]; then
  . /etc/default/gbrowse-aws-balancer
fi

mkdir -p $RUNDIR
chown -R $USER $RUNDIR
mkdir -p $LOGDIR
chown -R $USER $LOGDIR

PID="$RUNDIR/$NAME.pid"
LOG="$LOGDIR/gbrowse_aws_balancer"

case "$COMMAND" in
  start)
	echo "Starting $DESC: $NAME "
	ARGS="--background --conf $CONFFILE --verbosity $VERBOSITY --log $LOG --pid $PID --user $USER --access '$ACCESS_KEY' --secret '$SECRET_KEY'"
	/bin/sh -c "nice -n $NICE $DAEMON $ARGS"
	;;

etc/init.d/gbrowse-slave  view on Meta::CPAN


if [ "$*" != "" ]; then
    PORT=$*
fi

if [ -f $ETC/default/gbrowse-slave ]; then
  . $ETC/default/gbrowse-slave
fi

mkdir -p $RUNDIR
chown -R $USER $RUNDIR
mkdir -p $LOGDIR
chown -R $USER $LOGDIR

case "$COMMAND" in
  start)
	echo -n "Starting $DESC: $NAME "
	for port in $PORT; do
	    if [ -e $RUNDIR/$NAME.$port.pid ] && kill -0 `cat $RUNDIR/$NAME.$port.pid` >/dev/null 2>&1 ; then
		echo "$NAME already running, use restart instead."
	    else
                PRELOAD_DB=""
		if [ "$PRELOAD" != "" ]; then
                    PRELOAD_DB="--preload $PRELOAD"
	        fi
		if [ "$PREFORK" = "" ]; then
                    PREFORK="1"
                fi
		PID="$RUNDIR/$NAME.$port.pid"
		ARGS="--port $port --verbose $VERBOSITY --log $LOGDIR/gbrowse_slave --prefork $PREFORK --pid $PID $PRELOAD_DB"
		/bin/sh -c "nice -n $NICE $DAEMON $ARGS"
		chown $USER $PID
		echo -n "$port "
	    fi
	done
	echo "."
	;;
  stop)
	echo -n "Stopping $DESC: $NAME "
	killed=0
	for port in $PORT; do
	    if test -e $RUNDIR/$NAME.$port.pid ; then

htdocs/tutorial/tutorial.html  view on Meta::CPAN

<p>

Now you will change the permissions of the database and configuration
directories so that you can write to them without root privileges.
This is only an issue on Unix systems, and Windows users can safely
ignore this step.

<blockquote class="example"><pre>
% <b>su</b>
Password: <b>*********</b>
# <b>chown my_user_name /var/lib/gbrowse2/databases</b>
# <b>chown my_user_name /etc/gbrowse2</b>
# <b>exit</b>
%
</pre></blockquote>

<p>

(Be sure to replace "my_user_name" with your login name!)

<p>

install_util/GBrowseInstall.pm  view on Meta::CPAN

    mkpath($tmp);
    
    my ($uid,$gid) = (getpwnam($user))[2,3];

    # taint check issues
    $uid =~ /^(\d+)$/;
    $uid = $1;
    $gid =~ /^(\d+)$/;
    $gid = $1;
    
    unless (chown $uid,$gid,$tmp) {
	$self->ownership_warning($tmp,$user);
    }

    my $htdocs_i = File::Spec->catfile($self->install_path->{htdocs},'i');
    my $images   = File::Spec->catfile($tmp,'images');
    my $gbs_tmp  = File::Spec->catfile($self->install_path->{htdocs},'tmp');
    my $htdocs = $self->install_path->{htdocs};
    chown $uid,-1,$htdocs;
    {
	local $> = $uid;
	symlink($images,$htdocs_i);  # so symlinkifowner match works!
	symlink($tmp,$gbs_tmp);
    }
    chown $>,-1,$self->install_path->{htdocs};

    my $persistent = $self->install_path->{'persistent'};
    my $sessions   = File::Spec->catfile($persistent,'sessions');
    my $userdata   = File::Spec->catfile($persistent,'userdata');
    mkpath([$sessions,$userdata],0711);

    my $databases = $self->install_path->{'databases'};
    
    unless (chown $uid,$gid,glob(File::Spec->catfile($databases,'').'*')) {
	$self->ownership_warning($databases,$user);
    }

    chmod 0755,File::Spec->catfile($self->install_path->{'etc'},'init.d','gbrowse-slave');
    chmod 0755,File::Spec->catfile($self->install_path->{'etc'},'init.d','gbrowse-aws-balancer');
    $self->fix_selinux;

    my $base = basename($self->install_path->{htdocs});

    # Configure the databases, if needed.
    print STDERR "Updating user account database...\n";
    my $metadb_script = File::Spec->catfile("bin", "gbrowse_metadb_config.pl");
    my $perl          = $self->perl;
    my @inc           = map{"-I$_"} split ':',$self->added_to_INC;
    system $perl,@inc,$metadb_script;
    system 'sudo','chown','-R',"$uid.$gid",$sessions,$userdata;

    # make the gbrowse-aws-balancer file, which might contain secret keys, read-only to root
    if ($self->config_data('installetc') =~ /^[yY]/) {
	my $install_path = $self->install_path->{'etc'} || GBrowseGuessDirectories->etc;
	system 'sudo','chmod','go-rwx',File::Spec->catfile($install_path,'default','gbrowse-aws-balancer');
    }

    # enable CGI scripts on 2.4 systems
    if ($self->apache_version =~ /2\.4/) {
	print STDERR "Enabling CGI scripts on your Apache2 system...\n";

install_util/GBrowseInstall.pm  view on Meta::CPAN

                   :$id eq 'site'   ? 'installsitebin'
                   :$id eq 'vendor' ? 'installvendorbin'
		   :'installsitebin';
    return $Config::Config{$scriptdir};
}

sub ownership_warning {
    my $self = shift;
    my ($path,$owner) = @_;
    warn "*** WARNING: Using sudo to change ownership of $path to '$owner'. You may be prompted for your login password ***\n";
    system "sudo chown -R $owner $path";
}

sub cgiurl {
    my $self = shift;
    my $cgibin  = $self->config_data('cgibin');
    (my $cgiurl = $cgibin) =~ s!^.+/cgi-bin!/cgi-bin!;
    $cgiurl =~ s!^.+/CGI-Executables!/cgi-bin!; #Macs and their crazy paths
    return $cgiurl;
}

lib/Bio/Graphics/Browser2/Render/HTML.pm  view on Meta::CPAN

    my $gnome2_dir   = File::Spec->catfile($home,'.gnome2');
    if (-e $inkscape_dir && -w $inkscape_dir
	&&  -e $gnome2_dir   && -w $gnome2_dir) {
	return $CAN_PDF=1;
    } else {
	print STDERR
	    join(' ',
		 qq(GBROWSE NOTICE: To enable PDF generation, please enter the directory "$home"),
		 qq(and run the commands:),
		 qq("sudo mkdir -p .config/inkscape .gnome2"),
		 qq(and "sudo chown $user .config/inkscape .gnome2". ),
		 qq(To turn off this message add "generate pdf = 0"),
		 qq(to the [GENERAL] section of your GBrowse.conf configuration file.)
	    );
	return $CAN_PDF=0;
    }
}

# Truncated version (of track_config) for displaying citation only:
sub display_citation {
    my $self        = shift;

lib/Bio/Graphics/Browser2/Render/Slave/AWS_Balancer.pm  view on Meta::CPAN

    open my $out,'>',"$conf_file.new" or die "Couldn't open $conf_file: $!";
    while (<$in>) {
	chomp;
	s/^(data_snapshots\s*=).*/$1 @snapshot_ids # $timestamp/;
	print $out "$_\n";
    }
    close $in;
    close $out;
    rename "$conf_file","$conf_file.bak" or die "Can't rename $conf_file: $!";
    rename "$conf_file.new","$conf_file" or die "Can't rename $conf_file.new: $!";
    chown $user,$group,$conf_file;
}

#######################
# status
######################

# return true if slave is listening on at least one of the designated ports
sub ping_slave {
    my $self      = shift;
    my $instance  = shift;



( run in 1.671 second using v1.01-cache-2.11-cpan-71847e10f99 )