#!/usr/bin/perl -w use strict; # adjust_loci_file.pl, last update: 7/23/03 # Adjusts the previously made loci.gff file to a more usable format # By Chet Langin, clangin@siu.edu # SIU Plant Biotechnology and Genome Core-facility # start timer use Time::HiRes; my $start_time = Time::HiRes::time(); # check arguments if(scalar(@ARGV) != 2) { print "Usage: ./adjust_Loci_file.pl input_file output_file\n"; exit; } # if my $input_file_name = $ARGV[0]; my $output_file_name = $ARGV[1]; open(INPUT_FILE, "<", $input_file_name) or die "Cannot open input file: $!\n"; open(OUTPUT_FILE, ">", $output_file_name) or die "Cannot open output file: $!\n"; while() { chomp; s/^\s+//; s/\s+$//; my @old_fields = split /\t/; my @new_fields = (); $new_fields[0] = $old_fields[0]; # MLG $new_fields[1] = sprintf("%08d", $old_fields[3]); # start $new_fields[2] = sprintf("%08d", $old_fields[4]); # end my $midpoint_float = $old_fields[3] + (($old_fields[4] - $old_fields[3]) / 2); my $midpoint_int = sprintf("%08.0f", $midpoint_float); $new_fields[3] = $midpoint_int; my $name_field = $old_fields[8]; $_ = $name_field; my @name_array = split /"/; my $name = $name_array[1]; $new_fields[4] = $name; my $output_line = join "\t", @new_fields; print OUTPUT_FILE "$output_line\n"; } # while close INPUT_FILE; close OUTPUT_FILE; my $run_time = Time::HiRes::time() - $start_time; print "Run time: $run_time\n";