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

Diff of /FigWebServices/save_to_attributes.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Fri Sep 8 20:38:31 2006 UTC revision 1.5, Thu Jan 18 21:31:49 2007 UTC
# Line 11  Line 11 
11  print $cgi->header;  print $cgi->header;
12  my @params = $cgi->param;  my @params = $cgi->param;
13    
14    #curated_journals are journals decided to be relevant or notrelevant by the annotators
15    #all_journals are the original list of journals
16    
17  my $curated_journals = $cgi->param("listOfItems");  my $curated_journals = $cgi->param("listOfItems");
18  my $all_journals = $cgi->param("all_journals");  my $all_publications = $cgi->param("all_publications");
19  my $peg = $cgi->param ("peg");  my $peg = $cgi->param ("purpose_peg");
20  my $name  = $cgi->param ("master");  my $name  = $cgi->param ("master");
21  my $server_name = $ENV{'SERVER_NAME'};  my $server_name = $ENV{'SERVER_NAME'};
22  my %pmid2title = ();  
 my %att_pmid_anno = ();  
 my %att_pmid_status = ();  
23    
24  my $add_pmid = $cgi->param ("PMID");  my $add_pmid = $cgi->param ("PMID");
 my $add_date = $cgi->param ("date");  
 my $add_title = $cgi->param ("title");  
 my $add_url = $cgi->param ("url");  
25    
26  #Only allow the user to add to attributes if the user specify his/her name  my @pmid_array = split(/\s/, $add_pmid);
27    
28    #Check to see if the user specify his/her name. If not, then the page exits
29  if (($name eq "Name") || ($name eq "")) {  if (($name eq "Name") || ($name eq "")) {
30    
31          print "You must specify your name. <p>";          print "You must specify your name. <p>";
32          print "Press the back button <p>";          print "Press the back button <p>";
33          exit;          exit;
34  }  }
35    #print "$peg<p>";
36    #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  if ($add_pmid ne "") {  foreach (@pubmed_r_attributes) {
44          $fig->add_attribute($peg, "JOURNAL_CURATED_BY_$name", "$add_pmid, $add_title", $add_url);          my @att_line = @{$_};
45          print "Added to attributes as JOURNAL_CURATED_BY_$name, $add_pmid, $add_title<p>";          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    
52    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    
63    #Begin adding attributes that the curator specified
64    if (($add_pmid ne "") && ($add_pmid =~ /^\d+/)) {
65    
66  my @curated = split(/\;/, $curated_journals);          foreach my $to_add (@pmid_array) {
67  my @journal_title = split(/\;/, $all_journals);                  #Check to see if the pmid is already in the attributes for this peg
68                    #If it is then we exit
69  #print "@curated<p>";                  next if ($to_add =~ /PMID/);
70  my @attributes = $fig->get_attributes($peg);                  #print "ADD PMID is $to_add<p>";
   
 #Get what has been curated alreay. So we don't duplicate work.  
 foreach (@attributes) {  
         my @entry = @{$_};  
         my ($peg, $key, $value, $url) = @entry;  
         if ($key =~ m/CURATED/) {  
                 $key =~ m/(.*BY_)(.*)/;  
                 my $curation_name = $2;  
                 my ($attribute_pmid, @attribute_title) = split(/,/, $value);  
                 #print "-->$attribute_pmid<-->$curation_name<--<p>";  
71    
72                  #my $attribute_key = "$attribute_pmid"."_"."$curation_name";                  if( $pmid2key{$to_add} ne "") {
73                            print "PMID:$to_add is already in the attribute database<p>";
74    
75                  $att_pmid_anno{$attribute_pmid} = $curation_name;                  }
76                  my $key_no_name = $key;                  else {
77                  $key_no_name =~ s/(_BY_.*)//;                          my $add_title = &FigWebServices::SeedComponents::PubMed::pmid_to_title($to_add);
78                  $att_pmid_status{$attribute_pmid} = $key_no_name;                          my $add_url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$to_add";
79                  #print "This line $key $attribute_pmid $key_no_name<p>";                          $fig->add_attribute($peg, "PUBMED_CURATED_RELEVANT", "$name,$to_add,$add_title", $add_url);
80                            #print "Added to attributes as PUBMED_CURATED_RELEVANT, $name,$to_add, $add_title<p>";
81                            $pmid2whom{$to_add} = $name;
82                            $pmid2key{$to_add} = "PUBMED_CURATED_RELEVANT";
83          }          }
84  }  }
   
   
 # Put in values as id to journal title  
 foreach (@journal_title) {  
         my ($id, $title) = split(/\|/,$_);  
   
         $id =~ s/\(.*\)//;  
         $pmid2title{$id} = $title;  
   
85  }  }
86    
87    #Below conditions are for curated pubmed journals
88    
89  foreach (@curated) {  my @curated = split(/\;/, $curated_journals);
         my ($key, $pmid) = split(/\|/, $_);  
         $pmid =~ s/\(.*//;  
         my $value = "$pmid,$pmid2title{$pmid}";  
         #print "Add to attributes as Key:$key Value:$value<p>";  
   
         #print "-------------------------------<p>";  
         #print "-->$pmid<-- $att_pmid_anno{$pmid} versus $name, key is $key<p>";  
         #print "$att_pmid_status{$pmid} key is: $key<p>";  
         if (($att_pmid_status{$pmid} ne $key) && ($att_pmid_anno{$pmid} ne $name)  
                 && ($key !~ /\_NOT\_/)){  
   
                 $key = $key."_BY_$name";  
                 my $url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=".$pmid;  
                 print "Added to attributes as Key:$key Value:$value<p>";  
                 #print "DONE -------------- <p>";  
                 $fig->add_attribute($peg, $key, $value, $url);  
90    
91    foreach (@curated) {
92            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                    #print "Doesn't exist $pmid2key{$curated_pmid}";
110                    $fig->add_attribute($peg, $curated_key, "$name,$curated_pmid,$value", $url);
111                    #print "Doesn't exist - ADD $peg, $curated_key, $name,$curated_pmid, $value <p>";
112                    $pmid2whom{$curated_pmid} = $name;
113                    $pmid2key{$curated_pmid} = $curated_key;
114    
115            last;
116            }
117    
118            #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                    #print "ADD $peg, $curated_key, $name,$curated_pmid, $value <p>";
127                    #print "DELETE $pmid2key{$curated_pmid} $pmid2value{$curated_pmid}<p>";
128                    #Update the hash
129                    $pmid2whom{$curated_pmid} = $name;
130                    $pmid2key{$curated_pmid} = $curated_key;
131          }          }
132  }  }
133    
134    
135    
136  print "Please refresh protein page and press Attributes button to see the changes<p>";  print "Please refresh protein page and press Attributes button to see the changes<p>";
137    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3