<commit_before>package XrefParser::FantomParser;

use strict;
use POSIX qw(strftime);
use File::Basename;
use File::Spec::Functions;

use base qw( XrefParser::BaseParser );

# --------------------------------------------------------------------------------
# Parse command line and run if being run directly

if (!defined(caller())) {

  if (scalar(@ARGV) != 1) {
    print STDERR "\nUsage: FantomParser.pm file <source_id> <species_id>\n\n";
    exit(1);
  }

  run($ARGV[0]);

}


sub run {

  my $self = shift if (defined(caller(1)));

  my $source_id = shift;
  my $species_id = shift;
  my $files       = shift;
  my $release_file   = shift;
  my $verbose       = shift;

  my $file = @{$files}[0];

  if(!defined($source_id)){
    $source_id = XrefParser::BaseParser->get_source_id_for_filename($file);
  }
  if(!defined($species_id)){
    $species_id = XrefParser::BaseParser->get_species_id_for_filename($file);
  }

  my $dir = dirname($file);
  

  my (%embl) = %{XrefParser::BaseParser->get_valid_codes("embl",$species_id)};
  my (%ddbj) = %{XrefParser::BaseParser->get_valid_codes("ddbj",$species_id)};
  my (%genbank) = %{XrefParser::BaseParser->get_valid_codes("genbank",$species_id)};

  my $fantom_io =
    $self->get_filehandle( $file  );

  if ( !defined $fantom_io ) {
    print STDERR "ERROR: Could not open " . $file . "\n" ;
    return 1;    # 1 error
  }

#e.g.


  my $ecount =0;
  my $dcount =0;
  my $gcount =0;
  
  my $mismatch=0;

  $fantom_io->getline(); # remove header

  while ( $_ = $fantom_io->getline() ) {
    chomp;
    my ($master, $label, $acc) = split (/\s+/,$_);
    if(defined($embl{$master})){
      XrefParser::BaseParser->add_to_xrefs($embl{$master},$acc,'',$label,'','',$source_id,$species_id);
      $ecount++;
    }
    elsif(defined($ddbj{$master})){
      XrefParser::BaseParser->add_to_xrefs($ddbj{$master},$acc,'',$label,'','',$source_id,$species_id);
      $dcount++;
    }
    elsif(defined($genbank{$master})){
      XrefParser::BaseParser->add_to_xrefs($genbank{$master},$acc,'',$label,'','',$source_id,$species_id);
      $gcount++;
    }<commit_msg>set label to be label and accession<commit_after>package XrefParser::FantomParser;

use strict;
use POSIX qw(strftime);
use File::Basename;
use File::Spec::Functions;

use base qw( XrefParser::BaseParser );

# --------------------------------------------------------------------------------
# Parse command line and run if being run directly

if (!defined(caller())) {

  if (scalar(@ARGV) != 1) {
    print STDERR "\nUsage: FantomParser.pm file <source_id> <species_id>\n\n";
    exit(1);
  }

  run($ARGV[0]);

}


sub run {

  my $self = shift if (defined(caller(1)));

  my $source_id = shift;
  my $species_id = shift;
  my $files       = shift;
  my $release_file   = shift;
  my $verbose       = shift;

  my $file = @{$files}[0];

  if(!defined($source_id)){
    $source_id = XrefParser::BaseParser->get_source_id_for_filename($file);
  }
  if(!defined($species_id)){
    $species_id = XrefParser::BaseParser->get_species_id_for_filename($file);
  }

  my $dir = dirname($file);
  

  my (%embl) = %{XrefParser::BaseParser->get_valid_codes("embl",$species_id)};
  my (%ddbj) = %{XrefParser::BaseParser->get_valid_codes("ddbj",$species_id)};
  my (%genbank) = %{XrefParser::BaseParser->get_valid_codes("genbank",$species_id)};

  my $fantom_io =
    $self->get_filehandle( $file  );

  if ( !defined $fantom_io ) {
    print STDERR "ERROR: Could not open " . $file . "\n" ;
    return 1;    # 1 error
  }

#e.g.


  my $ecount =0;
  my $dcount =0;
  my $gcount =0;
  
  my $mismatch=0;

  $fantom_io->getline(); # remove header

  while ( $_ = $fantom_io->getline() ) {
    chomp;
    my ($master, $label, $acc) = split (/\s+/,$_);
    if(defined($embl{$master})){
      XrefParser::BaseParser->add_to_xrefs($embl{$master},$label,'',$label,'','',$source_id,$species_id);
      $ecount++;
    }
    elsif(defined($ddbj{$master})){
      XrefParser::BaseParser->add_to_xrefs($ddbj{$master},$label,'',$label,'','',$source_id,$species_id);
      $dcount++;
    }
    elsif(defined($genbank{$master})){
      XrefParser::BaseParser->add_to_xrefs($genbank{$master},$label,'',$label,'','',$source_id,$species_id);
      $gcount++;
    }
{'fraction_non_alphanumeric': 0.22478793590951932, 'fraction_numerical': 0.0051837888784165885, 'mean_word_length': 3.417273673257024, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, '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': '3309496', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1539, 'n_words': 272}