ensembl-analysis
GeneChecker
Toolbar
Summary
Bio::EnsEMBL::Test::GeneChecker
Package variables
No package variables defined.
Included modules
Inherit
Checker
Synopsis
Module to check the validity of a gene
Description
Performs various checks on a Bio::EnsEMBL::Gene object. These include:
1. Genes with long extents
2. Genes with no transcripts
2. Genes with more than a certain number of transccripts
3. Genes with transcripts on both strands
This class does not use stable_ids but instead dbIDs because stable_ids are
not set until after the gene build.
Methods
Methods description
Title : gene Usage : $obj->gene($newval) Function: Returns : value of gene Args : newvalue (optional) |
Methods code
sub adaptor
{ my ( $self, $arg ) = @_;
if( defined $arg ) {
$self->{_adaptor} = $arg;
}
return $self->{_adaptor}; } |
sub check
{ my $self = shift;
$self->check_Structure; } |
sub check_Structure
{ my $self = shift;
if ($self->gene->length > $self->maxgenelen) {
$self->add_Error("Gene too long\n", 'genelen');
}
if (scalar(@{$self->gene->get_all_Transcripts}) == 0) {
$self->add_Error("No transcripts in gene\n", 'notransgene');
}
if (scalar(@{$self->gene->get_all_Transcripts}) > $self->maxtransgene) {
$self->add_Error("Too many transcripts in gene\n", 'numtransgene');
}
my $firststrand = undef;
foreach my $trans (@{$self->gene->get_all_Transcripts}) {
if (!defined($firststrand)) {
$firststrand = $trans->strand;
}
if ($trans->strand != $firststrand) {
$self->add_Error("Transcripts on both strands in gene\n", 'bothstrandgene');
}
}
}
1; } |
sub gene
{ my $self = shift;
if( @_ ) {
my $value = shift;
if (!($value->isa('Bio::EnsEMBL::Gene'))) {
$self->throw("gene passed a non Bio::EnsEMBL::Gene object\n");
}
$self->{_gene} = $value;
}
return $self->{_gene}; } |
sub maxgenelen
{ my ( $self, $arg ) = @_;
if (defined $arg) {
$self->{_maxgenelen} = $arg;
}
return $self->{_maxgenelen}; } |
sub maxtransgene
{ my ( $self, $arg ) = @_;
if (defined $arg) {
$self->{_maxtransgene} = $arg;
}
return $self->{_maxtransgene}; } |
sub new
{ my ($class, @args) = @_;
my $self = bless {},$class;
my ( $gene, $maxgenelen, $maxtransgene, $ignorewarnings, $slice, $adaptor ) = rearrange
( [ qw ( GENE
MAXGENELEN
MAXTRANSGENE
IGNOREWARNINGS
SLICE
ADAPTOR
)], @args );
if( !defined $gene ) {
$self->throw("Gene must be set in new for GeneChecker")
}
$self->gene($gene);
if( defined $maxgenelen ) {
$self->maxgenelen( $maxgenelen );
} else {
$self->maxgenelen(2_000_000);
}
if( defined $maxtransgene ) {
$self->maxtransgene( $maxtransgene );
} else {
$self->maxtransgene(10);
}
if( defined $ignorewarnings) { $self->ignorewarnings($ignorewarnings); }
if( defined $slice) { $self->slice($slice); }
if( defined $adaptor ) { $self->adaptor( $adaptor )}
$self->{_errors} = [];
$self->{_warnings} = [];
return $self; } |
sub output
{ my $self = shift;
my $gene = $self->gene;
print "\n++++++++++++++++++\n";
print "Gene " . $self->gene->dbID . " " .
(defined($self->gene->stable_id) ? $self->gene->stable_id : "") . " type " . $self->gene->biotype . "\n";
my $vcoffset = 0;
if ($self->slice) {
$vcoffset = $self->slice->start - 1;
}
print " Extents: " . ($self->gene->start+$vcoffset) . " " . ($self->gene->end+$vcoffset) . " " . $self->gene->strand . "\n";
print " Length: " . $self->gene->length . "\n";
print " Num Transcripts: " . scalar(@{$self->gene->get_all_Transcripts}) . "\n";
foreach my $trans (@{$self->gene->get_all_Transcripts}) {
print " Transcript " . $trans->dbID . " " . ($trans->start+$vcoffset) . " " . ($trans->end+$vcoffset) . " " . $trans->length . "\n";
}
$self->SUPER::output; } |
sub slice
{ my $self = shift;
if( @_ ) {
my $value = shift;
if (!($value->isa('Bio::EnsEMBL::Slice'))) {
$self->throw("vc passed a non Bio::EnsEMBL::Slice object\n");
}
$self->{_slice} = $value;
}
return $self->{_slice}; } |
General documentation
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _