<commit_before># $Id$

# This sub-class of XrefParser::BaseParser serves as the parent class
# for parsers of Xref source data that we use coordinate overlap to
# determine the Xrefs to.

package XrefParser::CoordinateParser;

use strict;
use warnings;

use Carp;

use base qw( XrefParser::BaseParser );

our $add_xref_sth;
our $add_xref_sql = q(
  INSERT INTO coordinate_xref
  ( source_id,  species_id,
    accession,
    chromosome, strand,
    txStart,    txEnd,
    cdsStart,   cdsEnd,
    exonStarts, exonEnds )
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
);

sub add_xref {
  my $self = shift;
  my ( $source_id, $species_id, $xref ) = @_;

  if ( !defined($add_xref_sth) ) {
    $add_xref_sth = $self->dbi()->prepare_cached($add_xref_sql);
  }

  for my $required_key ( 'accession', 'chromosome',
                         'strand',    'txStart',
                         'txEnd',     'exonStarts',
                         'exonEnds' )
  {
    if ( !defined( $xref->{$required_key} ) ) {
      croak(
          sprintf( "Missing required key '%s' for Xref", $required_key )
      );
    }
  }

  $add_xref_sth->execute( $source_id,           $species_id,
                          $xref->{'accession'}, $xref->{'chromosome'},
                          $xref->{'strand'},    $xref->{'txStart'},<commit_msg>Print error if prepare fails.<commit_after># $Id$

# This sub-class of XrefParser::BaseParser serves as the parent class
# for parsers of Xref source data that we use coordinate overlap to
# determine the Xrefs to.

package XrefParser::CoordinateParser;

use strict;
use warnings;

use Carp;

use base qw( XrefParser::BaseParser );

our $add_xref_sth;
our $add_xref_sql = q(
  INSERT INTO coordinate_xref
  ( source_id,  species_id,
    accession,
    chromosome, strand,
    txStart,    txEnd,
    cdsStart,   cdsEnd,
    exonStarts, exonEnds )
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
);

sub add_xref {
  my $self = shift;
  my ( $source_id, $species_id, $xref ) = @_;

  if ( !defined($add_xref_sth) ) {
    my $dbh = $self->dbi();
    $add_xref_sth = $dbh->prepare_cached($add_xref_sql);
    if ( !defined($add_xref_sth) ) {
      croak( $dbh->errstr() );
    }
  }

  for my $required_key ( 'accession', 'chromosome',
                         'strand',    'txStart',
                         'txEnd',     'exonStarts',
                         'exonEnds' )
  {
    if ( !defined( $xref->{$required_key} ) ) {
      croak(
          sprintf( "Missing required key '%s' for Xref", $required_key )
      );
    }
  }

  $add_xref_sth->execute( $source_id,           $species_id,
                          $xref->{'accession'}, $xref->{'chromosome'},
                          $xref->{'strand'},    $xref->{'txStart'},
{'fraction_non_alphanumeric': 0.14740307242136064, 'fraction_numerical': 0.0, 'mean_word_length': 2.343520782396088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '3432098', 'n_tokens_mistral': 1017, 'n_tokens_neox': 972, 'n_words': 212}