<commit_before># Utilities for scripts for doing tasks such as defining/filtering input

package ScriptUtils;

use Exporter;
use vars qw(@ISA @EXPORT);
use strict;


@ISA=qw(Exporter);

@EXPORT=qw(
           filter_to_chr_list
           get_chrlengths_v20
           get_chrlengths_v19
           sort_chr_names
           );


sub get_chrlengths_v20 {
  my $db   = shift;
  my $type = shift;
  my $coordsystem = shift;

  my %chrhash;

  if ($coordsystem ne 'toplevel') {
    if (!$db->isa('Bio::EnsEMBL::DBSQL::DBAdaptor')) {
      die "get_chrlengths should be passed a Bio::EnsEMBL::DBSQL::DBAdaptor\n";
    }
  
    my $query = "select seq_region.name, seq_region.length as mce from seq_region,coord_system where" .
                " seq_region.coord_system_id=coord_system.coord_system_id and" .
                " coord_system.version = '" . $type . "' and coord_system.name='$coordsystem'";
  
    my $sth = $db->dbc->prepare($query);
  
    $sth->execute;<commit_msg>Added -ignore_haplotypes flag to method get_chrlengths_v20<commit_after># Utilities for scripts for doing tasks such as defining/filtering input

package ScriptUtils;

use Exporter;
use vars qw(@ISA @EXPORT);
use strict;


@ISA=qw(Exporter);

@EXPORT=qw(
           filter_to_chr_list
           get_chrlengths_v20
           get_chrlengths_v19
           sort_chr_names
           );


sub get_chrlengths_v20 {
  my $db   = shift;
  my $type = shift;
  my $coordsystem = shift;
  my $ignore_haplotypes = shift;

  my %chrhash;

  if ($coordsystem ne 'toplevel') {
    if (!$db->isa('Bio::EnsEMBL::DBSQL::DBAdaptor')) {
      die "get_chrlengths should be passed a Bio::EnsEMBL::DBSQL::DBAdaptor\n";
    }
  
    my $query = "select seq_region.name, seq_region.length as mce from seq_region,coord_system where" .
                " seq_region.coord_system_id=coord_system.coord_system_id and" .
                " coord_system.version = '" . $type . "' and coord_system.name='$coordsystem'";
    if ($ignore_haplotypes) {    
      $query .= " and seq_region.seq_region_id not in (select seq_region_id from assembly_exception where exc_type = 'HAP')";
    }

    my $sth = $db->dbc->prepare($query);
  
    $sth->execute;
{'fraction_non_alphanumeric': 0.11520947176684881, 'fraction_numerical': 0.006375227686703097, 'mean_word_length': 2.9945454545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7300951', 'n_tokens_mistral': 799, 'n_tokens_neox': 772, 'n_words': 167}