package CrosscheckLocusNames; =head1 NAME CrosscheckLocusNames -- Crosschecks the locus names in the clone2locus table with the locus names in the locus table. =head1 SYNOPSIS CrosscheckLocusNames -> new; =head1 DESCRIPTION CrosscheckLocusNames -- Crosschecks the locus names in the clone2locus table with the locus names in the locus table. Locus names without matches are written to a bad_locus_names.txt file. =head1 VERSION 0.001 (last update: 6/30/04) =head1 AUTHOR Chet Langin, clangin@siu.edu SIU Plant Biotechnology and Genomics Core-facility =head1 BUGS None known. =head1 SEE ALSO extropy ExtropyConstants ExtropyUtils Extropy::MenuMain =head1 COPYRIGHT Copyright 2004, Chet Langin, All Rights Reserved. This program is free software. You may copy or redistribute it under the same terms as Perl itself. =head1 METHODS The remainder of this document describes the methods available to the programmer. =cut # load the pragmas use warnings; use strict; # load other modules use ExtropyConstants; use ExtropyUtils; =head2 new() CrosscheckLocusNames->new; Crosschecks the locus names in the clone2locus table with the locus table to determine the ones without matches. =cut # package variables # ******************************** new ****************************** sub new { my $self = shift; my $configuration = shift; my $db_manager = shift; my $project = shift; message_start; if($project->{current_project} eq "") { message("You must activate a project, first."); } # if elsif($project->{locus_file} eq "") { message("You must read a locus file, first."); } # elsif elsif($project->{fpc_file} eq "") { message("You must read an FPC file, first."); } # elsif else { # The crosscheck can be made message("Connecting to the database."); $db_manager->connect; # Find the loci in clone_loci that match USDA loci message("Crosschecking the loci."); my $sth = $db_manager->execute("select clone_loci.locus from clone_loci, loci where clone_loci.locus = loci.locus"); # Read and save the results message("Marking the results in clone_loci."); my @row = (); while(@row = $sth->fetchrow_array()) { my $db_locus = $db_manager->{dbh}->quote(shift @row); my $db_yes = $db_manager->{dbh}->quote("yes"); $db_manager->execute("update clone_loci set good = $db_yes where locus = $db_locus"); } # while # Reset update indicator $project->{locus_names_updated} = FALSE; # Get the bad loci my $db_no = $db_manager->{dbh}->quote("no"); my $sth2 = $db_manager->execute("select locus from clone_loci where good = $db_no"); # Save the bad loci into a file message("Saving bad loci names into bad_loci_names.txt."); my $output_error = FALSE; open(OUTPUT_FILE, ">", "../working_data/bad_loci_names.txt") or $output_error = TRUE; if($output_error) { message_start; message("Could not open ../working_data/bad_loci_names.txt"); message("$!"); } # if else { my @row2 = (); while(@row2 = $sth2->fetchrow_array()) { my $output_locus = $db_manager->{dbh}->quote(shift @row2); $output_locus = substr($output_locus, 1, length($output_locus) - 2); print OUTPUT_FILE "$output_locus\n"; } # while $project->{locus_names_crosschecked} = TRUE; } # else close OUTPUT_FILE; message("Disconnecting from the database."); $db_manager->disconnect; } # else press_enter; } # new 1