#!/usr/bin/perl
package Reference_base;

##########################################################################
##### Author :	Shuai Weng
##### Date   :  July 2001
##### Description : This package contains all necessary methods for 
#####               retrieving reference related info
#####
#####  Usage: 
#####  use Reference;
#####
#####  To instantiate a new Reference object, you may use one of 
#####  following syntaxes:
#####  our $refObject = Reference->new(dbh=>$dbh,
#####	  	                      pubmed=>$pubmed);
#####  our $refObject = Reference->new(dbh=>$dbh,
#####			              reference_no=>$refNo);
#####
#####     passing $dbh 
#####     passing $pubmed OR $refNo
#####
#####  our $refNo = $refObject->reference_no;    
#####  our $pubmed = $refObject->pubmed;
#####  our $abstract = $refObject->abstract;
#####  our $citation = $refObject->citation;
#####  and more ....      
##### 
##### 
##### See documentation for the usage details. 
#####    
##### http:///usr/local/dicty/www_dictybase/db/lib/html/dictyBase/programmer/Reference.html
#####
#######################################################################
#####################################################################

use strict;
use DBI;
use CGI qw/:all :html3/;
use vars qw (@ISA %allowedConstructors);
use lib "/usr/local/dicty/www_dictybase/db/lib/dictyBase/Objects";
use dictyBase_Table;
use ConfigURLdictyBase;
use ConfigPathdictyBase;

@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 = (reference_no=>undef,
			pubmed=>undef);

####################################################################
sub abstract {
####################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        SELECT abstract
        FROM   $schema.abstract
        WHERE  reference_no = ?
    ");
    $sth->execute($self->reference_no);
    my $abstract = $sth->fetchrow;
    $sth->finish;
    return $abstract;
}

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

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

######################################################################
sub authorArrayRef {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
       SELECT A.author_name, AE.author_order
       FROM   $schema.author A, $schema.author_editor AE
       WHERE  AE.reference_no = ?
       AND    AE.author_no = A.author_no
       ORDER BY AE.author_order
    ");
    $sth->execute($self->reference_no);
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    return $arrayRef;
}

######################################################################
sub authorList {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
       SELECT A.author_name, AE.author_order
       FROM   $schema.author A, $schema.author_editor AE
       WHERE  AE.reference_no = ?
       AND    AE.author_no = A.author_no
       ORDER BY AE.author_order
    ");
    $sth->execute($self->reference_no);
    my $authorList;
    while(my ($author, $authorOrder) = $sth->fetchrow()) {
	if ($authorList) { $authorList .= ", "; }
	$authorList .= $author;
    }
    $sth->finish;
    return $authorList;
}

######################################################################
sub urlArrayRef {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
       SELECT U.url, U.url_type
       FROM   $schema.url U, $schema.ref_url RU
       WHERE  RU.reference_no = ?
       AND    RU.url_no = U.url_no
       AND    U.url_type != 'Reference supplement'
    ");
    $sth->execute($self->reference_no);
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    return $arrayRef;
}

######################################################################
sub pubtypeArrayRef {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
       SELECT pub_type
       FROM   $schema.publication_type
       WHERE  reference_no = ?
    ");
    $sth->execute($self->reference_no);
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    return $arrayRef;
}

######################################################################
sub locusArrayRef {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
       SELECT unique L.locus_name
       FROM   $schema.locus L, $schema.locus_gene_info LGI
       WHERE  LGI.reference_no = ?
       AND    LGI.locus_no = L.locus_no
       ORDER BY L.locus_name
    ");
    $sth->execute($self->reference_no);
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    return $arrayRef;
}

######################################################################
sub featureArrayRef {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
       SELECT unique F.feature_name
       FROM   $schema.feature F, $schema.feat_gene_info FGI
       WHERE  FGI.reference_no = ?
       AND    FGI.feature_no = F.feature_no
       ORDER BY F.feature_name
    ");
    $sth->execute($self->reference_no);
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    return $arrayRef;
}

######################################################################
sub locusTopicArrayRef {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
       SELECT LGI.literature_topic, L.locus_name
       FROM   CGM_DDB.locus_gene_info LGI, CGM_DDB.locus L
       WHERE  LGI.reference_no = ?
       AND    LGI.locus_no = L.locus_no
       AND    LGI.literature_topic ! = 'Not yet curated'
    ");
    $sth->execute($self->reference_no);
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    return $arrayRef;
}

