<commit_before>#! /usr/bin/perl -w
use strict;
use CGI;
use CGI::Ajax;
use CoGe::Accessory::LogUser;
use CoGe::Accessory::Web;
use HTML::Template;
use Text::Wrap qw($columns &wrap);
use Data::Dumper;
use LWP::Simple;
use LWP::Simple::Post qw(post post_xml);
use URI::Escape;
use CoGeX;
use POSIX;
use Digest::MD5 qw(md5_hex);
use DBIxProfiler;
use File::Temp;
use File::Basename;
use CoGe::Accessory::blast_report;
use CoGe::Accessory::blastz_report;
use CoGe::Graphics::GenomeView;
use CoGe::Graphics;
use CoGe::Graphics::Chromosome;
use CoGe::Graphics::Feature::HSP;
use Spreadsheet::WriteExcel;
use Benchmark qw(:all);
use Parallel::ForkManager;

$ENV{PATH} = "/opt/apache/CoGe/";
$ENV{BLASTDB}="/opt/apache/CoGe/data/blast/db/";
$ENV{BLASTMAT}="/opt/apache/CoGe/data/blast/matrix/";
use vars qw( $PAGE_NAME $TEMPDIR $TEMPURL $DATADIR $FASTADIR $BLASTDBDIR $FORMATDB $BLAST $BLASTZ $FORM $USER $DATE $coge $cogeweb $RESULTSLIMIT $MAX_PROC $connstr);
#refresh again?
$PAGE_NAME = "CoGeBlast.pl";
$TEMPDIR = "/opt/apache/CoGe/tmp/CoGeBlast";
$DATADIR = "/opt/apache/CoGe/data/";
$FASTADIR = $DATADIR.'/fasta/';
$BLASTDBDIR = $DATADIR.'/blast/db/';
$TEMPURL = "/CoGe/tmp/CoGeBlast";
$FORMATDB = "/usr/bin/formatdb";
$BLAST = "/usr/bin/blast -a 8 -K 100";
$BLASTZ = "/usr/bin/blastz";
$RESULTSLIMIT=100;
$MAX_PROC=8;

$DATE = sprintf( "%04d-%02d-%02d %02d:%02d:%02d",
		sub { ($_[5]+1900, $_[4]+1, $_[3]),$_[2],$_[1],$_[0] }->(localtime));
($USER) = CoGe::Accessory::LogUser->get_user();
$FORM = new CGI;
my %ajax = CoGe::Accessory::Web::ajax_func();

$coge = CoGeX->dbconnect();
#$coge->storage->debugobj(new DBIxProfiler());
#$coge->storage->debug(1);


my $pj = new CGI::Ajax(
		       gen_html=>\&gen_html,
		       source_search=>\&get_data_source_info_for_accn,
		       get_types=>\&get_types,
		       get_sequence=>\&get_sequence,
		       get_url=>\&get_url,
		       check_seq=>\&check_seq,
		       set_seq=>\&set_seq,
		       blast_param=>\&blast_param,
		       database_param=>\&database_param,
		       get_orgs=>\&get_orgs,
		       gen_dsg_menu=>\&gen_dsg_menu,
		       blast_search=>\&blast_search,
		       generate_feat_info=>\&generate_feat_info,
		       get_hsp_info=>\&get_hsp_info,
		       generate_overview_image=>\&generate_overview_image,
		       overlap_feats_parse=>\&overlap_feats_parse,
		       get_nearby_feats=>\&get_nearby_feats,
		       export_fasta_file=>\&export_fasta_file,
		       export_to_excel=>\&export_to_excel,
		       generate_tab_deliminated=>\&generate_tab_deliminated,
		       generate_feat_list=>\&generate_feat_list,
		       generate_blast=>\&generate_blast,
		       export_hsp_info=>\&export_hsp_info,
		       export_hsp_query_fasta=>\&export_hsp_query_fasta,
		       export_hsp_subject_fasta=>\&export_hsp_subject_fasta,
		       export_alignment_file=>\&export_alignment_file,
		       save_settings_cogeblast=>\&save_settings_cogeblast,
		       generate_basefile=>\&generate_basefile,
		       get_genome_info=>\&get_genome_info,
		       get_dsg_for_blast_menu=>\&get_dsg_for_blast_menu,
		       %ajax,
		      );
$pj->js_encode_function('escape');
print $pj->build_html($FORM, \&gen_html);
#print $FORM->header;
#print gen_html();


sub gen_html
  {
    my $html;
    unless ($USER)
      {
	$html = login();
      }
    else
     {
    my ($body) = gen_body();
    my $template = HTML::Template->new(filename=>'/opt/apache/CoGe/tmpl/generic_page.tmpl');
    $template->param(TITLE=>'CoGe BLAST Analysis');
    $template->param(PAGE_TITLE=>'BLAST');
    $template->param(HELP=>'CoGeBlast');
    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);
    $template->param(LOGO_PNG=>"CoGeBlast-logo.png");
    $template->param(BOX_NAME=>'CoGeBlast Settings');
    $template->param(ADJUST_BOX=>1);
    $template->param(BODY=>$body);
    my $prebox = HTML::Template->new(filename=>'/opt/apache/CoGe/tmpl/CoGeBlast.tmpl');
	$prebox->param(RESULTS_DIV=>1);
	$template->param(PREBOX=>$prebox->output);
    $html .= $template->output;
    }
  }

