#!/usr/bin/perl -w
use strict;

my $filein=shift;

my $tair_url="http://www.arabidopsis.org/servlets/TairObject?type=locus&name=";
my $links_file="/tmp/locus_links.txt";
my $out_file="/tmp/locus_details.txt";

my @ids_to_get=();

open FILEIN, "$filein";

#get the ids from file; trim version info
while(<FILEIN>){

    chomp;
    s/^.+\t(At[^\.]+).*$/$1/;
    push @ids_to_get, $_;

}

close FILEIN;


#write a url list for wget
open FILEOUT, ">$links_file";
foreach (@ids_to_get) {
    print FILEOUT $tair_url . $_ . "\n"; 
}
close FILEOUT;


my $syscmd="wget -q -i $links_file -O $out_file";

system($syscmd);

