GenomeContainer.pm 31.1 KB
Newer Older
1 2
=head1 LICENSE

3
Copyright [1999-2013] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
4

5 6 7 8 9 10 11 12 13 14 15 16 17
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.

=cut
18 19 20 21 22


=head1 CONTACT

  Please email comments or questions to the public Ensembl
Magali Ruffier's avatar
Magali Ruffier committed
23
  developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
24 25

  Questions may also be sent to the Ensembl help desk at
Magali Ruffier's avatar
Magali Ruffier committed
26
  <http://www.ensembl.org/Help/Contact>.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101

=cut

=head1 NAME

=head1 NAME

Bio::EnsEMBL::DBSQL::GenomeContainer - Encapsulates all access to 
genome related information

=head1 SYNOPSIS

  use Bio::EnsEMBL::Registry;

  Bio::EnsEMBL::Registry->load_registry_from_db(
    -host => 'ensembldb.ensembl.org',
    -user => 'anonymous'
  );

  $genome =
    Bio::EnsEMBL::Registry->get_adaptor( "human", "core", "GenomeContainer" );

  my $version = $genome->get_version;

  my $ref_length = $genome->get_ref_length;

  my $coord_systems = $genome->get_coord_systems;



=head1 DESCRIPTION

This module is responsible for fetching and storing genome-wide information.
Genome is an abstract object which contains information linking the species, the assembly and the ensembl annotation.

=head1 METHODS

=cut

package Bio::EnsEMBL::DBSQL::GenomeContainer;

use strict;
use warnings;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::DBSQL::BaseAdaptor;
use Bio::EnsEMBL::Utils::Exception qw( deprecate throw warning );
use Bio::EnsEMBL::Utils::Scalar qw( assert_ref );

use vars qw(@ISA);

@ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);



=head2 new

  Arg [...]  : Superclass args.  See Bio::EnsEMBL::DBSQL::BaseAdaptor
  Description: Instantiates a Bio::EnsEMBL::DBSQL::GenomeContainer
  Returntype : Bio::EnsEMBL::GenomeContainer
  Exceptions : none
  Caller     : DBAdaptor
  Status     : Stable

=cut


sub new {
  my $class = shift;

  my $self = $class->SUPER::new(@_);

  # cache creation could go here
  return $self;
}

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141


=head2 fetch_by_version

  Arg [1]    : (optional) Int $version
               Version used to fetch a genome object
               If none is provided, use the default version
  Example    : $genome = $genome_adaptor->fetch_by_version('GRCh37');
  Description: Retrieves a genome object
  Returntype : Bio::EnsEMBL::Genome
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub fetch_by_version {
  my ($self, $version) = @_;

  if (!$version) {
    my $csa = $self->db()->get_adaptor('CoordSystem');
    my @cs = @{ $csa->fetch_all() };
    $version = $cs[0]->version();
  }

  my $genome = Bio::EnsEMBL::Genome->new(
         -VERSION => $version,
         -ADAPTOR => $self,
        );

  return $genome;
}


=head2 store

  Arg [1]    : Statistic
               The type of statistic to store
  Arg [2]    : Value
               The corresponding value for the statistic
Magali Ruffier's avatar
Magali Ruffier committed
142
  Arg [3]    : (optional) Attribute
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
               If more than one value exists for the statistics, it will be distinguished by its attribute
  Example    : $genome_adaptor->store('coding_cnt', 20769);
  Description: Stores a genome statistic in the database
  Returntype : The database identifier (dbID) of the newly stored genome statistic
  Exceptions : 
  Caller     : general
  Status     : Stable

=cut

sub store {
  my ($self, $statistic, $value, $attribute) = @_;

  my $stats_id = @{ $self->_get_statistic($statistic, $attribute) }[0];
  if (defined $stats_id) {
    $self->update($statistic, $value, $attribute);
  } else {

    my $db = $self->db();
    my $species_id = $db->species_id();

    my $store_genome_sql = q{
    INSERT INTO genome_statistics 
       SET statistic = ?,
               value = ?,
          species_id = ?,
           timestamp = now()
    };

    if (defined $attribute) {
      $store_genome_sql .= ", attrib_type_id = ?";
    }

    my $sth = $self->prepare($store_genome_sql);
    $sth->bind_param(1,   $statistic,         SQL_VARCHAR);
    $sth->bind_param(2,   $value,             SQL_INTEGER);
    $sth->bind_param(3,   $species_id,        SQL_INTEGER);

    if (defined $attribute) {
      my $attribute_adaptor = $db->get_AttributeAdaptor();
      my $attribute_object = Bio::EnsEMBL::Attribute->new(-code => $attribute);
      my $attribute_type_id = $attribute_adaptor->_store_type($attribute_object);
      $sth->bind_param(4, $attribute_type_id, SQL_VARCHAR);
    }

    $sth->execute();
    $sth->finish();

    $stats_id = $sth->{'mysql_insertid'};
  }

  return $stats_id;
  
}

