#!/usr/local/bin/perl # fbreslist.pm # perl module for query result listings # jan'99, dgg, flybase # # ---- public methods & vars ------- # $useBriefFields $selectmanyForm $refineForm # init($query); # putResultsReports( $totalcount,$askdata,$noexit); # putResultsList ( $totalcount, $askdata, $noexit, $prettyquery); # printResultList( $datapath, $datafile, $pagesize, $startnum) # printResultsReports( $dpath, $dfile, $items) # # ---- main methods & vars ---- # $main::debug; # $main::dohtmlsup; # $main::fbidtag; # $main::gopath; $main::query # $main::host; $main::port; # $main::askmorepath main::askfile main::suffix # $main::reportStyles main::viewlist # &main::ConvertCodes( ($val) ) # # --- private methods ? --- # &fbreslist::redirectToUrl($url,$noexit); # &fbreslist::putNoResults($msg,$noexit); # putContentType() # ... package fbreslist; sub BEGIN { ## BEGIN forces package initialize? $debug= 0; $dohtmlsup= 1; ## use html super/sub codes ? $useBriefFields= 0; $reslisturl= "/.bin/fbreslist.pl"; $idurl= "/.bin/fbidq.html"; $pagesize= 20; $maxhits= $pagesize; $fbidtag= "ZZzz"; ## unknown $gopath= $ENV{'SERVER_PATH'}; $headlinedir= '/.etc/jdata/headlines'; ##? $javaResList= 0; $dataname= "FlyBase data"; $prettyquery= undef; $refineForm= undef; $selectmanyForm= undef; $footer= undef; $docgi= 0; $dohtml= 1; @views= ("text/html","text/plain","text/acode","text/acode-pretty", "text/xml" ); if ($ENV{'GATEWAY_INTERFACE'} =~ /CGI/) { $docgi= 1; $dohtml=3; } %DBNamesList=( 'FBgn', 'Genes', 'FBab', 'Aberrations', 'FBba', 'Balancers', 'FBal', 'Alleles', 'FBtp', 'Transposons/Vectors', 'FBti', 'Insertions', 'FBrf', 'References', 'FBpp', 'Polypeptides', 'FBtr', 'Transcripts', ## 'FBcl', 'Clones', ); %ScriptsList=( 'FBgn', 'fbgenq2', 'FBab', 'fbabsq2', 'FBrf', 'fbrefq2', 'FBcl', 'fbcloq', 'FBpp', 'fbppq', 'FBal', 'fbaleq.html', 'FBba', 'fbbalsq.html', 'FBtr', 'fbtransq.html', 'FBti', 'fbinsq.html', ); } # ------------------ START OF THE LIBRARY ------------ sub init() { local($query, $dname) = @_; # need reset some class vars here $refineForm= undef; $selectmanyForm= undef; $footer= undef; if ($dname) { $dataname= $dname; } else { $dataname= "FlyBase data"; } $debug= $main::debug; $dohtmlsup= $main::dohtmlsup; $dohtml= $main::dohtml; $fbidtag= $main::fbidtag; $gopath= $main::gopath; $viewlist= $main::viewlist; $reportStyles= $main::reportStyles; $maxhits= $main::maxhits if ($main::maxhits); if ($query) { $prettyquery= $query; } else { $prettyquery= $main::query; } } sub putContentType { local($contype)= @_; if ($ENV{'GATEWAY_INTERFACE'} =~ /CGI/) { $docgi= 1; $dohtml=3; } if (!$putcont && $main::putcont) { $putcont= $main::putcont; $contenttype= $main::contenttype; } return if ($putcont==1 && $contenttype ne ""); if ($contype) { $contenttype= $contype; } else { $contenttype= $ENV{'CGI_CONTYPE'}; } if (!$contenttype) { $contenttype= $ENV{'CONTENT_TYPE'}; } if (!$contenttype) { $contenttype= "text/html"; } if ($contenttype eq "application/x-www-form-urlencoded") { $contenttype= "text/html"; } if ($docgi) { print "Content-type: $contenttype\n\n"; $ENV{'CGI_CONTYPE'} = $contenttype; $putcont= 1; } } sub putNoResults { local($msg,$noexit)= @_; print STDERR "putNoResults: $msg\n" if $debug; &putContentType(); print "" if ($contenttype eq 'text/html'); print $msg; print "
" if ($contenttype eq 'text/html'); print "\n"; if ($noexit) { return(1); } else { exit(0); } # was &main::fbexit(0) } sub redirectToUrl { local($url,$noexit)= @_; if ($docgi) { if ($url !~ /^http/i) { ## prepend "http://$host:$port/" to url local($u)= "http://" . $main::host; $u .= ":" . $main::port if ($main::port != 80); $url= $u . $url; } print STDERR "redirectToUrl url= $url \n" if $debug; ## print "Status: 302\n"; ## == moved-temporarily, force httpd to do client-redirect !? print "Location: $url\n"; print "Content-Type: text/html\n\n"; print "
$dataname query '$prettyquery'
\n"; print "Results are at $url
\n"; if ($noexit) { return(0); } else { exit(0); } # was &main::fbexit(0) } } sub putResults { local( $nmatches, $askdata, $noexit, $moreResultsToFollow) = @_; $noexit= 1 if ($moreResultsToFollow); if ($nmatches < 1) { return &putNoResults("No matches in $dataname to query '$prettyquery'", $noexit); } elsif ( $nmatches == 1 && !$moreResultsToFollow) { return &putResultsReports( $nmatches, $askdata, $noexit); } else { return &putResultsList( $nmatches, $askdata, $noexit); } } sub putResultsReports { local( $totalcount,$askdata,$noexit) = @_; local( $i,$_,$id,$idq,$headline); print STDERR " putResultsReports count= $totalcount \n" if $debug; if ($totalcount < 1) { return &putNoResults("No matches in $dataname to query '$prettyquery'", $noexit); } else { if ( 1 ) { ## $dohtml unless (open(DATAF, "<$askdata")) { print STDERR " can't open $askdata \n" if $debug; return &putNoResults("Error reading results to query '$prettyquery'", $noexit); } $i= 0; while ( $i<$totalcount ) { $_= ; chop(); ## id should be first item on line, maybe only thing ($id,$headline) = split(/[\t]/,$_,2); $idq .= "+" if ($i>0); $idq .= $id; $i++; ## print STDERR " id= $id head=$headline \n" if $debug; } close(DATAF); if ($idq) { print STDERR "${idurl}?${idq}\n" if $debug; return &redirectToUrl("${idurl}?${idq}", $noexit); } else { print STDERR " no ids found in $askdata \n" if $debug; return &putNoResults("Error reading results to query '$prettyquery'", $noexit); } } else { ##? add support for gopher output? } } return 0; } sub getResultsListTitle { local( $query, $totalcount) = @_; local( $title); $title = "$dataname Results\n"; $title .= "$dataname query results
\n"; $title .= "Query: $query, " if ($query); $title .= "No. matches= $totalcount
"; return ($title); } sub getResultsSelectManyDialog0 { ## form to select items to return as one local($datafile)= @_; local($fm); ## note: $askdata == $askfile with path prefix and .data suffix ## $askdata = $gopath . $tmpdir . $askfile . ".data"; ##$fm .= "
\n"; $fm .= "\n"; $fm .= "\n"; $fm .= "

