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

Annotation of /FigWebServices/save_to_attributes.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download)

1 : hwang 1.1
2 :     #/usr/bin/perl
3 :     use FIG;
4 :     use strict;
5 :     use CGI;
6 :     use FigWebServices::SeedComponents::PubMed;
7 :    
8 :     my $cgi = new CGI;
9 :     my $fig = new FIG;
10 :    
11 :     print $cgi->header;
12 :     my @params = $cgi->param;
13 :    
14 : hwang 1.2 #curated_journals are journals decided to be relevant or notrelevant by the annotators
15 :     #all_journals are the original list of journals
16 :    
17 : hwang 1.1 my $curated_journals = $cgi->param("listOfItems");
18 : hwang 1.2 my $all_publications = $cgi->param("all_publications");
19 :     my $peg = $cgi->param ("listOfPeg");
20 :     my $purpose = $cgi->param ("purpose");
21 :     my $purpose_peg = $cgi->param ("purpose_peg");
22 : hwang 1.1 my $name = $cgi->param ("master");
23 :     my $server_name = $ENV{'SERVER_NAME'};
24 : hwang 1.2 my %pmid_to_peg = ();
25 :     my %uniq_pegs = ();
26 : hwang 1.1 my $add_pmid = $cgi->param ("PMID");
27 : hwang 1.2 my @pmid_array = split(/\s/, $add_pmid);
28 : hwang 1.1
29 : hwang 1.2 #Check to see if the user specify his/her name. If not, then the page exits
30 : hwang 1.1 if (($name eq "Name") || ($name eq "")) {
31 :    
32 :     print "You must specify your name. <p>";
33 :     print "Press the back button <p>";
34 :     exit;
35 :     }
36 :    
37 :    
38 : hwang 1.2
39 :     my @pmid_pegs = split(/\;/,$peg);
40 :     foreach (@pmid_pegs){
41 :     my($pmid,$thepegs) = split(/-/,$_);
42 :     $pmid_to_peg{$pmid} = $thepegs;
43 :     $uniq_pegs{$pmid} = $pmid;
44 :     #print "$_<p>";
45 : hwang 1.1 }
46 :    
47 : hwang 1.2 #print "!!! $curated_journals <p>";
48 : hwang 1.1 my @curated = split(/\;/, $curated_journals);
49 : hwang 1.2 foreach(@pmid_array) {
50 :     next if /\D+/;
51 :     #print "pushing $_";
52 :     push(@curated, "PUBMED_CURATED_RELEVANT|$_");
53 :     if($purpose eq 'peg') {
54 :     $pmid_to_peg{$_} = $purpose_peg;
55 : hwang 1.1 }
56 :     }
57 :    
58 :    
59 : hwang 1.2 foreach (@curated) {
60 :     my ($key, $pmid_curator) = split(/\|/, $_);
61 :     my $pmid = $pmid_curator;
62 :     $pmid =~ s/\(.*//;
63 :     my $curated_title = &FigWebServices::SeedComponents::PubMed::pmid_to_title($pmid);
64 :     my $curated_url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$pmid";
65 : hwang 1.1
66 : hwang 1.2 next if ($key eq "PUBMED_NOT_CURATED");
67 :    
68 :     my $curated_pegs = $pmid_to_peg{$pmid};
69 :     my @pegs_array = split(/\s/,$curated_pegs);
70 : hwang 1.1
71 : hwang 1.2 #print "IN $key $pmid_curator<p>";
72 :     foreach my $thepeg (@pegs_array) {
73 :     print "$thepeg<p>";
74 :     my @line = $fig->get_attributes($thepeg, "PUBMED_CURATED%", "%$pmid%%");
75 :     #If there is no response back, then we can add the attribute
76 :     if (!@line) {
77 :     print "Adding new attribute for peg $thepeg, pmid $pmid<p>";
78 :     $fig->add_attribute($thepeg,$key,"$name,$pmid,$curated_title",$curated_url);
79 :     }
80 :     #If the author is different, but the pmid is the same - then
81 :     #delete the old one and add the new one
82 :     #If author is the same, key is different, pmid is the same - then
83 :     #delete the old one and add the new one
84 :    
85 :     foreach(@line) {
86 :     my @publication_list = @{$_};
87 :     my $peg = $publication_list[0];
88 :     my $peg_key = $publication_list[1];
89 :     my $peg_value =$publication_list[2];
90 :     my $peg_url =$publication_list[3];
91 :     my ($peg_curator,$peg_pmid,$peg_title) = split(/,/,$peg_value);
92 :    
93 :     #print "$pmid is $peg_curator vs $name";
94 :    
95 :     if(($peg_curator ne $name) && ($peg_key ne $key) && ($pmid eq $peg_pmid)){
96 :     #print "Delete old one $pmid to be new curator $name<p>";
97 :     $fig->delete_attribute($thepeg,$peg_key,$peg_value,$peg_url);
98 :     $fig->add_attribute($thepeg,$key,"$name,$pmid,$curated_title",$curated_url);
99 :     }
100 :     elsif(($peg_key ne $key) && ($pmid eq $peg_pmid)) {
101 :     #print "Delete $peg_pmid as $peg_key<p>";
102 :     #print "Now $peg is $key and url is $peg_url<p>";
103 :     $fig->delete_attribute($thepeg,$peg_key,$peg_value,$peg_url);
104 :     $fig->add_attribute($thepeg,$key,"$name,$pmid,$curated_title",$curated_url);
105 :     }
106 : hwang 1.1
107 : hwang 1.2 }
108 :     }
109 :    
110 : hwang 1.1 }
111 :    
112 : hwang 1.2 print "Refresh protein.cgi page and press the Attribute button to see the changes<p>";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3