Magali Ruffier's avatar
Magali Ruffier committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215

=head2 update

  Arg [1]    : Statistic
               The type of statistic to update
  Arg [2]    : Value
               The corresponding value for the statistic
  Arg [3]    : (optional) Attribute
               If more than one value exists for the statistics, it will be distinguished by its attribute
  Example    : $genome_adaptor->update('coding_cnt', 20769);
  Description: Updates an existing genome statistic in the database
  Returntype : none
  Exceptions :
  Caller     : general
  Status     : Stable

=cut

216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
sub update {
  my ($self, $statistic, $value, $attribute) = @_;

  my $db = $self->db();

  my $update_genome_sql = q{
    UPDATE genome_statistics
       SET value = ?,
       timestamp = now() 
  };

  if (defined $attribute) {
    $update_genome_sql .= ', attrib_type_id = ?';
  }

  $update_genome_sql .= ' WHERE statistic = ?';
  
  my $sth = $self->prepare($update_genome_sql);
  $sth->bind_param(1,   $value,     SQL_INTEGER);

  my $increment = 2;
  if (defined $attribute) {
    my $attribute_adaptor = $db->get_AttributeAdaptor();
    my $attribute_object = Bio::EnsEMBL::Attribute->new(-code => $attribute);
    my $attribute_type_id = $attribute_adaptor->_store_type($attribute_object);
    $sth->bind_param($increment, $attribute_type_id, SQL_VARCHAR);
    $increment++;
  }
  
  $sth->bind_param($increment, $statistic, SQL_VARCHAR);

  $sth->execute();
  $sth->finish();
}


252 253 254 255 256 257 258 259
=head2 _meta_container

  Arg [1]    : none
  Example    : $meta_container = $genome->_meta_container();
  Description: Internal method to return a MetaContainer object for the genome
  Returntype : Bio::EnsEMBL::DBSQL::MetaContainer
  Exceptions : none
  Caller     : general
260
  Status     : Stable
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289

=cut

sub _meta_container {
  my $self = shift;
  return $self->db->get_adaptor('MetaContainer');
}


=head2 get_version

  Arg [1]    : (optional) assembly version
  Example    : $version = $genome->get_version();
  Description: Getter/Setter for the assembly version

  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_version {
  my ($self, $version) = @_;
  if (defined $version) {
    $self->{'version'} = $version;
  }
  if (!defined $self->{'version'}) {
    my $csa = $self->db()->get_adaptor('CoordSystem');
Magali Ruffier's avatar
Magali Ruffier committed
290
    $self->{'version'} = $csa->get_default_version;
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
  }
  return $self->{'version'};
}

=head2 get_accession

  Arg [1]    : (optional) assembly accession
  Example    : $accession = $genome->get_accession();
  Description: Getter/setter for the accession of the assembly currently used

  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_accession {
  my ($self, $accession) = @_;
  if (defined $accession) {
    $self->{'accession'} = $accession;
  }
  if (!defined $self->{'accession'}) {
    $self->{'accession'} = $self->_meta_container->single_value_by_key('assembly.accession');
  }
  return $self->{'accession'};
}

Magali Ruffier's avatar
Magali Ruffier committed
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469

=head2 get_assembly_name

  Arg [1]    : (optional) assembly name
  Example    : $assembly_name = $genome->get_assembly_name();
  Description: Getter/setter for the name of the assembly currently used

  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_assembly_name {
  my ($self, $assembly_name) = @_;
  if (defined $assembly_name) {
    $self->{'assembly_name'} = $assembly_name;
  }
  if (!defined $self->{'assembly_name'}) {
    $self->{'assembly_name'} = $self->_meta_container->single_value_by_key('assembly.name');
  }
  return $self->{'assembly_name'};
}


