[Bio] / FigWebServices / protein.cgi Repository:
ViewVC logotype

Diff of /FigWebServices/protein.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.75, Thu Jan 27 18:28:29 2005 UTC revision 1.76, Fri Jan 28 19:30:02 2005 UTC
# Line 456  Line 456 
456      my($fig_or_sprout,$cgi,$html,$peg,$user,$has_translation) = @_;      my($fig_or_sprout,$cgi,$html,$peg,$user,$has_translation) = @_;
457    
458      my $sims = $cgi->param('sims');      my $sims = $cgi->param('sims');
459      if ((! $sims) && $has_translation && (! $cgi->param('SPROUT'))) {      if ( (! $sims ) && $has_translation && ( ! $cgi->param('SPROUT') ) )
460          my $max_expand = $cgi->param('max_expand') ||  5;      {
461          my $maxN       = $cgi->param('maxN')       || 50;   #  Default 50, not 5 (GJO)          my $short_form = 1;
462          my $maxP       = $cgi->param('maxP')       ||  1.0e-5;          sims_request_form( $fig_or_sprout, $cgi, $html, $peg, $user, $short_form );
         my $ex_raw     = $cgi->param('expand_raw') ||  0;   #  Default 0, not 1 (GJO)  
         my $just_fig   = $cgi->param('just_fig')   ||  0;  
         my $show_env   = $cgi->param('show_env')   ||  0;  
         my $hide_alias = $cgi->param('hide_alias') ||  0;  
   
         push( @$html, $cgi->start_form(-action => "protein.cgi#Similarities"));  
         if ($cgi->param('translate')) {  
             push(@$html,$cgi->hidden(-name => 'translate', -value => 1));  
463          }          }
         my $sprout = $cgi->param('SPROUT') ? 1 : "";  
464    
465          push( @$html, $cgi->hidden(-name => 'prot', -value => $peg),      #  Added test $has_translation && (...) -- GJO
466                        $cgi->hidden(-name => 'sims', -value => 1),      elsif ( $has_translation && ( $sims || $cgi->param('SPROUT') ) )
467                        $cgi->hidden(-name => 'fid',  -value => $peg),      {
                       $cgi->hidden(-name => 'user', -value => $user),  
                       $cgi->hidden(-name => 'SPROUT', -value => $sprout),  
                       $cgi->submit('Similarities'),  
                       " MaxN: ", $cgi->textfield(-name => 'maxN', -size =>  5, -value => $maxN, -override => 1),  
                       " Max expand: ", $cgi->textfield(-name => 'max_expand', -size =>  5, -value => $max_expand, -override => 1),  
                       " MaxP: ", $cgi->textfield(-name => 'maxP', -size => 10, -value => $maxP),  
                       " Just FIG Ids: ", $cgi->checkbox(-name => 'just_fig', -value => 1, -checked => $just_fig, -override => 1, -label => ""),  
                       " Show Env. samples: ", $cgi->checkbox(-name => 'show_env', -value => 1, -checked => $show_env, -override => 1, -label => ""),  
                       " Hide aliases: ", $cgi->checkbox(-name => 'hide_alias', -value => 1, -checked => $hide_alias, -override => 1, -label => ""),  
                       $cgi->end_form  
             );  
     } elsif ($sims || $cgi->param('SPROUT')) {  
468          &print_similarities($fig_or_sprout,$cgi,$html,$peg);          &print_similarities($fig_or_sprout,$cgi,$html,$peg);
469      }      }
470  }  }
# Line 521  Line 500 
500          push(@$html,"<br><a href=$link target=checked_window>To Make an Annotation</a>\n");          push(@$html,"<br><a href=$link target=checked_window>To Make an Annotation</a>\n");
501      }      }
502    
503        #  Isn't this redundant?  Look up about 9 lines. -- GJO
504    
505      my $sprout = $cgi->param('SPROUT') ? 1 : "";      my $sprout = $cgi->param('SPROUT') ? 1 : "";
506      if (! $sprout)      if (! $sprout)
507      {      {
# Line 683  Line 664 
664      }      }
665  }  }
666    
667    
668  sub print_similarities_SPROUT {  sub print_similarities_SPROUT {
669      my($fig_or_sprout, $cgi, $html, $peg ) = @_;      my($fig_or_sprout, $cgi, $html, $peg ) = @_;
670    
# Line 858  Line 840 
840    
841  sub print_similarities_SEED {  sub print_similarities_SEED {
842      my( $fig_or_sprout, $cgi, $html, $peg ) = @_;      my( $fig_or_sprout, $cgi, $html, $peg ) = @_;
     my( $maxN, $maxP, $expand_groups, $ex_checked );  
843    
844      my $user = $cgi->param('user') || "";      my $user = $cgi->param('user') || "";
845      my $current_func = &trans_function_of($cgi,$fig_or_sprout,$peg,$user);      my $current_func = &trans_function_of($cgi,$fig_or_sprout,$peg,$user);
846    
     $maxN = defined( $cgi->param('maxN') ) ? $cgi->param('maxN') : 5;  
     $maxP = defined( $cgi->param('maxP') ) ? $cgi->param('maxP') : 1.0e-5;  
     $expand_groups = $cgi->param('expand_groups');  
     $ex_checked = $expand_groups ? "checked" : "";  
   
     my $max_expand = $cgi->param('max_expand') || 0;  
     my $just_fig   = $cgi->param('just_fig')   || 0;  
     my $show_env   = $cgi->param('show_env')   || 0;  
     my $hide_alias = $cgi->param('hide_alias') || 0;  
   
847      push( @$html, $cgi->hr,      push( @$html, $cgi->hr,
848                    "<a name=Similarities>",                    "<a name=Similarities>", $cgi->h1('Similarities'), "</a>\n"
                   $cgi->h1('Similarities'),  
                   "</a>\n"  
849          );          );
850    
851      #      #  Generate the request form, and return current option values in hash
     #  Instead of automatically doubling maxN, use the value of  
     #  $cgi->param("more similarities") to drive increase in maxN and  
     #  max_expand  
     #  
     if ( $cgi->param('more similarities') ) {  
         $maxN       *= 2;  
         $max_expand *= 2;  
         $cgi->delete('more similarities');  
     }  
852    
853      my ( $prev, $next ) = ( 0, 0 );      my $short_form = 0;
854      my ( $prefix, $protnum ) = $peg =~ /^(.*\.)(\d+)$/;      my $SimParams = sims_request_form( $fig_or_sprout, $cgi, $html, $peg, $user, $short_form );
     if ( $prefix && $protnum ) {  
         $prev = ( $protnum > 1 ) && &translatable($fig_or_sprout, $prefix . ($protnum-1) );  
         $next =                     &translatable($fig_or_sprout, $prefix . ($protnum+1) );  
     }  
855    
856      push(@$html, $cgi->start_form(-action => "protein.cgi#Similarities"));      my $maxN       = $SimParams->{ maxN };
857        my $maxP       = $SimParams->{ maxP };
858        my $max_expand = $SimParams->{ max_expand };
859        my $just_fig   = $SimParams->{ just_fig };
860        my $show_env   = $SimParams->{ show_env };
861        my $hide_alias = $SimParams->{ hide_alias };
862    
863        #  None of these are currently active: -- GJO
864        my $extra_opt  = $SimParams->{ extra_opt };
865        my $min_q_cov  = $SimParams->{ min_q_cov };
866        my $min_s_cov  = $SimParams->{ min_s_cov };
867        my $min_sim    = $SimParams->{ min_sim };
868        my $sim_meas   = $SimParams->{ sim_meas };
869        my $show_rep   = $SimParams->{ show_rep };
870        my $max_sim    = $SimParams->{ max_sim };
871        my $dyn_thrsh  = $SimParams->{ dyn_thrsh };
872        my $save_dist  = $SimParams->{ save_dist };
873        my $chk_which  = $SimParams->{ chk_which };
874    
875      if ($cgi->param('translate')) {      #  There is currently no control to turn this on! -- GJO
876          push(@$html,$cgi->hidden(-name => 'translate', -value => 1));      my $expand_groups = $SimParams->{ expand_groups };
     }  
877    
878      push(@$html, $cgi->hidden(-name => 'prot', -value => $peg),      my $select = $just_fig ? "fig" : "all";
                  $cgi->hidden(-name => 'sims', -value => 1),  
                  $cgi->hidden(-name => 'fid',  -value => $peg),  
                  $cgi->hidden(-name => 'user', -value => $user),  
                  " MaxN: ", $cgi->textfield(-name => 'maxN', -size => 5, -value => $maxN, -override => 1),  
                  " Max expand: ", $cgi->textfield(-name => 'max_expand', -size => 5, -value => $max_expand, -override => 1),  
                  " MaxP: ", $cgi->textfield(-name => 'maxP', -size => 10, -value => $maxP),  
                  " Just FIG Ids: ", $cgi->checkbox(-name => 'just_fig', -value => 1, -checked => $just_fig, -override => 1, -label => ""),  
                  " Show Env. samples: ", $cgi->checkbox(-name => 'show_env', -value => 1, -checked => $show_env, -override => 1, -label => ""),  
                  " Hide aliases: ", $cgi->checkbox(-name => 'hide_alias', -value => 1, -checked => $hide_alias, -override => 1, -label => ""),  
                  $cgi->br,  
                  $prev ? $cgi->submit('previous PEG') : (),  
                  $cgi->submit('resubmit'),  
                  $cgi->submit('more similarities'),  
                  $next ? $cgi->submit('next PEG') : (),  
                  $cgi->end_form  
          );  
879    
880      push( @$html, $cgi->hr );      #  Move filtering of sims list out of display loop.  Avoids many problems,
881        #  including display of table with no entries.  Anticipate more filters.
882        #  -- GJO
883    
884      my $select = $just_fig ? "fig" : "all";      my @sims = grep { $show_env || ( $_->id2 !~ /^fig\|999999/ ) }
885      my @sims = &sims($fig_or_sprout, $peg, $maxN, $maxP, $select, $max_expand );                 &sims( $fig_or_sprout, $peg, $maxN, $maxP, $select, $max_expand );
886    
887      if (@sims) {      if (@sims) {
888            push( @$html, $cgi->hr );
889          my @from = $cgi->radio_group(-name => 'from',          my @from = $cgi->radio_group(-name => 'from',
890                           -nolabels => 1,                           -nolabels => 1,
891                                       -override => 1,                                       -override => 1,
892                           -values => ["",$peg,map { $_->id2 } @sims]);                                        -values => [ "", $peg, map { $_->id2 } @sims ]
893                                        );
894    
895          my $target = "window$$";          my $target = "window$$";
896          # RAE: added a name to the form so tha the javascript works          # RAE: added a name to the form so tha the javascript works
# Line 1051  Line 1011 
1011          my $sim;          my $sim;
1012          foreach $sim ( @sims ) {          foreach $sim ( @sims ) {
1013              my $id2  = $sim->id2;              my $id2  = $sim->id2;
1014              if ((! $show_env) && ($id2 =~ /^fig\|99999/)) {  
1015                  shift @from;              # # Filtering moved outside of "if ( @sims ) {" -- GJO
1016                  next;              #
1017              }              # if ((! $show_env) && ($id2 =~ /^fig\|99999/)) {
1018                #     shift @from;
1019                #     next;
1020                # }
1021    
1022              my $cbox = &translatable($fig_or_sprout,$id2) ?              my $cbox = &translatable($fig_or_sprout,$id2) ?
1023                     qq(<input type=checkbox name=checked value="$id2">) : "";                     qq(<input type=checkbox name=checked value="$id2">) : "";
1024    
# Line 1218  Line 1182 
1182  }  }
1183    
1184    
1185    #------------------------------------------------------------------------
1186    #  Generate similarity query forms for the SEED.  Consolidates things like
1187    #  style and defaults in one place.
1188    #
1189    #   my $user = $cgi->param('user') || "";
1190    #   my $short_form = 0;
1191    #   my $SimParam = sims_request_form( $fig, $cgi, $html, $peg, $user, $short_form );
1192    #------------------------------------------------------------------------
1193    
1194    sub sims_request_form {
1195        my ( $fig, $cgi, $html, $peg, $user, $short_form ) = @_;
1196    
1197        #  Read available parameters, and fill in defaults:
1198    
1199        my $maxN       = defined( $cgi->param('maxN') )       ? $cgi->param('maxN')       : 50;
1200        my $max_expand = defined( $cgi->param('max_expand') ) ? $cgi->param('max_expand') :  5;
1201        my $maxP       = defined( $cgi->param('maxP') )       ? $cgi->param('maxP')       :  1.0e-5;
1202        my $just_fig   = $cgi->param('just_fig')   || 0;
1203        my $show_env   = $cgi->param('show_env')   || 0;
1204        my $hide_alias = $cgi->param('hide_alias') || 0;
1205        my $trans_role = $cgi->param('translate')  || 0;
1206        my $expand_groups = $cgi->param('expand_groups') || 0;
1207    
1208        #  New parameters.  Not yet implimented.
1209        #  Make the defaults loose ennough to pass everything:
1210    
1211        my $extra_opt = defined( $cgi->param('extra_opt') ) ? $cgi->param('extra_opt') : 0;
1212        my $min_sim   = defined( $cgi->param('min_sim') )   ? $cgi->param('min_sim')   : 0.01;
1213        my $min_q_cov = defined( $cgi->param('min_q_cov') ) ? $cgi->param('min_q_cov') : 0.01;
1214        my $min_s_cov = defined( $cgi->param('min_s_cov') ) ? $cgi->param('min_s_cov') : 0.01;
1215        my $sim_meas  = defined( $cgi->param('sim_meas') )  ? $cgi->param('sim_meas')  : 'id';
1216    
1217        #  The defaults for representative sequences might be tuned:
1218    
1219        my $show_rep  = defined( $cgi->param('show_rep') )  ? $cgi->param('show_rep')  : 0;
1220        my $max_sim   = defined( $cgi->param('max_sim') )   ? $cgi->param('max_sim')   : 0.70;
1221        my $dyn_thrsh = defined( $cgi->param('dyn_thrsh') ) ? $cgi->param('dyn_thrsh') : 0;
1222        my $save_dist = defined( $cgi->param('save_dist') ) ? $cgi->param('save_dist') : 0.80;
1223    
1224        #  Mark some of the sequences automatically?
1225    
1226        my $chk_which = defined( $cgi->param('chk_which') ) ? $cgi->param('chk_which')  : 'none';
1227    
1228        #  Use $cgi->param('more similarities') to drive increase in maxN and max_expand
1229    
1230        if ( $cgi->param('more similarities') ) {
1231            $maxN       *= 2;
1232            $max_expand *= 2;
1233            $cgi->delete('more similarities');
1234        }
1235    
1236        #  Act on request for more or fewer sim options
1237    
1238        if ( $cgi->param('more sim options') ) {
1239            $extra_opt = 1;
1240            $cgi->delete('more sim options');
1241        }
1242        if ( $cgi->param('fewer sim options') ) {
1243            $extra_opt = 0;
1244            $cgi->delete('fewer sim options');
1245        }
1246    
1247        #  We have processed all options.  Use them to build forms.
1248    
1249        #  Sanity checks on fixed vocabulary parameter values:
1250    
1251        $sim_meas  = 'id'   unless $sim_meas   eq 'pos' || $sim_meas  eq 'bpp';
1252        $chk_which = 'none' unless $chk_which  eq 'all' || $chk_which eq 'rep';
1253    
1254        #  Checkmarks for input tags
1255    
1256        my $chk_just_fig   = chked_if( $just_fig );
1257        my $chk_show_env   = chked_if( $show_env );
1258        my $chk_hide_alias = chked_if( $hide_alias );
1259    
1260        #  Features unique to the long form:
1261    
1262        if ( $short_form )
1263        {
1264            #  Use a here document to push the short version of the similarities form
1265            #  on @$html (many values are passed as hidden inputs).
1266    
1267            push @$html, <<"End_Short_Form";
1268    
1269    <FORM Action=\"protein.cgi#Similarities\">
1270        <input type=hidden name=prot      value=\"$peg\">
1271        <input type=hidden name=sims      value=1>
1272        <input type=hidden name=fid       value=\"$peg\">
1273        <input type=hidden name=user      value=\"$user\">
1274        <input type=hidden name=translate value=$trans_role>
1275    
1276        <input type=submit name=Similarities value=Similarities>
1277        Max sims:<input type=text name=maxN size=5 value=$maxN>
1278        Max expand:<input type=text name=max_expand size=5 value=$max_expand>
1279        Max E-val:<input type=text name=maxP size=8 value=$maxP>
1280        Just FIG IDs:<input type=checkbox name=just_fig value=1 $chk_just_fig>
1281        Show Env. samples:<input type=checkbox name=show_env value=1 $chk_show_env>
1282        Hide aliases:<input type=checkbox name=hide_alias value=1 $chk_hide_alias><br />
1283    </FORM>
1284    End_Short_Form
1285    
1286        }
1287        else
1288        {
1289            #  Navigation buttons
1290    
1291            my ( $prev_peg_btn, $next_peg_btn ) = ( "", "" );
1292            my ( $prefix, $protnum ) = $peg =~ /^(.*\.)(\d+)$/;
1293            if ( $prefix && $protnum ) {
1294                if ( ( $protnum > 1 ) && &translatable( $fig_or_sprout, $prefix . ($protnum-1) ) )
1295                {
1296                    $prev_peg_btn = $cgi->submit('previous PEG');
1297                }
1298                if ( &translatable( $fig_or_sprout, $prefix . ($protnum+1) ) )
1299                {
1300                    $next_peg_btn = $cgi->submit('next PEG');
1301                }
1302            }
1303    
1304            #  Add/remove extra options button
1305    
1306            my $extra_opt_btn = $extra_opt ? $cgi->submit('fewer sim options')
1307                                           : $cgi->submit('more sim options');
1308    
1309            #  Checkmarks for input tags
1310    
1311            my $chk_sim_meas_id  = select_if( $sim_meas eq 'id' );
1312            my $chk_sim_meas_pos = select_if( $sim_meas eq 'pos' );
1313            my $chk_sim_meas_bpp = select_if( $sim_meas eq 'bpp' );
1314            my $chk_show_rep     = chked_if( $show_rep );
1315            my $chk_dyn_thrsh    = chked_if( $dyn_thrsh );
1316            my $chk_chk_none     = select_if( $chk_which eq 'none' );
1317            my $chk_chk_all      = select_if( $chk_which eq 'all' );
1318            my $chk_chk_rep      = select_if( $chk_which eq 'rep' );
1319    
1320            #  Default options
1321    
1322            push @$html, <<"End_Default_Options";
1323    <FORM Action=\"protein.cgi#Similarities\">
1324        <input type=hidden name=prot      value=\"$peg\">
1325        <input type=hidden name=sims      value=1>
1326        <input type=hidden name=fid       value=\"$peg\">
1327        <input type=hidden name=user      value=\"$user\">
1328        <input type=hidden name=translate value=$trans_role>
1329    
1330        Max sims:<input type=text name=maxN size=5 value=$maxN>
1331        Max expand:<input type=text name=max_expand size=5 value=$max_expand>
1332        Max E-val:<input type=text name=maxP size=8 value=$maxP>
1333        Just FIG IDs:<input type=checkbox name=just_fig value=1 $chk_just_fig>
1334        Show Env. samples:<input type=checkbox name=show_env value=1 $chk_show_env>
1335        Hide aliases:<input type=checkbox name=hide_alias value=1 $chk_hide_alias><br />
1336    End_Default_Options
1337    
1338            #  Extra options
1339    
1340            push @$html, <<"End_Extra_Options" if $extra_opt;
1341        Min similarity:<input type=text name=min_sim size=5 value=$min_sim>
1342        As defined by
1343        <select name=sim_meas>
1344            <option value=id  $chk_sim_meas_id>identities</option>
1345            <option value=pos $chk_sim_meas_pos>\"positives\"</option>
1346            <option value=bpp $chk_sim_meas_bpp>bit score per position</option>
1347        </select>
1348        Min query coverage:<input type=text name=min_q_cov size=5 value=$min_q_cov>
1349        Min subject coverage:<input type=text name=min_s_cov size=5 value=$min_s_cov>
1350    
1351        <TABLE Cols=2>
1352            <TR>
1353                <TD Valign=top><input type=checkbox name=show_rep $chk_show_rep></TD>
1354                <TD> Show only representative sequences whose similarities to one another
1355                    are less than <input type=text size=5 name=max_sim value=$max_sim>
1356                    <br />
1357                    <input type=checkbox name=dyn_thrsh value=1 $chk_dyn_thrsh> But keep sequences
1358                    that are at least <input type=text size=5 name=save_dist value=$save_dist>
1359                    times as distant from one another as from the query</TD>
1360            </TR>
1361        </TABLE>
1362    
1363        Automatically Select (check) which sequences:<select name=chk_which>
1364            <option value=none $chk_chk_none>none</option>
1365            <option value=all  $chk_chk_all>all shown</option>
1366            <option value=rep  $chk_chk_rep>representative set</option>
1367        </select><br />
1368    End_Extra_Options
1369    
1370            #  Submit buttons
1371    
1372            push @$html, <<"End_of_Buttons";
1373        <input type=submit name='resubmit' value='resubmit'>
1374        <input type=submit name='more similarities' value='more similarities'>
1375        $prev_peg_btn
1376        $next_peg_btn
1377        <!-- $extra_opt_btn -->
1378    </FORM>
1379    End_of_Buttons
1380    
1381        }
1382    
1383        #  Return the current parameter values in a hash
1384    
1385        { maxN          => $maxN,
1386          maxP          => $maxP,
1387          max_expand    => $max_expand,
1388          just_fig      => $just_fig,
1389          show_env      => $show_env,
1390          hide_alias    => $hide_alias,
1391          trans_role    => $trans_role,
1392          extra_opt     => $extra_opt,
1393          min_sim       => $min_sim,
1394          min_q_cov     => $min_q_cov,
1395          min_s_cov     => $min_s_cov,
1396          sim_meas      => $sim_meas,
1397          show_rep      => $show_rep,
1398          max_sim       => $max_sim,
1399          dyn_thrsh     => $dyn_thrsh,
1400          save_dist     => $save_dist,
1401          chk_which     => $chk_which,
1402          expand_groups => $expand_groups
1403        }
1404    }
1405    
1406    
1407    #------------------------------------------------------------------------
1408    #  Auxilliary function to acivate checkmark for input fields
1409    #------------------------------------------------------------------------
1410    sub chked_if { $_[0] ? 'checked ' : '' }
1411    
1412    sub select_if { $_[0] ? 'selected ' : '' }
1413    
1414    
1415    
1416  ################# Context on the Chromosome ############################  ################# Context on the Chromosome ############################
1417    
1418  sub print_context {  sub print_context {

Legend:
Removed from v.1.75  
changed lines
  Added in v.1.76

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3