#!/usr/bin/perl
package GeneInfo_base;

##########################################################################
##### Author :	Shuai Weng
##### Date   :  Jan. 2001
##### Description : This package contains all necessary methods for 
#####               retrieving gene info for a specified locus or feature.
#####
#####  Usage: 
#####  use GeneInfo;
#####
#####  To instantiate a new GeneInfo object, you may use one of 
#####  following syntaxes:
#####  our $giObject = GeneInfo->new(dbh=>$dbh,
#####	  	                     locus=>$locusNm);                       
#####  our $giObject = GeneInfo->new(database=>$database,
##### 		                     locus=>$locusNm); 
#####  
#####     * $locusNm is optional. It can be locus name or feature name
#####     
#####
#####  our $curatedRef = $giObject->curatedRef;
#####  our $notYetCuratedRef = $giObject->notYetCuratedRef;
#####  our $mutantPhenoRef = $giObject->mutantsPhenotypes;
#####  our $geneticInterRef = $giObject->geneticInteraction;
#####  and more ......  
# $Author: emj466 $
# $Date: 2010/08/31 18:58:17 $
# $Header: /projects/dicty/build/source_files/db/lib/site_name/Objects/GeneInfo_base.pm,v 1.3 2010/08/31 18:58:17 emj466 Exp $
# $Log: GeneInfo_base.pm,v $
# Revision 1.3  2010/08/31 18:58:17  emj466
# merged HEAD with release-2-18
# Committed on the Free edition of March Hare Software CVSNT Server.
# Upgrade to CVS Suite for more features and support:
# http://march-hare.com/cvsnt/
#
# Revision 1.2.20.1  2010/08/31 16:54:17  emj466
# merged with no-prepare-cache branch
# Committed on the Free edition of March Hare Software CVSNT Server.
# Upgrade to CVS Suite for more features and support:
# http://march-hare.com/cvsnt/
#
# Revision 1.2.24.1  2010/08/30 21:04:06  emj466
# changed prepare_cached to prepare
# Committed on the Free edition of March Hare Software CVSNT Server.
# Upgrade to CVS Suite for more features and support:
# http://march-hare.com/cvsnt/
#
# Revision 1.2  2007/06/19 15:11:12  emj466
# substitute @@_dbuser_ @@ for cgm_ddb
#
# Revision 1.1  2006/10/25 18:29:12  emj466
# new build directory
#
# Revision 1.1.1.2  2003/08/18 22:50:41  emj466
# no message
#
# Revision 1.1.1.1  2003/08/15 20:18:41  emj466
# initial load of dicty/build
#
# Revision 1.10  2003/05/27 18:16:23  shuai
# *** empty log message ***
#
# Revision 1.6  2003/04/24 01:58:35  shuai
# *** empty log message ***
#
# Revision 1.5  2003/04/24 01:48:55  shuai
# *** empty log message ***
#
# Revision 1.9  2003/04/23 18:13:16  shuai
# *** empty log message ***
#
# Revision 1.8  2002/11/13 22:51:05  kara
# added dateInfo method to get the papers added to dictyBase over the course of a w
#
# Revision 1.4  2002/11/13 22:09:35  kara
# finished (hopefully) editing the dateInfo method.
#
# Revision 1.3  2002/11/13 18:48:17  kara
# edited the dateInfo routine
#
# Revision 1.2  2002/11/13 17:44:38  kara
# added dateInfo method to get references added within the last week.
#
# $Revision: 1.3 $
# $Source: /projects/dicty/build/source_files/db/lib/site_name/Objects/GeneInfo_base.pm,v $
# $State: Exp $
# $Locker:  $
    
#######################################################################
use strict;
use DBI;
use lib "/usr/local/dicty/www_dictybase/db/lib/common";
use Login qw (ConnectToDatabase);
use lib "/usr/local/dicty/www_dictybase/db/lib/dictyBase/Objects";
use Feature;
use Locus;


#######################################################################
#################### global variables #################################
#######################################################################

our $dbh;

#######################################################################
sub new {      ############ constructor ###############################
#######################################################################
       
    my ($type, %args) = @_;

    my $self = {};
    bless $self, $type;

    if ($args{'dbh'}) { 
	$dbh = $args{'dbh'};
    }
    elsif ($args{'database'}) {
	$self->{'_database'} = $args{'database'};
	$dbh = &ConnectToDatabase($args{'database'});
    }
    else {
	print "No database name or database handle is passed to this object.";
	return;
    }
    if ($args{'locus'}) {
	$self->{'_locus'} = $args{'locus'};
	$self->initInfo;
    }
    return $self;
}

#######################################################################
sub initInfo {
#######################################################################
    my ($self) = @_;
  
    my $locusObj = Locus->new(dbh=>$dbh, 
			      locus_name=>$self->{'_locus'});
    if ($locusObj) {
	$self->{'_locusNo'} = $locusObj->locus_no;
	$self->{'_locusNm'} = $self->{'_locus'};
	$self->{'_tabNm'} = "CGM_DDB.locus_gene_info GI";
	$self->{'_NoNm'} = "GI.locus_no";
	$self->{'_No'} = $locusObj->locus_no;
	$self->{'_paragraphNo'} = $locusObj->paragraph_no;
    }
    else {
	my $featObj = Feature->new(dbh=>$dbh, 
				   feature_name=>$self->{'_locus'});
	if ($featObj) {
	    $self->{'_featureNo'} = $featObj->feature_no;
	    $self->{'_featureNm'} = $self->{'_locus'};
	    $self->{'_tabNm'} = "CGM_DDB.feat_gene_info GI";
	    $self->{'_NoNm'} = "GI.feature_no";
	    $self->{'_No'} = $featObj->feature_no;
	}
	else {
	    print "The locus/feature name (",$self->{'_locus'},") is not found in database.";
	    return;
	}
    }
    $self->findTopics;
}