=head2 get_assembly_date

  Arg [1]    : (optional) assembly date
  Example    : $assembly_date = $genome->get_assembly_date();
  Description: Getter/setter for the date of the assembly currently used

  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_assembly_date {
  my ($self, $assembly_date) = @_;
  if (defined $assembly_date) {
    $self->{'assembly_date'} = $assembly_date;
  }
  if (!defined $self->{'assembly_date'}) {
    $self->{'assembly_date'} = $self->_meta_container->single_value_by_key('assembly.date');
  }
  return $self->{'assembly_date'};
}


=head2 get_genebuild_start_date

  Arg [1]    : (optional) genebuild start date
  Example    : $genebuild_start_date = $genome->get_genebuild_start_date();
  Description: Getter/setter for the start date of the genebuild currently used

  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_genebuild_start_date {
  my ($self, $genebuild_start_date) = @_;
  if (defined $genebuild_start_date) {
    $self->{'genebuild_start_date'} = $genebuild_start_date;
  }
  if (!defined $self->{'genebuild_start_date'}) {
    $self->{'genebuild_start_date'} = $self->_meta_container->single_value_by_key('genebuild.start_date');
  }
  return $self->{'genebuild_start_date'};
}


=head2 get_genebuild_method

  Arg [1]    : (optional) genebuild start date
  Example    : $genebuild_method = $genome->get_genebuild_method();
  Description: Getter/setter for the method of the genebuild currently used

  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_genebuild_method {
  my ($self, $genebuild_method) = @_;
  if (defined $genebuild_method) {
    $self->{'genebuild_method'} = $genebuild_method;
  }
  if (!defined $self->{'genebuild_method'}) {
    $self->{'genebuild_method'} = $self->_meta_container->single_value_by_key('genebuild.method');
  }
  return $self->{'genebuild_method'};
}


=head2 get_genebuild_initial_release_date

  Arg [1]    : (optional) genebuild initial release date
  Example    : $genebuild_initial_release_date = $genome->get_initial_release_date();
  Description: Getter/setter for the initial release date of the genebuild currently used

  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_genebuild_initial_release_date {
  my ($self, $genebuild_initial_release_date) = @_;
  if (defined $genebuild_initial_release_date) {
    $self->{'genebuild_initial_release_date'} = $genebuild_initial_release_date;
  }
  if (!defined $self->{'genebuild_initial_release_date'}) {
    $self->{'genebuild_initial_release_date'} = $self->_meta_container->single_value_by_key('genebuild.initial_release_date');
  }
  return $self->{'genebuild_initial_release_date'};
}


=head2 get_genebuild_last_geneset_update

  Arg [1]    : (optional) genebuild last geneset update
  Example    : $genebuild_last_geneset_update = $genome->get_last_geneset_update();
  Description: Getter/setter for the last geneset update of the genebuild currently used

  Returntype : string
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_genebuild_last_geneset_update {
  my ($self, $genebuild_last_geneset_update) = @_;
  if (defined $genebuild_last_geneset_update) {
    $self->{'genebuild_last_geneset_update'} = $genebuild_last_geneset_update;
  }
  if (!defined $self->{'genebuild_last_geneset_update'}) {
    $self->{'genebuild_last_geneset_update'} = $self->_meta_container->single_value_by_key('genebuild.last_geneset_update');
  }
  return $self->{'genebuild_last_geneset_update'};
}


470 471 472 473 474 475 476 477
=head2 _get_length

  Arg [1]    : none
  Example    : $length = $genome->_get_length('toplevel');
  Description: Internal method to return the length for a type of slices
  Returntype : integer
  Exceptions : none
  Caller     : general
478
  Status     : Stable
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512

=cut

sub _get_length {
  my ($self, $cs_name) = @_;
  my $slice_adaptor = $self->db->get_adaptor('Slice');
  my $seqlevel = $slice_adaptor->fetch_all($cs_name);
  my $count;
  foreach my $seq (@$seqlevel) {
    $count += $seq->length();
  }
  return $count;
}