######################################################################
sub featureTopicArrayRef {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
       SELECT FGI.literature_topic, F.feature_name
       FROM   CGM_DDB.feat_gene_info FGI, CGM_DDB.feature F
       WHERE  FGI.reference_no = ?
       AND    FGI.feature_no = F.feature_no
       AND    FGI.literature_topic != 'Not yet curated'
    ");
    $sth->execute($self->reference_no);
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    return $arrayRef;
}



######################################################################
sub relatedRefNo {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        SELECT reference_no
        FROM   $schema.related_ref
        WHERE  related_ref_no = ?
    ");
    $sth->execute($self->reference_no);
    my $refNo = $sth->fetchrow;
    $sth->finish;
    return $refNo;
}

######################################################################
sub relatedRefArrayRef {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        SELECT reference_no, pub_type
        FROM   $schema.related_ref
        WHERE  related_ref_no = ?
    ");
    $sth->execute($self->reference_no);
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    return $arrayRef;
}

######################################################################
sub webSupplementUrl {
######################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        SELECT U.url
        FROM   $schema.ref_url RU, $schema.url U
        WHERE  RU.url_no = U.url_no
        AND    RU.reference_no = ?
        AND    U.url_type = 'Reference supplement'
    ");
    $sth->execute($self->reference_no);
    my $urls;
    while(my ($url) = $sth->fetchrow()) {
	$urls .= "\t".$url;
    }
    $sth->finish;
    $urls =~ s/^\t//;
    return $urls;
}

########################################################################
sub getCuratedLoci {
########################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
         SELECT unique L.locus_name, L.locus_no, upper(l.locus_name)
         FROM   $schema.locus_gene_info LGI, $schema.locus L
         WHERE  LGI.reference_no = ?
         AND    LGI.locus_no = L.locus_no
         AND    upper(literature_topic) != 'NOT YET CURATED'
         ORDER BY upper(L.LOCUS_NAME)
    ");
    $sth->execute($self->reference_no);
    my @loci;
    while(my ($locus, $locusNo) = $sth->fetchrow()) {
	 push(@loci, "${locus}:$locusNo");
    }
    $sth->finish;
    return @loci;
}

########################################################################
sub getNotYetLoci {
########################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
         SELECT unique L.locus_name, L.locus_no, upper(l.locus_name)
         FROM   $schema.locus_gene_info LGI, $schema.locus L
         WHERE  LGI.reference_no = ?
         AND    LGI.locus_no = L.locus_no
         AND    upper(literature_topic) = 'NOT YET CURATED'
         ORDER BY upper(L.LOCUS_NAME)
    ");
    $sth->execute($self->reference_no);
    my @loci;
    while(my ($locus, $locusNo) = $sth->fetchrow()) {
	 push(@loci, "${locus}:$locusNo");
    }
    $sth->finish;
    return @loci;
}

########################################################################
sub getUnlinkedLoci {
########################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
         SELECT unique L.locus_name, L.locus_no
         FROM   $schema.reference R, $schema.ref_unlink RUL, 
                $schema.locus L
         WHERE  R.reference_no = ?
         AND    R.pubmed = RUL.pubmed
         AND    RUL.tab_name = 'LOCUS'
         AND    RUL.primary_key = L.locus_no
    ");
    $sth->execute($self->reference_no);
    my @loci;
    while(my ($locus, $locusNo) = $sth->fetchrow()) {
	 push(@loci, "${locus}:$locusNo");
    }
    $sth->finish;
    return @loci;
}

########################################################################
sub getCuratedFeatures {
########################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
         SELECT unique F.feature_name, F.feature_no
         FROM   $schema.feat_gene_info FGI, $schema.feature F
         WHERE  FGI.reference_no = ?
         AND    FGI.feature_no = F.feature_no
         AND    upper(literature_topic) != 'NOT YET CURATED'
    ");
    $sth->execute($self->reference_no);
    my @feats;
    while(my ($featNm, $featNo) = $sth->fetchrow()) {
	 push(@feats, "${featNm}:$featNo");
    }
    $sth->finish;
    return @feats;
}


