[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.3, Tue Nov 28 21:38:48 2006 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 ("listOfPeg");
20    my $purpose = $cgi->param ("purpose");
21    my $purpose_peg = $cgi->param ("purpose_peg");
22  my $name  = $cgi->param ("master");  my $name  = $cgi->param ("master");
23  my $server_name = $ENV{'SERVER_NAME'};  my $server_name = $ENV{'SERVER_NAME'};
24  my %pmid2title = ();  my %pmid_to_peg = ();
25  my %att_pmid_anno = ();  my %uniq_pegs = ();
 my %att_pmid_status = ();  
   
26  my $add_pmid = $cgi->param ("PMID");  my $add_pmid = $cgi->param ("PMID");
27  my $add_date = $cgi->param ("date");  my @pmid_array = split(/\s/, $add_pmid);
 my $add_title = $cgi->param ("title");  
 my $add_url = $cgi->param ("url");  
28    
29  #Only allow the user to add to attributes if the user specify his/her name  #Check to see if the user specify his/her name. If not, then the page exits
30  if (($name eq "Name") || ($name eq "")) {  if (($name eq "Name") || ($name eq "")) {
31    
32          print "You must specify your name. <p>";          print "You must specify your name. <p>";
# Line 34  Line 35 
35  }  }
36    
37    
 if ($add_pmid ne "") {  
         $fig->add_attribute($peg, "JOURNAL_CURATED_BY_$name", "$add_pmid, $add_title", $add_url);  
         print "Added to attributes as JOURNAL_CURATED_BY_$name, $add_pmid, $add_title<p>";  
 }  
   
38    
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    }
46    
47    #print "!!! $curated_journals <p>";
48  my @curated = split(/\;/, $curated_journals);  my @curated = split(/\;/, $curated_journals);
49  my @journal_title = split(/\;/, $all_journals);  foreach(@pmid_array) {
50            next if /\D+/;
51  #print "@curated<p>";          #print "pushing $_";
52  my @attributes = $fig->get_attributes($peg);          push(@curated, "PUBMED_CURATED_RELEVANT|$_");
53            if($purpose eq 'peg') {
54  #Get what has been curated alreay. So we don't duplicate work.            $pmid_to_peg{$_} = $purpose_peg;
 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>";  
   
                 #my $attribute_key = "$attribute_pmid"."_"."$curation_name";  
   
                 $att_pmid_anno{$attribute_pmid} = $curation_name;  
                 my $key_no_name = $key;  
                 $key_no_name =~ s/(_BY_.*)//;  
                 $att_pmid_status{$attribute_pmid} = $key_no_name;  
                 #print "This line $key $attribute_pmid $key_no_name<p>";  
55          }          }
56  }  }
57    
58    
59  # Put in values as id to journal title  foreach (@curated) {
60  foreach (@journal_title) {          my ($key, $pmid_curator) = split(/\|/, $_);
61          my ($id, $title) = split(/\|/,$_);          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    
66            next if ($key eq "PUBMED_NOT_CURATED");
67    
68          $id =~ s/\(.*\)//;          my $curated_pegs = $pmid_to_peg{$pmid};
69          $pmid2title{$id} = $title;          my @pegs_array = split(/\s/,$curated_pegs);
70    
71            #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  foreach (@curated) {                          #print "$pmid is $peg_curator vs $name";
         my ($key, $pmid) = split(/\|/, $_);  
         $pmid =~ s/\(.*//;  
         my $value = "$pmid,$pmid2title{$pmid}";  
         #print "Add to attributes as Key:$key Value:$value<p>";  
94    
95          #print "-------------------------------<p>";                          if(($peg_curator ne $name) && ($peg_key ne $key) && ($pmid eq $peg_pmid)){
96          #print "-->$pmid<-- $att_pmid_anno{$pmid} versus $name, key is $key<p>";                                  #print "Delete old one $pmid to be new curator $name<p>";
97          #print "$att_pmid_status{$pmid} key is: $key<p>";                                  $fig->delete_attribute($thepeg,$peg_key,$peg_value,$peg_url);
98          if (($att_pmid_status{$pmid} ne $key) && ($att_pmid_anno{$pmid} ne $name)                                  $fig->add_attribute($thepeg,$key,"$name,$pmid,$curated_title",$curated_url);
99                  && ($key !~ /\_NOT\_/)){                          }
100                            elsif(($peg_key ne $key) && ($pmid eq $peg_pmid)) {
101                  $key = $key."_BY_$name";                                  #print "Delete $peg_pmid as $peg_key<p>";
102                  my $url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=".$pmid;                                  #print "Now $peg is $key and url is $peg_url<p>";
103                  print "Added to attributes as Key:$key Value:$value<p>";                                  $fig->delete_attribute($thepeg,$peg_key,$peg_value,$peg_url);
104                  #print "DONE -------------- <p>";                                  $fig->add_attribute($thepeg,$key,"$name,$pmid,$curated_title",$curated_url);
105                  $fig->add_attribute($peg, $key, $value, $url);                          }
106    
107          }          }
108  }  }
109    
110  print "Please refresh protein page and press Attributes button to see the changes<p>";  }
111    
112    print "Refresh protein.cgi page and press the Attribute button to see the changes<p>";

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3