#!/bin/bash
# -*- ENCODING: UTF-8 -*-
# fichero de entrada es salida.out
input=$1
output=$2
working_dir=$PWD
sift_output="$working_dir/sift_output.txt"

grep sp\| "$input" |head -n$3 |awk 'BEGIN {FS="|"};{print $2}' | awk 'BEGIN {FS="."};{print $1".fasta"}' >"$sift_output"
while read line
do 
   echo "wget http://www.uniprot.org/uniprot/$line" | sh
   cat $line >>"$output"
   rm "$line"
done < "$sift_output"
