#!/usr/local/bin/perl -w

#
# swiss2ip  - write interpro hits for a list of spIDS
#           
# Author: Leonardo Marino-Ramirez <marino@tofu.tamu.edu>
# 
# Please cite the author in any work or product based on this material.
#         

use strict;
use Getopt::Std;
use File::Basename;

use vars qw($ipfile $infile $sp_id @sp_ids $opt_i $hit $opt_h
	    );

## Check command line
my $prog = basename($0);

getopt('hi');

if ($opt_h) {
    usage($prog); exit();
} if ($opt_i) {
$infile = "$opt_i";
} else {
    usage($prog); exit();
}

@sp_ids = `cat $infile`; chomp (@sp_ids);
## Location of your protein2ipr.dat file
$ipfile = "/home/marino/db/interpro/protein2ipr.dat";

foreach $sp_id (@sp_ids) {
    system "grep $sp_id $ipfile";
}

## Normal end
exit(0);

## Usage display
sub usage {
  my $p = shift;
  print STDERR <<USAGE
usage: $p [options] <file>

options [default]:
    -h           Usage display.
    -i <file>    Input file.
USAGE
}