[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.5 - (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 : hwang 1.4 my $peg = $cgi->param ("purpose_peg");
20 : hwang 1.1 my $name = $cgi->param ("master");
21 :     my $server_name = $ENV{'SERVER_NAME'};
22 : hwang 1.4
23 :    
24 : hwang 1.1 my $add_pmid = $cgi->param ("PMID");
25 : hwang 1.4
26 : hwang 1.2 my @pmid_array = split(/\s/, $add_pmid);
27 : hwang 1.1
28 : hwang 1.2 #Check to see if the user specify his/her name. If not, then the page exits
29 : hwang 1.1 if (($name eq "Name") || ($name eq "")) {
30 :    
31 :     print "You must specify your name. <p>";
32 :     print "Press the back button <p>";
33 :     exit;
34 :     }
35 : hwang 1.5 #print "$peg<p>";
36 : hwang 1.4 #print $curated_journals;
37 :    
38 :     my @pubmed_r_attributes = $fig->get_attributes($peg, "PUBMED_CURATED_RELEVANT");
39 :     my %pmid2whom=();
40 :     my %pmid2key=();
41 :     my %pmid2value =();
42 :    
43 :     foreach (@pubmed_r_attributes) {
44 :     my @att_line = @{$_};
45 :     my ($peg, $att_key, $value, $url) = @att_line;
46 :     my ($who_curated, $pmid, undef) = split(/\,/, $value);
47 :     $pmid2whom{$pmid} = $who_curated;
48 :     $pmid2key{$pmid} = $att_key;
49 :     $pmid2value{$pmid} = $value;
50 :     }
51 : hwang 1.1
52 : hwang 1.4 my @pubmed_nr_attributes = $fig->get_attributes($peg, "PUBMED_CURATED_NOTRELEVANT");
53 :     my %hash_nr=();
54 :     foreach (@pubmed_nr_attributes) {
55 :     my @att_line = @{$_};
56 :     my ($peg, $att_key, $value, $url) = @att_line;
57 :     my ($who_curated, $pmid, undef) = split(/\,/, $value);
58 :     $pmid2whom{$pmid} = $who_curated;
59 :     $pmid2key{$pmid} = $att_key;
60 :     $pmid2value{$pmid} = $value;
61 :     }
62 : hwang 1.1
63 : hwang 1.4 #Begin adding attributes that the curator specified
64 :     if (($add_pmid ne "") && ($add_pmid =~ /^\d+/)) {
65 : hwang 1.1
66 : hwang 1.4 foreach my $to_add (@pmid_array) {
67 :     #Check to see if the pmid is already in the attributes for this peg
68 :     #If it is then we exit
69 :     next if ($to_add =~ /PMID/);
70 : hwang 1.5 #print "ADD PMID is $to_add<p>";
71 : hwang 1.4
72 :     if( $pmid2key{$to_add} ne "") {
73 :     print "PMID:$to_add is already in the attribute database<p>";
74 :    
75 :     }
76 :     else {
77 :     my $add_title = &FigWebServices::SeedComponents::PubMed::pmid_to_title($to_add);
78 :     my $add_url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$to_add";
79 :     $fig->add_attribute($peg, "PUBMED_CURATED_RELEVANT", "$name,$to_add,$add_title", $add_url);
80 : hwang 1.5 #print "Added to attributes as PUBMED_CURATED_RELEVANT, $name,$to_add, $add_title<p>";
81 : hwang 1.4 $pmid2whom{$to_add} = $name;
82 :     $pmid2key{$to_add} = "PUBMED_CURATED_RELEVANT";
83 :     }
84 : hwang 1.1 }
85 :     }
86 :    
87 : hwang 1.4 #Below conditions are for curated pubmed journals
88 :    
89 :     my @curated = split(/\;/, $curated_journals);
90 : hwang 1.1
91 : hwang 1.2 foreach (@curated) {
92 : hwang 1.4 my ($curated_key, $key_value) = split(/\|/, $_);
93 :     my $curated_pmid = $key_value;
94 :     $curated_pmid =~ s/\(.*\)//;
95 :    
96 :     #SKIP if the PMID's KEY is not curated
97 :     next if ($curated_key =~ /\_NOT\_/);
98 :     #print "curated/label key is $curated_key pmid is $curated_pmid<p>";
99 :    
100 :     my $value = &FigWebServices::SeedComponents::PubMed::pmid_to_title($curated_pmid);
101 :     my $base_url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=";
102 :     my $url = "$base_url.$curated_pmid";
103 :    
104 :     #If the pmid is not in the not/relevant hash, add it to the attribute. Also add it to the
105 :     #hash
106 :    
107 :     if (! $pmid2key{$curated_pmid})
108 :     {
109 : hwang 1.5 #print "Doesn't exist $pmid2key{$curated_pmid}";
110 : hwang 1.4 $fig->add_attribute($peg, $curated_key, "$name,$curated_pmid,$value", $url);
111 : hwang 1.5 #print "Doesn't exist - ADD $peg, $curated_key, $name,$curated_pmid, $value <p>";
112 : hwang 1.4 $pmid2whom{$curated_pmid} = $name;
113 :     $pmid2key{$curated_pmid} = $curated_key;
114 :    
115 :     last;
116 :     }
117 : hwang 1.2
118 : hwang 1.4 #If the keys are the same, but the person is different -
119 :     # delete the old attribute
120 :     if ( $curated_key ne $pmid2key{$curated_pmid}
121 :     ) {
122 :     my $delete_url = $url;
123 :     $fig->delete_attribute($peg,$pmid2key{$curated_pmid},$pmid2value{$curated_pmid},$delete_url);
124 :     $fig->add_attribute($peg,$curated_key,"$name,$curated_pmid,$value",$url);
125 :    
126 : hwang 1.5 #print "ADD $peg, $curated_key, $name,$curated_pmid, $value <p>";
127 :     #print "DELETE $pmid2key{$curated_pmid} $pmid2value{$curated_pmid}<p>";
128 : hwang 1.4 #Update the hash
129 :     $pmid2whom{$curated_pmid} = $name;
130 :     $pmid2key{$curated_pmid} = $curated_key;
131 :     }
132 :     }
133 : hwang 1.1
134 : hwang 1.4
135 : hwang 1.1
136 : hwang 1.4 print "Please refresh protein page and press Attributes button to see the changes<p>";
137 : hwang 1.1

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3