<commit_before>#!/usr/bin/env perl
# Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#      http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# This is a script to aid the transition from "headerless" species_set schema
# to the schema where species_set_header table generates and maintains unique species_set_ids

use strict;
use warnings;
use Data::Dumper;

use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor;

my $starting_from_rel = 49;     # 49 is the earliest
my $current_rel       = 62;     # 62 is the current
my $header_table_name = 'species_set_header';

sub get_compara_url {
    my $rel = shift @_;

    if($rel eq 'master') {
        return "mysql://ensro\@compara1/sf5_ensembl_compara_master";
#    } elsif($rel == 61) {
#        return "mysql://ensro\@compara1/sf5_ensembl_compara_61";
    } elsif((48<=$rel) and ($rel<=$current_rel)) {
        return "mysql://ensro\@ensdb-archive:5304/ensembl_compara_$rel";
    } elsif((29<=$rel) and ($rel<=47)) {
        return "mysql://ensro\@ensdb-archive:3304/ensembl_compara_$rel";
    }

    return 'mysql://ensro@compara1/sf5_ensembl_compara_master';
}


sub get_contents {
    my $rel = shift @_;

    my $dbc = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor->new( -url=> get_compara_url($rel) )->dbc();

    my %id_to_contents = ();
    my $sth = $dbc->prepare(q{
        SELECT ss.species_set_id,
            GROUP_CONCAT(distinct ss.genome_db_id) x,
    }.(($rel eq 'master' or $rel>=57)
        ? q{ IFNULL(GROUP_CONCAT(distinct mlss.name),CONCAT('COLOURED:',sst.value)) y }
        : ' GROUP_CONCAT(distinct mlss.name) y '
    ).q{
        FROM species_set ss
        LEFT JOIN method_link_species_set mlss ON ss.species_set_id=mlss.species_set_id
    }.(($rel eq 'master' or $rel>=57)
        ? q{ LEFT JOIN species_set_tag sst ON ss.species_set_id=sst.species_set_id AND sst.tag='name' }
        : ''
    ).q{<commit_msg>Updated the connection details<commit_after>#!/usr/bin/env perl
# Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#      http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# This is a script to aid the transition from "headerless" species_set schema
# to the schema where species_set_header table generates and maintains unique species_set_ids

use strict;
use warnings;
use Data::Dumper;

use Bio::EnsEMBL::Compara::DBSQL::DBAdaptor;

my $starting_from_rel = 49;     # 49 is the earliest
my $current_rel       = 79;     # 79 is the current
my $header_table_name = 'species_set_header';

sub get_compara_url {
    my $rel = shift @_;

    if($rel eq 'master') {
        return "mysql://ensro\@compara1/sf5_ensembl_compara_master";
#    } elsif($rel == 61) {
#        return "mysql://ensro\@compara1/sf5_ensembl_compara_61";
    } elsif((48<=$rel) and ($rel<=$current_rel)) {
        return "mysql://<EMAIL>:5306/ensembl_compara_$rel";
    } elsif((29<=$rel) and ($rel<=47)) {
        return "mysql://<EMAIL>:4306/ensembl_compara_$rel";
    }

    return 'mysql://ensro@compara1/sf5_ensembl_compara_master';
}


sub get_contents {
    my $rel = shift @_;

    my $dbc = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor->new( -url=> get_compara_url($rel) )->dbc();

    my %id_to_contents = ();
    my $sth = $dbc->prepare(q{
        SELECT ss.species_set_id,
            GROUP_CONCAT(distinct ss.genome_db_id) x,
    }.(($rel eq 'master' or $rel>=57)
        ? q{ IFNULL(GROUP_CONCAT(distinct mlss.name),CONCAT('COLOURED:',sst.value)) y }
        : ' GROUP_CONCAT(distinct mlss.name) y '
    ).q{
        FROM species_set ss
        LEFT JOIN method_link_species_set mlss ON ss.species_set_id=mlss.species_set_id
    }.(($rel eq 'master' or $rel>=57)
        ? q{ LEFT JOIN species_set_tag sst ON ss.species_set_id=sst.species_set_id AND sst.tag='name' }
        : ''
    ).q{
{'fraction_non_alphanumeric': 0.12161323681489142, 'fraction_numerical': 0.01985522233712513, 'mean_word_length': 3.6410748560460653, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '5392671', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1621, 'n_words': 448}