<commit_before>#!/usr/bin/env perl
# $Source: /tmp/ENSCOPY-ENSEMBL-ANALYSIS/scripts/buildchecks/check_GBGenes.pl,v $
# $Revision: 1.20 $

# Script to check the integrity of some or all of the genes in an Ensembl 
# database 

# any questions please send to <EMAIL>

=head1 NAME

check_GBGenes.pl

=head1 SYNOPSIS

perl check_GBGenes.pl -chromosome 1 -coordsystem chromosome -transcripts

This will run the transcript checks on chromosome 1 on the final database and
reference database specified in Bio::EnsEMBL::Pipeline::Config::GeneBuild::Databases

Note: If submitting to LSF you will need to specify memory requiremensts of >100MB
      For instance, 1GB suffices all human chromosomes:

      bsub -R"select[mem>1000] rusage[mem=1000]" -M1000000 

=head1 DESCRIPTION

This script runs a series of tests on genes in the database it is pointed
too. These tests are described in more detail in the various perl
modules in this directory

=head1 OPTIONS

  -dbhost database host
  -dbuser database user
  -dbpass database password
  -dbport database port
  -dbname database name
  -dnahost host for dna database
  -dnaport port for dna database
  -dnadbname name for dna database

  These settings by default are taken from:
  Bio::EnsEMBL::Analysis::Config::Databases

  -ignorewarnings flag to specify whether to ignore the warnings in the 
                  code

  This is take by default from:
  Bio::EnsEMBL::Pipeline::Config::GeneBuild::GeneBuilder


  -chromosome name of seq region to get genes from
  -coordsystem name of the coordinate system the seq region belongs to

  these are both obligatory options

  -chrstart the start coordinate of the piece of seq region to fetch
  -chrend the end coordinate of the piece of seq region to fetch

  without these the whole seq region if fetched

  -duplicates check for duplicate exons (off by default)
  -transcripts check the transcripts (on by default)

  -help print the perl docs

=head1 EXAMPLES

perl check_GBGenes.pl -chromosome 1 -coordsystem chromosome -transcripts

runs the standard checks on chromosomes using the databases defined in
configuration


perl check_GBGenes.pl -chromosome 3 -coordsystem chromosome -duplicates
-host yourhost -user youruser -port 3306 -dbname yourdb -dnahost yourhost
-dnaport 3306 -dnadbname yourdnadb

runs the standard checks and checks for duplicate exons on the database
specified on the commandline

=head1 NOTES

Note this script uses several settings from the
Bio::EnsEMBL::Analysis::Config::GeneBuild::GeneBuilder

Also this scripts uses several modules which can be found in this
directory so you need to make sure you run the script in this
directory or alternatively put this directory in your PERL5LIB

=cut

use strict;
use warnings;
use Getopt::Long;

use Bio::EnsEMBL::DBSQL::DBAdaptor;
use TranscriptChecker;
use ContigGenesChecker;
use GeneChecker;
use ScriptUtils;
use Bio::EnsEMBL::Analysis::Config::GeneBuild::BuildChecks qw (
                                                               MAXSHORTINTRONLEN
                                                               MINSHORTINTRONLEN
                                                               MINLONGINTRONLEN
                                                               MAX_EXONSTRANSCRIPT
                                                               MAXSHORTEXONLEN
                                                               MINSHORTEXONLEN
                                                               MINLONGEXONLEN 
                                                               MAXTRANSCRIPTS
                                                               MINTRANSLATIONLEN
                                                               IGNOREWARNINGS
                                                               MAXGENELEN
                                                              ); ;
use Bio::EnsEMBL::Analysis::Tools::Utilities;


$| = 1;

my $host;
my $dbname;
my $user;
my $pass;
my $port;
my $gene_database_name;
my $path;

# default path comes out of database

my $maxshortintronlen  =  50;
if (defined($MAXSHORTINTRONLEN)) { $maxshortintronlen  = $MAXSHORTINTRONLEN; }

