#!usr/local/bin/perl

open (FILE, "hela");
open (OUT, ">tabela_hela_final");
while ($line = <FILE>) {
	@line_counter[$a] = $line;
	$a++;
}

$number_of_lines = @line_counter;
$number_of_lines = ($number_of_lines-1);

close FILE;
open (FILE, "hela");
print OUT ("\@ENTITY_TYPE SAMPLE
\@SAMPLES TEMPORAL
\@SPECIES 9606
\@FEATURE_TYPE ($number_of_lines,GENE)
\%hela time series
\%Created by francisco\@vettatech.com march 09, 2004
\%Please refer to Script /mnt/aregano/BiomindDatasets/yeast_time_serie.pl
\@ENTITY ID='hela' DESC='' CATEG='xxx'\n");

$line = <FILE>;
@current_line = split (/\t/, "$line");
shift @current_line;
shift @current_line;
shift @current_line;
print OUT ("\t");
foreach $name (@current_line) {
	$name =~ s/"//g;
	@final_name = split (/\s/, $name);
	print OUT ("$final_name[0]_$final_name[1]\t");
}
print OUT ("\n");
$line = <FILE>;
while ($line = <FILE>) {
	@current_line = split (/\t/, "$line");
	if ($current_line[1] eq "") {
		$ID = shift @current_line;
		$current_line_2 = join ("\t", @current_line[3..50]);		
		print OUT ("$ID\t$current_line_2");
	}
	else {
		$current_line_2 = join ("\t", @current_line[3..50]);
		print OUT ("$current_line[1]\t$current_line_2");
		
	}
}