<commit_before>#!/usr/local/bin/perl

BEGIN {
    require "Bio/EnsEMBL/Pipeline/pipeConf.pl";
}


use Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor;
use Sys::Hostname;

use Getopt::Long;


#parameters for Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor

my $host;
my $dbname;
my $dbuser;

my $port            = '3306';
my $pass            = undef;
my $module          = undef;

my $test_env; #not used at present but could be used to test LSF machine

my $object_file;
my $job_id;

print STDERR join( " ", @ARGV ),"\n";

GetOptions(
    'host=s'    => \$host,
    'port=n'    => \$port,
    'dbname=s'  => \$dbname,
    'dbuser=s'  => \$dbuser,
    'pass=s'    => \$pass,
    'check!'    => \$check,
    'objfile=s' => \$object_file,
    'module=s'  => \$module
)
or die ("Couldn't get options");

if( defined $check ) {
  my $host = hostname();
  if ( ! -e $::pipeConf{'nfstmp.dir'} ) {
    die "no nfs connection";
  }
  my $deadhostfile = $::pipeConf{'nfstmp.dir'}."/deadhosts";
  open( FILE, $deadhostfile ) or exit 0;
  while( <FILE> ) {
    chomp;
    if( $host eq $_ ) {
      die "Cant use this host";
    }
  }

  # tests for DB existence - these probably shouldn't be hard-wired in ...
  if (defined (my $dir = $ENV{"BLASTDB"})) {
    -e "$dir/unigene.seq" or warn "Not found unigene";
    -e "$dir/sptr" or warn "Not found sptr";
  }
  exit 0;

}

print STDERR "In runner\n";
my $db = Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor->new(
    -host   => $host,
    -user   => $dbuser,
    -dbname => $dbname,
    -pass   => $<PASSWORD>,
    -port   => $port,
    -perlonlyfeatures  => 1,
    -perlonlysequences => 1
)
or die ("Failed to create Bio::EnsEMBL::Pipeline::DBAdaptor to db $dbname \n");

print STDERR "Connected to database\n";


print STDERR "Getting job adaptor\n";

my $job_adaptor = $db->get_JobAdaptor();

# Print a list of jobs in this 'batch' - this is perhaps useful later
# to parse these output files for CPU/Mem usage etc.
print STDOUT "LSF Batch summary\n";
print STDOUT "Time ", scalar localtime time, " (", time, ")\n";
# print STDOUT "LSF ID: ", $job_adaptor->fetch_by_dbID($ARGV[0])->LSF_id, "\n";
print STDOUT "Job ID\tinput ID\tanalysis ID\n";

foreach my $id (@ARGV) {
    my $job = $job_adaptor->fetch_by_dbID($id);
    print STDOUT join ("\t", $id, $job->input_id, $job->analysis->logic_name), "\n";
    # print STDOUT $id, "\n";
}
<commit_msg>Small correction to an error message.<commit_after>#!/usr/local/bin/perl

BEGIN {
    require "Bio/EnsEMBL/Pipeline/pipeConf.pl";
}


use Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor;
use Sys::Hostname;

use Getopt::Long;


#parameters for Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor

my $host;
my $dbname;
my $dbuser;

my $port            = '3306';
my $pass            = undef;
my $module          = undef;

my $test_env; #not used at present but could be used to test LSF machine

my $object_file;
my $job_id;

print STDERR join( " ", @ARGV ),"\n";

GetOptions(
    'host=s'    => \$host,
    'port=n'    => \$port,
    'dbname=s'  => \$dbname,
    'dbuser=s'  => \$dbuser,
    'pass=s'    => \$pass,
    'check!'    => \$check,
    'objfile=s' => \$object_file,
    'module=s'  => \$module
)
or die ("Couldn't get options");

if( defined $check ) {
  my $host = hostname();
  if ( ! -e $::pipeConf{'nfstmp.dir'} ) {
    die "no nfs connection";
  }
  my $deadhostfile = $::pipeConf{'nfstmp.dir'}."/deadhosts";
  open( FILE, $deadhostfile ) or exit 0;
  while( <FILE> ) {
    chomp;
    if( $host eq $_ ) {
      die "Cant use this host";
    }
  }

  # tests for DB existence - these probably shouldn't be hard-wired in ...
  if (defined (my $dir = $ENV{"BLASTDB"})) {
    -e "$dir/unigene.seq" or warn "Not found unigene";
    -e "$dir/sptr" or warn "Not found sptr";
  }
  exit 0;

}

print STDERR "In runner\n";
my $db = Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor->new(
    -host   => $host,
    -user   => $dbuser,
    -dbname => $dbname,
    -pass   => $<PASSWORD>,
    -port   => $port,
    -perlonlyfeatures  => 1,
    -perlonlysequences => 1
)
or die ("Failed to create Bio::EnsEMBL::Pipeline::DBSQL::DBAdaptor to db $dbname \n");

print STDERR "Connected to database\n";


print STDERR "Getting job adaptor\n";

my $job_adaptor = $db->get_JobAdaptor();

# Print a list of jobs in this 'batch' - this is perhaps useful later
# to parse these output files for CPU/Mem usage etc.
print STDOUT "LSF Batch summary\n";
print STDOUT "Time ", scalar localtime time, " (", time, ")\n";
# print STDOUT "LSF ID: ", $job_adaptor->fetch_by_dbID($ARGV[0])->LSF_id, "\n";
print STDOUT "Job ID\tinput ID\tanalysis ID\n";

foreach my $id (@ARGV) {
    my $job = $job_adaptor->fetch_by_dbID($id);
    print STDOUT join ("\t", $id, $job->input_id, $job->analysis->logic_name), "\n";
    # print STDOUT $id, "\n";
}

{'fraction_non_alphanumeric': 0.1789385357667296, 'fraction_numerical': 0.003775959723096287, 'mean_word_length': 3.106804478897502, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 53, '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': '4026712', 'n_tokens_mistral': 1927, 'n_tokens_neox': 1859, 'n_words': 499}