protein2geneid.pl 416 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/perl -w
  2. die "USage\n\tperl $0 gene_protein pep.fa > pep_geneid.fa\n" unless(@ARGV==2);
  3. open IN1, $ARGV[0]||die $!;
  4. open IN2,$ARGV[1]||die $!;
  5. my %hash;
  6. while(<IN1>){
  7. chomp;
  8. next if(/^\s*$/);
  9. my @a=split/\t/,$_;
  10. $hash{$a[1]}=$a[0];
  11. }
  12. while(<IN2>){
  13. chomp;
  14. next if(/^\s*$/);
  15. #next unless(/^>/);
  16. if(/^>/){
  17. $_=~s/^>//;
  18. print ">$hash{$_}\n";
  19. }else{
  20. print "$_\n";
  21. }
  22. }
  23. close IN1;
  24. close IN2;