<commit_before>#!/usr/bin/env perl

use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/../perl5", "$FindBin::Bin/../../perl5";

use Unison::WWW;
use Unison::WWW::Page;
use Unison::WWW::Table;

my $p = new Unison::WWW::Page;
my $u = $p->{unison};
my $v = $p->Vars();
$v->{params_id} = 15 unless defined $v->{params_id};
$p->ensure_required_params(qw(pseq_id params_id));
$p->add_footer_lines('$Id: pseq_paprospect2.pl,v 1.18 2004/06/25 00:20:14 rkh Exp $ ');


my $sql = sprintf(<<EOSQL,$v->{pseq_id},$v->{params_id});
select M.name as "model",A.start,A.stop,A.mstart,A.mstop,M.len,A.score,A.eval,M.acc
  from pahmm A join pmhmm M on A.pmodel_id=M.pmodel_id
  where pseq_id=%d and params_id=%d order by eval
EOSQL
my $ar = edit_rows( $u->selectall_arrayref($sql,undef) );
my @f = ('name', 'start-stop', 'mstart-mstop', '[]', 'score', 'eval');


my @ps = @{ $u->selectall_arrayref("select params_id,name from params where name~'^Pfam' order by name") };
my %ps = map { $_->[0] => "$_->[1] (set $_->[0])" } @ps;


print $p->render
  (
   "HMM alignments to Unison:$v->{pseq_id}",
   $p->best_annotation($v->{pseq_id}),

   '<!-- parameters -->',
   $p->start_form(-method=>'GET'),
   $p->hidden('pseq_id',$v->{pseq_id}),
   '<br>parameters: ', $p->popup_menu(-name => 'params_id',
									  -values => [map {$_->[0]} @ps],
									  -labels => \%ps,
									  -default => "$v->{params_id}"),
   $p->submit(-value=>'redisplay'),
   $p->end_form(), "\n",

   '<!-- results -->',
   (($#$ar==-1 and $v->{params_id}==15)
	? $p->warn("No alignments... consider selecting the Pfam_fs 12.0 parameter set and clicking redisplay.")
	: ''),

   $p->group("HMM alignments",
			 Unison::WWW::Table::render(\@f,$ar)),

   '<!-- sql -->',
   $p->sql($sql)
  );


sub edit_rows {
  my $ar = shift;
  foreach my $r (@$ar) {
	$r->[0] = sprintf('<a href="http://pfam.wustl.edu/cgi-bin/getdesc?acc=%s">%s</a>',
					   $r->[$#$r], $r->[0]);<commit_msg>* updated pfam link to use names instead of accessions<commit_after>#!/usr/bin/env perl

use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/../perl5", "$FindBin::Bin/../../perl5";

use Unison::WWW;
use Unison::WWW::Page;
use Unison::WWW::Table;

my $p = new Unison::WWW::Page;
my $u = $p->{unison};
my $v = $p->Vars();
$v->{params_id} = 15 unless defined $v->{params_id};
$p->ensure_required_params(qw(pseq_id params_id));
$p->add_footer_lines('$Id: pseq_pahmm.pl,v 1.7 2004/07/13 23:58:31 rkh Exp $ ');


my $sql = sprintf(<<EOSQL,$v->{pseq_id},$v->{params_id});
select M.name as "model",A.start,A.stop,A.mstart,A.mstop,M.len,A.score,A.eval,M.acc
  from pahmm A join pmhmm M on A.pmodel_id=M.pmodel_id
  where pseq_id=%d and params_id=%d order by eval
EOSQL
my $ar = edit_rows( $u->selectall_arrayref($sql,undef) );
my @f = ('name', 'start-stop', 'mstart-mstop', '[]', 'score', 'eval');


my @ps = @{ $u->selectall_arrayref("select params_id,name from params where name~'^Pfam' order by name") };
my %ps = map { $_->[0] => "$_->[1] (set $_->[0])" } @ps;


print $p->render
  (
   "HMM alignments to Unison:$v->{pseq_id}",
   $p->best_annotation($v->{pseq_id}),

   '<!-- parameters -->',
   $p->start_form(-method=>'GET'),
   $p->hidden('pseq_id',$v->{pseq_id}),
   '<br>parameters: ', $p->popup_menu(-name => 'params_id',
									  -values => [map {$_->[0]} @ps],
									  -labels => \%ps,
									  -default => "$v->{params_id}"),
   $p->submit(-value=>'redisplay'),
   $p->end_form(), "\n",

   '<!-- results -->',
   (($#$ar==-1 and $v->{params_id}==15)
	? $p->warn("No alignments... consider selecting the Pfam_fs 12.0 parameter set and clicking redisplay.")
	: ''),

   $p->group("HMM alignments",
			 Unison::WWW::Table::render(\@f,$ar)),

   '<!-- sql -->',
   $p->sql($sql)
  );


sub edit_rows {
  my $ar = shift;
  foreach my $r (@$ar) {
	#my ($acc) = $r->[$#$r] =~ m/^(PF\d+)/;
	#$r->[0] = sprintf('<a href="http://pfam.wustl.edu/cgi-bin/getdesc?acc=%s">%s</a>',
	#				   $acc, $r->[0]);
	$r->[0] = sprintf('<a href="http://pfam.wustl.edu/cgi-bin/getdesc?name=%s">%s</a>',
					   $r->[0], $r->[0]);
{'fraction_non_alphanumeric': 0.2622145838448318, 'fraction_numerical': 0.016940829855143627, 'mean_word_length': 3.7704918032786887, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 98, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '731958', 'n_tokens_mistral': 1854, 'n_tokens_neox': 1721, 'n_words': 325}