#!/usr/bin/perl -w 

use strict;
use warnings;

if ($#ARGV ne 0) {
  print "perl $0 <protein sequences (*.faa/*_FULL.faa)>\n";
  exit;
}

my $infile = shift;
my @tmp = split(/\//, $infile);
$tmp[$#tmp] =~s/\.faa$//gi;
$tmp[$#tmp] =~s/\_FULL$//gi;

open(IN,$infile)||die ":$!";
open(OUT,">$tmp[$#tmp].fasta")||die ":$!";
while (<IN>) {
  chomp;
  if (/^\>(\S+)/) {
    print OUT ">".$tmp[$#tmp]."|".$1."\n";
  } else {
    print OUT $_."\n";
  }
}
close(OUT)||die ":$!";
close(IN)||die ":$!";

