#! /usr/bin/perl -w
#
## author: axel wintsche
## mail: wint(spider monkey)bioinf(dot)uni-leipzig(dot)de
use strict;

##---------------- vars -----------------
# name file
my $names_file = "/scr/k10/taxonomy/names.dmp";


##-------------- main --------------

$#ARGV == 0 or die "type: getNCBIid.pl <spec-list>\n";

open(LIST, "<$ARGV[0]");

foreach(<LIST>)
{

	my @line = split(/\s+/, $_);
	chomp @line;
	
	my $grep = `grep -m 1 -P '^$line[1]\\s.+scientific name' '$names_file'`;
	if( $grep eq "" ) { print STDERR "$line[1] not found\n"; next; }
	my @temp = split( /\s*\|\s*/, $grep );
	$temp[1] =~ s/[\(\),:]//g;
	print $line[0]."\t".$line[1]."\t".$temp[1]."\n";
}

close(LIST);

