Bio::EnsEMBL::Compara::Production GeneSet
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
Bio::EnsEMBL::Compara::Production::GeneSet
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::Compara::Graph::CGObject
Bio::EnsEMBL::Compara::Member
Inherit
Bio::EnsEMBL::Compara::Graph::CGObject
Synopsis
An abstract data class for holding an arbitrary collection of
(ENSEMBLGENE)Member objects and providing set operations and
cross-reference operations to compare to another GeneSet object.
Also used by HomologySet.
Description
A 'set' object of Gene objects. Uses Member::stable_id to identify unique genes.
Is used for comparing GeneSet objects with each other and building comparison
matrixes.
Not really a production object, but more an abstract data type for use by
post analysis scripts. Placed in Production since I could not think of a better location.
The design of this object essentially was within the homology_diff.pl script
but has now been formalized into a proper object design.
Methods
add
No description
Code
clear
No description
Code
dealloc
No description
Code
find_gene_like
No description
Code
hashref_by_genome
No description
Code
includes
No description
Code
init
No description
Code
intersection
No description
Code
list
No description
Code
merge
No description
Code
print_stats
No description
Code
relative_complement
No description
Code
size
No description
Code
Methods description
None available.
Methods code
adddescriptionprevnextTop
sub add {
  my $self = shift;
  my @gene_list = @_; 
  
  foreach my $gene (@gene_list) {
    next if(defined($self->{'gene_hash'}->{$gene->stable_id}));
    $self->{'gene_hash'}->{$gene->stable_id} = $gene;
  }  
  return $self;
}
cleardescriptionprevnextTop
sub clear {
  my $self = shift;
    
  $self->{'gene_hash'} = {};
}
deallocdescriptionprevnextTop
sub dealloc {
  my $self = shift;
  return $self->SUPER::dealloc;
}
find_gene_likedescriptionprevnextTop
sub find_gene_like {
  my $self = shift;
  my $gene = shift;
  return $self->{'gene_hash'}->{$gene->stable_id};
}


### debug printing ###
}
hashref_by_genomedescriptionprevnextTop
sub hashref_by_genome {
  my $self = shift;
  my %types;
  foreach my $gene (@{$self->list}) {
    unless(defined($types{$gene->genome_db_id})) {
      $types{$gene->genome_db_id} = 
         new Bio::EnsEMBL::Compara::Production::GeneSet;
    }
    $types{$gene->genome_db_id}->add($gene);
  }
  return\% types;
}


############################################
#
# set theory operations
#
############################################
}
includesdescriptionprevnextTop
sub includes {
  my $self = shift;
  my $gene = shift;
  return 1 if(defined($self->{'gene_hash'}->{$gene->stable_id}));
  return 0;
}
initdescriptionprevnextTop
sub init {
  my $self = shift;
  $self->SUPER::init;
  $self->clear;
  return $self;
}
intersectiondescriptionprevnextTop
sub intersection {
  my $self = shift;
  my $other_set = shift;
  
  my $new_set = new Bio::EnsEMBL::Compara::Production::GeneSet;
  foreach my $gene (@{$self->list}) {
    if($other_set->includes($gene)) {
      $new_set->add($gene);
    }
  }
  return $new_set;
}


1;
}
listdescriptionprevnextTop
sub list {
  my $self = shift;
  my @genes = values(%{$self->{'gene_hash'}});
  return\@ genes;
}
mergedescriptionprevnextTop
sub merge {
  my $self = shift;
  my $other_set = shift;
  
  $self->add(@{$other_set->list});
  return $self;
}


### gene ###
}
print_statsdescriptionprevnextTop
sub print_stats {
  my $self = shift;
  
  printf("%d unique genes\n", $self->size);
}
relative_complementdescriptionprevnextTop
sub relative_complement {
  my $self = shift;
  my $other_set = shift;
  
  #genes in other_set that are not in my set
my $new_set = new Bio::EnsEMBL::Compara::Production::GeneSet; foreach my $gene (@{$other_set->list}) { unless($self->includes($gene)) { $new_set->add($gene); } } return $new_set;
}
sizedescriptionprevnextTop
sub size {
  my $self = shift;
  return scalar(@{$self->list});
}
General documentation
CONTACTTop
  Contact Jessica Severin on module implemetation/design detail: jessica@ebi.ac.uk
Contact Abel Ureta-Vidal on EnsEMBL/Compara: abel@ebi.ac.uk
Contact Ewan Birney on EnsEMBL in general: birney@sanger.ac.uk
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _