#!/usr/bin/perl -w use strict; # extract_annotation.plx, last update: 11/7/03 # extracts annotations from a file that Jeff provides and puts it into # a relation file which I can use. # by Chet Langin, clangin@siu.edu # SIU Plant Biotechnology and Genomics Core-facility # set the timer use Time::HiRes; my $start_time = Time::HiRes::time; my $input_str = "annotation.txt"; my $output_str = "clone2comment.txt"; my %comment_hash = (); open(INPUT, "<", $input_str) or die "Cannot open input file: $!\n"; my @file_array = ; close INPUT; # making a hash of all of the comments for a clone my $file_length = scalar(@file_array); for(my $lcv = 0; $lcv < scalar(@file_array); $lcv++) { my $current_line = $file_array[$lcv]; next if($current_line =~ /reference/); chomp $current_line; my @line_array = split / /, $current_line; my $relation = $line_array[1]; my @feature_array = split /_/, $relation; my $clone_name = $feature_array[0]; next if($clone_name eq "Empty"); next if($clone_name eq "EMPTY"); my $mtp_name = $feature_array[1]; if(exists($comment_hash{$clone_name})) { $comment_hash{$clone_name} .= " $mtp_name"; } # if else { $comment_hash{$clone_name} = $mtp_name; } # else # print ". "; } # for open(OUTPUT, ">", $output_str) or die "Cannot open output file: $!\n"; foreach my $each_clone (keys %comment_hash) { print OUTPUT "$each_clone\t$comment_hash{$each_clone}\n"; } # foreach close OUTPUT; # display the time my $run_time = Time::HiRes::time - $start_time; if($run_time < 60) { print "\nRun time: $run_time seconds\n"; } # if else { my $minutes = int($run_time / 60); $run_time %= 60; print "\nRun time: $minutes minutes, $run_time seconds\n"; } # if