=head2 get_ref_length

  Arg [1]    : (optional) golden path length
  Example    : $ref_length = $genome->get_ref_length();
  Description: Getter/setter for the golden path of the assembly currently used
  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_ref_length {
  my ($self, $ref_length) = @_;
  if (defined $ref_length) {
    $self->{'ref_length'} = $ref_length;
  }
  if (!defined $self->{'ref_length'}) {
513
    $self->{'ref_length'} = @{ $self->_get_statistic('ref_length')}[2];
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
  }
  return $self->{'ref_length'};
}


=head2 get_total_length

  Arg [1]    : (optional) base pair length
  Example    : $total_length = $genome->get_total_length();
  Description: Getter/setter for the total length (number of base pairs) for the assembly currently used

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_total_length {
  my ($self, $total_length) = @_;
  if (defined $total_length) {
    $self->{'total_length'} = $total_length;
  }
  if (!defined $self->{'total_length'}) {
538
    $self->{'total_length'} = @{ $self->_get_statistic('total_length')}[2];
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
  }
  return $self->{'total_length'};
}

=head2 get_toplevel

  Arg [1]    : none
  Example    : $toplevel = $genome->get_toplevel();
  Description: Returns the toplevel for the assembly currently used

  Returntype : ListRef of Bio::EnsEMBL::Slice
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_toplevel {
Magali Ruffier's avatar
Magali Ruffier committed
557 558
  my ($self) = @_;
  my $sa = $self->db->get_adaptor('Slice');
559
  $self->{'toplevel'} = $sa->fetch_all('toplevel', undef, undef, 1);
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
  return $self->{'toplevel'};
}


=head2 get_karyotype

  Arg [1]    : none
  Example    : $karyotype = $genome->get_karyotype();
  Description: Returns the karyotype for the assembly currently used

  Returntype : ListRef of Bio::EnsEMBL::Slice
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_karyotype {
Magali Ruffier's avatar
Magali Ruffier committed
578 579 580
  my ($self) = @_;
  my $sa = $self->db->get_adaptor('Slice');
  $self->{'karyotype'} = $sa->fetch_all_karyotype;
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
  return $self->{'karyotype'};
}

=head2 get_coord_systems

  Arg [1]    : none
  Example    : $coord_systems = $genome->get_coord_systems();
  Description: Returns the coord_systems for the assembly currently used

  Returntype : ListRef of Bio::EnsEMBL::CoordSystem
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_coord_systems {
Magali Ruffier's avatar
Magali Ruffier committed
598 599 600 601
  my ($self, $all) = @_;
  my $csa = $self->db->get_adaptor('CoordSystem');
  if (!$all) {
    my $version = $self->get_version();
602
    $self->{'coord_systems'} = $csa->fetch_all_by_version($version);
Magali Ruffier's avatar
Magali Ruffier committed
603 604
  } else {
    $self->{'coord_systems'} = $csa->fetch_all();
605 606 607 608 609 610 611 612 613 614 615 616
  }
  return $self->{'coord_systems'};
}

=head2 _get_count

  Arg [1]    : none
  Example    : $count = $genome->_get_count('coding_cnt');
  Description: Internal method to return a count for a given attribute code
  Returntype : integer
  Exceptions : none
  Caller     : general
617
  Status     : Stable
618 619 620 621

=cut

sub _get_count {
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
  my ($self, $code, $attribute) = @_;
  my @results = @{ $self->_get_statistic($code, $attribute) };
  return $results[2];
}

=head2 _get_statistic

  Arg [1]    : none
  Example    : $results = $genome->_get_statistic('coding_cnt');
  Description: Internal method to return the results for a given statistic
  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub _get_statistic {
  my ($self, $statistic, $attribute) = @_;
  my $db = $self->db;
  my ($value, $timestamp);
  my $fetch_sql = q{
    SELECT genome_statistics_id, statistic, value, species_id, code, timestamp
      FROM genome_statistics, attrib_type 
     WHERE genome_statistics.attrib_type_id = attrib_type.attrib_type_id
       AND statistic = ?
  };
  if (defined $attribute) {
    $fetch_sql .= " AND code = ?";
  }

  my $sth = $self->prepare($fetch_sql);
  $sth->bind_param(1, $statistic, SQL_VARCHAR);
  if (defined $attribute) {
    $sth->bind_param(2, $attribute, SQL_VARCHAR);
  }
  $sth->execute();
  my @results = $sth->fetchrow_array();
  $sth->finish();

  return \@results;
663 664
}

