#!/usr/bin/perl
package dictyBaseid;

#####################################################################
# Author : Shuai Weng
# Date   : July 2001
# 
# See documentation for the usage details. 
#    
# http:///usr/local/dicty/www_dictybase/db/lib/html/dictyBase/programmer/dictyBaseid.html
#
#####################################################################

use strict;
use DBI;
use Carp;
use vars qw (@ISA %allowedConstructors);
use dictyBase_Table;
@ISA = qw (dictyBase_Table); # base class

# Class Globals

# put column names in the hash below, that are able to uniquely
# specify a row in the table

%allowedConstructors = (dictyBaseid_no=>undef,
			dictyBaseid=>undef);


####################################################################
sub feature_no {
####################################################################
    my ($self) = @_;
    if ($self->tab_name eq 'FEATURE') {
	return $self->primary_key;
    }
    return;
}

####################################################################
sub feature_name {
####################################################################
    my ($self) = @_;
    if (!$self->feature_no) { return; }
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        SELECT feature_name
        FROM   $schema.feature
        WHERE  feature_no = ?
    ");
    $sth->execute($self->feature_no);
    my $featNm = $sth->fetchrow;
    $sth->finish;
    return $featNm;
}

####################################################################
sub locus_no {
####################################################################
    my ($self) = @_;
    if ($self->tab_name eq 'LOCUS') {
	return $self->primary_key;
    }
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        SELECT locus_no
        FROM   $schema.feature
        WHERE  feature_no = ?
    ");
    $sth->execute($self->primary_key);
    my $locusNo = $sth->fetchrow;
    $sth->finish;
    return $locusNo;
}

####################################################################
sub locus_name {
####################################################################
    my ($self) = @_;
    if (!$self->locus_no) { return; }
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        SELECT locus_name
        FROM   $schema.locus
        WHERE  locus_no = ?
    ");
    $sth->execute($self->locus_no);
    my $locusNm = $sth->fetchrow;
    $sth->finish;
    return $locusNm;
}

####################################################################
sub DESTROY{
####################################################################
# nothing needs to be done 

}


####################################################################
1; #################################################################
####################################################################

=pod

=head1 Name

dictyBaseid.pm

=head1 Description

This perl object (dictyBaseid.pm) acts as container for dictyBaseid info in oracle database. Once an object has been instantiated, several methods are available to retrieve the attributes of the object. 


=head1 Instantiating a New dictyBaseid Object

To instantiate a new dictyBaseid object, you may use one of the following syntaxes: 

my $obj = dictyBaseid->new(dbh=>$dbh,
		     dictyBaseid_no=>$dictyBaseidNo);



OR 


my $obj = dictyBaseid->new(dbh=>$dbh,
		     dictyBaseid=>$dictyBaseid);


where $dbh is a valid database handle to either dictyBase or SDEV. All passed in values must be valid values for the columns that were provided, otherwise the script will die, with an appropriate error message.
 

=head1 Accessor Methods


All accessor methods take the form of : 


my $column_value = $obj->column_name, eg: 


my $dictyBaseid = $obj->dictyBaseid; 


my $dictyBaseidType = $obj->dictyBaseid_type;


my $tabNm = $obj->tab_name;


my $primaryKey = $obj->primary_key;


etc. You can use an accessor for any valid column in the dictyBaseid table. 

See valid columns in abstact table:

http:///usr/local/dicty/www_dictybase/db/lib/cgi-bin/dictyBase/tableSpecifications?table=dictyBaseID

=head1 getRow method

Usage:

my $row = $obj->getRow;

This method returns a tab-delimited row from dictyBaseid table.

=head1 locus_no method

Usage:

my $locusNo = $obj->locus_no;

This method returns the locus_no for a given dictyBaseid.

=head1 locus_name method

Usage:

my $locusNm = $obj->locus_name;

This method returns the locus_name for a given dictyBaseid.


=head1 feature_no method

Usage:

my $featureNo = $obj->feature_no;

This method returns the feature_no for a given dictyBaseid.

=head1 feature_name method

Usage:

my $featureNm = $obj->feature_name;

This method returns the feature_name for a given dictyBaseid.


=head1 Insert, update and delete Methods

You can also use 'Insert' class method and 'update' and 'delete' 
instance methods for inserting new row into database, updating and 
deleting info for a specified row. 

See dictyBase_Table documentation for usage details :

Update : http:///usr/local/dicty/www_dictybase/db/lib/staff/dictyBase/programmer/dictyBase_Table.html#Update_Method

Insert : http:///usr/local/dicty/www_dictybase/db/lib/staff/dictyBase/programmer/dictyBase_Table.html#Insert_Method

Delete : http:///usr/local/dicty/www_dictybase/db/lib/staff/dictyBase/programmer/dictyBase_Table.html#Delete_Method

=head1 Author

Shuai Weng

shuai@genome.stanford.edu

=cut











