#!/usr/bin/perl

$n = 1;
open (I, $ARGV[0]); # trackDb.organized.info
$head = <I>;
chomp ($head);
@names = split (/\t/, $head);
while (<I>){
	chomp;
	@arr = split (/\t/);
	
	if ($arr[8] eq $lastGroup){
		$n ++;
	}
	else {
		$n = 1;
	}
	
	for ($i=0; $i<@arr; $i++){
		if ($arr[$i] ne ''){
			if ($arr[8] == $lastGroup){
				if ($names[$i] eq 'shortLabel'){
					$nn = sprintf ("%03s", $n);
					print "$names[$i] ($nn)\.$arr[$i]\n";
				}
				else {
					print "$names[$i] $arr[$i]\n";
				}
			}
			else {
				if ($names[$i] eq 'shortLabel'){
					print "$names[$i] (001)\.$arr[$i]\n";
				}
				else {
					print "$names[$i] $arr[$i]\n";
				}
			}
		}
	}
	
	$lastGroup = $arr[8];
	print "\n";
	
}
close I;


# this need to be change depend on situations
