Bio::Tools
ECnumber
Toolbar
Summary
ECnumber - representation of EC numbers
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
use Bio::Tools::ECnumber;
# Creation of ECnumber objects
# ----------------------------
my $EC1 = Bio::Tools::ECnumber->new( -ec_string => "4.3.2.1" );
my $EC2 = Bio::Tools::ECnumber->new( -ec_string => "EC 1.1.1.1" );
my $EC3 = Bio::Tools::ECnumber->new();
# Copying
# -------
my $EC4 = $EC1->copy();
# Modification of ECnumber objects
# --------------------------------
print $EC3->EC_string( "1.01.01.001" ); # Prints "1.1.1.1".
# To string
# ---------
print $EC3->EC_string();
# or:
print $EC3->to_string();
# Test for equality
# -----------------
# Against ECnumber object:
if ( $EC3->is_equal( $EC2 ) ) { # Prints "equal".
print "equal";
}
# Against string representation of EC number:
if ( ! $EC3->is_equal( "1.1.1.-" ) ) { # Prints "not equal".
print "not equal";
}
# Test for membership
# -------------------
my $EC5 = Bio::Tools::ECnumber->new( -ec_string => "4.3.2.-" );
# Against ECnumber object.
if ( $EC1->is_member( $EC5 ) ) { # Prints "member".
print "member";
}
# Against string representation of EC number.
if ( ! $EC1->is_member( "4.3.1.-" ) ) { # Prints "not member".
print "not member";
}
Description
Methods
Methods description
Title : EC_string Usage : $EC3->EC_string( "1.1.1.-" ); or print $EC3->EC_string(); Function: Set/get for string representations of EC numbers. Parses a EC number from "x.x.x.x", "EC x.x.x.x", "ECx.x.x.x", or "EC:x.x.x.x"; x being either a positive integer or a "-". Returns : A string representations of a EC number. Args : A string representations of a EC number. |
Title : comment Usage : $EC1->comment( "deprecated" ); or print $EC1->comment(); Function: Set/get for a arbitrary comment. Returns : A comment [scalar]. Args : A comment [scalar]. |
Title : copy() Usage : $EC2 = $EC1->copy(); Function: Creates a new ECnumber object which is an exact copy of this ECnumber. Returns : A copy of this ECnumber. Args : |
Title : enzyme_class Usage : $EC1->enzyme_class( 1 ); or print $EC1->enzyme_class(); Function: Set/get for the enzyme class number of ECnumbers. Returns : The enzyme class number of this ECnumber. Args : A positive integer or "-". |
Title : init() Usage : $EC1->init(); # EC1 is now "-.-.-.-" Function: Initializes this ECnumber to default values. Returns : Args : |
Title : is_equal Usage : if ( $EC3->is_equal( $EC2 ) ) or if ( $EC3->is_equal( "1.1.1.-" ) ) Function: Checks whether this ECnumber is equal to the argument EC number (please note: "1.1.1.1" != "1.1.1.-"). Returns : True (1) or false (0). Args : A ECnumber object or a string representation of a EC number. |
Title : is_member Usage : if ( $EC1->is_member( $EC5 ) ) or if ( $EC1->is_member( "4.3.-.-" ) ) Function: Checks whether this ECnumber is a member of the (incomplete) argument EC number (e.g. "1.1.1.1" is a member of "1.1.1.-" but not of "1.1.1.2"). Returns : True (1) or false (0). Args : A ECnumber object or a string representation of a EC number. |
Title : new Usage : $EC1 = Bio::Tools::ECnumber->new( -ec_string => "4.3.2.1" ); or $EC2 = Bio::Tools::ECnumber->new( -ec_string => "4.3.2.2", -comment => "Is EC 4.3.2.2" ); or $EC3 = Bio::Tools::ECnumber->new(); # EC3 is now "-.-.-.-" Function: Creates a new ECnumber object. Parses a EC number from "x.x.x.x", "EC x.x.x.x", "ECx.x.x.x", or "EC:x.x.x.x"; x being either a positive integer or a "-". Returns : A new Ecnumber object. Args : A string representing a EC number, e.g. "4.3.2.1" or "EC 4.3.2.1" or "1.-.-.-". |
Title : serial_number Usage : $EC1->serial_number( 482 ); or print $EC1->serial_number(); Function: Set/get for the serial number of ECnumbers. Returns : The serial number of this ECnumber. Args : A positive integer or "-". |
Title : sub_class Usage : $EC1->sub_class( 4 ); or print $EC1->sub_class(); Function: Set/get for the enzyme sub class number of ECnumbers. Returns : The enzyme sub class number of this ECnumber. Args : A positive integer or "-". |
Title : sub_sub_class Usage : $EC1->sub_sub_class( 12 ); or print $EC1->sub_sub_class(); Function: Set/get for the enzyme sub sub class number of ECnumbers. Returns : The enzyme sub sub class number of this ECnumber. Args : A positive integer or "-". |
Title : to_string() Usage : print $EC3->to_string(); Function: To string method for EC numbers (equals the "get" functionality of "EC_string"). Returns : A string representations of a EC number. Args : |
Methods code
sub EC_string
{ my ( $self, $value ) = @_;
if ( defined $value) {
$value =~ s/\s+//g; $value =~ s/^EC//i; $value =~ s/^://;
if ( $value =~ /^([\d-]*)\.([\d-]*)\.([\d-]*)\.([\d-]*)$/ ) {
$self->enzyme_class( $1 );
$self->sub_class( $2 );
$self->sub_sub_class( $3 );
$self->serial_number( $4 );
}
else {
$self->throw( "Illegal format error [$value]" );
}
}
return $self->to_string();
}
} |
sub _check_for_illegal_defaults
{ my ( $self ) = @_;
if ( ( $self->sub_sub_class() eq DEFAULT
&& $self->serial_number() ne DEFAULT ) ||
( $self->sub_class() eq DEFAULT
&& $self->sub_sub_class() ne DEFAULT ) ||
( $self->enzyme_class() eq DEFAULT
&& $self->sub_class() ne DEFAULT ) ) {
$self->throw( "Illegal format error for comparison ["
. $self->to_string() . "]" );
}
}
} |
sub _check_number
{ my ( $self, $value ) = @_;
my $original_value = $value;
$value =~ s/\s+//g; if ( $value eq "" ) {
$value = DEFAULT;
}
$value =~ s/^0+//; if ( $value eq "" ) { $value = "0";
}
elsif ( $value ne DEFAULT
&& $value =~ /\D/ ) {
$self->throw( "Illegal format error [$original_value]" );
}
return $value;
}
} |
sub _is_ECnumber_object
{ my ( $self, $value ) = @_;
unless( $value->isa( "Bio::Tools::ECnumber" ) ) {
$self->throw( "Found [". ref( $value )
."] where [Bio::Tools::ECnumber] expected" );
}
}
1; } |
sub _is_not_reference
{ my ( $self, $value ) = @_;
return ( ! ref( $value ) );
}
} |
sub comment
{ my ( $self, $value ) = @_;
if ( defined $value) {
$self->{ "_comment" } = $value;
}
return $self->{ "_comment" };
}
} |
sub copy
{ my( $self ) = @_;
my $new_ec = $self->new();
$new_ec->enzyme_class( $self->enzyme_class() );
$new_ec->sub_class( $self->sub_class() );
$new_ec->sub_sub_class( $self->sub_sub_class() );
$new_ec->serial_number( $self->serial_number() );
$new_ec->comment( $self->comment() );
return $new_ec;
}
} |
sub enzyme_class
{ my ( $self, $value ) = @_;
if ( defined $value) {
$self->{ "_enzyme_class" } = $self->_check_number( $value );
}
return $self->{ "_enzyme_class" };
}
} |
sub init
{ my( $self ) = @_;
$self->enzyme_class( DEFAULT );
$self->sub_class( DEFAULT );
$self->sub_sub_class( DEFAULT );
$self->serial_number( DEFAULT );
$self->comment( "" );
}
} |
sub is_equal
{ my ( $self, $value ) = @_;
if ( $self->_is_not_reference( $value ) ) {
$value = $self->new( -ec_string => $value );
}
else {
$self->_is_ECnumber_object( $value );
}
unless ( $self->enzyme_class() eq $value->enzyme_class() ) {
return FALSE;
}
unless ( $self->sub_class() eq $value->sub_class() ) {
return FALSE;
}
unless ( $self->sub_sub_class() eq $value->sub_sub_class() ) {
return FALSE;
}
unless ( $self->serial_number() eq $value->serial_number() ) {
return FALSE;
}
return TRUE;
}
} |
sub is_member
{ my ( $self, $value ) = @_;
if ( $self->_is_not_reference( $value ) ) {
$value = $self->new( -ec_string => $value );
}
else {
$self->_is_ECnumber_object( $value );
}
$self->_check_for_illegal_defaults();
$value->_check_for_illegal_defaults();
unless ( $value->enzyme_class() eq DEFAULT
|| $self->enzyme_class() eq $value->enzyme_class() ) {
return FALSE;
}
unless ( $value->sub_class() eq DEFAULT
|| $self->sub_class() eq $value->sub_class() ) {
return FALSE;
}
unless ( $value->sub_sub_class() eq DEFAULT
|| $self->sub_sub_class() eq $value->sub_sub_class() ) {
return FALSE;
}
unless ( $value->serial_number() eq DEFAULT
|| $self->serial_number() eq $value->serial_number() ) {
return FALSE;
}
return TRUE;
}
} |
sub new
{ my( $class, @args ) = @_;
my $self = $class->SUPER::new( @args );
my ( $EC_string, $comment )
= $self->_rearrange( [ qw( EC_STRING COMMENT ) ], @args );
$self->init();
$EC_string && $self->EC_string( $EC_string );
$comment && $self->comment( $comment );
return $self;
}
} |
sub serial_number
{ my ( $self, $value ) = @_;
if ( defined $value) {
$self->{ "_serial_number" } = $self->_check_number( $value );
}
return $self->{ "_serial_number" };
}
} |
sub sub_class
{ my ( $self, $value ) = @_;
if ( defined $value) {
$self->{ "_sub_class" } = $self->_check_number( $value );
}
return $self->{ "_sub_class" };
}
} |
sub sub_sub_class
{ my ( $self, $value ) = @_;
if ( defined $value) {
$self->{ "_sub_sub_class" } = $self->_check_number( $value );
}
return $self->{ "_sub_sub_class" };
}
} |
sub to_string
{ my ( $self ) = @_;
my $s = $self->enzyme_class() . ".";
$s .= $self->sub_class() . ".";
$s .= $self->sub_sub_class() . ".";
$s .= $self->serial_number();
return $s;
}
} |
General documentation
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bio.perl.org/MailList.html - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via email
or the web:
bioperl-bugs@bio.perl.org
http://bugzilla.bioperl.org/
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _