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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3