[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.2, Tue Nov 28 20:11:41 2006 UTC revision 1.5, Thu Jan 18 21:31:49 2007 UTC
# Line 16  Line 16 
16    
17  my $curated_journals = $cgi->param("listOfItems");  my $curated_journals = $cgi->param("listOfItems");
18  my $all_publications = $cgi->param("all_publications");  my $all_publications = $cgi->param("all_publications");
19  my $peg = $cgi->param ("listOfPeg");  my $peg = $cgi->param ("purpose_peg");
 my $purpose = $cgi->param ("purpose");  
 my $purpose_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 %pmid_to_peg = ();  
23  my %uniq_pegs = ();  
24  my $add_pmid = $cgi->param ("PMID");  my $add_pmid = $cgi->param ("PMID");
25    
26  my @pmid_array = split(/\s/, $add_pmid);  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  #Check to see if the user specify his/her name. If not, then the page exits
# Line 33  Line 32 
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    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    
52  my @pmid_pegs = split(/\;/,$peg);  my @pubmed_nr_attributes = $fig->get_attributes($peg, "PUBMED_CURATED_NOTRELEVANT");
53  foreach (@pmid_pegs){  my %hash_nr=();
54          my($pmid,$thepegs) = split(/-/,$_);  foreach (@pubmed_nr_attributes) {
55          $pmid_to_peg{$pmid} = $thepegs;          my @att_line = @{$_};
56          $uniq_pegs{$pmid} = $pmid;          my ($peg, $att_key, $value, $url) = @att_line;
57          #print "$_<p>";          my ($who_curated, $pmid, undef)  = split(/\,/, $value);
58            $pmid2whom{$pmid} = $who_curated;
59            $pmid2key{$pmid} = $att_key;
60            $pmid2value{$pmid} = $value;
61  }  }
62    
63  #print "!!! $curated_journals <p>";  #Begin adding attributes that the curator specified
64  my @curated = split(/\;/, $curated_journals);  if (($add_pmid ne "") && ($add_pmid =~ /^\d+/)) {
65  foreach(@pmid_array) {  
66          next if /\D+/;          foreach my $to_add (@pmid_array) {
67          #print "pushing $_";                  #Check to see if the pmid is already in the attributes for this peg
68          push(@curated, "PUBMED_CURATED_RELEVANT|$_");                  #If it is then we exit
69          if($purpose eq 'peg') {                  next if ($to_add =~ /PMID/);
70            $pmid_to_peg{$_} = $purpose_peg;                  #print "ADD PMID is $to_add<p>";
71    
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                            #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          }          }
85  }  }
86    
87    #Below conditions are for curated pubmed journals
88    
89    my @curated = split(/\;/, $curated_journals);
90    
91  foreach (@curated) {  foreach (@curated) {
92          my ($key, $pmid_curator) = split(/\|/, $_);          my ($curated_key, $key_value) = split(/\|/, $_);
93          my $pmid = $pmid_curator;          my $curated_pmid = $key_value;
94          $pmid =~ s/\(.*//;          $curated_pmid =~ s/\(.*\)//;
         my $curated_title = &FigWebServices::SeedComponents::PubMed::pmid_to_title($pmid);  
         my $curated_url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$pmid";  
95    
96          next if ($key eq "PUBMED_NOT_CURATED");          #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 $curated_pegs = $pmid_to_peg{$pmid};          my $value = &FigWebServices::SeedComponents::PubMed::pmid_to_title($curated_pmid);
101          my @pegs_array = split(/\s/,$curated_pegs);          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          #print "IN $key $pmid_curator<p>";          #If the pmid is not in the not/relevant hash, add it to the attribute. Also add it to the
105          foreach my $thepeg (@pegs_array) {          #hash
                 print "$thepeg<p>";  
                 my @line = $fig->get_attributes($thepeg, "PUBMED_CURATED%", "%$pmid%%");  
                 #If there is no response back, then we can add the attribute  
                 if (!@line) {  
                 print "Adding new attribute for peg $thepeg, pmid $pmid<p>";  
                         $fig->add_attribute($thepeg,$key,"$name,$pmid,$curated_title",$curated_url);  
                 }  
                 #If the author is different, but the pmid is the same - then  
                 #delete the old one and add the new one  
                 #If author is the same, key is different, pmid is the same - then  
                 #delete the old one and add the new one  
106    
107                  foreach(@line) {          if (! $pmid2key{$curated_pmid})
108                      my @publication_list = @{$_};          {
109                      my $peg = $publication_list[0];                  #print "Doesn't exist $pmid2key{$curated_pmid}";
110                      my $peg_key = $publication_list[1];                  $fig->add_attribute($peg, $curated_key, "$name,$curated_pmid,$value", $url);
111                      my $peg_value =$publication_list[2];                  #print "Doesn't exist - ADD $peg, $curated_key, $name,$curated_pmid, $value <p>";
112                      my $peg_url =$publication_list[3];                  $pmid2whom{$curated_pmid} = $name;
113                      my ($peg_curator,$peg_pmid,$peg_title) = split(/,/,$peg_value);                  $pmid2key{$curated_pmid} = $curated_key;
114    
115                          #print "$pmid is $peg_curator vs $name";          last;
   
                         if(($peg_curator ne $name) && ($peg_key ne $key) && ($pmid eq $peg_pmid)){  
                                 #print "Delete old one $pmid to be new curator $name<p>";  
                                 $fig->delete_attribute($thepeg,$peg_key,$peg_value,$peg_url);  
                                 $fig->add_attribute($thepeg,$key,"$name,$pmid,$curated_title",$curated_url);  
                         }  
                         elsif(($peg_key ne $key) && ($pmid eq $peg_pmid)) {  
                                 #print "Delete $peg_pmid as $peg_key<p>";  
                                 #print "Now $peg is $key and url is $peg_url<p>";  
                                 $fig->delete_attribute($thepeg,$peg_key,$peg_value,$peg_url);  
                                 $fig->add_attribute($thepeg,$key,"$name,$pmid,$curated_title",$curated_url);  
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    
 print "Refresh protein.cgi page and press the Attribute button to see the changes<p>";  
135    
136    print "Please refresh protein page and press Attributes button to see the changes<p>";
137    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3