#!/usr/bin/perl -w use strict; # get_ave_clone_band_size.pl, last update: 7/29/03 # gets the average clone size in bands # by Chet Langin, clangin@siu.edu # SIU Plant Biotechnology and Genome Core_facility # get start time use Time::HiRes; my $start_time = Time::HiRes::time; # check arguments if(scalar(@ARGV) != 1) { print "Usage: ./get_ave_clone_band_size.pl input_file\n"; print "Example: ./get_ave_clone_band_size.pl sorted_contig2clone_relations.txt\n"; exit; } # if my $input_file_str = $ARGV[0]; use constant AVE_CLONE_LENGTH => 145000; open(INPUT_FILE, "<", $input_file_str) or die "Cannot open input file: $!\n"; my %lengths = (); my $length_sum = 0; my $length_divisor = 0; while() { chomp; my @fields = split /\t/; my $start = $fields[2]; my $end = $fields[3]; my $length = $end - $start; $length_sum += $length; $length_divisor++; if(exists($lengths{$length})) { $lengths{$length}++; } # if else { $lengths{$length} = 1; } # else } # while close INPUT_FILE; # print the hash foreach my $length (sort keys %lengths) { if($lengths{$length}) { print "$length: $lengths{$length}\n"; } # if } # foreach $length_divisor = 1 if ($length_divisor == 0); my $ave_length = $length_sum / $length_divisor; print "Average length: $ave_length\n"; my $band_length = AVE_CLONE_LENGTH / $ave_length; print "Average band length: $band_length\n"; # get run time my $run_time = Time::HiRes::time - $start_time; print "Run time: $run_time seconds\n";