<commit_before>#!/bin/perl
# 1st Feb 2011
# Generate an HTML documentation page from an SQL file.
#
# It needs to have a "javascript like" documentation above each table. e.g.:
####################################################################################
#/**
#@table variation

#@desc This is the schema's generic representation of a variation.

#@colour #FF0000

#@column variation_id				Primary key, internal identifier.
#@column source_id					Foreign key references to the @link source table.
#@column name								Name of the variation. e.g. "rs1333049".
#@column validation_status	Variant discovery method and validation from dbSNP.
#@column ancestral_allele		Taken from dbSNP to show ancestral allele for the variation.
#@column flipped						This is set to 1 if the variant is flipped.
#@column class_so_id				Class of the variation, based on the Sequence Ontology.

#@see variation_synonym
#@see flanking_sequence
#@see failed_variation
#@see variation_feature
#@see variation_group_variation
#@see allele
#@see allele_group_allele
#@see individual_genotype_multiple_bp
#*/
#
#
#create table variation (
#		variation_id int(10) unsigned not null auto_increment, # PK
#		source_id int(10) unsigned not null, 
#		name varchar(255),
#		validation_status SET('cluster','freq','submitter','doublehit','hapmap','1000Genome','failed','precious'),
#		ancestral_allele text,
#		flipped tinyint(1) unsigned NULL DEFAULT NULL,
#		class_so_id ENUM('SO:0001483','SO:1000002','SO:0000667') DEFAULT 'SO:0001059', # default to sequence_alteration
#
#		primary key( variation_id ),
#		unique ( name ),
#		key source_idx (source_id)
#);
#
#/**
#@legend #FF0000 Table storing variation data
#*/
#
########################################################################################
# Tags description:
# /** and */ : begin and end of the document block
# @header    : tag to create a group of tables
# @table     : name of the sql table
# @desc      : description of the role/content of the table, set or info tags
# @colour    : tag to colour the header of the table (e.g. if the tables are coloured in the graphic SQL schema and you want to reproduce it in the HTML version)
# @column    : column_name [tab(s)] Column description. Note: 1 ligne = 1 column
# @see       : tables names linked to the described table
# @link      : Internal link to an other table description. The format is ... @link table_name ...
# @info      : tag to describe additional information about a table or a set of tables
# @legend    : tag to fill the colour legend table at the end of the HTML page

use strict;
use POSIX;
use Getopt::Long;

###############
### Options ###
###############
my ($sql_file,$html_file,$db_team,$show_colour,$header_flag,$sort_headers,$sort_tables,$help);

usage() if (!scalar(@ARGV));
 
GetOptions(
    'i=s' => \$sql_file,
    'o=s' => \$html_file,
		'd=s' => \$db_team,
		'c=i' => \$show_colour,
    'show_header=i' => \$header_flag,
		'sort_headers=i' => \$sort_headers,
    'sort_tables=i' => \$sort_tables,
		'help!' => \$help
);

usage() if ($help);

if (!$sql_file) {
	print "> Error! Please give a sql file using the option '-i' \n";
	usage();
}
if (!$html_file) {
	print "> Error! Please give an output file using the option '-o'\n";
	usage();
}

$show_colour  = 1 if (!defined($show_colour));
$header_flag  = 1 if (!defined($header_flag));
$sort_headers = 1 if (!defined($sort_headers));
$sort_tables  = 1 if (!defined($sort_tables));


##############
### Header ###
##############
my $html_header = qq{
<html>
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />
<title>$db_team Schema Documentation</title>

<script language="Javascript" type="text/javascript">
	// Function to show/hide the columns table
	function show_hide (param) {
		div   = document.getElementById('div_'+param);
		alink = document.getElementById('a_'+param);
		if (div.style.display=='inline') {
			div.style.display='none';
			alink.innerHTML='Show';
		}
		else {
			if (div.style.display=='none') {
				div.style.display='inline';
				alink.innerHTML='Hide';
			}
		}
	}
	
	// Function to show/hide all the tables
	function show_hide_all () {
		expand_flag = document.getElementById('expand');
		divs = document.getElementsByTagName('div');
		for(var i=0; i < divs.length; i++){
			param = divs[i].id.substring(4);
			div   = document.getElementById('div_'+param);
		  alink = document.getElementById('a_'+param);
			
			if (expand_flag.value=='0') {
				div.style.display='inline';
				alink.innerHTML='Hide';
			}
			else {
				div.style.display='none';
				alink.innerHTML='Show';
			}
		}
		if (expand_flag.value=='0') {
			expand_flag.value='1';
		}
		else {
			expand_flag.value='0';
		}
	}
</script>

</head>

<body>
<h1>Ensembl $db_team Schema Documentation</h1>

<h2>Introduction</h2>

<p><i>
&lt;please, insert your introduction here&gt;
</i></p>
<br />
};


##############
### Footer  ##<commit_msg>Fixed the fix when the html page is included into the ensembl website<commit_after>#!/bin/perl
# 1st Feb 2011
# Generate an HTML documentation page from an SQL file.
#
# It needs to have a "javascript like" documentation above each table. e.g.:
####################################################################################
#/**
#@table variation