Magali Ruffier's avatar
Magali Ruffier committed
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691
=head2 get_attrib

  Arg [1]    : statistic
  Example    : $results = $genome->_get_attrib('coding_cnt');
  Description: Returns the attribute object for a given statistic
  Returntype : Bio::EnsEMBL::Attrib
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_attrib {
  my ($self, $statistic) = @_;
  my $db = $self->db();
  my $attribute_adaptor = $db->get_adaptor('attribute');
  my @results = @{ $self->_get_statistic($statistic) };
  my $code = $results[4];
  my @attribs = @{ $attribute_adaptor->fetch_by_code($code) };
  my $attrib = Bio::EnsEMBL::Attribute->new(
  -code => $attribs[1],
  -name => $attribs[2],
  -description => $attribs[3]
  );
  return $attrib;
}

692 693
=head2 get_coding_count

Magali Ruffier's avatar
Magali Ruffier committed
694
  Arg [1]    : (optional) coding count
695
  Example    : $coding_count = $genome->get_coding_count();
Magali Ruffier's avatar
Magali Ruffier committed
696
  Description: Getter/setter for the number of coding genes in the current build
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_coding_count {
  my ($self, $coding_count) = @_;
  if (defined $coding_count) {
    $self->{'coding_count'} = $coding_count;
  }
  if (!defined $self->{'coding_count'}) {
    $self->{'coding_count'} = $self->_get_count('coding_cnt');
  }
  return $self->{'coding_count'};
}

716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
=head2 get_rcoding_count

  Arg [1]    : (optional) readthrough coding count
  Example    : $rcoding_count = $genome->get_rcoding_count();
  Description: Getter/setter for the number of readthrough coding genes in the current build

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_rcoding_count {
  my ($self, $rcoding_count) = @_;
  if (defined $rcoding_count) {
    $self->{'rcoding_count'} = $rcoding_count;
  }
  if (!defined $self->{'rcoding_count'}) {
    $self->{'rcoding_count'} = $self->_get_count('coding_rcnt');
  }
  return $self->{'rcoding_count'};
}

740 741 742

=head2 get_snoncoding_count

Magali Ruffier's avatar
Magali Ruffier committed
743
  Arg [1]    : (optional) short non coding count
744
  Example    : $snoncoding_count = $genome->get_snoncoding_count();
Magali Ruffier's avatar
Magali Ruffier committed
745
  Description: Getter/setter for the number of short non coding genes in the current build
746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_snoncoding_count {
  my ($self, $snoncoding_count) = @_;
  if (defined $snoncoding_count) {
    $self->{'snoncoding_count'} = $snoncoding_count;
  }
  if (!defined $self->{'snoncoding_count'}) {
    $self->{'snoncoding_count'} = $self->_get_count('snoncoding_cnt');
  }
  return $self->{'snoncoding_count'};
}

765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789
=head2 get_rsnoncoding_count

  Arg [1]    : (optional) readthrough short non coding count
  Example    : $rsnoncoding_count = $genome->get_rsnoncoding_count();
  Description: Getter/setter for the number of readthrough short non coding genes in the current build

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_rsnoncoding_count {
  my ($self, $rsnoncoding_count) = @_;
  if (defined $rsnoncoding_count) {
    $self->{'rsnoncoding_count'} = $rsnoncoding_count;
  }
  if (!defined $self->{'rsnoncoding_count'}) {
    $self->{'rsnoncoding_count'} = $self->_get_count('snoncoding_rcnt');
  }
  return $self->{'rsnoncoding_count'};
}


790 791
=head2 get_lnoncoding_count

Magali Ruffier's avatar
Magali Ruffier committed
792
  Arg [1]    : (optional) long non coding count
793
  Example    : $lnoncoding_count = $genome->get_lnoncoding_count();
Magali Ruffier's avatar
Magali Ruffier committed
794
  Description: Getter/setter for the number of long non coding genes in the current build
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_lnoncoding_count {
  my ($self, $lnoncoding_count) = @_;
  if (defined $lnoncoding_count) {
    $self->{'lnoncoding_count'} = $lnoncoding_count;
  }
  if (!defined $self->{'lnoncoding_count'}) {
    $self->{'lnoncoding_count'} = $self->_get_count('lnoncoding_cnt');
  }
  return $self->{'lnoncoding_count'};
}