my $minshortintronlen  =  3;
if (defined($MINSHORTINTRONLEN)) { $minshortintronlen  = $MINSHORTINTRONLEN; }

my $minlongintronlen   =  100000;
if (defined($MINLONGINTRONLEN )) { $minlongintronlen   = $MINLONGINTRONLEN; }

my $maxexonstranscript =  150;
if (defined($MAX_EXONSTRANSCRIPT)) { $maxexonstranscript = $MAX_EXONSTRANSCRIPT; }

my $maxshortexonlen    =  10;
if (defined($MAXSHORTEXONLEN)) { $maxshortexonlen    = $MAXSHORTEXONLEN; }

my $minshortexonlen    =  3;
if (defined($MINSHORTEXONLEN)) { $minshortexonlen    = $MINSHORTEXONLEN; }

my $minlongexonlen     =  50000;
if (defined($MINLONGEXONLEN )) { $minlongexonlen     = $MINLONGEXONLEN; }

my $maxtranscripts     =  10; 
if (defined($MAXTRANSCRIPTS)) { $maxtranscripts     = $MAXTRANSCRIPTS; }

my $mintranslationlen  =  10; 
if (defined($MINTRANSLATIONLEN)) { $mintranslationlen  = $MINTRANSLATIONLEN; }

my $ignorewarnings     =  0; 
if (defined($IGNOREWARNINGS)) { $ignorewarnings     = $IGNOREWARNINGS; }

my $maxgenelen     =  2_000_000; 
if (defined($MAXGENELEN)) { $maxgenelen     = $MAXGENELEN; }

my @chromosomes;

my $specstart = 1;
my $specend   = undef;

my $dnadbname = "";
my $dnahost   = "";
my $dnaport   = "";<commit_msg>The default port for MySQL is 3306.  Having to specify this explicitly should be universally banned.<commit_after>#!/usr/bin/env perl
# $Source: /tmp/ENSCOPY-ENSEMBL-ANALYSIS/scripts/buildchecks/check_GBGenes.pl,v $
# $Revision: 1.21 $

# Script to check the integrity of some or all of the genes in an Ensembl 
# database 

# any questions please send to <EMAIL>

=head1 NAME

check_GBGenes.pl

=head1 SYNOPSIS

perl check_GBGenes.pl -chromosome 1 -coordsystem chromosome -transcripts

This will run the transcript checks on chromosome 1 on the final database and
reference database specified in Bio::EnsEMBL::Pipeline::Config::GeneBuild::Databases

Note: If submitting to LSF you will need to specify memory requiremensts of >100MB
      For instance, 1GB suffices all human chromosomes:

      bsub -R"select[mem>1000] rusage[mem=1000]" -M1000000 

=head1 DESCRIPTION

This script runs a series of tests on genes in the database it is pointed
too. These tests are described in more detail in the various perl
modules in this directory

=head1 OPTIONS

  -dbhost database host
  -dbuser database user
  -dbpass database password
  -dbport database port
  -dbname database name
  -dnahost host for dna database
  -dnaport port for dna database
  -dnadbname name for dna database

  These settings by default are taken from:
  Bio::EnsEMBL::Analysis::Config::Databases

  -ignorewarnings flag to specify whether to ignore the warnings in the 
                  code

  This is take by default from:
  Bio::EnsEMBL::Pipeline::Config::GeneBuild::GeneBuilder


  -chromosome name of seq region to get genes from
  -coordsystem name of the coordinate system the seq region belongs to

  these are both obligatory options

  -chrstart the start coordinate of the piece of seq region to fetch
  -chrend the end coordinate of the piece of seq region to fetch

  without these the whole seq region if fetched

  -duplicates check for duplicate exons (off by default)
  -transcripts check the transcripts (on by default)

  -help print the perl docs

=head1 EXAMPLES

perl check_GBGenes.pl -chromosome 1 -coordsystem chromosome -transcripts