sub gen_body<commit_msg>updated link to help page<commit_after>#! /usr/bin/perl -w
use strict;
use CGI;
use CGI::Ajax;
use CoGe::Accessory::LogUser;
use CoGe::Accessory::Web;
use HTML::Template;
use Text::Wrap qw($columns &wrap);
use Data::Dumper;
use LWP::Simple;
use LWP::Simple::Post qw(post post_xml);
use URI::Escape;
use CoGeX;
use POSIX;
use Digest::MD5 qw(md5_hex);
use DBIxProfiler;
use File::Temp;
use File::Basename;
use CoGe::Accessory::blast_report;
use CoGe::Accessory::blastz_report;
use CoGe::Graphics::GenomeView;
use CoGe::Graphics;
use CoGe::Graphics::Chromosome;
use CoGe::Graphics::Feature::HSP;
use Spreadsheet::WriteExcel;
use Benchmark qw(:all);
use Parallel::ForkManager;

$ENV{PATH} = "/opt/apache/CoGe/";
$ENV{BLASTDB}="/opt/apache/CoGe/data/blast/db/";
$ENV{BLASTMAT}="/opt/apache/CoGe/data/blast/matrix/";
use vars qw( $PAGE_NAME $TEMPDIR $TEMPURL $DATADIR $FASTADIR $BLASTDBDIR $FORMATDB $BLAST $BLASTZ $FORM $USER $DATE $coge $cogeweb $RESULTSLIMIT $MAX_PROC $connstr);
#refresh again?
$PAGE_NAME = "CoGeBlast.pl";
$TEMPDIR = "/opt/apache/CoGe/tmp/CoGeBlast";
$DATADIR = "/opt/apache/CoGe/data/";
$FASTADIR = $DATADIR.'/fasta/';
$BLASTDBDIR = $DATADIR.'/blast/db/';
$TEMPURL = "/CoGe/tmp/CoGeBlast";
$FORMATDB = "/usr/bin/formatdb";
$BLAST = "/usr/bin/blast -a 8 -K 100";
$BLASTZ = "/usr/bin/blastz";
$RESULTSLIMIT=100;
$MAX_PROC=8;

$DATE = sprintf( "%04d-%02d-%02d %02d:%02d:%02d",
		sub { ($_[5]+1900, $_[4]+1, $_[3]),$_[2],$_[1],$_[0] }->(localtime));
($USER) = CoGe::Accessory::LogUser->get_user();
$FORM = new CGI;
my %ajax = CoGe::Accessory::Web::ajax_func();

$coge = CoGeX->dbconnect();
#$coge->storage->debugobj(new DBIxProfiler());
#$coge->storage->debug(1);


my $pj = new CGI::Ajax(
		       gen_html=>\&gen_html,
		       source_search=>\&get_data_source_info_for_accn,
		       get_types=>\&get_types,
		       get_sequence=>\&get_sequence,
		       get_url=>\&get_url,
		       check_seq=>\&check_seq,
		       set_seq=>\&set_seq,
		       blast_param=>\&blast_param,
		       database_param=>\&database_param,
		       get_orgs=>\&get_orgs,
		       gen_dsg_menu=>\&gen_dsg_menu,
		       blast_search=>\&blast_search,
		       generate_feat_info=>\&generate_feat_info,
		       get_hsp_info=>\&get_hsp_info,
		       generate_overview_image=>\&generate_overview_image,
		       overlap_feats_parse=>\&overlap_feats_parse,
		       get_nearby_feats=>\&get_nearby_feats,
		       export_fasta_file=>\&export_fasta_file,
		       export_to_excel=>\&export_to_excel,
		       generate_tab_deliminated=>\&generate_tab_deliminated,
		       generate_feat_list=>\&generate_feat_list,
		       generate_blast=>\&generate_blast,
		       export_hsp_info=>\&export_hsp_info,
		       export_hsp_query_fasta=>\&export_hsp_query_fasta,
		       export_hsp_subject_fasta=>\&export_hsp_subject_fasta,
		       export_alignment_file=>\&export_alignment_file,
		       save_settings_cogeblast=>\&save_settings_cogeblast,
		       generate_basefile=>\&generate_basefile,
		       get_genome_info=>\&get_genome_info,
		       get_dsg_for_blast_menu=>\&get_dsg_for_blast_menu,
		       %ajax,
		      );
$pj->js_encode_function('escape');
print $pj->build_html($FORM, \&gen_html);
#print $FORM->header;
#print gen_html();


sub gen_html
  {
    my $html;
    unless ($USER)
      {
	$html = login();
      }
    else
     {
    my ($body) = gen_body();
    my $template = HTML::Template->new(filename=>'/opt/apache/CoGe/tmpl/generic_page.tmpl');
    $template->param(TITLE=>'CoGe BLAST Analysis');
    $template->param(PAGE_TITLE=>'BLAST');
    $template->param(HELP=>'/wiki/index.php?title=CoGeBlast');
    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);
    $template->param(LOGO_PNG=>"CoGeBlast-logo.png");
    $template->param(BOX_NAME=>'CoGeBlast Settings');
    $template->param(ADJUST_BOX=>1);
    $template->param(BODY=>$body);
    my $prebox = HTML::Template->new(filename=>'/opt/apache/CoGe/tmpl/CoGeBlast.tmpl');
	$prebox->param(RESULTS_DIV=>1);
	$template->param(PREBOX=>$prebox->output);
    $html .= $template->output;
    }
  }

sub gen_body
{'fraction_non_alphanumeric': 0.17735191637630662, 'fraction_numerical': 0.008594657375145181, 'mean_word_length': 4.2442143727162, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 157, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6390295', 'n_tokens_mistral': 3552, 'n_tokens_neox': 3324, 'n_words': 461}