814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837
=head2 get_rlnoncoding_count

  Arg [1]    : (optional) readthrough long non coding count
  Example    : $rlnoncoding_count = $genome->get_rlnoncoding_count();
  Description: Getter/setter for the number of readthrough long non coding genes in the current build

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_rlnoncoding_count {
  my ($self, $rlnoncoding_count) = @_;
  if (defined $rlnoncoding_count) {
    $self->{'rlnoncoding_count'} = $rlnoncoding_count;
  }
  if (!defined $self->{'rlnoncoding_count'}) {
    $self->{'rlnoncoding_count'} = $self->_get_count('lnoncoding_rcnt');
  }
  return $self->{'rlnoncoding_count'};
}

838 839
=head2 get_pseudogene_count

Magali Ruffier's avatar
Magali Ruffier committed
840
  Arg [1]    : (optional) pseudogene count
841
  Example    : $pseudogene_count = $genome->get_pseudogene_count();
Magali Ruffier's avatar
Magali Ruffier committed
842
  Description: Getter/setter for the number of pseudogenes in the current build
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut


sub get_pseudogene_count {
  my ($self, $pseudogene_count) = @_;
  if (defined $pseudogene_count) {
    $self->{'pseudogene_count'} = $pseudogene_count;
  }
  if (!defined $self->{'pseudogene_count'}) {
    $self->{'pseudogene_count'} = $self->_get_count('pseudogene_cnt');
  }
  return $self->{'pseudogene_count'};
}

863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887
=head2 get_rpseudogene_count

  Arg [1]    : (optional) readthrough pseudogene count
  Example    : $rpseudogene_count = $genome->get_rpseudogene_count();
  Description: Getter/setter for the number of readthrough pseudogenes in the current build

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut


sub get_rpseudogene_count {
  my ($self, $rpseudogene_count) = @_;
  if (defined $rpseudogene_count) {
    $self->{'rpseudogene_count'} = $rpseudogene_count;
  }
  if (!defined $self->{'rpseudogene_count'}) {
    $self->{'rpseudogene_count'} = $self->_get_count('pseudogene_rcnt');
  }
  return $self->{'rpseudogene_count'};
}

888 889
=head2 get_alt_coding_count

Magali Ruffier's avatar
Magali Ruffier committed
890
  Arg [1]    : (optional) alt coding count
891
  Example    : $alt_coding_count = $genome->get_alt_coding_count();
Magali Ruffier's avatar
Magali Ruffier committed
892
  Description: Getter/setter for the number of coding genes on alternate sequences
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_alt_coding_count {
  my ($self, $alt_coding_count) = @_;
  if (defined $alt_coding_count) {
    $self->{'alt_coding_count'} = $alt_coding_count;
  }
  if (!defined $self->{'alt_coding_count'}) {
    $self->{'alt_coding_count'} = $self->_get_count('coding_acnt');
  }
  return $self->{'alt_coding_count'};
}

912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935
=head2 get_alt_rcoding_count

  Arg [1]    : (optional) alt readthrough coding count
  Example    : $alt_rcoding_count = $genome->get_alt_rcoding_count();
  Description: Getter/setter for the number of readthrough coding genes on alternate sequences

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_alt_rcoding_count {
  my ($self, $alt_rcoding_count) = @_;
  if (defined $alt_rcoding_count) {
    $self->{'alt_rcoding_count'} = $alt_rcoding_count;
  }
  if (!defined $self->{'alt_rcoding_count'}) {
    $self->{'alt_rcoding_count'} = $self->_get_count('coding_racnt');
  }
  return $self->{'alt_rcoding_count'};
}

936 937 938

=head2 get_alt_snoncoding_count

Magali Ruffier's avatar
Magali Ruffier committed
939
  Arg [1]    : (optional) alt short non coding count
940
  Example    : $alt_snoncoding_count = $genome->get_alt_snoncoding_count();
Magali Ruffier's avatar
Magali Ruffier committed
941
  Description: Getter/setter for the number of short non coding genes on alternate sequences
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_alt_snoncoding_count {
  my ($self, $alt_snoncoding_count) = @_;
  if (defined $alt_snoncoding_count) {
    $self->{'alt_snoncoding_count'} = $alt_snoncoding_count;
  }
  if (!defined $self->{'alt_snoncoding_count'}) {
    $self->{'alt_snoncoding_count'} = $self->_get_count('snoncoding_acnt');
  }
  return $self->{'alt_snoncoding_count'};
}

