#!/usr/bin/perl -w

if ($#ARGV != 0) {die "ERROR: need 1 parameters: \n".
                     "       rnaz input file \n"; }

my  $rnaz_file = $ARGV[0];
print "read file ".$rnaz_file."\n";
open (FILE,"<".$rnaz_file) or die " File ".$rnaz_file." not found.\n";
	my @all=<FILE>;
close(FILE);
print "ready. \n";

my @output;

my $i=0;

for($i=0;$i<=$#all;$i++){
	if ((index($all[$i],'>')==0) && (index($all[$i],'>consensus')<0)){
				#my @SequA=split(' ',$Sequ);
		my $line = "";
		my @temp = split('\.',$all[$i]);
		my $len =0;
		my $lentemp=$all[$i+1];
		$lentemp =~ s/-//g;
		$lentemp =~ s/\n//g;
		
		$len=length($lentemp);
		
		$line = ">".$temp[1].".0 ".$temp[2]." ".$len." ".$temp[3]." ".$temp[4]."\n";
		
		push(@output,$line);
	}else{
		push(@output,$all[$i]);
	}
}

open(FILE,">$rnaz_file.clean");
	for($i=0;$i<=$#output;$i++){
		print FILE $output[$i];
	}
close(FILE);