Batch download

\n"; $fm .= ":\n"; $fm .= "All\n"; $fm .= "Items: \n"; $fm .= " (e.g., '1..5,10..11')\n"; $fm .= "
\n"; $fm .= "Format: \n" if ($viewlist); $fm .= "Report style: \n" if ($reportStyles); $fm .= "
\n"; $fm .= "
\n"; return ($fm); } sub getResultsSelectManyDialog { ## form to select items to return as one local($datafile,$headlinepath)= @_; local($fm); ## note: $askdata == $askfile with path prefix and .data suffix ## $askdata = $gopath . $tmpdir . $askfile . ".data"; ## was METHOD=GET, why? $fm = <
Batch Download
: All Items: (e.g., '1..5,10..11') TEOF $fm .= "\n" if ($headlinepath); $fm .= "  Format: \n" if ($viewlist); ## $fm .= "Report style: \n" if ($reportStyles); $fm .= "\n"; $fm .= "
\n"; return ($fm); } sub putResultsList { local( $totalcount, $askdata, $noexit, $pquery) = @_; local( $i,$_,$id,$headline); ## dang, get rid of main:: global vars ## $main::fbidtag $main::query $fbidtag= $main::fbidtag; $prettyquery= $pquery if ($pquery); print STDERR " putResultsList count= $totalcount\n" if $debug; if ($totalcount < 1) { return &putNoResults("No matches to query '$prettyquery'", $noexit); } else { ## $|= 1; # force flush output, otherwise java output beats perl to client ... ## &putContentType(); local( $dpath, $dfile, $at); $dfile= $askdata; $at= rindex($askdata, "/"); if ($at>0) { $dfile= substr( $askdata, $at+1); $dpath= substr( $askdata, 0, $at); } if ( open(TF,">>$askdata") ) { print TF "0\tDATANAME|$dataname\n"; print TF "0\tQUERY|$prettyquery\n"; &setClassVars($fbidtag); $selectmanyForm = &getResultsSelectManyDialog($dfile) if (!$selectmanyForm); $refineForm= &getRefineDialog($main::query,$prettyquery) if (!$refineForm); local $footer = $selectmanyForm; $footer .= $refineForm if $refineForm; $footer =~ tr/\n/\t/; print TF "0\tFOOTER|$footer\n"; close(TF); } ## drop this for call in printResultList() ?? if ($javaResList) { local(@myclasses) = ( "fbqueryj.jar", "jgl3.1.0.jar" ); &initJavaEnv(@myclasses); $japp= "flybase.query.FbQuery"; $jflags= ""; $javaparms = "debug " . $javaparms if ($debug); $javaparms .= " maxhit=$maxhits" if ($maxhits); $javaparms .= " path=$dpath" if ($dpath); local($cmd)= "$javabin $jflags $japp $javaparms kind=querylist class=$fbidtag data=$dfile"; print STDERR "putResultsList: $cmd\n" if $debug; system($cmd); unlink $envtemp; } else { &printResultList( $dpath, $dfile, $maxhits, 1); } ## print $selform; ## print to tmp and have japp use } return 0; } sub makeHeadlines { local( $obspath, $headpath, $idtag) = @_; &setClassVars($idtag); local $obsfile= "$obspath/$idtag.acode"; local $headlist= "$headpath/$idtag.list"; print STDERR "makeHeadlines $obsfile --> $headlist\n" if $debug; return 0 if (! -f $obsfile); unlink $headlist if ( -f $headlist); system("grep '^RETE' $obsfile > $headlist"); system("echo 'DATANAME|$dataname' >> $headlist"); return &makeReslistIndex( $headpath, "$idtag.list"); } sub makeReslistIndex { local( $dpath, $dfile) = @_; $kIdxrecsize= 4; ## change "L" to "N" for always big-endian (crass-unix compat) local($record)= pack("L", 5000); # dummy to get fixed rec size $reslistIndexRecsize= length($record); ## 8 * 1 = 8 unless (open(DLIB, "<$dpath/$dfile")) { print STDERR " can't open $dpath/$dfile \n" if $debug; return &putNoResults("Error reading results data", 1); } ##? unlink("$dpath/$dfile.idx"); unless (open(DIDX, ">$dpath/$dfile.idx")) { print STDERR " can't write $dpath/$dfile.idx \n" if $debug; return &putNoResults("Error writing results index", 1); } local $nrecords= 0; ##?? line count of $dfile ## while ($_ = ) { $nrecords++; } ## no need to read thru twice ## toprec -- nrecords && sortkey ## change "L" to "N" for always big-endian (crass-unix compat) print DIDX pack("L", $nrecords); print DIDX pack("L", 0); # sort hash key seek(DLIB, 0, 0); ## rewind local $at= 0; while ($_ = ) { $nrecords++; ## change "L" to "N" for always big-endian (crass-unix compat) print DIDX pack("L", $at); $at= tell(DLIB); } ## change "L" to "N" for always big-endian (crass-unix compat) print DIDX pack("L", $at); ## do we need add this to $dfile ? ## fprintf( outf, "0\tLISTINFO|matches=%d\tstart=%d\tend=%d\tquery=%s\n", ## maxN, startN, lastN, sQuery); ## oat= ftell( outf); ## fwrite( &oat, sizeof(Int4), 1, oidx); ## fprintf( outf, "0\tLISTKEYS|%s\n", keys); seek(DIDX, 0, 0); ## rewind ## change "L" to "N" for always big-endian (crass-unix compat) print DIDX pack("L", $nrecords); close(DLIB); close(DIDX); return 0; } sub openResultList { local( $dpath, $dfile) = @_; $dataFile= $dfile; $dataPath= undef; ## if ($dpath =~ /tmp/) ??? ($dataPath= $dpath) =~ s/^$gopath// if ($dpath !~ /tmp/); $kIdxrecsize= 4; ## change "L" to "N" for always big-endian (crass-unix compat) local($record)= pack("L", 5000); # dummy to get fixed rec size $reslistIndexRecsize= length($record); ## 8 * 1 = 8 unless (open(RLIB, "<$dpath/$dfile")) { print STDERR " can't open $dpath/$dfile \n" if $debug; return &putNoResults("Error reading results data", 1); } if (!open(RIDX, "<$dpath/$dfile.idx")) { &makeReslistIndex( $dpath, $dfile); unless (open(RIDX, "<$dpath/$dfile.idx")) { print STDERR " can't open $dpath/$dfile.idx \n" if $debug; return &putNoResults("Error reading results index", 1); } } read(RIDX, $record, $reslistIndexRecsize); ## change "L" to "N" for always big-endian (crass-unix compat) ($nrecords) = unpack("L", $record); $toprecsize= 2 * $kIdxrecsize; print STDERR "nrecords= $nrecords\n" if $debug; return 0; } sub closeResultList { close(RLIB); close(RIDX); } sub seekResultItem { local($linenum)= @_; local($record); local($idxseek)= $toprecsize + $kIdxrecsize * ($linenum-1); seek(RIDX, $idxseek, 0); read(RIDX, $record, $reslistIndexRecsize); ## change "L" to "N" for always big-endian (crass-unix compat) local($datseek) = unpack("L", $record); seek(RLIB, $datseek, 0); } sub getResultListInfo { local( $dpath, $dfile)= @_; ## at end of RLIB resultlist data ##0 LISTINFO|matches=983 start=1 end=983 query= [fbgenes-org:Dmel] & [fbgenes-all:wing] ##0 LISTKEYS|ID CLA NAM GSYM DT RESZ PDOM PTD DBA FNC CEL WT CLOC KLOC ALESR SK REF GLOC HG PDIS FSQ ##0 DATANAME|FlyBase Genes ##0 QUERY| species=[Dmel] and all=[wing] ##0 FOOTER|
: All Items: (e.g., '1..5,10..11')
Report style: Format:

$footer= undef; $dataname= undef; &seekResultItem( $nrecords-1); ## seek last data line, to get FBid class !? while ($_ = ) { chop; local($key,$val) = split(/\|/,$_,2); print STDERR "reslist info: $key | $val\n" if $debug; if ($key =~ /LISTINFO/) { if ($val =~ /\tquery=([^\t]+)/) { $prettyquery= $1; } } elsif ($key =~ /DATANAME/) { $dataname= $val; } elsif ($key =~ /QUERY/) { $prettyquery= $val; } elsif ($key =~ /FOOTER/) { $footer= $val; $footer =~ tr/\t/\n/; } ##elsif ($key =~ /[FP][BF]([A-z]{2})\d/) { $fbidtag= "FB" . $1; } ##elsif ($val =~ /[FP][BF]([A-z]{2})\d/) { $fbidtag= "FB" . $1; } elsif ($key =~ /([A-z]{4})\d/) { $fbidtag= $1; } elsif ($val =~ /([A-z]{4})\d/) { $fbidtag= $1; } } if (!$footer) { local $ishead= ($dpath =~ m/headlines/); &setClassVars($fbidtag); $footer = &getResultsSelectManyDialog($dfile,$ishead); } } sub getColHeader { ## $sortKinds='KLOC=2|DT=3|RESZ=1|DBA=1|REF=1|SK=1|ALESR=1'; local($doarray) = @_; local($s); if ($useBriefFields) { $s= $briefFields; } else { $s= $visibleFields; } local(@hd) = split(/\|/,$s); unshift(@hd, "#"); local($nh)= $#hd; local($hl)= ""; @headkeys= (); %headsize= (); %numIsVal= (); # flag that we use count instead of val (drop val) of key_num_val triplet local(@sk) = split(/\|/,$sortKinds); foreach (@sk) { local($k, $v) = split(/=/, $_); $numIsVal{$k}= 1 if ($v == 1); ##? or other #v != 0 ?? } for ($i=0; $i<=$nh; $i++) { local( $h, $w, $k, $t) ; $h= $hd[$i]; if ($h eq "#") { $k= undef; $w= 4; } elsif ($h =~ /([^:]+):(\d+)=?(.+)/) { $k= $1; $w= $2; $t= $3; } if ($t) { $t =~ s/=(.+)//; $h= $t; $sortkey= $1 if ($1); } push(@headkeys, $k) if ($k); $headsize{$k}= $w; $hd[$i]= $h; if (!$doarray && $h ne "#") { $hl .= $h . ' '; local $len= $w - length($h) - 1; if ($len>0) { $hl .= substr('.....................................................',0,$len); } } } if ($doarray) { return @hd; } else { return $hl; } } sub getSRSQueryPipesOptions { local($idtag)=@_; local $name= $DBNamesList{$idtag}; return "" if (!$name); local $s= "
Search $name , retrieve only.\n"; return $s; } sub putbutton { local( $label, $filler, $start, $dolink) = @_; $label =~ s|>|>|g; $label =~ s|<|<|g; if ($dolink) { local $url= $reslisturl . '?'; $url .= "start=" . $start . '&' if ($start>1) ; # $url .= "end=" . $enditem . '&' if ($enditem>1) ; $url .= "data=" . $dataFile . '&' if ($dataFile) ; $url .= "maxhit=" . $pagesize . '&' if ($pagesize>0) ; if ($dataPath =~ /headline/) { $url .= "head" . '&' ; } elsif ($dataPath) { $url .= "path=" . $dataPath . '&'; } print ""; print $label; print ""; } else { print $label; } print $filler; } sub putpagebarNoTable { ##Go to item: [1] .. [<<<] .. [<1<] .. [>41>] .. [>>>] .. [1057]
local($startN,$maxN,$pageSize)= @_; return if ($pageSize >= $maxN); local($lastTop) = $maxN - $pageSize; $lastTop= 1 if ($lastTop < 1) ; local($fastStep)= int($maxN / 4); $fastStep= $pageSize * 4 if ($fastStep < $pageSize * 4); print "Go to item: "; putbutton( "[1]"," .. ", 1, ($startN > 1) ); local $at = $startN - $fastStep; $at= 1 if ($at < 1) ; putbutton( "[<<<]"," .. ", $at, ($at < $startN) ); $at = $startN - $pageSize; $at= 1 if ($at < 1); putbutton( "[<" . $at . "<]"," .. ", $at, ($at < $startN) ); $at = $startN + $pageSize; $at= $lastTop if ($at > $lastTop); putbutton( "[>". $at .">]"," .. ", $at, ($at > $startN) ); $at = $startN + $fastStep; $at= $lastTop if ($at > $lastTop); putbutton( "[>>>]"," .. ", $at, ($at > $startN) ); putbutton( "[" . $maxN . "]", "", $lastTop, ($lastTop > $startN )); print "
\n"; } sub putbuttonbox { local( $label, $clr, $start, $dolink) = @_; $label =~ s|>|>|g; $label =~ s|<|<|g; print ""; if ($dolink) { local $url= $reslisturl . '?'; $url .= "start=" . $start . '&' if ($start>1) ; # $url .= "end=" . $enditem . '&' if ($enditem>1) ; $url .= "data=" . $dataFile . '&' if ($dataFile) ; $url .= "maxhit=" . $pagesize . '&' if ($pagesize>0) ; if ($dataPath =~ /headline/) { $url .= "head" . '&' ; } elsif ($dataPath) { $url .= "path=" . $dataPath . '&'; } print ""; print $label; print ""; } else { print $label; } print "\n"; } sub putpagebar { local($startN,$maxN,$pageSize)= @_; return if ($pageSize >= $maxN); if ( $ENV{'FB_LIST_HSTYLE'} eq 'preformat' ) { &putpagebarNoTable($startN,$maxN,$pageSize); return; } local($lastTop) = $maxN - $pageSize; $lastTop= 1 if ($lastTop < 1) ; local($fastStep)= int($maxN / 4); $fastStep= $pageSize * 4 if ($fastStep < $pageSize * 4); print < EOF putbuttonbox( "First page", "#d0d0f0", 1, ($startN > 1) ); local $at = $startN - $fastStep; $at= 1 if ($at < 1) ; putbuttonbox( "Fast back\n <<< [$at]", "#e0e0f0", $at, ($at < $startN) ); $at = $startN - $pageSize; $at= 1 if ($at < 1); putbuttonbox( "Prior page\n < [$at]", "#e8e8f0", $at, ($at < $startN)); $at = $startN + $pageSize; $at= $lastTop if ($at > $lastTop); putbuttonbox( "Next page\n > [$at]", "#f0e8e8", $at, ($at > $startN)); $at = $startN + $fastStep; $at= $lastTop if ($at > $lastTop); putbuttonbox( "Fast forward\n >>> [$at]", "#f0e0e0", $at, ($at > $startN)); putbuttonbox( "Last page\n [$maxN]", "#f0d0d0", $lastTop, ($lastTop > $startN )); print "
Page to item
\n"; } sub printHeader0 { print "\n"; local($myhost)= $ENV{'HTTP_HOST'}; if ($myhost) { print "\n"; } print <$dataname result list