runs the standard checks on chromosomes using the databases defined in
configuration


perl check_GBGenes.pl -chromosome 3 -coordsystem chromosome -duplicates
-host yourhost -user youruser -port 3306 -dbname yourdb -dnahost yourhost
-dnaport 3306 -dnadbname yourdnadb

runs the standard checks and checks for duplicate exons on the database
specified on the commandline

=head1 NOTES

Note this script uses several settings from the
Bio::EnsEMBL::Analysis::Config::GeneBuild::GeneBuilder

Also this scripts uses several modules which can be found in this
directory so you need to make sure you run the script in this
directory or alternatively put this directory in your PERL5LIB

=cut

use strict;
use warnings;
use Getopt::Long;

use Bio::EnsEMBL::DBSQL::DBAdaptor;
use TranscriptChecker;
use ContigGenesChecker;
use GeneChecker;
use ScriptUtils;
use Bio::EnsEMBL::Analysis::Config::GeneBuild::BuildChecks qw (
                                                               MAXSHORTINTRONLEN
                                                               MINSHORTINTRONLEN
                                                               MINLONGINTRONLEN
                                                               MAX_EXONSTRANSCRIPT
                                                               MAXSHORTEXONLEN
                                                               MINSHORTEXONLEN
                                                               MINLONGEXONLEN 
                                                               MAXTRANSCRIPTS
                                                               MINTRANSLATIONLEN
                                                               IGNOREWARNINGS
                                                               MAXGENELEN
                                                              ); ;
use Bio::EnsEMBL::Analysis::Tools::Utilities;


$| = 1;

my $host;
my $dbname;
my $user;
my $pass;
my $port='3306';
my $gene_database_name;
my $path;

# default path comes out of database

my $maxshortintronlen  =  50;
if (defined($MAXSHORTINTRONLEN)) { $maxshortintronlen  = $MAXSHORTINTRONLEN; }

my $minshortintronlen  =  3;
if (defined($MINSHORTINTRONLEN)) { $minshortintronlen  = $MINSHORTINTRONLEN; }

my $minlongintronlen   =  100000;
if (defined($MINLONGINTRONLEN )) { $minlongintronlen   = $MINLONGINTRONLEN; }

my $maxexonstranscript =  150;
if (defined($MAX_EXONSTRANSCRIPT)) { $maxexonstranscript = $MAX_EXONSTRANSCRIPT; }

my $maxshortexonlen    =  10;
if (defined($MAXSHORTEXONLEN)) { $maxshortexonlen    = $MAXSHORTEXONLEN; }

my $minshortexonlen    =  3;
if (defined($MINSHORTEXONLEN)) { $minshortexonlen    = $MINSHORTEXONLEN; }

my $minlongexonlen     =  50000;
if (defined($MINLONGEXONLEN )) { $minlongexonlen     = $MINLONGEXONLEN; }

my $maxtranscripts     =  10; 
if (defined($MAXTRANSCRIPTS)) { $maxtranscripts     = $MAXTRANSCRIPTS; }

my $mintranslationlen  =  10; 
if (defined($MINTRANSLATIONLEN)) { $mintranslationlen  = $MINTRANSLATIONLEN; }

my $ignorewarnings     =  0; 
if (defined($IGNOREWARNINGS)) { $ignorewarnings     = $IGNOREWARNINGS; }

my $maxgenelen     =  2_000_000; 
if (defined($MAXGENELEN)) { $maxgenelen     = $MAXGENELEN; }

my @chromosomes;

my $specstart = 1;
my $specend   = undef;

my $dnadbname = "";
my $dnahost   = "";
my $dnaport   = '3306';
{'fraction_non_alphanumeric': 0.06820692194403534, 'fraction_numerical': 0.014911634756995583, 'mean_word_length': 2.417741428122051, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2871243', 'n_tokens_mistral': 3328, 'n_tokens_neox': 3038, 'n_words': 1018}