<commit_before>#!/usr/bin/perl -w

use strict;
use CGI;
use CGI::Cookie;
use CGI::Carp 'fatalsToBrowser';
use CGI::Ajax;
use HTML::Template;
use Data::Dumper;
use CoGe::Accessory::LogUser;
use Digest::MD5 qw(md5_base64);
use CoGeX;

use vars qw($USER $FORM $DATE $update $coge);

$ENV{PATH} = "/opt/apache/CoGe";
$FORM = new CGI;
($USER) = CoGe::Accessory::LogUser->get_user();
#print STDERR Dumper $USER->user_name;

$DATE = sprintf( "%04d-%02d-%02d %02d:%02d:%02d",
		 sub { ($_[5]+1900, $_[4]+1, $_[3]),$_[2],$_[1],$_[0] }->(localtime));
my $pj = new CGI::Ajax(
		       gen_html=>\&gen_html,
		       login=>\&login,
		      );
$update =0;
$coge = new CoGeX->dbconnect;
print $pj->build_html($FORM, \&gen_html);
#print gen_html();



sub gen_html
  {
    my $template = HTML::Template->new(filename=>'/opt/apache/CoGe/tmpl/generic_page.tmpl');
    $template->param(TITLE=>'A new kind of Comparative Genomics');
    $template->param(HELP=>'CoGe');

    if ($FORM->param('logout') || !$USER)
      {
	$template->param(USER=>"public");
      }
    else
      {
	my $name = $USER->user_name;
	$name = $USER->first_name if $USER->first_name;
	$name .= " ".$USER->last_name if $USER->first_name && $USER->last_name;
	$template->param(USER=>$name);
	$template->param(LOGON=>1) unless $USER->user_name eq "public";

      }
    $template->param(DATE=>$DATE);
    my $welcome = "Welcome to CoGe!&nbsp&nbsp&nbsp";
    unless ($update)
      {
      	$welcome .= "<span class='species small'>Organisms: ";
	$welcome .= commify($coge->resultset('Organism')->count());
	$welcome .= "&nbsp&nbsp&nbsp&nbsp   Nucleotides: ";
	$welcome .= commify($coge->resultset('GenomicSequence')->count()*10000);
	$welcome .= "</span>";
      }
    $template->param(BOX_NAME=>$welcome);
     $template->param(ADJUST_BOX=>1);
    $template->param(LOGO_PNG=>"CoGe-logo.png");
    $template->param(BODY=>gen_body());

    my $html;
    $html .= $template->output;
    return $html;
  }

sub gen_body
  {
    my $tmpl = HTML::Template->new(filename=>'/opt/apache/CoGe/tmpl/index.tmpl');
    my $html;
    my $disable = 1;
    $disable = 0 if $FORM->param('wheel');
    if ($update)
      {
	$tmpl->param(update=>1);
      }
    elsif ($USER && !$FORM->param('logout') && !$FORM->param('login'))
      {
	if ($disable)
	  {
	    $tmpl->param(DISABLE=>1);
	    $tmpl->param(ACTIONS=>[map {{ACTION=>$_->{ACTION}, DESC=>$_->{DESC}}} sort {$a->{ID} <=> $b->{ID}}@{actions()}  ]);
	  }
	else
	  {
	    $tmpl->param(ANIMATE=>1);
	    $tmpl->param(ACTIONS=>actions());
	  }
	$tmpl->param('INTRO'=>1);
	$tmpl->param('NSF'=>1);
      }
#     else
#       {
# 	$tmpl->param(LOGIN=>1);
 	my $url = $FORM->param('url') if $FORM->param('url');
 	$url =~ s/:::/;/g if $url;
 	$tmpl->param(url=>$url);
#       }

    if ($FORM->param('logout'))
      {
	my $session = md5_base64($USER->user_name.$ENV{REMOTE_ADDR});
	$session =~ s/\+/1/g;
	($session) = $coge->resultset('UserSession')->find({session=>$session});
	$session->delete if $session;
	$tmpl->param(READY=>"delete_cookie();");
	$tmpl->param(LOGIN=>1);
      }
    $tmpl->param(LOGIN=>1) if $FORM->param('login');
    $html .= $tmpl->output;
    return $html;
  }

