[Bio] / FigKernelPackages / FIGUtilities.pm Repository:
ViewVC logotype

View of /FigKernelPackages/FIGUtilities.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Mon Oct 31 21:11:34 2005 UTC (14 years, 3 months ago) by olson
Branch: MAIN
CVS Tags: caBIG-00-00-00
some standalone (don't need a FIG object) utility routines.

#
# Package of simple fig utility fns. Names exported to calling namespace.
#

package FIGUtilities;

use base 'Exporter';

@EXPORT = qw(
	     max
	     min
	     ftype
	     genome_of
	    );


sub max {
    my(@x) = @_;
    my($max,$i);

    (@x > 0) || return undef;
    $max = $x[0];
    for ($i=1; ($i < @x); $i++) {
        $max = ($max < $x[$i]) ? $x[$i] : $max;
    }
    return $max;
}

sub min {
    my(@x) = @_;
    my($min,$i);

    (@x > 0) || return undef;
    $min = $x[0];
    for ($i=1; ($i < @x); $i++) {
        $min = ($min > $x[$i]) ? $x[$i] : $min;
    }
    return $min;
}
sub ftype {
    my($feature_id) = @_;

    if ($feature_id =~ /^fig\|\d+\.\d+\.([^\.]+)/) {
        return $1;
    }
    return undef;
}

sub genome_of {
    my $prot_id = (@_ == 1) ? $_[0] : $_[1];

    if ($prot_id =~ /^fig\|(\d+\.\d+)/) { return $1; }
    return undef;
}


1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3