<commit_before>
=pod
=head1 LICENSE

  Copyright (c) 1999-2011 The European Bioinformatics Institute and
  Genome Research Limited.  All rights reserved.

  This software is distributed under a modified Apache license.
  For license details, please see

    http://www.ensembl.org/info/about/code_licence.html

=head1 CONTACT

  Please email comments or questions to the public Ensembl
  developers list at <<EMAIL>>.

  Questions may also be sent to the Ensembl help desk at
  <<EMAIL>>.
 
=cut

package Bio::EnsEMBL::Utils::MetaData::MetaDataDumper::TT2MetaDataDumper;
use base qw( Bio::EnsEMBL::Utils::MetaData::MetaDataDumper );
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Carp;
use XML::Simple;
use strict;
use warnings;

sub new {
    my ( $proto, @args ) = @_;
    my $self = $proto->SUPER::new(@args);
    my ($file) = rearrange( ['FILE'], @args );
    $self->{file} = $file || 'species.tt2';
    $self->{div_links} = { EnsemblBacteria => "http://bacteria.ensembl.org/",
                           EnsemblFungi    => "http://fungi.ensembl.org/",
                           EnsemblMetazoa  => "http://metazoa.ensembl.org/",
                           EnsemblProtists => "http://protists.ensembl.org/",
                           EnsemblPlants   => "http://plants.ensembl.org/" };

    return $self;
}

sub file {
    my ($self) = @_;
    return $self->{file};
}

sub dump_metadata {
    my ( $self, $metadata ) = @_;
    open( my $tt2_file, '>', $self->{file} )
      || croak "Could not write to " . $self->{file};
    print $tt2_file
"<table><tr><th>Species</th><th>Division</th><th>Taxonomy ID</th><th>Assembly</th><th>Genebuild</th></tr>";
    for my $md (
        @{ $metadata->{genome} } )
    {
        my $div_link = $self->{div_links}->{ $md->{division} };
        if ( !defined $div_link ) {
            croak "No division defined for $md->{name}";
        }
        $div_link .= $md->{name};
        my $line =
            "<tr><td><a href='${div_link}'>"
          . $md->{name}
          . "</a></td><td><a href='"<commit_msg>Correct tt2 format<commit_after>
=pod
=head1 LICENSE

  Copyright (c) 1999-2011 The European Bioinformatics Institute and
  Genome Research Limited.  All rights reserved.

  This software is distributed under a modified Apache license.
  For license details, please see

    http://www.ensembl.org/info/about/code_licence.html

=head1 CONTACT

  Please email comments or questions to the public Ensembl
  developers list at <<EMAIL>>.

  Questions may also be sent to the Ensembl help desk at
  <<EMAIL>>.
 
=cut

package Bio::EnsEMBL::Utils::MetaData::MetaDataDumper::TT2MetaDataDumper;
use base qw( Bio::EnsEMBL::Utils::MetaData::MetaDataDumper );
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Carp;
use XML::Simple;
use strict;
use warnings;

sub new {
    my ( $proto, @args ) = @_;
    my $self = $proto->SUPER::new(@args);
    my ($file) = rearrange( ['FILE'], @args );
    $self->{file} = $file || 'species.tt2';
    $self->{div_links} = { EnsemblBacteria => "http://bacteria.ensembl.org/",
                           EnsemblFungi    => "http://fungi.ensembl.org/",
                           EnsemblMetazoa  => "http://metazoa.ensembl.org/",
                           EnsemblProtists => "http://protists.ensembl.org/",
                           EnsemblPlants   => "http://plants.ensembl.org/" };

    return $self;
}

sub file {
    my ($self) = @_;
    return $self->{file};
}

sub dump_metadata {
    my ( $self, $metadata ) = @_;
    open( my $tt2_file, '>', $self->{file} )
      || croak "Could not write to " . $self->{file};
    print $tt2_file
"<table><tr><th>Species</th><th>Division</th><th>Taxonomy ID</th><th>Assembly</th><th>Genebuild</th></tr>";
    for my $md (
        @{ $metadata->{genome} } )
    {
        my $div_link = $self->{div_links}->{ $md->{division} };
        if ( !defined $div_link ) {
            croak "No division defined for $md->{name}";
        }
        $div_link .= $md->{species};
        my $line =
            "<tr><td><a href='${div_link}'>"
          . $md->{name}
          . "</a></td><td><a href='"
{'fraction_non_alphanumeric': 0.1714424477901894, 'fraction_numerical': 0.007042253521126761, 'mean_word_length': 2.6099912357581068, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2770670', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1395, 'n_words': 317}