sub actions
  {
    my @actions = (
		   {
		    ID=>5,
		    LOGO=>qq{<a href="./GEvo.pl"><img src="/CoGe/picts/carousel/GEvo-logo.png" width="227" height="75" border="0"></a>},
		    ACTION=>qq{<a href="./GEvo.pl">GEvo</a>},
		    DESC => qq{Compare sequences and genomic regions to discover patterns of genome evolution.},
		    SCREENSHOT=>qq{<a href="./GEvo.pl"><img src="/CoGe/picts/preview/GEvo.png"border="0"></a>},
		   },
		   {
		    ID=>3,
		    LOGO=>qq{<a href="./FeatView.pl"><img src="/CoGe/picts/carousel/FeatView-logo.png" width="227" height="75" border="0"></a>},
		    ACTION=>qq{<a href="./FeatView.pl">FeatView</a>},
		    DESC => qq{Find and display information about a genomic feature (e.g. gene).},
		    SCREENSHOT=>qq{<a href="./FeatView.pl"><img src="/CoGe/picts/preview/FeatView.png" width="400" height="241" border="0"></a>},
		   },
# 		   {
# 		    ID=>3,
# 		    LOGO=>qq{<a href="./MSAView.pl"><img src="/CoGe/picts/carousel/MSAView-logo.png" width="227" height="75" border="0"></a>},
# 		    ACTION => qq{<a href="./MSAView.pl">MSAView: Multiple Sequence Alignment Viewer</a>},
# 		    DESC   => qq{Allows users to submit a multiple sequence alignment in FASTA format (if people would like additional formats, please request via e-mail) in order to quickly check the alignment, find conserved regions, etc.  This program also generates a consensus sequence from the alignment and displays some basic statistics about the alignment.},
# 		    SCREENSHOT=>qq{<a href="./MSAView.pl"><img src="/CoGe/picts/preview/MSAView.png"border="0"></a>},
# 		   },
# 		   {
# 		    ID=>4,
# 		    LOGO=>qq{<a href="./TreeView.pl"><img src="/CoGe/picts/carousel/TreeView-logo.png" width="227" height="75" border="0"></a>},
# 		    ACTION => qq{<a href="./TreeView.pl">TreeView: Phylogenetic Tree Viewer</a>},
# 		    DESC   => qq{Allows users to submit a tree file and get a graphical view of their tree.  There is support for drawing rooted and unrooted trees, zooming and unzooming functions, and coloring and shaping nodes based on user specifications.},
# 		    SCREENSHOT=>qq{<a href="./FeatView.pl"><img src="/CoGe/picts/preview/TreeView.png"border="0"></a>},
# 		   },
		   {
		    ID=>1,
		    LOGO => qq{<a href="./GenomeView.pl"><img src="/CoGe/picts/carousel/GenomeView-logo.png" width="227" height="75" border="0"></a>},
		    ACTION => qq{<a href="./GenomeView.pl">OrganismView</a>},
		    DESC   => qq{Search for organisms, get an overview of their genomic make-up, and visualize them using a dynamic, interactive genome browser.},
		    SCREENSHOT => qq{<img src="/CoGe/picts/preview/GenomeView.png" border="0"></a>},<commit_msg>updated for new prog name for OrgnaismView<commit_after>#!/usr/bin/perl -w

use strict;
use CGI;
use CGI::Cookie;
use CGI::Carp 'fatalsToBrowser';
use CGI::Ajax;
use HTML::Template;
use Data::Dumper;
use CoGe::Accessory::LogUser;
use Digest::MD5 qw(md5_base64);
use CoGeX;

use vars qw($USER $FORM $DATE $update $coge);

$ENV{PATH} = "/opt/apache/CoGe";
$FORM = new CGI;
($USER) = CoGe::Accessory::LogUser->get_user();
#print STDERR Dumper $USER->user_name;

$DATE = sprintf( "%04d-%02d-%02d %02d:%02d:%02d",
		 sub { ($_[5]+1900, $_[4]+1, $_[3]),$_[2],$_[1],$_[0] }->(localtime));
my $pj = new CGI::Ajax(
		       gen_html=>\&gen_html,
		       login=>\&login,
		      );
$update =0;
$coge = new CoGeX->dbconnect;
print $pj->build_html($FORM, \&gen_html);
#print gen_html();



sub gen_html
  {
    my $template = HTML::Template->new(filename=>'/opt/apache/CoGe/tmpl/generic_page.tmpl');
    $template->param(TITLE=>'A new kind of Comparative Genomics');
    $template->param(HELP=>'CoGe');

    if ($FORM->param('logout') || !$USER)
      {
	$template->param(USER=>"public");
      }
    else
      {
	my $name = $USER->user_name;
	$name = $USER->first_name if $USER->first_name;
	$name .= " ".$USER->last_name if $USER->first_name && $USER->last_name;
	$template->param(USER=>$name);
	$template->param(LOGON=>1) unless $USER->user_name eq "public";

      }
    $template->param(DATE=>$DATE);
    my $welcome = "Welcome to CoGe!&nbsp&nbsp&nbsp";
    unless ($update)
      {
      	$welcome .= "<span class='species small'>Organisms: ";
	$welcome .= commify($coge->resultset('Organism')->count());
	$welcome .= "&nbsp&nbsp&nbsp&nbsp   Nucleotides: ";
	$welcome .= commify($coge->resultset('GenomicSequence')->count()*10000);
	$welcome .= "</span>";
      }
    $template->param(BOX_NAME=>$welcome);
     $template->param(ADJUST_BOX=>1);
    $template->param(LOGO_PNG=>"CoGe-logo.png");
    $template->param(BODY=>gen_body());

    my $html;
    $html .= $template->output;
    return $html;
  }

sub gen_body
  {
    my $tmpl = HTML::Template->new(filename=>'/opt/apache/CoGe/tmpl/index.tmpl');
    my $html;
    my $disable = 1;
    $disable = 0 if $FORM->param('wheel');
    if ($update)
      {
	$tmpl->param(update=>1);
      }
    elsif ($USER && !$FORM->param('logout') && !$FORM->param('login'))
      {
	if ($disable)
	  {
	    $tmpl->param(DISABLE=>1);
	    $tmpl->param(ACTIONS=>[map {{ACTION=>$_->{ACTION}, DESC=>$_->{DESC}}} sort {$a->{ID} <=> $b->{ID}}@{actions()}  ]);
	  }
	else
	  {
	    $tmpl->param(ANIMATE=>1);
	    $tmpl->param(ACTIONS=>actions());
	  }
	$tmpl->param('INTRO'=>1);
	$tmpl->param('NSF'=>1);
      }
#     else
#       {
# 	$tmpl->param(LOGIN=>1);
 	my $url = $FORM->param('url') if $FORM->param('url');
 	$url =~ s/:::/;/g if $url;
 	$tmpl->param(url=>$url);
#       }

    if ($FORM->param('logout'))
      {
	my $session = md5_base64($USER->user_name.$ENV{REMOTE_ADDR});
	$session =~ s/\+/1/g;
	($session) = $coge->resultset('UserSession')->find({session=>$session});
	$session->delete if $session;
	$tmpl->param(READY=>"delete_cookie();");
	$tmpl->param(LOGIN=>1);
      }
    $tmpl->param(LOGIN=>1) if $FORM->param('login');
    $html .= $tmpl->output;
    return $html;
  }

sub actions
  {
    my @actions = (
		   {
		    ID=>5,
		    LOGO=>qq{<a href="./GEvo.pl"><img src="/CoGe/picts/carousel/GEvo-logo.png" width="227" height="75" border="0"></a>},
		    ACTION=>qq{<a href="./GEvo.pl">GEvo</a>},
		    DESC => qq{Compare sequences and genomic regions to discover patterns of genome evolution.},
		    SCREENSHOT=>qq{<a href="./GEvo.pl"><img src="/CoGe/picts/preview/GEvo.png"border="0"></a>},
		   },
		   {
		    ID=>3,
		    LOGO=>qq{<a href="./FeatView.pl"><img src="/CoGe/picts/carousel/FeatView-logo.png" width="227" height="75" border="0"></a>},
		    ACTION=>qq{<a href="./FeatView.pl">FeatView</a>},
		    DESC => qq{Find and display information about a genomic feature (e.g. gene).},
		    SCREENSHOT=>qq{<a href="./FeatView.pl"><img src="/CoGe/picts/preview/FeatView.png" width="400" height="241" border="0"></a>},
		   },
# 		   {
# 		    ID=>3,
# 		    LOGO=>qq{<a href="./MSAView.pl"><img src="/CoGe/picts/carousel/MSAView-logo.png" width="227" height="75" border="0"></a>},
# 		    ACTION => qq{<a href="./MSAView.pl">MSAView: Multiple Sequence Alignment Viewer</a>},
# 		    DESC   => qq{Allows users to submit a multiple sequence alignment in FASTA format (if people would like additional formats, please request via e-mail) in order to quickly check the alignment, find conserved regions, etc.  This program also generates a consensus sequence from the alignment and displays some basic statistics about the alignment.},
# 		    SCREENSHOT=>qq{<a href="./MSAView.pl"><img src="/CoGe/picts/preview/MSAView.png"border="0"></a>},
# 		   },
# 		   {
# 		    ID=>4,
# 		    LOGO=>qq{<a href="./TreeView.pl"><img src="/CoGe/picts/carousel/TreeView-logo.png" width="227" height="75" border="0"></a>},
# 		    ACTION => qq{<a href="./TreeView.pl">TreeView: Phylogenetic Tree Viewer</a>},
# 		    DESC   => qq{Allows users to submit a tree file and get a graphical view of their tree.  There is support for drawing rooted and unrooted trees, zooming and unzooming functions, and coloring and shaping nodes based on user specifications.},
# 		    SCREENSHOT=>qq{<a href="./FeatView.pl"><img src="/CoGe/picts/preview/TreeView.png"border="0"></a>},
# 		   },
		   {
		    ID=>1,
		    LOGO => qq{<a href="./OrganismView.pl"><img src="/CoGe/picts/carousel/OrganismView-logo.png" width="227" height="75" border="0"></a>},
		    ACTION => qq{<a href="./OrganismView.pl">OrganismView</a>},
		    DESC   => qq{Search for organisms, get an overview of their genomic make-up, and visualize them using a dynamic, interactive genome browser.},
		    SCREENSHOT => qq{<img src="/CoGe/picts/preview/OrganismView.png" border="0"></a>},
{'fraction_non_alphanumeric': 0.2152428095928992, 'fraction_numerical': 0.016215754886062986, 'mean_word_length': 3.6629526462395545, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 311, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6220867', 'n_tokens_mistral': 4692, 'n_tokens_neox': 4406, 'n_words': 829}