#######################################################################
sub findTopics {
#######################################################################
    my ($self) = @_;
    my $tabNm = $self->tabNm;
    my $NoNm = $self->NoNm;
    my $sth = $dbh->prepare("
        SELECT unique GI.literature_topic
        FROM   $tabNm
        WHERE  $NoNm = ?
    ");
    $sth->execute($self->No);
    while(my ($topic) = $sth->fetchrow()) {
	$self->{"$topic"} = 1;
	if ($topic !~ /not yet curated/i) {
	    $self->{_curated} = 1;
        }
    }
}

#######################################################################
sub topicInfo {
#######################################################################
    my ($self, $topic) = @_;

    $topic = "\U$topic";
    my $sth;

    if (!$topic) {

	my $tabNm = $self->tabNm;
	my $NoNm = $self->NoNm;
	
	$sth = $dbh->prepare("
            SELECT unique GI.reference_no, R.citation, R.year
            FROM   $tabNm, CGM_DDB.reference R
            WHERE  GI.reference_no = R.reference_no
            AND    $NoNm = ?
            ORDER by R.year
        ");
	$sth->execute($self->No);
	my $arrayRef = $sth->fetchall_arrayref();
	$sth->finish;
	return $arrayRef;
	
    }
    elsif ($self->tabNm && $self->NoNm) {
	my $tabNm = $self->tabNm;
	my $NoNm = $self->NoNm;
	if ($topic =~ /^curated$/i) {
	    $topic = "NOT YET CURATED";
	    $sth = $dbh->prepare("
                SELECT unique GI.reference_no, R.citation, R.year
                FROM   $tabNm, CGM_DDB.reference R
                WHERE  GI.reference_no = R.reference_no
                AND    $NoNm = ?
                AND    upper(GI.literature_topic) != ?
                ORDER by R.year
            ");
	}
	else {
	    $sth = $dbh->prepare("
                SELECT GI.reference_no, R.citation, R.year
                FROM   $tabNm, CGM_DDB.reference R
                WHERE  GI.reference_no = R.reference_no
                AND    $NoNm = ?
                AND    upper(GI.literature_topic) = ?
                ORDER by R.year
            ");
	}
	$sth->execute($self->No, $topic);
	my $arrayRef = $sth->fetchall_arrayref();
	$sth->finish;
	return $arrayRef;
    }
    else { ### for all loci + features
	### from locus_gene_info table
	if ($topic =~ /^curated$/i) {
	    $topic = "NOT YET CURATED";
	    $sth = $dbh->prepare("
                SELECT unique GI.reference_no, R.citation, R.year, 
                       R.pubmed, J.abbreviation
                FROM   CGM_DDB.locus_gene_info GI, CGM_DDB.reference R,
                       CGM_DDB.journal J
                WHERE  GI.reference_no = R.reference_no
                AND    R.journal_no = J.journal_no(+)
                AND    upper(GI.literature_topic) != ?
                ORDER by R.year
            ");
	}
	else {
	    $sth = $dbh->prepare("
                SELECT unique GI.reference_no, R.citation, R.year, R.pubmed,
                       J.abbreviation
                FROM   CGM_DDB.locus_gene_info GI, CGM_DDB.reference R,
                       CGM_DDB.journal J
                WHERE  GI.reference_no = R.reference_no
                AND    R.journal_no = J.journal_no(+)
                AND    upper(GI.literature_topic) = ?
                ORDER by R.year
            ");
	}
	$sth->execute($topic);
	my $arrayRef = $sth->fetchall_arrayref();
	$sth->finish;
	### from feat_gene_info table
	if ($topic =~ /^curated$/i) {
	    $topic = "NOT YET CURATED";
	    $sth = $dbh->prepare("
                SELECT unique GI.reference_no, R.citation, R.year,
                       R.pubmed, J.abbreviation
                FROM   CGM_DDB.feat_gene_info GI, CGM_DDB.reference R,
                       CGM_DDB.journal J
                WHERE  GI.reference_no = R.reference_no
                AND    R.journal_no = J.journal_no(+)
                AND    upper(GI.literature_topic) != ?
                ORDER by R.year
            ");
	}
	else {
	    $sth = $dbh->prepare("
                SELECT unique GI.reference_no, R.citation, R.year,
                       R.pubmed, J.abbreviation
                FROM   CGM_DDB.feat_gene_info GI, CGM_DDB.reference R,
                       CGM_DDB.journal J
                WHERE  GI.reference_no = R.reference_no
                AND    R.journal_no = J.journal_no(+)
                AND    upper(GI.literature_topic) = ?
                ORDER by R.year
            ");
	}   
	$sth->execute($topic);
	my $arrayRef2 = $sth->fetchall_arrayref();
	push(@$arrayRef, @$arrayRef2);
	return $arrayRef;
    }
}
#######################################################################
sub dateInfo {
#######################################################################
    # KD added to get published papers added over the past week
    my $self = shift;
    my $sth;
 ### for all loci + features
	### from locus_gene_info table
    $sth = $dbh->prepare("
                SELECT unique GI.reference_no, R.citation, R.year, R.pubmed,
                       J.abbreviation
                FROM   CGM_DDB.locus_gene_info GI, CGM_DDB.reference R,
                       CGM_DDB.journal J
                WHERE  GI.reference_no = R.reference_no
                AND    R.journal_no = J.journal_no(+)
                AND    R.status = 'Published'
                AND    R.date_created >= sysdate-7
            ");
    $sth->execute();
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    ### from feat_gene_info table
    $sth = $dbh->prepare("
                SELECT unique GI.reference_no, R.citation, R.year,
                       R.pubmed, J.abbreviation
                FROM   CGM_DDB.feat_gene_info GI, CGM_DDB.reference R,
                       CGM_DDB.journal J
                WHERE  GI.reference_no = R.reference_no
                AND    R.journal_no = J.journal_no(+)
                AND    R.status = 'Published'
                AND    R.date_created >= sysdate-7
            ");
    $sth->execute();
    my $arrayRef2 = $sth->fetchall_arrayref();
    push(@$arrayRef, @$arrayRef2);
    return $arrayRef;
}  
#######################################################################
sub getLocusNm4RefNoHashRef {
#######################################################################
    my ($self)= @_;
    my $sth;
    $sth = $dbh->prepare("
        SELECT unique GI.reference_no, L.locus_name
        FROM   CGM_DDB.locus_gene_info GI, CGM_DDB.locus L
        WHERE  GI.locus_no = L.locus_no
        ORDER BY upper(L.locus_name)
    ");    
    $sth->execute;
    my %locusNm4RefNo;
    while(my($refNo, $locusNm) = $sth->fetchrow()) {
	if ($locusNm4RefNo{$refNo}) {
	    $locusNm4RefNo{$refNo} .= "\t";
	}
	$locusNm4RefNo{$refNo} .= $locusNm;
    }
    return \%locusNm4RefNo;
}

#######################################################################
sub getFeatNm4RefNoHashRef {
#######################################################################
    my ($self) = @_;
    my $sth = $dbh->prepare("
        SELECT unique GI.reference_no, F.feature_name
        FROM   CGM_DDB.feat_gene_info GI, CGM_DDB.feature F
        WHERE  GI.feature_no = F.feature_no
        ORDER BY upper(F.feature_name)
    ");
   
    $sth->execute;
    my %featNm4RefNo;
    while(my($refNo, $featNm) = $sth->fetchrow()) {
	if ($featNm4RefNo{$refNo}) {
	    $featNm4RefNo{$refNo} .= "\t";
	}
	$featNm4RefNo{$refNo} .= $featNm;
    }
    return \%featNm4RefNo;
}

#######################################################################
sub getUrl4RefNoHashRef {
#######################################################################
    my ($self) = @_;
    my $sth = $dbh->prepare("
       SELECT RU.reference_no, U.url
       FROM   CGM_DDB.ref_url RU, CGM_DDB.url U
       WHERE  RU.url_no = U.url_no
       AND    U.url_type != 'Reference supplement'
    ");
    $sth->execute;
    my %url4RefNo;
    while(my($refNo, $url) = $sth->fetchrow()) {
	if ($url4RefNo{$refNo}) {
	    $url4RefNo{$refNo} .= "\t";
	}
	$url4RefNo{$refNo} .= $url;
    }
    return \%url4RefNo;
}

#######################################################################
sub getRelatedRefInfo4RefNoHashRef {
#######################################################################
    my ($self) = @_;
    my $sth = $dbh->prepare("
        SELECT reference_no, pub_type, related_ref_no
        FROM   CGM_DDB.related_ref
    ");
    $sth->execute;
    my %relatedRefInfo4RefNo;
    while(my($refNo, $pubtype, $relatedRefNo) = $sth->fetchrow()) {
	if ($relatedRefInfo4RefNo{$relatedRefNo}) {
	    $relatedRefInfo4RefNo{$relatedRefNo} .= "\t";
	}
	$relatedRefInfo4RefNo{$relatedRefNo} .= ${refNo}."::".$pubtype;
    }
    return \%relatedRefInfo4RefNo;  
}

#######################################################################
sub getWebSupplementUrl4RefNoHashRef {
#######################################################################
    my ($self) = @_;
    my $sth = $dbh->prepare("
        SELECT RU.reference_no, U.url
        FROM   CGM_DDB.ref_url RU, CGM_DDB.url U
        WHERE  RU.url_no = U.url_no
        AND    U.url_type = 'Reference supplement'
    ");
    $sth->execute;
    my %webSupplementUrl4RefNo;
    while(my($refNo, $url) = $sth->fetchrow()) {
      	$webSupplementUrl4RefNo{$refNo} = $url;
    }
    return \%webSupplementUrl4RefNo;
}

#######################################################################
sub curatedRefNum {
#######################################################################
    my ($self) = @_;
    my $tabNm = $self->tabNm;
    my $NoNm = $self->NoNm;
    my $sth = $dbh->prepare("
        SELECT count (unique reference_no)
        FROM   $tabNm
        WHERE  $NoNm = ?
        AND    literature_topic != 'Not yet curated'
    ");
    $sth->execute($self->No);
    my $num = $sth->fetchrow;
    return $num;
}

#######################################################################
sub notYetCuratedRefNum {
#######################################################################
    my ($self) = @_;
    my $tabNm = $self->tabNm;
    my $NoNm = $self->NoNm;
    my $sth = $dbh->prepare("
        SELECT count(unique reference_no)
        FROM   $tabNm
        WHERE  $NoNm = ?
        AND    literature_topic = 'Not yet curated'
    ");
    $sth->execute($self->No);
    my $num = $sth->fetchrow;
    return $num;
}

#######################################################################
sub communityAnnotatedRefNum {
#######################################################################
    my ($self) = @_;
    my $tabNm = $self->tabNm;
    my $NoNm = $self->NoNm;
    my $sth = $dbh->prepare("
        SELECT count(unique reference_no)
        FROM   $tabNm
        WHERE  $NoNm = ?
        AND    reference_no in 
               (select reference_no 
                from   CGM_DDB.reflink
                where  tab_name = 'ANNOTATION_SET'
               )
    ");
    $sth->execute($self->No);
    my $num = $sth->fetchrow;
    return $num;
}


#######################################################################
sub minCuratedDate {
#######################################################################
    my ($self) = @_;
    my $tabNm = $self->tabNm;
    my $NoNm = $self->NoNm;
    my $sth = $dbh->prepare("
        SELECT min(last_curated)
        FROM   $tabNm
        WHERE  $NoNm = ?
        AND    literature_topic != 'Not yet curated'
    ");
    $sth->execute($self->No);
    my $date = $sth->fetchrow;
    return $date;
}

#######################################################################
sub maxCuratedDate {
#######################################################################
    my ($self) = @_;
    my $tabNm = $self->tabNm;
    my $NoNm = $self->NoNm;
    my $sth = $dbh->prepare("
        SELECT max(last_curated)
        FROM   $tabNm
        WHERE  $NoNm = ?
        AND    literature_topic != 'Not yet curated'
    ");
    $sth->execute($self->No);
    my $date = $sth->fetchrow;
    return $date;
}

#######################################################################
sub maxPubmedSearchDate {
#######################################################################
    my ($self) = @_;
    my $sth = $dbh->prepare("
        SELECT max(date_created)
        FROM   CGM_DDB.reference
    ");
    $sth->execute;
    my $date = $sth->fetchrow;
    return $date;
}

#######################################################################
sub geneNum {
#######################################################################
    my ($self) = @_;
    my $tabNm = $self->tabNm;
    my $NoNm = $self->NoNm;
    my $sth = $dbh->prepare("
        SELECT count(unique locus_no)
        FROM   CGM_DDB.locus_gene_info
        WHERE  reference_no in
               (select unique reference_no
                from   $tabNm
                where  $NoNm = ?
                and    reference_no not in 
                (select reference_no 
                 from   $tabNm
                 where  $NoNm = ?
                 and    literature_topic = 'Genome-wide Analysis'))
    ");
    $sth->execute($self->No, $self->No);
    my $num1 = $sth->fetchrow;
    $sth = $dbh->prepare("
        SELECT count(unique feature_no)
        FROM   CGM_DDB.feat_gene_info
        WHERE  reference_no in
               (select unique reference_no
                from   $tabNm
                where  $NoNm = ?
                and reference_no not in 
                 (select  reference_no 
                  from   $tabNm
                  where  $NoNm = ?
                  and    literature_topic = 'Genome-wide Analysis'))
    ");
    $sth->execute($self->No, $self->No);
    my $num2 = $sth->fetchrow;
    if ($num1+$num2-1 < 0) {
	return 0;
    }
    else {
	return ($num1+$num2-1);
    }
}

#######################################################################
sub locusList {
#######################################################################
    my ($self) = @_;
    my $tabNm = $self->tabNm;
    my $NoNm = $self->NoNm;
    my $sth = $dbh->prepare("
        SELECT unique L.locus_name
        FROM   CGM_DDB.locus_gene_info G, CGM_DDB.locus L
        WHERE  G.locus_no = L.locus_no
        AND    G.reference_no in
               (select unique reference_no
                from   $tabNm 
                where  $NoNm = ?)
        ORDER BY L.locus_name
    ");
    $sth->execute($self->No);
    my $arrayRef = $sth->fetchall_arrayref();
    return $arrayRef;
}

#######################################################################
sub featureList {
#######################################################################
    my ($self) = @_;
    my $tabNm = $self->tabNm;
    my $NoNm = $self->NoNm;
    my $sth = $dbh->prepare("
        SELECT unique F.feature_name
        FROM   CGM_DDB.feat_gene_info G, CGM_DDB.feature F
        WHERE  G.feature_no = F.feature_no
        AND    G.reference_no in
               (select unique reference_no
                from   $tabNm 
                where  $NoNm = ?)
        ORDER BY F.feature_name
    ");
    $sth->execute($self->No);
    my $arrayRef = $sth->fetchall_arrayref();
    return $arrayRef;
} 


#######################################################################
sub database { $_[0]->{_database} }
sub locusNm {$_[0]->{_locusNm} }
sub locusNo {$_[0]->{_locusNo} }
sub featureNm {$_[0]->{_featureNm} }
sub featureNo {$_[0]->{_featureNo} }
sub tabNm { $_[0]->{_tabNm} }
sub NoNm { $_[0]->{_NoNm} }
sub No { $_[0]->{_No} }
sub paragraphNo {$_[0]->{_paragraphNo} }
####################################################
sub curatedRef { $_[0]->topicInfo("curated") }
sub notYetCuratedRef { $_[0]->topicInfo("Not yet curated") }
sub mutantsPhenotypesRef { $_[0]->topicInfo("Mutants/Phenotypes") }
sub geneticInteractionsRef { $_[0]->topicInfo("Genetic Interactions") }
sub functionProcessRef {$_[0]->topicInfo("Function/Process") }
sub cellularLocationRef   {$_[0]->topicInfo("Cellular Location") }	  
sub regulationOfRef {$_[0]->topicInfo("Regulation of") }
sub regulatoryRoleRef {$_[0]->topicInfo("Regulatory Role") }
sub cellCyclePhaseInvolvedRef {$_[0]->topicInfo("Cell Cycle Phase Involved") }
sub strainsConstructsRef {$_[0]->topicInfo("Strains/Constructs") } 
sub aliasRef {$_[0]->topicInfo("Alias") }
sub techniquesAndReagentsRef {$_[0]->topicInfo("Techniques and Reagents") }
sub otherFeaturesRef  {$_[0]->topicInfo("Other Features") }
sub reviewsRef {$_[0]->topicInfo("Reviews") }
sub archivedLiteratureRef {$_[0]->topicInfo("Archived Literature") }
sub selectedReviewRef {$_[0]->topicInfo("Selected Review") }
sub genomeWideAnalysisRef {$_[0]->topicInfo("Genome-wide Analysis") }
sub dnaRnaSequenceFeaturesRef {$_[0]->topicInfo("DNA/RNA Sequence Features") }
sub mappingRef {$_[0]->topicInfo("Mapping") }
sub rnaLevelsAndProcessingRef {$_[0]->topicInfo("RNA Levels and Processing") }
sub transcriptionRef {$_[0]->topicInfo("Transcription") }
sub translationalRegulationRef {$_[0]->topicInfo("Translational Regulation") }
sub proteinSequenceFeaturesRef {$_[0]->topicInfo("Protein Sequence Features") }
sub proteinPhysicalPropertiesRef {$_[0]->topicInfo("Protein Physical Properties")}
sub proteinNucleicAcidStructureRef {$_[0]->topicInfo("Protein/Nucleic Acid Structure") }
sub proteinProcessingRegulationRef{$_[0]->topicInfo("Protein Processing/Regulation") }
sub proteinProteinInteractionsRef {$_[0]->topicInfo("Protein-protein Interactions") }
sub proteinNucleicAcidInteractionsRef {$_[0]->topicInfo("Protein-Nucleic Acid Interactions") }
sub substratesLigandsCofactorsRef {$_[0]->topicInfo("Substrates/Ligands/Cofactors") }
sub fungalRelatedGenesProteinsRef {$_[0]->topicInfo("Fungal Related Genes/Proteins") }
sub nonFungalRelatedGenesProteinsRef {$_[0]->topicInfo("Non-Fungal Related Genes/Proteins") }
sub diseaseGeneRelatedRef {$_[0]->topicInfo("Disease Gene Related") }

########################################################################
sub hasCurated { $_[0]->{_curated} }
sub hasNotYetCurated { $_[0]->{"Not yet curated"} }
sub hasMutantsPhenotypes { $_[0]->{"Mutants/Phenotypes"} }
sub hasGeneticInteractions { $_[0]->{"Genetic Interactions"} }
sub hasFunctionProcess {$_[0]->{"Function/Process"} }
sub hasCellularLocation   {$_[0]->{"Cellular Location"} }	  
sub hasRegulationOf {$_[0]->{"Regulation of"} }
sub hasRegulatoryRole {$_[0]->{"Regulatory Role"} }
sub hasCellCyclePhaseInvolved {$_[0]->{"Cell Cycle Phase Involved"} }
sub hasStrainsConstructs {$_[0]->{"Strains/Constructs"} } 
sub hasAlias {$_[0]->{"Alias"} }
sub hasTechniquesAndReagents {$_[0]->{"Techniques and Reagents"} }
sub hasOtherFeatures  {$_[0]->{"Other Features"} }
sub hasReviews {$_[0]->{"Reviews"} }
sub hasArchivedLiterature {$_[0]->{"Archived Literature"} }
sub hasSelectedReview {$_[0]->{"Selected Review"} }
sub hasGenomeWideAnalysis {$_[0]->{"Genome-wide Analysis"} }
sub hasDnaRnaSequenceFeatures {$_[0]->{"DNA/RNA Sequence Features"} }
sub hasMapping {$_[0]->{"Mapping"} }
sub hasRnaLevelsAndProcessing {$_[0]->{"RNA Levels and Processing"} }
sub hasTranscription {$_[0]->{"Transcription"} }
sub hasTranslationalRegulation {$_[0]->{"Translational Regulation"} }
sub hasProteinSequenceFeatures {$_[0]->{"Protein Sequence Features"} }
sub hasProteinPhysicalProperties {$_[0]->{"Protein Physical Properties"}}
sub hasProteinNucleicAcidStructure {$_[0]->{"Protein/Nucleic Acid Structure"} }
sub hasProteinProcessingRegulation {$_[0]->{"Protein Processing/Regulation"} }
sub hasProteinProteinInteractions {$_[0]->{"Protein-protein Interactions"} }
sub hasProteinNucleicAcidInteractions {$_[0]->{"Protein-Nucleic Acid Interactions"} }
sub hasSubstratesLigandsCofactors {$_[0]->{"Substrates/Ligands/Cofactors"} }
sub hasFungalRelatedGenesProteins {$_[0]->{"Fungal Related Genes/Proteins"} }
sub hasNonFungalRelatedGenesProteins {$_[0]->{"Non-Fungal Related Genes/Proteins"} }
sub hasDiseaseGeneRelated {$_[0]->{"Disease Gene Related"} }


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

=pod

=head1 Name

GeneInfo.pm    

=head1 Author

Shuai Weng, shuai@genome.stanford.edu

=head1 Description

This perl object (GeneInfo.pm) acts as a container for all
gene info related information associated with a locus name or feature name
in oracle database.  Once an object has been instantiated, several methods
are available to retrieve the attributes of the object. Each accessor method
listed below will return an array reference and each element in this array 
is another array reference for a paper info (reference_no, citation, and publication_year). The papers are ordered by publication_year (oldest to newest). 

=head1 Instantiating a New GeneInfo Object

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

my $giObject = GeneInfo->new(dbh=>$dbh,
			     locus=>$locus);

my $giObject = GeneInfo->new(database=>$database,
			     locus=>$locus);

***** $locus can be gene name or orf name.

You need to pass database_handle/database_name and gene/feature name 
to the object.

=head1 Accessor Methods


=head2 curatedRefNum

Usage :

my $curatedRefNum = $giObject->curatedRefNum;

This accessor returns curated reference number associated with the specified locus/feature.

=head2 notYetCuratedRefNum

Usage :

my $notYetCuratedRefNum = $giObject->notYetCuratedRefNum;

This accessor returns 'not yet curated' reference number associated with the specified locus/feature.

=head2 minCuratedDate

Usage :

my $oldestCuratedDate = $giObject->minCuratedDate;

This accessor returns the oldest LAST_CURATED date in the set of curated papers for the specified locus/feature.


=head2 maxCuratedDate

Usage :

my $newestCuratedDate = $giObject->maxCuratedDate;

This accessor returns the most recent LAST_CURATED date in the set of curated papers for the specified locus/feature.

=head2 geneNum

Usage :

my $geneNum = $giObject->geneNum;

This accessor returns the number of other genes referred to the literatures for the specified locus/feature.


=head2 maxPubmedSearchDate

Usage :

my $lastPubmedSearchDate = $giObject->maxPubmedSearchDate;

This accessor returns the date of last pubmed search.

=head2 curatedRef

Usage :

my $curatedRef = $giObject->curatedRef;

foreach my $rowRef (@$curatedRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all curated references associated with the specified locus/feature.

=head2 notYetCuratedRef

Usage :

my $notYetCuratedRef = $giObject->notYetCuratedRef;

foreach my $rowRef (@$notYetCuratedRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all not yet curated references associated with the specified locus/feature.

=head2 aliasRef

Usage :

my $aliasRef = $giObject->aliasRef;

foreach my $rowRef (@$aliasRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Alias'

=head2 archivedLiteratureRef

Usage :

my $archivedLiteratureRef = $giObject->archivedLiteratureRef;

foreach my $rowRef (@$archivedLiteratureRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Archived Literature'

=head2 cellCyclePhaseInvolvedRef

Usage :

my $cellCyclePhaseInvolvedRef = $giObject->cellCyclePhaseInvolvedRef;

foreach my $rowRef (@$cellCyclePhaseInvolvedRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Cell Cycle Phase Involved'

=head2 cellularLocationRef

Usage :

my $cellularLocationRef = $giObject->cellularLocationRef;

foreach my $rowRef (@$cellularLocationRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Cellular Location'

=head2 dnaRnaSequenceFeaturesRef

Usage :

my $dnaRnaSequenceFeaturesRef = $giObject->dnaRnaSequenceFeaturesRef;

foreach my $rowRef (@$dnaRnaSequenceFeaturesRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'DNA/RNA Sequence Features'

=head2 diseaseGeneRelatedRef

Usage :

my $diseaseGeneRelatedRef = $giObject->diseaseGeneRelatedRef;

foreach my $rowRef (@$diseaseGeneRelatedRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Disease Gene Related'

=head2 functionProcessRef

Usage :

my $functionProcessRef = $giObject->functionProcessRef;

foreach my $rowRef (@$functionProcessRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Function/Process'

=head2 geneticInteractionsRef

Usage :

my $geneticInteractionsRef = $giObject->geneticInteractionsRef;

foreach my $rowRef (@$geneticInteractionRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Genetic Interactions'

=head2 genomeWideAnalysisRef

Usage :

my $genomeWideAnalysisRef = $giObject->genomeWideAnalysisRef;

foreach my $rowRef (@$genomeWideAnalysisRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Genome-wide Analysis'

=head2 mappingRef

Usage :

my $mappingRef = $giObject->mappingRef;

foreach my $rowRef (@$mappingRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Mapping'

=head2 mutantsPhenotypesRef

Usage :

my $mutantsPhenotypesRef = $giObject->mutantsPhenotypesRef;

foreach my $rowRef (@$mutantsPhenotypesRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Mutants/Phenotypes'

=head2 nonFungalRelatedProteinsRef

Usage :

my $nonFungalRelatedGenesProteinsRef = $giObject->nonFungalRelatedGenesProteinsRef;

foreach my $rowRef (@$nonFungalRelatedGenesProteinsRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Non-Fungal Related Genes/Proteins'

=head2 otherFeaturesRef

Usage :

my $otherFeaturesRef = $giObject->otherFeaturesRef;

foreach my $rowRef (@$otherFeaturesRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Other Features'

=head2 proteinPhysicalPropertiesRef

Usage :

my $proteinPhysicalPropertiesRef = $giObject->proteinPhysicalPropertiesRef;

foreach my $rowRef (@$proteinPhysicalPropertiesRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Protein Physical Properties'

=head2 proteinProcessingRegulationRef

Usage :

my $proteinProcessingRegulationRef = $giObject->proteinProcessingRegulationRef;

foreach my $rowRef (@$proteinProcessingRegulationRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Protein Processing/Regulation'

=head2 proteinSequenceFeaturesRef

Usage :

my $proteinSequenceFeaturesRef = $giObject->proteinSequenceFeaturesRef;

foreach my $rowRef (@$proteinSequenceFeaturesRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Protein Sequence Features'

=head2 proteinStructureRef

Usage :

my $proteinNucleicAcidStructureRef = $giObject->proteinNucleicAcidStructureRef;

foreach my $rowRef (@$proteinNucleicAcidStructureRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Protein/Nucleic Acid Structure'

=head2 proteinNucleicAcidInteractionsRef

Usage :

my $proteinNucleicAcidInteractionsRef = $giObject->proteinNucleicAcidInteractionsRef;

foreach my $rowRef (@$proteinNucleicAcidInteractionsRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Protein-Nucleic Acid Interactions'

=head2 proteinProteinInteractionsRef

Usage :

my $proteinProteinInteractionsRef = $giObject->proteinProteinInteractionsRef;

foreach my $rowRef (@$proteinProteinInteractionsRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Protein-protein Interactions'

=head2 rnaLevelsAndProcessingRef

Usage :

my $rnaLevelsAndProcessingRef = $giObject->rnaLevelsAndProcessingRef;

foreach my $rowRef (@$rnaLevelsAndProcessingRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'RNA Levels and Processing'

=head2 regulatedByRef

Usage :

my $regulationOfRef = $giObject->regulationOfRef;

foreach my $rowRef (@$regulationOfRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Regulation of'

=head2 regulatoryRoleRef

Usage :

my $regulatoryRoleRef = $giObject->regulatoryRoleRef;

foreach my $rowRef (@$regulatoryRoleRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Regulatory Role'

=head2 reviewsRef

Usage :

my $reviewsRef = $giObject->reviewsRef;

foreach my $rowRef (@$reviewsRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Reviews'

=head2 selectedReviewRef

Usage :

my $selectedReviewRef = $giObject->selectedReviewRef;

foreach my $rowRef (@$selectedReviewRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Selected Review'

=head2 strainsConstructsRef

Usage :

my $strainsConstructsRef = $giObject->strainsConstructsRef;

foreach my $rowRef (@$strainsConstructsRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Strains/Constructs'

=head2 substratesLigandsCofactorsRef

Usage :

my $substratesLigandsCofactorsRef = $giObject->substratesLigandsCofactorsRef;

foreach my $rowRef (@$substratesLigandsCofactorsRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Substrates/Ligands/Cofactors'

=head2 techniquesAndReagentsRef

Usage :

my $techniquesAndReagentsRef = $giObject->techniquesAndReagentsRef;

foreach my $rowRef (@$techniquesAndReagentsRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Techniques and Reagents'

=head2 transcriptionRef

Usage :

my $transcriptionRef = $giObject->transcriptionRef;

foreach my $rowRef (@$transcriptionRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Transcription'

=head2 translationalRegulationRef

Usage :

my $translationalRegulationRef = $giObject->translationalRegulationRef;

foreach my $rowRef (@$translationalRegulationRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Translational Regulation'

=head2 fungalRelatedProteinsRef

Usage :

my $fungalRelatedGenesProteinsRef = $giObject->fungalRelatedGenesProteinsRef;

foreach my $rowRef (@$fungalRelatedGenesProteinsRef) {

    my ($refNo, $citation, $year) = @$rowRef;

    ....

}

This accessor returns all references associated with the specified locus/feature with topic 'Fungal Related Genes/Proteins'

=head2 hasCurated

Usage :

if ($giObject->hasCurated) {
   ### do something here;
}

returns : a boolean 

This accessor returns a boolean to indicate whether any curated references were associated with the specified locus/feature.

=head2 hasNotYetCurated

Usage :

if ($giObject->hasNotYetCurated) {
   ### do something here;
}

returns : a boolean 

This accessor returns a boolean to indicate whether any 'not yet curated' references were associated with the specified locus/feature.

=head2 hasAlias

Usage :

if ($giObject->hasAlias) {
    ### do something here;
}

returns : a boolean

This accessor returns a boolean to indicate whether any references with topic 'Alias' were associated with the specified locus/feature.

=head2 hasArchivedLiterature

Usage :

if ($giObject->hasArchivedLiterature) {
    ### do something here;
}

This accessor returns a boolean to indicate whether any references with topic 'Archived Literature' were associated with the specified locus/feature.

=head2 hasCellCyclePhaseInvolved

Usage :

if ($giObject->hasCellCyclePhaseInvolved) {
    ### do something here;
}

This accessor returns a boolean to indicate whether any references with topic 'Cell Cycle Phase Involved' were associated with the specified locus/feature.

=head2 hasCellularLocation

Usage :

if ($giObject->hasCellularLocation) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Cellular Location' were associated with the specified locus/feature.

=head2 hasDnaRnaSequenceFeatures

Usage :

if ($giObject->hasDnaRnaSequenceFeatures) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'DNA/RNA Sequence Features' were associated with the specified locus/feature.

=head2 hasDiseaseGeneRelated

Usage :

if ($giObject->hasDiseaseGeneRelated) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Disease Gene Related' were associated with the specified locus/feature.

=head2 hasFunctionProcess

Usage :

if ($giObject->hasFunctionProcess) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Function/Process' were associated with the specified locus/feature.

=head2 hasGeneticInteractions

Usage :

if ($giObject->hasGeneticInteractions) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Genetic Interactions' were associated with the specified locus/feature.

=head2 hasGenomeWideAnalysis

Usage :

if ($giObject->hasGenomeWideAnalysis) {
    ### do something here;
}
 
    

This accessor returns a boolean to indicate whether any references with topic 'Genome-wide Analysis' were associated with the specified locus/feature.

=head2 hasMapping

Usage :

if ($giObject->hasMapping) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Mapping' were associated with the specified locus/feature.

=head2 hasMutantsPhenotypes

Usage :

if ($giObject->hasMutantsPhenotypes) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Mutants/Phenotypes' were associated with the specified locus/feature.

=head2 hasNonFungalRelatedGenesProteins

Usage :

if ($giObject->hasNonFungalRelatedGenesProteins) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Non-Fungal Related Genes/Proteins' were associated with the specified locus/feature.

=head2 hasOtherFeatures

Usage :

if ($giObject->hasOtherFeatures) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Other Features' were associated with the specified locus/feature.

=head2 hasProteinPhysicalProperties

Usage :

if ($giObject->hasProteinPhysicalProperties) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Protein Physical Properties' were associated with the specified locus/feature.

=head2 hasProteinProcessingRegulation

Usage :

if ($giObject->hasProteinProcessingRegulation) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Protein Processing/Regulation' were associated with the specified locus/feature.

=head2 hasProteinSequenceFeatures

Usage :

if ($giObject->hasProteinSequenceFeatures) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Protein Sequence Features' were associated with the specified locus/feature.

=head2 hasProteinNucleicAcidStructure

Usage :

if ($giObject->hasProteinNucleicAcidStructure) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Protein/Nucleic Acid Structure' were associated with the specified locus/feature.

=head2 hasProteinNucleicAcidInteractions

Usage :

if ($giObject->hasProteinNucleicAcidInteractions) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Protein-Nucleic Acid Interactions' were associated with the specified locus/feature.

=head2 hasProteinProteinInteractions

Usage :

if ($giObject->hasProteinProteinInteractions) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Protein-protein Interactions' were associated with the specified 
locus/feature.

=head2 hasRnaLevelsAndProcessing
  
Usage :

if ($giObject->hasRnaLevelsAndProcessing) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'RNA Levels and Processing' were associated with the specified locus/feature.

=head2 hasRegulationOf

Usage :

if ($giObject->hasRegulationOf) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Regulation of' were associated with the specified locus/feature.

=head2 hasRegulatoryRole

Usage :

if ($giObject->hasRegulatoryRole) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Regulatory Role' were associated with the specified locus/feature.

=head2 hasReviews

Usage :

if ($giObject->hasReviews) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Reviews' were associated with the specified locus/feature.

=head2 hasSelectedReview

Usage :

if ($giObject->hasSelectedReview) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Selected Review' were associated with the specified locus/feature.

=head2 hasStrainsConstructs

Usage :

if ($giObject->hasStrainsConstructs) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Strains/Constructs' were associated with the specified locus/feature.

=head2 hasSubstratesLigandsCofactors

Usage :

if ($giObject->hasSubstratesLigandsCofactors) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Substrates/Ligands/Cofactors' were associated with the specified locus/feature.

=head2 hasTechniquesAndReagents

Usage :

if ($giObject->hasTechniquesAndReagents) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Techniques and Reagents' were associated with the specified locus/feature.

=head2 hasTranscription

Usage :

if ($giObject->hasTranscription) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Transcription' were associated with the specified locus/feature.

=head2 hasTranslationalRegulation

Usage :

if ($giObject->hasTranslationalRegulation) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Translational Regulation' were associated with the specified locus/feature.

=head2 hasFungalRelatedGenesProteins

Usage :

if ($giObject->hasFungalRelatedGenesProteins) {
    ### do something here;
} 

This accessor returns a boolean to indicate whether any references with topic 'Fungal Related Genes/Proteins' were associated with the specified locus/feature.

=cut











