#!@@_perl_root_@@/bin/perl.exe
package FeatureTable;

##########################################################
#                                                        #
# dictyBase Extension of FeatureTable                    #
#                                                        #
##########################################################

use FeatureTable_base;

BEGIN { %FeatureTable:: = %FeatureTable_base:: }



#
#  "fake out" num2rom, we don't want roman numbers
#

our %num2rom = ('1'=>'1', '2'=>'2', '3'=>'3', 
	       '4'=>'4', '5'=>'5', '6'=>'6', '7'=>'M', 
	       '8'=>'2F', '9'=>'3F', '10'=>'F');
#
#
# took out physical map link
#
########################################################################
sub featureTable {
########################################################################
        my ($self) = shift;

	my @rows;

#
# changed next link from DictyosteliumServerRoor to dictyBaseCGIRoot
#
	my $geneSeqResourceUrl = $configUrl->dictyBaseCGIRoot.
	                "dictyBase/seqTools?seqname=";
	my $infoUrl = $configUrl->dictyBaseCGIRoot.
	                "gene_page.pl?dictybaseid=";
	my $physmapUrl = $configUrl->dictyBaseCGIRoot.
	                "$dblink/PHYSMAP/PHYSmap?dictyBaseid=";

	my $arrayRef = Feature->GetFeatureTableArrayRefByChrBegEnd(
					 dbh=>$dbh,
					 chromosome=>$self->{'_chr'},
                                         start_coord=>$self->{'_beg'},
                                         stop_coord=>$self->{'_end'});
	my %foundOrf;
	foreach my $rowRef (@$arrayRef) {
	    my ($orf, $start, $stop, $strand, $gene, $desc, $dictyBaseid, $type)
		= @$rowRef;
	    if ($foundOrf{$orf}) { next; }
	    ($start, $stop) = ($stop, $start) if ($start > $stop);
	    if (!$gene) { $gene = "-"; }
	    else { 
		$gene = a({-href=>"$infoUrl$dictyBaseid", -target=>'infowin'}, $gene); 
	    }
	    my $geneSeqResource = a({-href=>"$geneSeqResourceUrl$orf", 
				     -target=>'infowin'}, 
				    "Gene/Seq Resources");
	    my $info = a({-href=>"$infoUrl$dictyBaseid", 
			  -target=>'infowin'}, 
			 "Info");
	    my $physmap = a({-href=>"$physmapUrl$dictyBaseid",
			     -target=>'infowin'}, 
			    "PhysicalMap");
	    if (!$desc) { $desc = "-"; }
#  took out physical map link (dictyBase)
#	    push(@rows, td($orf).td($start).td($stop).td($strand).td($geneSeqResource.br."|".$info."|".$physmap).td($gene).td($desc));
	    push(@rows, td($orf).td($start).td($stop).td($strand).td($geneSeqResource.br.$info).td($gene).td($desc));
		
	    $foundOrf{$orf}++;
	}
        if (@rows > 0) {
	    return center(table({-border=>3,
				 -cellspacing=>3,
				 -cellpadding=>3},
				Tr({-align=>'center'},
				   th({-rowspan=>2}, "Feature").
				   th({-colspan=>2}, "Chromosomal Coordinates").
				   th({-rowspan=>2}, "Strand").
				   th({-rowspan=>2}, "Retrieve").
				   th({-rowspan=>2}, "Locus").
				   th({-rowspan=>2}, "Locus Description")).
			        Tr({-align=>'center'},
				   th("Begin").
				   th("End")).
		                Tr({-align=>'center'},
				   [@rows])
		       ));
	}
	else {
	    return 0;
	}
}



########################################################################
1;
########################################################################



















