These documents are For the HEAD of the CVS repository on July 19, 2007
Api docs for previous releases
Modware
Has_synonyms
Modware::Has_synonyms - Mixin class, provides accessor methods for classes tha have synonyms.
|
No package variables defined. |
USE CASE: ADD A SYNONYM TO OBJECT
my $gene = new Modware::Gene( -name => 'testGene' ); $gene->add_synoym( 'new synonym' );
USE CASE: PRINT A LIST OF SYNONYMS FOR OBJECT
my $gene = new Modware::Gene( -name => 'testGene' );
foreach $synonym ( @{ $gene->synonyms() } ) { print $synonym."\n"; }
|
Abstract class to provide methods for objects which carry arrays of synonyms Never instantiate this object, only inherit All database operations are handled in the implementing class for example see _get_synonyms and _update_synonyms in Modware::Feature::GENE _update_synonyms must be called in both the insert() and update() method of the implementor.
|
Methods description
Title : _get_synonyms
Usage : $gene->_get_synonyms();
Function : gets the synonyms for this gene ( arrayref of strings )
Returns : nothing
Args : none
Title : _update_synonyms
Function : adds/links/unlinks synonyms from this gene
: compares list from database to current gene product list, inserts/deletes as necessary
Returns : nothing
Args : none
Title : add_synonym
Usage : $gene->add_synonym( 'test synonym' );
Function : adds an synonym to the synonym array IF IT DOES NOT EXIST
Returns : nothing
Args : string
TO DO : need to add second argument (is_automated) to set the is automated property of a new gene product
Title : remove_synonym
Usage : $gene->remove_synonym( 'test product' );
Function : removes a synonym the synonyms array if the synonym_name matches
Returns : nothing
Args : string
Title : synonyms
Usage : foreach my $synonym ( @{ $gene->synonyms() ) {
: print $synonym."\n";
: }
Function : get/set synonyms for this gene
Returns : reference to array of strings
Args : reference to array of strings ( optional )
Methods code
sub _get_synonyms
{ my ($self) = @_;
$self->throw_not_implemented();
}
sub _update_synonyms
{ my ($self, @args) = @_;
$self->throw_not_implemented();
}
sub add_synonym
{ my ($self, $synonym_name ) = @_;
$self->throw( "need synonym to add") if !$synonym_name;
if ( !grep { $_ eq $synonym_name } @{ $self->synonyms() } ) {
push @{ $self->synonyms }, $synonym_name;
}
}
sub remove_synonym
{ my ($self, $synonym_name) = @_;
$self->throw( "need synonym to remove") if !$synonym_name;
my @synonyms = grep { $_ ne $synonym_name } @{ $self->synonyms() };
$self->synonyms (\@ synonyms );
}
sub synonyms
{ my ($self, $obj) = @_;
#
# fetches synonyms from database (_get_synonyms) if synonyms is not yet defined
# and the user is not attempting to set the synonyms options
#
exists $self->{synonyms} || scalar @_ > 1 || $self->_get_synonyms();
if(scalar @_ > 1) {
$self->{synonyms} = $obj;
}
return $self->{synonyms};
}
General documentation
Copyright © 2006, Northwestern University
All rights reserved.
|
|