#!/usr/bin/perl


use strict;
use warnings;

my $inputfile = $ARGV[0];

if ($inputfile =~ /.gz$/) {
    open(GENOMESEQ, "gzip -dc $inputfile |") || die "cannot open $inputfile\n";
} else {
    open(GENOMESEQ, "<$inputfile") || die "cannot open $inputfile\n";
}


my %seqs;
$/=">";<GENOMESEQ>;$/="\n";
while(<GENOMESEQ>) {
   chomp;
   my $seqname = $_;
   $/=">";
   my $seq=<GENOMESEQ>;
   chomp($seq);
   if($seqname =~ /^\d/ or $seqname =~ /^X/ or $seqname =~ /^Y/ or $seqname =~ /^M/ or $seqname =~ /^Pt/) {
        print ">chr".$seqname."\n".$seq."\n";
   } else {
	print ">".$seqname."\n".$seq."\n";
   }
   $/="\n";
}
close GENOMESEQ;