#@desc This is the schema's generic representation of a variation.

#@colour #FF0000

#@column variation_id				Primary key, internal identifier.
#@column source_id					Foreign key references to the @link source table.
#@column name								Name of the variation. e.g. "rs1333049".
#@column validation_status	Variant discovery method and validation from dbSNP.
#@column ancestral_allele		Taken from dbSNP to show ancestral allele for the variation.
#@column flipped						This is set to 1 if the variant is flipped.
#@column class_so_id				Class of the variation, based on the Sequence Ontology.

#@see variation_synonym
#@see flanking_sequence
#@see failed_variation
#@see variation_feature
#@see variation_group_variation
#@see allele
#@see allele_group_allele
#@see individual_genotype_multiple_bp
#*/
#
#
#create table variation (
#		variation_id int(10) unsigned not null auto_increment, # PK
#		source_id int(10) unsigned not null, 
#		name varchar(255),
#		validation_status SET('cluster','freq','submitter','doublehit','hapmap','1000Genome','failed','precious'),
#		ancestral_allele text,
#		flipped tinyint(1) unsigned NULL DEFAULT NULL,
#		class_so_id ENUM('SO:0001483','SO:1000002','SO:0000667') DEFAULT 'SO:0001059', # default to sequence_alteration
#
#		primary key( variation_id ),
#		unique ( name ),
#		key source_idx (source_id)
#);
#
#/**
#@legend #FF0000 Table storing variation data
#*/
#
########################################################################################
# Tags description:
# /** and */ : begin and end of the document block
# @header    : tag to create a group of tables
# @table     : name of the sql table
# @desc      : description of the role/content of the table, set or info tags
# @colour    : tag to colour the header of the table (e.g. if the tables are coloured in the graphic SQL schema and you want to reproduce it in the HTML version)
# @column    : column_name [tab(s)] Column description. Note: 1 ligne = 1 column
# @see       : tables names linked to the described table
# @link      : Internal link to an other table description. The format is ... @link table_name ...
# @info      : tag to describe additional information about a table or a set of tables
# @legend    : tag to fill the colour legend table at the end of the HTML page

use strict;
use POSIX;
use Getopt::Long;

###############
### Options ###
###############
my ($sql_file,$html_file,$db_team,$show_colour,$header_flag,$sort_headers,$sort_tables,$help);

usage() if (!scalar(@ARGV));
 
GetOptions(
    'i=s' => \$sql_file,
    'o=s' => \$html_file,
		'd=s' => \$db_team,
		'c=i' => \$show_colour,
    'show_header=i' => \$header_flag,
		'sort_headers=i' => \$sort_headers,
    'sort_tables=i' => \$sort_tables,
		'help!' => \$help
);

usage() if ($help);

if (!$sql_file) {
	print "> Error! Please give a sql file using the option '-i' \n";
	usage();
}
if (!$html_file) {
	print "> Error! Please give an output file using the option '-o'\n";
	usage();
}

$show_colour  = 1 if (!defined($show_colour));
$header_flag  = 1 if (!defined($header_flag));
$sort_headers = 1 if (!defined($sort_headers));
$sort_tables  = 1 if (!defined($sort_tables));


##############
### Header ###
##############
my $html_header = qq{
<html>
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />
<title>$db_team Schema Documentation</title>

<script language="Javascript" type="text/javascript">
	// Function to show/hide the columns table
	function show_hide (param) {
		div   = document.getElementById('div_'+param);
		alink = document.getElementById('a_'+param);
		if (div.style.display=='inline') {
			div.style.display='none';
			alink.innerHTML='Show';
		}
		else {
			if (div.style.display=='none') {
				div.style.display='inline';
				alink.innerHTML='Hide';
			}
		}
	}
	
	// Function to show/hide all the tables
	function show_hide_all () {
		expand_flag = document.getElementById('expand');
		divs = document.getElementsByTagName('div');
		for(var i=0; i < divs.length; i++){
			param = divs[i].id.substring(4);
			div   = document.getElementById('div_'+param);
		  alink = document.getElementById('a_'+param);
			
			if (div && alink) {
				if (expand_flag.value=='0') {
					div.style.display='inline';
					alink.innerHTML='Hide';
				}
				else {
					div.style.display='none';
					alink.innerHTML='Show';
				}
			}
		}
		if (expand_flag.value=='0') {
			expand_flag.value='1';
		}
		else {
			expand_flag.value='0';
		}
	}
</script>

</head>

<body>
<h1>Ensembl $db_team Schema Documentation</h1>

<h2>Introduction</h2>

<p><i>
&lt;please, insert your introduction here&gt;
</i></p>
<br />
};


##############
### Footer  ##
{'fraction_non_alphanumeric': 0.18581759742868623, 'fraction_numerical': 0.01566894335074327, 'mean_word_length': 4.361873990306947, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 59, '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': '6310519', 'n_tokens_mistral': 3545, 'n_tokens_neox': 3168, 'n_words': 943}