$dataname result list

XEOF print "Query:   $prettyquery,  " if $prettyquery; print "No. matches= $nrecords\n"; } sub printHeader { ## ! fix - may have already done ... print < $dataname query results XEOF print "\n" if (!$onepageOfMatches); print "\n"; print "\n" if ($footer =~ m/refine/); print "
$dataname query resultsSelect
page
Batch
download
Refine
query

\n"; print "Query:   $prettyquery,  " if $prettyquery; print "No. matches= $nrecords\n"; } sub printResultsReports { local( $dpath, $dfile, $items, $repstyle, $contype) = @_; ##? need gopher support print STDERR "printResultsReports: path=$dpath data=$dfile items=$items\n" if $debug; $err= &openResultList( $dpath, $dfile); if ($err) { return; } &getResultListInfo( $dpath, $dfile); if ($items eq "*") { $items= "1..$nrecords"; } # faster to just step thru RLIB local @list = ("1","2"); $items =~ tr/ /,/; $items =~ s/--/-/g; $items =~ s/-/../g; ## let 1-5 work for eval() @list = eval("($items);"); # items in format "1,2,3..5,7,9..20" local $idlist= undef; local ($item, $i); foreach $item (@list) { &seekResultItem( $item); local $line = ; ##print STDERR "item=$item line=$line" if $debug; if ($line =~ /([A-Za-z]{4}\d+)/) { $idlist .= "+" if ($i>0); $idlist .= $1; $i++; } } &closeResultList(); if ($idlist) { if ($repstyle) { $idlist .= "&content=$repstyle"; } if ($contype) { $idlist .= "&mimetype=$contype"; } ## print STDERR "${idurl}?${idlist}\n" if $debug; return &redirectToUrl("${idurl}?${idlist}", 1); } else { print STDERR " no ids found in $askdata \n" if $debug; return &putNoResults("Error reading results to query '$prettyquery'", 1); } } sub convertCodes { if (defined &main::ConvertCodes) { return &main::ConvertCodes( @_ ); } else { return @_; } } sub printResultList { local( $dpath, $dfile, $pgsize, $startNum) = @_; local($str,$i); local($do_table)=0; $pagesize= $pgsize if ($pgsize>0); if ($javaResList || $ENV{'FB_QUERYLIST_X'}==1 ) { local(@myclasses) = ( "fbqueryj.jar", "jgl3.1.0.jar" ); &initJavaEnv(@myclasses); $japp= "flybase.query.FbQuery"; $jflags= ""; $javaparms = "debug " . $javaparms if ($debug); $javaparms .= " path=$dpath" if ($dpath); $javaparms .= " class=$fbidtag" if ($fbidtag); $javaparms .= " maxhit=$pagesize"; $javaparms .= " start=$startNum" if ($startNum); local($cmd)= "$javabin $jflags $japp $javaparms kind=querylist data=$dfile"; print STDERR "printResultList: $cmd\n" if $debug; system($cmd); unlink $envtemp; return; } print STDERR "printResultList: path=$dpath data=$dfile start=$startNum\n" if $debug; &putContentType(); $err= &openResultList( $dpath, $dfile); if ($err) { $onepageOfMatches= 1; &printHeader(); return; } &getResultListInfo( $dpath, $dfile); &setClassVars($fbidtag); if( !($dohtml) ) { ## GOPHER ## for( $i=0; $i <= $#outarray; $i++) { print $outarray[$i]; } return; } if( !$startNum || $startNum<1 ) { $startNum=1; } ## &out_html_hits_page(@outarray); $onepageOfMatches= ($pagesize >= $nrecords); &printHeader(); if( $ENV{'FB_LIST_HSTYLE'} ne 'preformat' ) { $do_table=1; } ## eq 'table' ?? if( $do_table ) { local(@heads)= &getColHeader(1); print "\n"; print ""; foreach $hd ( @heads ) { print ""; } print "\n"; } else { local($colhdr)= &getColHeader(0); print "
    \n"; print "
    $colhdr\n";  
    		}
    
      local($irow, $linenum);
      local($more)= 1;
      while ($more)
      {
      	$lineno= $startNum + $irow;
      	$more= 0 if ($lineno > $nrecords);
      	$more= 0 if ($irow >= $pagesize);
      	last if (!$more);
      	$irow++;
      	
    		&seekResultItem( $lineno);
      	$str = ;
      	##$more= 0 if (!$str); 
      	
    		if ($str) {
    			$str =~ s|\n+$||;
    			local @tparts = split(/\t/, $str, 999);
      	  if( $do_table ) { 
            $str = ($irow % 2 == 1) ? "
" : ""; print $str; print ""; } else { print "
  • "; } local($i); %vals= (); $id= undef; for ( $i=0; $i<=$#tparts; $i++ ) { local $part= $tparts[$i]; $part =~ s/^RETE\|//; if ($part =~ /^[A-Za-z]{4}\d/) { $id= $part; } else { ($key,$num,$val)= split(' ',$part,3); # print STDERR "key=$key num=$num val=$val\n" if $debug; #$key= 'SYM' if ($key eq "GSYM"); ## hack fix for FBgn ##$val= &getCommonOrgName($val) if ($key eq 'ORG'); if ($key eq "ID") { $id= $val; } elsif (!$val || $numIsVal{ $key }) { $val= $num; } else { ($val) = convertCodes( $val ); } } if ($headsize{$key}) { $vals{$key}= $val; } } for ( $i=0; $i<=$#headkeys; $i++ ) { local $key= $headkeys[$i]; local $val= $vals{ $key }; $val= "-" if (!$val || $val =~ m/^\s+$/); local $dolink= (($key eq $gSymbolKey) && $id); if ($dolink) { $url= $idurl . '?' . $id; } if( $do_table ) { print '
  • '; } else { print "" if ($dolink); print $val; print '' if ($dolink); local $spc= ' '; local $len= $headsize{$key} - length($val) - 1; $spc .= substr(' ',0,$len) if ($len>0); print $spc; } } if( $do_table ) { print ""; } } print " \n"; } if ( $do_table ) { print "
    $hd
    ". $lineno ."'; print "" if ($dolink); print $val; print '' if ($dolink); print '
    \n"; } else { print "\n"; } print "


    \n"; &putpagebar( $startNum, $nrecords, $pagesize); print $footer if ($footer); print "\n"; ## dang - may not be last - move to &printEnd() ?? &closeResultList(); } sub initJavaEnv { local(@classes) = @_; $jlib = "$gopath/.etc/jlib"; $envtemp = "$gopath/tmp/fbjava$$.env"; if (!$contenttype) { $contenttype= $ENV{'CGI_CONTYPE'}; } if (!$contenttype) { $contenttype= $ENV{'CONTENT_TYPE'}; } if (!$contenttype) { $contenttype= "text/html"; } if ($contenttype eq "application/x-www-form-urlencoded") { $contenttype= "text/html"; } $javapath= "$gopath/.totop/java-local/"; if (! -d $javapath ) { $javapath= "$gopath/.totop/bin-local/java/"; if (! -d $javapath ) { $javapath= $ENV{"JAVA_HOME"}; } } if ( -d $javapath ) { $javabin= "$javapath/bin/java"; $javalib= "$javapath/lib/classes.zip"; } else { return &putNoResults("No java runtime available", $noexit); } ## ?? set $javalib from $ENV{"CLASSPATH"} ?? $classpath= "$jlib"; local($i); for ($i= 0; $i<=$#classes; $i++) { $classpath .= ":$jlib/" . $classes[$i]; } $classpath .= ":$javalib"; $ENV{"CLASSPATH"}= $classpath; print STDERR "CLASSPATH='$classpath'\n" if $debug; open(ENVF,">$envtemp"); while (local($key,$val) = each %ENV) { print ENVF "$key=$val\n"; } close(ENVF); $javaparms= "httpcall mimetype=$contenttype env=${envtemp} "; } sub setClassVars { local($_) = @_; ## parameter is section value or FBid value local($idokay); $idokay = 1; @views= ("text/html","text/plain","text/acode","text/acode-pretty", "text/xml" ); $gSymbolKey='SYM'; if (/^FBgn/i) { $dataname = "FlyBase Genes"; ## if (!$dataname || $dataname =~ /FlyBase data/); $fbidtag = "FBgn"; @repStyles= ("short","long","abstract","reftable","allele-table"); $gSymbolKey='GSYM'; $visibleFields0='GSYM:15=Symbol|NAM:15=Name|CLA:8=Class' . '|CLOC:15=Map Location=KLOC|ALESR:10=No. Alleles|SK:10=No. Stocks' . '|REF:10=No. Ref.|DBA:10=No. DNA acc.|DT:8=Date|RESZ:8=Rept. size'; $visibleFields='GSYM:15=Symbol|NAM:15=Name' . '|CLOC:15=Map Location=KLOC|ALESR:8=Alleles|SK:8=Stocks' . '|REF:6=Refs|DBA:8=DNA acc.|DT:8=Date|RESZ:8=Rept. size'; $briefFields='GSYM:15=Symbol|NAM:25=Name|CLOC:15=Map Location=KLOC|SK:10=No. Stocks'; $sortKinds='KLOC=2|DT=3|RESZ=1|DBA=1|REF=1|SK=1|ALESR=1'; } elsif (/^FBal/i) { $dataname = "FlyBase Alleles"; ## if (!$dataname || $dataname =~ /FlyBase data/); $fbidtag = "FBal"; ## $colhdr= ' Map location | Symbol .......................'; @repStyles= ("short","long","abstract","reftable"); $gSymbolKey='GSYM'; $visibleFields0='GSYM:15=Symbol|NAM:15=Name|CLA:8=Class|SK:8=Stocks|REF:8=Ref.s'; $visibleFields='GSYM:15=Symbol|NAM:15=Name|SK:8=Stocks|REF:8=Ref.s'; $briefFields= $visibleFields; $sortKinds='KLOC=2|DT=3|RESZ=1|DBA=1|REF=1|SK=1|ALESR=1'; } elsif (/^FBab/i) { $dataname = "FlyBase Aberrations"; ## if (!$dataname || $dataname =~ /FlyBase data/); $fbidtag = "FBab"; @repStyles= ("short","long","abstract","reftable"); $gSymbolKey='GSYM'; $visibleFields0='GSYM:15=Symbol|NAM:15=Name|CLA:8=Class' . '|CLOC:15=Map Location=KLOC|ALESR:10=No. Variants|SK:10=No. Stocks' . '|REF:10=No. Ref.|DT:10=Date|RESZ:10=Rept. size'; $visibleFields='GSYM:15=Symbol|NAM:15=Name|CLA:8=Class' . '|CLOC:15=Map Location=KLOC|SK:10=No. Stocks|REF:6=Refs|DT:10=Date'; $briefFields='GSYM:15=Symbol|NAM:25=Name|CLOC:15=Map Location=KLOC|SK:10=No. Stocks'; $sortKinds='KLOC=2|DT=3|RESZ=1|DBA=1|REF=1|SK=1|ALESR=1'; } elsif (/^FBba/i) { $dataname = "FlyBase Balancers"; ## if (!$dataname || $dataname =~ /FlyBase data/); $fbidtag = "FBba"; @repStyles= ("short","long","abstract","reftable"); $gSymbolKey='GSYM'; $visibleFields='GSYM:15=Symbol|NAM:15=Name|CLA:8=Class|SK:10=No. Stocks|REF:6=Refs'; $briefFields= $visibleFields; $sortKinds='KLOC=2|DT=3|RESZ=1|DBA=1|REF=1|SK=1|ALESR=1'; } elsif (/^FBrf/i) { $dataname = "FlyBase References"; ## if (!$dataname || $dataname =~ /FlyBase data/); $fbidtag = "FBrf"; ## $colhdr= ' First Author..... | Year | Title................... | Journal/Book'; push(@views, ("application/endnote","application/refer" )); @repStyles= ("long"); $gSymbolKey='AU'; $visibleFields='AU:20=Authors|YR:6=Year|TI:30=Title|REFM:15=Mini ref.|TP:8=Class'; $visibleFields0='AU:20=Authors|YR:6=Year|TI:30=Title|REFM:15=Mini ref.'; $briefFields='AU:25=Authors|YR:6=Year|TI:50=Title'; $sortKinds='YR=4'; } elsif (/^FBcl/i || /^XXcl/i) { $dataname = "FlyBase Clones"; ## if (!$dataname || $dataname =~ /FlyBase data/); $fbidtag = "FBcl"; @repStyles= ( "long"); $gSymbolKey='SYM'; $visibleFields='SYM:15=Symbol|CLA:8=Class|CCLOC:15=Map Location|DBA:8=DNA acc.|CPW:10=Lib. plate well'; $briefFields= $visibleFields; # CCLOC:15=Map Location=KLOC -- when KLOC is available $sortKinds='KLOC=2|DT=3|RESZ=1|DBA=1|CPW=1'; } elsif (/^FBpp/i) { $dataname = "FlyBase Polypeptides"; ## if (!$dataname || $dataname =~ /FlyBase data/); $fbidtag = "FBpp"; @repStyles= ("short","long","abstract","reftable"); $gSymbolKey='SYM'; ## $visibleFields='SYM:15=Symbol|AAL:8=Length|TRS:10=Size (KD)|DBA:8=DNA acc.|HG:8=Homologs' . ## $visibleFields='SYM:15=Symbol|AAL:8=Length|TRS:10=Size (KD)|REF:6=Refs|DT:8=Date|RESZ:10=Rept. size'; $visibleFields='SYM:15=Symbol|AAL:8=Length|TRS:10=Size (KD)|HG:6=Homologs|DBA:6=DB Links|REF:6=Refs|DT:8=Date|RESZ:10=Rept. size'; $briefFields= $visibleFields; $sortKinds='DT=3|RESZ=1'; # DBA=1|HG=1|REF=1 ## < 0) { # more than 1 foreach $v (@repStyles) { $reportStyles .= "$v\n"; $sel= ""; } } $viewlist= ""; if ($#views > 0) { # more than 1 foreach $v (@views) { if ($v eq "text/html") { $viewlist .= "