diff --git a/modules/Bio/EnsEMBL/GoXref.pm b/modules/Bio/EnsEMBL/GoXref.pm index 94287b7a3c19fab90d80256cc0582559c8701869..e99d7f512c08c4e025a67c6000cbbb1be61a8705 100644 --- a/modules/Bio/EnsEMBL/GoXref.pm +++ b/modules/Bio/EnsEMBL/GoXref.pm @@ -1,9 +1,3 @@ - -# -# EnsEMBL module for GoXref.pl -# -# Cared for by Arne Stabenau <stabenau@ebi.ac.uk> -# # Copyright EnsEMBL 2000-2003 # # You may distribute this module under the same terms as perl itself @@ -16,38 +10,38 @@ Bio::EnsEMBL::GoXref =head1 DESCRIPTION -This class extends the DBEntry in order to associate Evidence Tags to the -relationship between EnsEMBL objects and GO identifiers. The relationship -to GO that is stored in the database is actually derived through the -relationship of EnsEMBL peptides to SwissProt peptides. +This class extends the DBEntry in order to associate Evidence Tags +to the relationship between EnsEMBL objects and GO identifiers. The +relationship to GO that is stored in the database is actually derived +through the relationship of EnsEMBL peptides to SwissProt peptides. I.e. The relationship is derived like this: -ENSP -> SWISSPROT -> GO - -An the evidence tag describes the relationship between the SWISSPROT Peptide -and the GO entry. +ENSP -> SWISSPROT -> GO + +An the evidence tag describes the relationship between the SWISSPROT +Peptide and the GO entry. In reality, however, we store this in the database like this: ENSP -> SWISSPROT ENSP -> GO -and the evidence tag hangs off of the relationship between the ENSP and -the GO identifier. Some ENSPs are associated with multiple closely related -Swissprot entries which may both be associated with the same GO identifier but -with different evidence tags. For this reason a single 'GoXref' can have -multiple evidence tags. +and the evidence tag hangs off of the relationship between the ENSP +and the GO identifier. Some ENSPs are associated with multiple closely +related Swissprot entries which may both be associated with the same GO +identifier but with different evidence tags. For this reason a single +'GoXref' can have multiple evidence tags. =head1 SYNOPSIS -my $goxref = Bio::EnsEMBL::GoXref->new; -$goxref->add_linkage_type('IEA') + my $goxref = Bio::EnsEMBL::GoXref->new; + $goxref->add_linkage_type('IEA'); -foreach my $evtag (@{$goxref->get_all_linkage_types()}) { - print "$evtag\n"; -} + foreach my $evtag ( @{ $goxref->get_all_linkage_types() } ) { + print "$evtag\n"; + } =head1 CONTACT @@ -61,15 +55,14 @@ package Bio::EnsEMBL::GoXref; use vars qw(@ISA); use strict; - @ISA = qw( Bio::EnsEMBL::DBEntry ); - =head2 add_linkage_type Arg [1] : string $value - allowed are "IC", "IDA", "IEA", "IEP", "IGI", "IMP", "IPI", "ISS", - "NAS", "NS", "TAS", "NR" + allowed values: + 'IC', 'IDA', 'IEA', 'IEP', 'IGI', 'IMP', 'IPI', + 'ISS', NAS', 'ND', 'TAS', 'NR', 'RCA' Arg [2] : (optional) Bio::EnsEMBL::DBEntry $source Example : $go_xref->add_linkage_type('IGI'); Description: Associates a linkage type and source DBEntry with this go_xref @@ -82,17 +75,20 @@ use strict; =cut sub add_linkage_type { - my $self = shift; - my $lt = shift; - my $source_dbentry = shift || undef(); - - $self->throw("linkage type argument required") if(!$lt); - $self->throw("source_xref must be a Bio::EnsEMBL::DBEntry") - if($source_dbentry - and ! UNIVERSAL::isa($source_dbentry,'Bio::EnsEMBL::DBEntry')); + my ( $self, $lt, $source_dbentry ) = @_; + + $self->throw("linkage type argument required") if ( !$lt ); + + if ( defined($source_dbentry) + && !$source_dbentry->isa('Bio::EnsEMBL::DBEntry') ) + { + $self->throw("source_dbentry must be a Bio::EnsEMBL::DBEntry"); + } $self->{'linkage_types'} ||= []; - push @{$self->{'linkage_types'}}, [$lt, ( $source_dbentry || () )]; + + push @{ $self->{'linkage_types'} }, + [ $lt, ( $source_dbentry || () ) ]; } @@ -111,7 +107,7 @@ sub add_linkage_type { =cut sub get_all_linkage_info { - my $self = shift; + my ($self) = @_; return $self->{'linkage_types'} || []; } @@ -120,7 +116,9 @@ sub get_all_linkage_info { =head2 get_all_linkage_types Arg [1] : none - Example : foreach my $et (@{$goxr->get_all_linkage_types}){ print "$et ";} + Example : print( join( ' ', + @{ $goxr->get_all_linkage_types() } ), + "\n" ); Description: Retrieves a unique list of evidence tags associated with this go_xref Returntype : none @@ -131,9 +129,12 @@ sub get_all_linkage_info { =cut sub get_all_linkage_types { - my $self = shift; + my ($self) = @_; + my %seen; - return[ grep{!$seen{$_}++} map{$_->[0]} @{$self->{'linkage_types'}} ]; + return [ grep { !$seen{$_}++ } + map { $_->[0] } @{ $self->{'linkage_types'} } ]; + #return [ map{ $_->[0]} @{ $self->{'linkage_types'} || [] } ]; } @@ -151,8 +152,8 @@ sub get_all_linkage_types { =cut sub flush_linkage_types { - my $self = shift; - + my ($self) = @_; + $self->{'linkage_types'} = []; }