961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985
=head2 get_alt_rsnoncoding_count

  Arg [1]    : (optional) alt readthrough short non coding count
  Example    : $alt_rsnoncoding_count = $genome->get_alt_snoncoding_count();
  Description: Getter/setter for the number of readthrough short non coding genes on alternate sequences

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_alt_rsnoncoding_count {
  my ($self, $alt_rsnoncoding_count) = @_;
  if (defined $alt_rsnoncoding_count) {
    $self->{'alt_rsnoncoding_count'} = $alt_rsnoncoding_count;
  }
  if (!defined $self->{'alt_rsnoncoding_count'}) {
    $self->{'alt_rsnoncoding_count'} = $self->_get_count('snoncoding_racnt');
  }
  return $self->{'alt_rsnoncoding_count'};
}


986 987
=head2 get_alt_lnoncoding_count

988
  Arg [1]    : (optional) alt long non coding count
989
  Example    : $alt_lnoncoding_count = $genome->get_alt_lnoncoding_count();
Magali Ruffier's avatar
Magali Ruffier committed
990
  Description: Getter/setter for the number of long non coding genes on alternate sequences
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_alt_lnoncoding_count {
  my ($self, $alt_lnoncoding_count) = @_;
  if (defined $alt_lnoncoding_count) {
    $self->{'alt_lnoncoding_count'} = $alt_lnoncoding_count;
  }
  if (!defined $self->{'alt_lnoncoding_count'}) {
    $self->{'alt_lnoncoding_count'} = $self->_get_count('lnoncoding_acnt');
  }
  return $self->{'alt_lnoncoding_count'};
}

1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034
=head2 get_alt_rlnoncoding_count

  Arg [1]    : (optional) alt readthrough long non coding count
  Example    : $alt_lnoncoding_count = $genome->get_alt_lnoncoding_count();
  Description: Getter/setter for the number of readthrough long non coding genes on alternate sequences

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_alt_rlnoncoding_count {
  my ($self, $alt_rlnoncoding_count) = @_;
  if (defined $alt_rlnoncoding_count) {
    $self->{'alt_rlnoncoding_count'} = $alt_rlnoncoding_count;
  }
  if (!defined $self->{'alt_rlnoncoding_count'}) {
    $self->{'alt_rlnoncoding_count'} = $self->_get_count('lnoncoding_racnt');
  }
  return $self->{'alt_rlnoncoding_count'};
}


1035 1036 1037

=head2 get_alt_pseudogene_count

1038
  Arg [1]    : (optional) alt pseudogene count
1039
  Example    : $alt_pseudogene_count = $genome->get_alt_pseudogene_count();
Magali Ruffier's avatar
Magali Ruffier committed
1040
  Description: Getter/setter for the number of pseudogenes on alternate sequences
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_alt_pseudogene_count {
  my ($self, $alt_pseudogene_count) = @_;
  if (defined $alt_pseudogene_count) {
    $self->{'alt_pseudogene_count'} = $alt_pseudogene_count;
  }
  if (!defined $self->{'alt_pseudogene_count'}) {
    $self->{'alt_pseudogene_count'} = $self->_get_count('pseudogene_acnt');
  }
  return $self->{'alt_pseudogene_count'};
}

1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
=head2 get_alt_rpseudogene_count

  Arg [1]    : (optional) alt readthrough pseudogene count
  Example    : $alt_rpseudogene_count = $genome->get_alt_pseudogene_count();
  Description: Getter/setter for the number of readthrough pseudogenes on alternate sequences

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_alt_rpseudogene_count {
  my ($self, $alt_rpseudogene_count) = @_;
  if (defined $alt_rpseudogene_count) {
    $self->{'alt_rpseudogene_count'} = $alt_rpseudogene_count;
  }
  if (!defined $self->{'alt_rpseudogene_count'}) {
    $self->{'alt_rpseudogene_count'} = $self->_get_count('pseudogene_racnt');
  }
  return $self->{'alt_rpseudogene_count'};
}

1084
=head2 get_short_variation_count
1085

