update empty fixture to something that is more up to date.
[sgn.git] / cgi-bin / phenome / locus_pub_rank.pl
blobfe88e53084e55cd5559cfef0fa76364b1dbdb630
1 #!/usr/bin/perl/
3 use strict;
4 use warnings;
6 use CXGN::Page;
7 use CXGN::Login;
8 use CXGN::Apache::Error;
9 use CXGN::DB::Connection;
10 use CXGN::Page::FormattingHelpers qw /info_section_html
11 tooltipped_text /;
13 use CXGN::Chado::Publication;
14 use CXGN::Phenome::Locus;
15 use CXGN::Phenome::Locus::LocusRanking;
17 my $page=CXGN::Page->new( "locus_pub_rank", "Naama");
19 my %args = $page->cgi_params(); #multi-valued parameters have values in a string, delimited by \0
20 my $locus_id= $args{locus_id};
21 my $dbh=CXGN::DB::Connection->new('phenome');
23 $page->jsan_use("CXGN.Phenome.Locus");
24 $page->jsan_use("Prototype");
27 my($person_id,$user_type)=CXGN::Login->new($dbh)->has_session();
29 my $locus=CXGN::Phenome::Locus->new($dbh,$locus_id);
30 my $locus_name=$locus->get_locus_name();
32 my @assoc_pubs= $locus->get_dbxrefs_by_type('literature');
33 $page->simple_header("Publication list for locus $locus_name", "Curator tool: Validate publications associated with locus <a href=locus_display.pl?locus_id=$locus_id target=blanc>$locus_name</a>");
35 my $locus_pub_ranks=$locus->get_locus_pub();
36 my $pubs="";
37 my ($val_pubs, $rej_pubs, $pending_pubs, $a_pubs)= ("" x 4);
39 my @pub;
41 foreach(sort { $locus_pub_ranks->{$b} <=> $locus_pub_ranks->{$a} } keys %$locus_pub_ranks ) {
42 #foreach ( keys %$locus_pub_ranks) {
43 my $publication=CXGN::Chado::Publication->new($dbh, $_);
44 my $pub_id = $publication->get_pub_id();
45 my $dbxref_id = $publication->get_dbxref_id_by_db('PMID');
46 my $title=$publication->get_title();
47 my $pyear=$publication->get_pyear();
48 my $series=$publication->get_series_name();
49 my $volume=$publication->get_volume();
50 my $issue=$publication->get_issue();
51 my $pages=$publication->get_pages();
52 my $abstract= $publication->get_abstract();
53 my $authors=$publication->get_authors_as_string();
54 my $locusRank = CXGN::Phenome::Locus::LocusRanking->new($dbh, $locus_id, $pub_id);
55 my $validated = $locusRank->get_validate() || "";
56 my $score = $locusRank->get_rank();
58 my $val_form= "<BR><BR>";
59 if ($user_type eq 'curator') {
60 $val_form= qq|
61 <div id='locusPubForm_$pub_id'>
62 <div id='pub_dbxref_id_$dbxref_id'>
63 <input type="hidden"
64 value=$dbxref_id
65 id="dbxref_id_$pub_id">
66 <select id="$dbxref_id" >
67 <option value="" selected></option>
68 <option value="no">no</option>
69 <option value="yes">yes</option>
70 <option value="maybe">maybe</option>
71 </select>
72 <input type="button"
73 id="associate_pub_button"
74 value="associate publication"
75 onclick="Locus.addLocusDbxref('$locus_id', '$dbxref_id');this.disabled=false;">
76 </div>
77 </div>
78 <BR>
81 my $associated= $publication->is_associated_publication('locus', $locus_id);
82 my $pub_link= tooltipped_text("$authors ($pyear)",$abstract) . qq| <a href="/publication/$pub_id/view">$title.</a> $series. $volume($issue):$pages <b> Match score = $score </b> | . $val_form;
83 if ($validated eq 'no') {
84 $rej_pubs .= $pub_link;
85 }elsif ($validated eq 'yes') {
86 $val_pubs .= $pub_link;
87 }elsif ($validated eq 'maybe') {
88 $pending_pubs .= $pub_link;
89 }elsif (!$associated) {
90 $pubs .= $pub_link;
91 }elsif ($associated) {
92 $a_pubs .=$pub_link;
93 print STDERR "$associated ! pub $pub_id associated with locus $locus_id\n"; }
97 print info_section_html(title => 'Suggested publication list',
98 contents => $pubs,
101 print info_section_html(title => 'Associated publications',
102 subtitle =>'(these publications are already linked with the locus, but were not validated by a curator)',
103 contents => $a_pubs,
106 print info_section_html(title => 'Validated publications',
107 contents => $val_pubs,
109 print info_section_html(title => 'Pending publications',
110 contents => $pending_pubs,
112 print info_section_html(title => 'Rejected publications',
113 contents => $rej_pubs,
117 $page->simple_footer();
119 print <<EOF;
120 <a href="javascript:window.close();">Close This Window</a>