#######################################################################
# This software has been created by Genome Research Limited (GRL).    # 
# GRL hereby grants permission to use, copy, modify and distribute    # 
# this software and its documentation for non-commercial purposes     # 
# without fee at the user's own risk on the basis set out below.      #
# GRL neither undertakes nor accepts any duty whether contractual or  # 
# otherwise in connection with the software, its use or the use of    # 
# any derivative, and makes no representations or warranties, express #
# or implied, concerning the software, its suitability, fitness for   #
# a particular purpose or non-infringement.                           #
# In no event shall the authors of the software or GRL be responsible # 
# or liable for any loss or damage whatsoever arising in any way      # 
# directly or indirectly out of the use of this software or its       # 
# derivatives, even if advised of the possibility of such damage.     #
# Our software can be freely distributed under the conditions set out # 
# above, and must contain this copyright notice.                      #
#######################################################################

# $Id: gull_summary_sql.pm,v 1.3 1999/01/27 10:22:47 dn1 Exp $
# $Log: gull_summary_sql.pm,v $
# Revision 1.3  1999/01/27 10:22:47  dn1
# *** empty log message ***
#

# DN1
########################################
# SQL calls needed for gull_summary.pm
########################################

use strict;

package summary;

sub get_entries {
    my ($pkg, $dbh, $project) = @_;
#    warn "($pkg, $dbh, $project) \n";

    my $statement = "
select ID_SUMMARY, PROJECTNAME, SUMMARYDATE, NUM_CONTIGS, TOTAL_CTG_LEN, NUM_LGE_CONTIGS, LGE_CTG_LEN, NUM_READS, FINISHED_LENGTH_BP, COVERAGE
from project_summary
where projectname = \'$project\'
order by SUMMARYDATE
";

#    warn "@@@@@@@@@@@@@@@@@ \n $statement \n @@@@@@@@@@@@@@@@@ \n";


    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my ($SUMMARY, $PROJECTNAME, $SUMMARYDATE, $NUM_CONTIGS, $TOTAL_CTG_LEN, $NUM_LGE_CONTIGS, $LGE_CTG_LEN, $NUM_READS, $FINISHED_LENGTH_BP, $COVERAGE);
    my %hash;
    my $number = 0;
    while (($SUMMARY, $PROJECTNAME, $SUMMARYDATE, $NUM_CONTIGS, $TOTAL_CTG_LEN, $NUM_LGE_CONTIGS, $LGE_CTG_LEN, $NUM_READS, $FINISHED_LENGTH_BP, $COVERAGE) = $sth->fetchrow() ){
           
	my %hash2;
	$number++;
	$hash2{SUMMARY} = $SUMMARY;
	$hash2{PROJECTNAME} = $PROJECTNAME;
	$hash2{SUMMARYDATE} = $SUMMARYDATE;
	$hash2{NUM_CONTIGS} = $NUM_CONTIGS;
	$hash2{TOTAL_CTG_LEN} = $TOTAL_CTG_LEN;
	$hash2{NUM_LGE_CONTIGS} = $NUM_LGE_CONTIGS;
	$hash2{LGE_CTG_LEN} = $LGE_CTG_LEN;
	$hash2{NUM_READS} = $NUM_READS;
	$hash2{FINISHED_LENGTH_BP} = $FINISHED_LENGTH_BP;
	$hash2{COVERAGE} = $COVERAGE;

	$hash{$number} = \%hash2;
    }
    $sth->finish;
    my $return = \%hash;
    return ($return);
}

1;