Magali Ruffier's avatar
Magali Ruffier committed
1086
  Arg [1]    : (optional) short variation count
1087
  Example    : $short_variation_count = $genome->get_short_variation_count();
Magali Ruffier's avatar
Magali Ruffier committed
1088
  Description: Getter/setter for the number of short variants in the current build
1089 1090 1091 1092 1093 1094 1095 1096

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

1097 1098 1099 1100
sub get_short_variation_count {
  my ($self, $short_variation_count) = @_;
  if (defined $short_variation_count) {
    $self->{'short_variation_count'} = $short_variation_count;
1101
  }
1102
  if (!defined $self->{'short_variation_count'}) {
1103
    $self->{'short_variation_count'} = $self->_get_count('SNPCount');
1104
  }
1105
  return $self->{'short_variation_count'};
1106 1107 1108 1109 1110 1111
}


=head2 get_prediction_count

  Arg [1]    : (optional) logic_name
Magali Ruffier's avatar
Magali Ruffier committed
1112
  Arg [2]    : (optional) prediction count
1113
  Example    : $prediction_count = $genome->get_prediction_count();
Magali Ruffier's avatar
Magali Ruffier committed
1114
  Description: Getter/setter for the number of predicted genes in the current build
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124
               Can be restricted to a given analysis

  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_prediction_count {
Magali Ruffier's avatar
Magali Ruffier committed
1125 1126 1127 1128
  my ($self, $logic_name, $prediction_count) = @_;
  if (defined $prediction_count) {
    $self->{'prediction_count'} = $prediction_count;
  }
1129
  if (!defined $self->{'prediction_count'}) {
1130
    $self->{'prediction_count'} = $self->_get_count('PredictionTranscript', $logic_name);
1131 1132 1133 1134 1135
  }
  return $self->{'prediction_count'};
}


1136
=head2 get_structural_variation_count
1137 1138

  Arg [1]    : none
1139 1140
  Example    : $structural_variation_count = $genome->get_structural_variation_count();
  Description: Return the number of structural variations in the current build
1141 1142 1143
  Returntype : integer
  Exceptions : none
  Caller     : general
1144
  Status     : Stable
1145 1146 1147

=cut

1148
sub get_structural_variation_count {
Magali Ruffier's avatar
Magali Ruffier committed
1149 1150 1151 1152
  my ($self, $structural_variation_count) = @_;
  if (defined $structural_variation_count) {
    $self->{'structural_variation_count'} = $structural_variation_count;
  }
1153 1154 1155 1156
  if (!defined $self->{'structural_variation_count'}) {
    $self->{'structural_variation_count'} = $self->_get_count('StructuralVariation');
   }
  return $self->{'structural_variation_count'};
1157 1158
}

1159 1160
=head2 get_transcript_count

Magali Ruffier's avatar
Magali Ruffier committed
1161
  Arg [1]    : (optional) transcript count
1162
  Example    : $transcript_count = $genome->get_transcript_count();
Magali Ruffier's avatar
Magali Ruffier committed
1163
  Description: Getter/setter for the number of transcripts in the current build
1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183
  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_transcript_count {
  my ($self, $transcript_count) = @_;
  if (defined $transcript_count) {
    $self->{'transcript_count'} = $transcript_count;
  }
  if (!defined $self->{'transcript_count'}) {
    $self->{'transcript_count'} = $self->_get_count('transcript');
  }
  return $self->{'transcript_count'};
}

=head2 get_alt_transcript_count

Magali Ruffier's avatar
Magali Ruffier committed
1184
  Arg [1]    : (optional) alt transcript count
1185
  Example    : $alt_transcript_count = $genome->get_alt_transcript_count();
Magali Ruffier's avatar
Magali Ruffier committed
1186
  Description: Getter/setter for the number of transcripts on alternate sequences in the current build
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204
  Returntype : integer
  Exceptions : none
  Caller     : general
  Status     : Stable

=cut

sub get_alt_transcript_count {
  my ($self, $alt_transcript_count) = @_;
  if (defined $alt_transcript_count) {
    $self->{'alt_transcript_count'} = $alt_transcript_count;
  }
  if (!defined $self->{'alt_transcript_count'}) {
    $self->{'alt_transcript_count'} = $self->_get_count('alt_transcript');
  }
  return $self->{'alt_transcript_count'};
}

1205 1206

1;