package CountCloneAnchors; =head1 NAME CountCloneAnchors -- Counts the number of locus anchors for each clone and saves the results in the clones table. =head1 SYNOPSIS CountCloneAnchors -> new; =head1 DESCRIPTION CountCloneAnchors -- Counts the number of locus anchors for each clone and saves the results in the clones table. =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 The module is under development and is not yet finished. =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() CountCloneAnchors->new; Counts the number of locus anchors for each clone and saves the results in the clones table. =cut # package variables # ******************************** new ****************************** sub new { my $self = shift; my $configuration = shift; my $db_manager = shift; my $project = shift; my $number_lines = 0; message_start; if($project->{current_project} eq "") { message("You must activate a project, first."); blank_line; press_enter; } # if elsif(!$project->{locus_names_updated}) { message("You must update locus names, first."); blank_line; press_enter; } # elsif else { # The counts can be made message("Connecting to the database."); $db_manager->connect; message("Clearing the counts in the clones table."); $db_manager->execute("update clones set anchors = 0"); message("Counting the anchors."); my $sth = $db_manager->execute("select count(clone), clone from clone2locus3 group by clone"); message("Saving the counts to the clones table."); my @row = (); while(@row = $sth->fetchrow_array()) { my $db_count = $db_manager->{dbh}->quote(shift @row); my $db_clone = $db_manager->{dbh}->quote(shift @row); $db_manager->execute("update clones set anchors = $db_count where clone = $db_clone"); } # while $project->{clone_anchors_counted} = TRUE; message("Finding the clones with more than one anchor."); my $sth2 = $db_manager->execute("select clones.clone, clones.anchors, clone2locus3.locus, clone2locus3.mlg, loci.mlg, loci.anchor from clones, clone2locus3, loci where clones.anchors > 1 and clones.clone = clone2locus3.clone and clone2locus3.locus = loci.locus order by clones.anchors, clones.clone"); message("Saving the clone information to ../working_data/clone_dups.txt"); my $output_error = FALSE; open (OUTPUT_FILE, ">", "../working_data/clone_dups.txt") or $output_error = TRUE; if($output_error) { message("Could not open ../working/data/clone_dups.txt"); message("$!"); } # if my @row2 = (); while(@row2 = $sth2->fetchrow_array()) { my $clone = shift @row2; my $anchors = shift @row2; my $locus = shift @row2; my $mlg1 = shift @row2; my $mlg2 = shift @row2; my $anchor = shift @row2; if(!$output_error) { print OUTPUT_FILE "$clone\t$anchors\t$locus\t$mlg1\t$mlg2\t$anchor\n"; } # if } # while close OUTPUT_FILE; message("Disconnecting from the database."); $db_manager->disconnect; press_enter; } # else } # new 1