########################################################################
sub getNotYetFeatures {
########################################################################
    my ($self) = @_;

    my $schema = $self->schema;

    my $sth = $self->dbh->prepare("
         SELECT unique F.feature_name, F.feature_no
         FROM   $schema.feat_gene_info FGI, $schema.feature F
         WHERE  FGI.reference_no = ?
         AND    FGI.feature_no = F.feature_no
         AND    upper(literature_topic) = 'NOT YET CURATED'
    ");
    $sth->execute($self->reference_no);

    my @feats;
    while(my ($featNm, $featNo) = $sth->fetchrow()) {
	 push(@feats, "${featNm}:$featNo");
    }
    $sth->finish;
    return @feats;

}

########################################################################
sub getUnlinkedFeatures {
########################################################################
    my ($self) = @_;

    my $schema = $self->schema;

    my $sth = $self->dbh->prepare("
         SELECT unique F.feature_name, F.feature_no
         FROM   $schema.reference R, $schema.ref_unlink RUL, 
                $schema.feature F
         WHERE  R.reference_no = ?
         AND    R.pubmed = RUL.pubmed
         AND    RUL.tab_name = 'FEATURE'
         AND    RUL.primary_key = F.feature_no
    ");

    $sth->execute($self->reference_no);

    my @feats;
    while(my ($featNm, $featNo) = $sth->fetchrow()) {
	push(@feats, "${featNm}:$featNo");
    }
    $sth->finish;
    return @feats;

}

####################################################################
sub formatedCitationWithFullAuthor {
####################################################################
    my ($self) = @_;
    my $citation = $self->citation;
    my $authorList = $self->authorList;
    $citation =~ s/^([^0-9]+)(\([0-9]{4}\))(.+)$/<b>$authorList $2<\/b>$3/;
    my $citation = $self->_formatCitation($citation);
    return $citation;
}

####################################################################
sub formatedCitation4notYetTopic {
####################################################################
    my ($self) = @_;
    my $citation = $self->citation;
    $citation =~ s/^([^0-9]+\([0-9]{4}\))(.+)$/<b>$1<\/b>$2/;
    $citation =~ s/^([^0-9]+\([0-9]{4}\))$/<b>$1<\/b> personal communication/;
    $citation =~ s/et al\./<i>et al\.<\/i>/;
    my $citation = $self->_formatCitation($citation, "papericon3.png");
    return $citation;
}

####################################################################
sub formatedCitation4erratum {
####################################################################
    my ($self) = @_;
    my $citation = $self->citation;
    $citation =~ s/^([^0-9]+\([0-9]{4}\))(.+)$/<b>$1<\/b>$2/;
    $citation =~ s/^([^0-9]+\([0-9]{4}\))$/<b>$1<\/b> personal communication/;
    $citation =~ s/et al\./<i>et al\.<\/i>/;
    my $citation = $self->_formatCitation($citation, "dictyBaserefsml.gif", 
					  "erratum");
    return $citation;
}

####################################################################
sub formatedCitation4CurateEmail {
####################################################################
    my ($self) = @_;
    my $citation = $self->citation;
    my $authorList = $self->authorList;
    $citation =~ s/^([^0-9]+)(\([0-9]{4}\))(.+)$/<b>$authorList $2<\/b>$3/;
    my $citation = $self->_formatCitation($citation, "dictyBaserefsml.gif");
    return $citation;
}

####################################################################
sub formatedCitation {
####################################################################
    my ($self) = @_;
    my $citation = $self->citation;
    $citation =~ s/^([^0-9]+\([0-9]{4}\))(.+)$/<b>$1<\/b>$2/;
    $citation =~ s/^([^0-9]+\([0-9]{4}\))$/<b>$1<\/b> personal communication/;
    $citation =~ s/et al\./<i>et al\.<\/i>/;
    my $citation = $self->_formatCitation($citation, "dictyBaserefsml.gif");
    return $citation;
}



####################################################################
sub _formatCitation {
####################################################################
    my ($self, $citation, $image, $isErratum) = @_;
    if ($citation =~ /^(.+)(http:.+)$/) {
	$citation = $1 . a({-href=>"$2", -target=>'infowin'}, $2);
    }
    else { 
	my $journal = $self->journal;
	if ($journal) {
	    $citation =~ s/$journal/<i>$journal<\/i>/;
	}
    }
    my $configPath = ConfigPathdictyBase->new;
    my $configUrl = ConfigURLdictyBase->new;
    my $dblink = $configUrl->dblink($self->dbh->{Name});
    if ($image) {
	$citation .= br.a({-href=>$configUrl->dictyBaseCGIRoot."$dblink/reference/reference.pl?refNo=".$self->reference_no,
		           -target=>'infowin'},
			  img({-src=>$configUrl->dictyBaseImages."$image",
			       -border=>'0',
			       -alt=>"dictyBase Papers Entry"}))."&nbsp;&nbsp;";
    }
    else { $citation .= br; }
	
    my $pubmed =$self->pubmed;
    if ($pubmed) {
	$citation .= a({-href=>$configUrl->ncbiUrlRoot."query.fcgi?cmd=Retrieve&db=PubMed&list_uids=${pubmed}&dopt=Abstract",
		      -target=>'infowin'},
			  img({-src=>$configUrl->dictyBaseImages."pubmedrefsml.gif",
			       -border=>'0',
			       -alt=>"Pubmed Entry"}))."&nbsp;&nbsp;";
    }
    my $urlArrayRef = $self->urlArrayRef;
#    my ($url) = $$urlArrayRef[0]->[0];
#    if ($url) {
    foreach my $rowRef (@$urlArrayRef) {
	my ($url, $type) = @$rowRef;
	my $journalGif = "full_text.gif";
#	if ($type =~ /LINKOUT/i) {
#	    $journalGif = "full_text.gif";
#	}
#	else {
#	    $journalGif = $self->journal; 
#	    $journalGif =~ s/ /\./g;
#	    $journalGif .= ".gif";
#	}
#	if (! -e $configPath->gifDir."$journalGif") { 
#	    $journalGif = "Generic.gif"; 
#	}
	$citation .= a({-href=>"$url",
		        -target=>'infowin'},
		       img({-src=>$configUrl->dictyBaseImages."$journalGif",
			    -border=>'0',
			    -alt=>"$type"}))."&nbsp;&nbsp;";
    }
    my $webSuppUrl = $self->webSupplementUrl;
    if ($webSuppUrl) {
	my @suppUrl = split(/\t/, $webSuppUrl);
	foreach my $suppUrl (@suppUrl) {
	    $citation .= a({-href=>"$suppUrl",
			    -target=>'infowin'},
		       img({-src=>$configUrl->dictyBaseImages."webSupplement.gif",
			    -border=>'0',
			    -alt=>"Web Supplement"}))."&nbsp;&nbsp;";
	}
    }
    if (!$isErratum) {
	my $relatedRefArrayRef = $self->relatedRefArrayRef;
	if ($$relatedRefArrayRef[0]) {
	    $citation .= a({-href=>$configUrl->dictyBaseCGIRoot."$dblink/reference/reference.pl?refNo=".$self->reference_no."&type=other",
			    -target=>'infowin'},
			   img({-src=>$configUrl->dictyBaseImages."C&E.gif",
			       -border=>'0',
			       -alt=>"dictyBase Curated Comments & Errata"}));
	}
    }
    if ($self->dictyBaseidForCommunityAnnotatedRef) {
	$citation .= a({-href=>$configUrl->dictyBaseCGIRoot."$dblink/DisplayCommuAnno?refNo=".$self->reference_no,
			-target=>'infowin'},
		       img({-src=>$configUrl->dictyBaseImages."star.gif",
			    -border=>0}));
	    

    }
    return $citation;

}

####################################################################
sub dictyBaseidForCommunityAnnotatedRef {
####################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        SELECT unique CA.dictyBaseid
        FROM   $schema.community_annotation CA, 
               $schema.reflink RL
        WHERE  RL.reference_no = ?
        AND    RL.tab_name = 'ANNOTATION_SET'
        AND    RL.primary_key = CA.annotation_set_no
    ");
    $sth->execute($self->reference_no);

    my @dictyBaseid;

    while( my ($dictyBaseid) = $sth->fetchrow()) {

	push(@dictyBaseid, $dictyBaseid);

    }

    $sth->finish;

    return join('|', @dictyBaseid);

}

####################################################################
sub deleteAuthorEditor {
####################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        DELETE from $schema.author_editor
        WHERE  reference_no = ?
    ");
    $sth->execute($self->reference_no);
    $sth->finish;
}

####################################################################
sub deletePubType {
####################################################################
    my ($self) = @_;
    my $schema = $self->schema;
    my $sth = $self->dbh->prepare("
        DELETE from $schema.publication_type
        WHERE  reference_no = ?
    ");
    $sth->execute($self->reference_no);
    $sth->finish;
}

####################################################################
sub GetMinMaxYear {
####################################################################
    my ($self, %args) = @_;
    my $dbh = $args{'dbh'} || die "A database handle must be passed to the 'MinMaxYear method.";
    my $schema = $self->schema;
    my $sth = $dbh->prepare("
        SELECT min(year), max(year)
        FROM   $schema.reference
    ");
    $sth->execute;
    my ($minYear, $maxYear) = $sth->fetchrow;
    $sth->finish;
    return ($minYear, $maxYear);
}

####################################################################
sub GetReferenceNoBYaceNm {
####################################################################
    my ($self, %args) = @_;
    my $dbh = $args{'dbh'} || die "A database handle must be passed to 'GetReferenceNoBYaceNm' method";
    my $schema = $self->schema;
    my $sth = $dbh->prepare("
        SELECT primary_key
        FROM   $schema.acelink
        WHERE  tab_name = 'REFERENCE'
        AND    ace_class = 'Paper'
        AND    ace_object = ?
    ");
    $sth->execute($args{'ACEname'});
    my $refNo = $sth->fetchrow;
    $sth->finish;
    return $refNo;
}

####################################################################
sub GetRefInfoArrayRefBYauthor {
####################################################################
    my ($self, %args) = @_;
    my $dbh = $args{'dbh'} || die "A database handle must be passed to 'GetRefInfoArrayRefBYauthor' method";
    my $schema = $self->schema;
    my $sth = $dbh->prepare("
        SELECT AE.reference_no, R.citation, R.year
        FROM   $schema.author A, $schema.author_editor AE, 
               $schema.reference R
        WHERE  upper(A.author_name) like ?
        AND    A.author_no = AE.author_no
        AND    AE.reference_no = R.reference_no
        ORDER By R.year
    ");
    $sth->execute(uc($args{'author'}));
    my $arrayRef = $sth->fetchall_arrayref();
    $sth->finish;
    return $arrayRef;
}

####################################################################
sub GetRefNo4pubmedHashRef {
####################################################################
    my ($self, %args) = @_;
    my $dbh = $args{'dbh'} || die "A database handle must be passed to 'GetRefNo4pubmedHashRef' method";
    my $schema = $self->schema;
    my $sth = $dbh->prepare("
        SELECT reference_no, pubmed
        FROM   $schema.reference
        WHERE  pubmed is not null
    ");
    $sth->execute;
    my $refNo4pubmedRef = $args{'ReferenceNo4PubmedRef'};
    while(my ($refNo, $pubmed) = $sth->fetchrow()) {
	$$refNo4pubmedRef{$pubmed} = $refNo;
    }
    $sth->finish;
}

####################################################################
sub GetRefNoBYcitation {
####################################################################
    my ($self, %args) = @_;
    my $dbh = $args{'dbh'} || die "A database handle must be passed to 'GetRefNoBYcitation' method";
    my $schema = $self->schema;
    my $sth = $dbh->prepare("
        SELECT reference_no
        FROM   $schema.reference
        WHERE  citation = ?
    ");
    $sth->execute($args{'citation'});
    my $refNo = $sth->fetchrow;
    $sth->finish;
    return $refNo;
}

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

}


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

=pod

=head1 Name

Reference.pm

=head1 Description

This perl object (Reference.pm) acts as container for Reference 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 Reference Object

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

my $Obj = Reference->new(dbh=>$dbh,
			 reference_no=>$refNo);


OR


my $Obj = Reference->new(dbh=>$dbh, 
			 pubmed=>$pubmed);


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 $citation = $Obj->citation; 

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

See valid columns in abstact table:

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

You may use following methods to retrieve other reference related info.

=head2 abstract

Usage :

my $abstract = $Obj->abstract;

This method returns abstract for the specified reference.


=head2 journal

Usage :

my $journal = $Obj->journal;

This method returns journal name for the specified reference.

=head2 book

Usage :

my $book = $Obj->book;

This method returns book title for the specified reference.


=head2 authorArrayRef

Usage :

foreach my $rowRef (@{$Obj->authorArrayRef}) {

    my ($author_name, $author_order) = @$rowRef;

    #####

}

This method returns author info for the specified reference.


=head2 authorList

Usage :

my $authorList = $Obj->authorList;

This method returns comma (', ') separated author list for the given reference.


=head2 urlArrayRef 


Usage :

foreach my $rowRef (@{$Obj->urlArrayRef}) {

    my ($url) = @$rowRef;

    #####

} 

This method returns url info for the given reference.

=head2 pubtypeArrayRef

Usage :

foreach my $rowRef (@{$Obj->pubtypeArrayRef}) {

    my ($pub_type) = @$rowRef;

    #####

} 

This method returns pub_type info for the given reference.


=head2 locusArrayRef 

Usage :

foreach my $rowRef (@{$Obj->locusArrayRef}) {

    my ($locusNm) = @$rowRef;

    #####

} 


This method returns loci info for the given reference.


=head2 featureArrayRef

Usage :

foreach my $rowRef (@{$Obj->featureArrayRef}) {

    my ($featNm) = @$rowRef;

    #####

} 

This method returns feature info for the given reference.

=head2 locusTopicArrayRef

Usage :

foreach my $rowRef (@{$Obj->locusTopicArrayRef}) {

    my ($literature_topic, $locusNm) = @$rowRef;

    #####

} 

This method returns literature_topic and locus info for the given reference.


=head2 featureTopicArrayRef 

Usage :

foreach my $rowRef (@{$Obj->featureTopicArrayRef}) {

    my ($literature_topic, $featNm) = @$rowRef;

    #####

} 

This method returns literature_topic and feature info for the given reference.

=head2 relatedRefNo

Usage :

my $relatedRefNo = $Obj->relatedRefNo;

This method returns related reference_no for the given reference.

=head2 relatedRefArrayRef

Usage :

foreach my $rowRef (@{$Obj->relatedRefArrayRef}) {

    my ($refNo, $pub_type) = @$rowRef;

    #####

} 


This method returns related ref info for the given reference.


=head2 webSupplementUrl

Usage :

my $webSupplementUrl = $Obj->webSupplementUrl;

This method returns web supplement url for the given reference.

=head2 getCuratedLoci

Usage :

my @loci = $Obj->getCuratedLoci;

foreach my $row (@loci) {

    my ($locusNm, $locusNo) = split(/:/, $row);

    #####

}

This method returns associated curated loci info for the given reference.

=head2 getNotYetLoci

Usage :

my @loci = $Obj->getNotYetLoci;

foreach my $row (@loci) {

    my ($locusNm, $locusNo) = split(/:/, $row);

    #####

}

This method returns associated not_yet curated loci info for the given reference.


=head2 getCuratedFeatures 

Usage :

my @features = $Obj->getCuratedFeatures;

foreach my $row (@features) {

    my ($featNm, $featNo) = split(/:/, $row);

    #####

}

This method returns associated curated feature info for the given reference.


=head2 getNotYetFeatures

Usage :

my @features = $Obj->getNotYetFeatures;


foreach my $row (@features) {

    my ($featNm, $featNo) = split(/:/, $row);

    #####

}

This method returns associated not-yet curated feature info for the given reference.

=head2 formatedCitationWithFullAuthor

Usage :

my $citation = $Obj->formatedCitationWithFullAuthor;

This method returns formated citation with full author names for the given reference.


=head2 formatedCitation4notYetTopic

Usage :

my $citation = $Obj->formatedCitation4notYetTopic;

This method returns formated citation with the not_yet curated topic for the given reference.

=head2 formatedCitation4erratum

Usage :

my $citation = $Obj->formatedCitation4erratum;

This method returns formated citation with erratum as pub_type for the given reference.

=head2 formatedCitation4CurateEmail

Usage :

my $citation = $Obj->formatedCitation4CurateEmail;

This method returns formated citation with full author list and all three image links.

=head2 formatedCitation

Usage :

my $citation = $Obj->formatedCitation;

This method returns formated citation for the given reference.

=head2 getRow

Usage :

my $row = $Obj->getRow;

This method returns tab-delimited row entry for the given reference in reference table.

=head2 GetMinMaxYear

Usage :

my ($minYear, $maxYear) = Reference->GetMinMaxYear(dbh=>$dbh);

This method returns min and max publication year in reference table.

=head2 GetReferenceNoBYaceNm

Usage :

my $reference_no = Reference->GetReferenceNoBYaceNm(dbh=>$dbh,
						    ACEname=>$aceNm);


This method returns reference_no for the ace reference object.


=head2 GetRefInfoArrayRefBYauthor 

Usage :

my $arrayRef = Reference->GetRefInfoArrayRefBYauthor(dbh=>$dbh,
						     author=>$authorNm);


foreach my $rowRef (@$arrayRef) {

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

    #####

}

=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











