package UpdateCloneAnchors; =head1 NAME UpdateCloneAnchors -- Updates the clone anchors in the clone_anchors table so that differences involved with multiple anchors are resolved. =head1 SYNOPSIS UpdateCloneAnchors -> new; =head1 DESCRIPTION UpdateCloneAnchors -- Updates the clone anchors in the clone_anchors table so that differences involved with multiple anchors are resolved. The updating is done via a file, ../working_data/clone_anchors.txt, provided by the user. This is a tab-delimited text file with the first column being the clone name, the second column being the anchor, a location, the third column indicates the index number of a duplicated clone with multiple references, the fourth column indicates the total number of duplications for a clone, and additional columns provide more information for the benefit of the user on direct inspection. =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() UpdateCloneAnchors->new; Updates the clone anchors in the clone_anchors table so that they resolve multiple references to anchors. =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."); } # if elsif(!$project->{clone_anchors_counted}) { message("You must count clone anchors, first."); } # elsif else { # The updates can be made message("Connecting to the database."); $db_manager->connect; # Open and read the update file message("Opening ../working_data/clone_anchors.txt."); my $open_error = FALSE; open(INPUT_FILE, "<", "../working_data/clone_anchors.txt") or $open_error = TRUE; if($open_error) { message_start; message("Could not open ../working_data/clone_anchors.txt"); message("$!"); } # if else { message("Deleting clone_anchors table for new data"); $db_manager->execute("delete from clone_anchors"); message("Obtaining data from clone2locus3 table."); my $sth = $db_manager->execute("select clone2locus3.clone, loci.mlg, loci.anchor from clone2locus3, loci, clones where clone2locus3.clone = clones.clone and clones.anchors = 1 and clone2locus3.locus = loci.locus"); message("Saving the clone2locus data into clone_anchors."); my @row = (); while(@row = $sth->fetchrow_array()) { my $db_eid = $db_manager->{dbh}->quote(""); my $db_clone = $db_manager->{dbh}->quote(shift @row); my $db_mlg = $db_manager->{dbh}->quote(shift @row); my $db_anchor = $db_manager->{dbh}->quote(shift @row); my $db_dup = $db_manager->{dbh}->quote("1"); $db_manager->execute("insert into clone_anchors values($db_eid, $db_clone, $db_mlg, $db_anchor, $db_dup, $db_dup)"); } # while message("Getting and saving data from the input file."); my @file_array = ; close INPUT_FILE; my $number_lines = scalar(@file_array); # look at each line in the input file for(my $current_line=0; $current_line < $number_lines; $current_line++) { my $this_line = $file_array[$current_line]; chomp $this_line; my @field_array = split /\t/, $this_line; next if($field_array[2] == 0); my $db_eid = $db_manager->{dbh}->quote(""); my $db_clone = $db_manager->{dbh}->quote($field_array[0]); my $db_anchor = $db_manager->{dbh}->quote($field_array[1]); my $db_dup1 = $db_manager->{dbh}->quote($field_array[2]); my $db_dup2 = $db_manager->{dbh}->quote($field_array[3]); my $db_mlg = $db_manager->{dbh}->quote($field_array[7]); # Save the data in the clone_anchors table $db_manager->execute("insert into clone_anchors values($db_eid, $db_clone, $db_mlg, $db_anchor, $db_dup1, $db_dup2)"); } # for close INPUT_FILE; $project->{clone_anchors_updated} = TRUE; message("Disconnecting from the database."); $db_manager->disconnect; } # else } # else press_enter; } # new 1