<commit_before>#!/usr/local/ensembl/bin/perl -w

#
# Test script for Bio::EnsEMBL::Compara::GenomicAlignBlock module
#
# Written by <NAME> (<EMAIL>)
#
# Copyright (c) 2004. EnsEMBL Team
#
# You may distribute this module under the same terms as perl itself

=head1 NAME

genomicAlignBlock.t

=head1 INSTALLATION

*_*_*_*_*_*_*_*_*_*_*_*_*_*_   W A R N I N G  _*_*_*_*_*_*_*_*_*_*_*_*_*_*

YOU MUST EDIT THE <MultiTestDB.conf> FILE BEFORE USING THIS TEST SCRIPT!!!

*_*_*_*_*_*_*_*_*_*_*_*_*_*_   W A R N I N G  _*_*_*_*_*_*_*_*_*_*_*_*_*_*

Please, read the README file for instructions.

=head1 SYNOPSIS

For running this test only:
perl -w ../../../ensembl-test/scripts/runtests.pl genomicAlignBlock.t

For running all the test scripts:
perl -w ../../../ensembl-test/scripts/runtests.pl

For running all the test scripts and cleaning the database afterwards:
perl -w ../../../ensembl-test/scripts/runtests.pl -c

=head1 DESCRIPTION

This script uses a small compara database build following the specifitions given in the MultiTestDB.conf file.

This script (as far as possible) tests all the methods defined in the
Bio::EnsEMBL::Compara::GenomicAlignBlock module.

This script includes 36 tests.

=head1 AUTHOR

<NAME> (<EMAIL>)

=head1 COPYRIGHT

Copyright (c) 2004. EnsEMBL Team

You may distribute this module under the same terms as perl itself

=head1 CONTACT

This modules is part of the EnsEMBL project (http://www.ensembl.org)

Questions can be posted to the ensembl-dev mailing list:
<EMAIL>

=cut



use strict;

BEGIN { $| = 1;  
    use Test;
    plan tests => 36;
}

use Bio::EnsEMBL::Utils::Exception qw (warning verbose);
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Compara::GenomicAlignBlock;

# switch off the debug prints 
our $verbose = 0;

my $multi = Bio::EnsEMBL::Test::MultiTestDB->new( "multi" );
my $homo_sapiens = Bio::EnsEMBL::Test::MultiTestDB->new("homo_sapiens");
my $mus_musculus = Bio::EnsEMBL::Test::MultiTestDB->new("mus_musculus");
my $rattus_norvegicus = Bio::EnsEMBL::Test::MultiTestDB->new("rattus_norvegicus");

my $compara_db = $multi->get_DBAdaptor( "compara" );
my $gdba = $compara_db->get_GenomeDBAdaptor();

my $hs_genome_db = $gdba->fetch_by_name_assembly(
        $homo_sapiens->get_DBAdaptor('core')->get_MetaContainer->get_Species->binomial,
        $homo_sapiens->get_DBAdaptor('core')->get_CoordSystemAdaptor->fetch_all->[0]->version
    );
my $mm_genome_db = $gdba->fetch_by_name_assembly(
        $mus_musculus->get_DBAdaptor('core')->get_MetaContainer->get_Species->binomial,
        $mus_musculus->get_DBAdaptor('core')->get_CoordSystemAdaptor->fetch_all->[0]->version
    );
my $rn_genome_db = $gdba->fetch_by_name_assembly(
        $rattus_norvegicus->get_DBAdaptor('core')->get_MetaContainer->get_Species->binomial,
        $rattus_norvegicus->get_DBAdaptor('core')->get_CoordSystemAdaptor->fetch_all->[0]->version
    );

$hs_genome_db->db_adaptor($homo_sapiens->get_DBAdaptor('core'));
$mm_genome_db->db_adaptor($mus_musculus->get_DBAdaptor('core'));
$rn_genome_db->db_adaptor($rattus_norvegicus->get_DBAdaptor('core'));
  
# my $genomic_align;
# my $all_genomic_aligns;
my $genomic_align_adaptor = $compara_db->get_GenomicAlignAdaptor();
my $genomic_align_block_adaptor = $compara_db->get_GenomicAlignBlockAdaptor();
my $method_link_species_set_adaptor = $compara_db->get_MethodLinkSpeciesSetAdaptor();
# my $dnafrag_adaptor = $compara_db->get_DnaFragAdaptor();
# my $genomeDB_adaptor = $compara_db->get_GenomeDBAdaptor();
# my $fail;
# 
# my $dbID = 7279606;
# my $genomic_align_block_id = 3639804;
# my $genomic_align_block = $genomic_align_block_adaptor->fetch_by_dbID($genomic_align_block_id);
# my $dnafrag_id = 19;
# my $dnafrag = $dnafrag_adaptor->fetch_by_dbID($dnafrag_id);
# my $dnafrag_start = 50007134;
# my $dnafrag_end = 50007289;
# my $dnafrag_strand = 1;
# my $level_id = 1;
# my $cigar_line = "15MG78MG63M";
# my $aligned_sequence = "TCATTGGCTCATTTT-ATTGCATTCAATGAATTGTTGGAAATTAGAGCCAGCCAAAAATTGTATAAATATTGGGCTGTGTCTGCTTCTCTGACA-CTAGATGAAGATGGCATTTGTGCCTGTGTGTCTGTGGGGTCCTCAGGAAGCTCTTCTCCTTGA";
# my $original_sequence = "TCATTGGCTCATTTTATTGCATTCAATGAATTGTTGGAAATTAGAGCCAGCCAAAAATTGTATAAATATTGGGCTGTGTCTGCTTCTCTGACACTAGATGAAGATGGCATTTGTGCCTGTGTGTCTGTGGGGTCCTCAGGAAGCTCTTCTCCTTGA";

my $genomic_align_blocks;
my $genomic_align_block;
my $genomic_align_block_id = 3639804;
my $method_link_species_set_id = 2;
my $method_link_species_set = $method_link_species_set_adaptor->fetch_by_dbID($method_link_species_set_id);
my $score = 4491;
my $perc_id = 63;
my $length = 158;
my $genomic_algin_1_dbID = 7279606;
my $genomic_align_1 = $genomic_align_adaptor->fetch_by_dbID($genomic_algin_1_dbID);
my $genomic_algin_2_dbID = 7279608;
my $genomic_align_2 = $genomic_align_adaptor->fetch_by_dbID($genomic_algin_2_dbID);
my $genomic_align_array = [$genomic_align_1, $genomic_align_2];

my $slice_adaptor = $homo_sapiens->get_DBAdaptor("core")->get_SliceAdaptor();
my $slice_coord_system_name = "chromosome";
my $slice_seq_region_name = "14";
my $slice_start = 50000000;
my $slice_end = 50001000;

# 
# 1
# 
debug("Test Bio::EnsEMBL::Compara::GenomicAlignBlock->new(void) method");
  $genomic_align_block = new Bio::EnsEMBL::Compara::GenomicAlignBlock();
  ok($genomic_align_block->isa("Bio::EnsEMBL::Compara::GenomicAlignBlock"));

# 
# 2-9
# 
debug("Test Bio::EnsEMBL::Compara::GenomicAlignBlock->new(ALL) method");
  $genomic_align_block = new Bio::EnsEMBL::Compara::GenomicAlignBlock(
          -adaptor => $genomic_align_block_adaptor,
          -dbID => $genomic_align_block_id,
          -method_link_species_set => $method_link_species_set,
          -score => $score,
          -length => $length,
          -genomic_align_array => $genomic_align_array
      );
  ok($genomic_align_block->isa("Bio::EnsEMBL::Compara::GenomicAlignBlock"));<commit_msg>Update data in order to match new test DB New smarter way to connect to the core DBs using the MultiTestDB.conf file<commit_after>#!/usr/local/ensembl/bin/perl -w

#
# Test script for Bio::EnsEMBL::Compara::GenomicAlignBlock module
#
# Written by <NAME> (<EMAIL>)
#
# Copyright (c) 2004. EnsEMBL Team
#
# You may distribute this module under the same terms as perl itself

=head1 NAME

genomicAlignBlock.t

=head1 INSTALLATION

*_*_*_*_*_*_*_*_*_*_*_*_*_*_   W A R N I N G  _*_*_*_*_*_*_*_*_*_*_*_*_*_*

YOU MUST EDIT THE <MultiTestDB.conf> FILE BEFORE USING THIS TEST SCRIPT!!!

*_*_*_*_*_*_*_*_*_*_*_*_*_*_   W A R N I N G  _*_*_*_*_*_*_*_*_*_*_*_*_*_*

Please, read the README file for instructions.

=head1 SYNOPSIS

For running this test only:
perl -w ../../../ensembl-test/scripts/runtests.pl genomicAlignBlock.t

For running all the test scripts:
perl -w ../../../ensembl-test/scripts/runtests.pl

For running all the test scripts and cleaning the database afterwards:
perl -w ../../../ensembl-test/scripts/runtests.pl -c

=head1 DESCRIPTION

This script uses a small compara database build following the specifitions given in the MultiTestDB.conf file.

This script (as far as possible) tests all the methods defined in the
Bio::EnsEMBL::Compara::GenomicAlignBlock module.

This script includes 36 tests.

=head1 AUTHOR

<NAME> (<EMAIL>)

=head1 COPYRIGHT

Copyright (c) 2004. EnsEMBL Team

You may distribute this module under the same terms as perl itself

=head1 CONTACT

This modules is part of the EnsEMBL project (http://www.ensembl.org)

Questions can be posted to the ensembl-dev mailing list:
<EMAIL>

=cut



use strict;

BEGIN { $| = 1;  
    use Test;
    plan tests => 36;
}

use Bio::EnsEMBL::Utils::Exception qw (warning verbose);
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Compara::GenomicAlignBlock;

#####################################################################
## Connect to the test database using the MultiTestDB.conf file

my $multi = Bio::EnsEMBL::Test::MultiTestDB->new( "multi" );
my $compara_db_adaptor = $multi->get_DBAdaptor( "compara" );
my $genome_db_adaptor = $compara_db_adaptor->get_GenomeDBAdaptor();

my $species = [
        "homo_sapiens",
#         "mus_musculus",
        "rattus_norvegicus",
        "gallus_gallus",
    ];

my $species_db;
my $species_db_adaptor;
my $species_gdb;
## Connect to core DB specified in the MultiTestDB.conf file
foreach my $this_species (@$species) {
  $species_db->{$this_species} = Bio::EnsEMBL::Test::MultiTestDB->new($this_species);
  die if (!$species_db->{$this_species});
  $species_db_adaptor->{$this_species} = $species_db->{$this_species}->get_DBAdaptor('core');
  $species_gdb->{$this_species} = $genome_db_adaptor->fetch_by_name_assembly(
          $species_db_adaptor->{$this_species}->get_MetaContainer->get_Species->binomial,
          $species_db_adaptor->{$this_species}->get_CoordSystemAdaptor->fetch_all->[0]->version
      );
  $species_gdb->{$this_species}->db_adaptor($species_db_adaptor->{$this_species});
}

##
#####################################################################

# switch off the debug prints 
our $verbose = 0;

# my $genomic_align;
# my $all_genomic_aligns;
my $genomic_align_adaptor = $compara_db_adaptor->get_GenomicAlignAdaptor();
my $genomic_align_block_adaptor = $compara_db_adaptor->get_GenomicAlignBlockAdaptor();
my $method_link_species_set_adaptor = $compara_db_adaptor->get_MethodLinkSpeciesSetAdaptor();
# my $dnafrag_adaptor = $compara_db->get_DnaFragAdaptor();
# my $genomeDB_adaptor = $compara_db->get_GenomeDBAdaptor();
# my $fail;
# 
# my $dbID = 7279606;
# my $genomic_align_block_id = 3639804;
# my $genomic_align_block = $genomic_align_block_adaptor->fetch_by_dbID($genomic_align_block_id);
# my $dnafrag_id = 19;
# my $dnafrag = $dnafrag_adaptor->fetch_by_dbID($dnafrag_id);
# my $dnafrag_start = 50007134;
# my $dnafrag_end = 50007289;
# my $dnafrag_strand = 1;
# my $level_id = 1;
# my $cigar_line = "15MG78MG63M";
# my $aligned_sequence = "TCATTGGCTCATTTT-ATTGCATTCAATGAATTGTTGGAAATTAGAGCCAGCCAAAAATTGTATAAATATTGGGCTGTGTCTGCTTCTCTGACA-CTAGATGAAGATGGCATTTGTGCCTGTGTGTCTGTGGGGTCCTCAGGAAGCTCTTCTCCTTGA";
# my $original_sequence = "TCATTGGCTCATTTTATTGCATTCAATGAATTGTTGGAAATTAGAGCCAGCCAAAAATTGTATAAATATTGGGCTGTGTCTGCTTCTCTGACACTAGATGAAGATGGCATTTGTGCCTGTGTGTCTGTGGGGTCCTCAGGAAGCTCTTCTCCTTGA";

my $genomic_align_blocks;
my $genomic_align_block;
my $genomic_align_block_id = 5857270;
my $method_link_species_set_id = 72;
my $method_link_species_set = $method_link_species_set_adaptor->fetch_by_dbID($method_link_species_set_id);
my $score = 4581;
my $perc_id = 48;
my $length = 283;
my $genomic_algin_1_dbID = 11714534;
my $genomic_align_1 = $genomic_align_adaptor->fetch_by_dbID($genomic_algin_1_dbID);
my $genomic_algin_2_dbID = 11714544;
my $genomic_align_2 = $genomic_align_adaptor->fetch_by_dbID($genomic_algin_2_dbID);
my $genomic_align_array = [$genomic_align_1, $genomic_align_2];
die if (!$species_db);
print STDERR $species_db;
my $slice_adaptor = $species_db->{"homo_sapiens"}->get_DBAdaptor("core")->get_SliceAdaptor();
my $slice_coord_system_name = "chromosome";
my $slice_seq_region_name = "14";
my $slice_start = 50000000;
my $slice_end = 50001000;

# 
# 1
# 
debug("Test Bio::EnsEMBL::Compara::GenomicAlignBlock->new(void) method");
  $genomic_align_block = new Bio::EnsEMBL::Compara::GenomicAlignBlock();
  ok($genomic_align_block->isa("Bio::EnsEMBL::Compara::GenomicAlignBlock"));

# 
# 2-9
# 
debug("Test Bio::EnsEMBL::Compara::GenomicAlignBlock->new(ALL) method");
  $genomic_align_block = new Bio::EnsEMBL::Compara::GenomicAlignBlock(
          -adaptor => $genomic_align_block_adaptor,
          -dbID => $genomic_align_block_id,
          -method_link_species_set => $method_link_species_set,
          -score => $score,
          -length => $length,
          -genomic_align_array => $genomic_align_array
      );
  ok($genomic_align_block->isa("Bio::EnsEMBL::Compara::GenomicAlignBlock"));
{'fraction_non_alphanumeric': 0.14209950332519572, 'fraction_numerical': 0.020961360383870697, 'mean_word_length': 6.088305489260144, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 127, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '7531595', 'n_tokens_mistral': 4900, 'n_tokens_neox': 4487, 'n_words': 819}