[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.3, Tue Nov 28 21:38:48 2006 UTC revision 1.6, Tue Mar 20 18:15:29 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 $role = $cgi->param("functional_role");
22  my $server_name = $ENV{'SERVER_NAME'};  my $server_name = $ENV{'SERVER_NAME'};
23  my %pmid_to_peg = ();  
24  my %uniq_pegs = ();  
25  my $add_pmid = $cgi->param ("PMID");  my $add_pmid = $cgi->param ("PMID");
26    
27  my @pmid_array = split(/\s/, $add_pmid);  my @pmid_array = split(/\s/, $add_pmid);
28    
29  #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 33 
33          print "Press the back button <p>";          print "Press the back button <p>";
34          exit;          exit;
35  }  }
36    #print "$peg<p>";
37    #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    
53  my @pmid_pegs = split(/\;/,$peg);  my @pubmed_nr_attributes = $fig->get_attributes($peg, "PUBMED_CURATED_NOTRELEVANT");
54  foreach (@pmid_pegs){  my %hash_nr=();
55          my($pmid,$thepegs) = split(/-/,$_);  foreach (@pubmed_nr_attributes) {
56          $pmid_to_peg{$pmid} = $thepegs;          my @att_line = @{$_};
57          $uniq_pegs{$pmid} = $pmid;          my ($peg, $att_key, $value, $url) = @att_line;
58          #print "$_<p>";          my ($who_curated, $pmid, undef)  = split(/\,/, $value);
59            $pmid2whom{$pmid} = $who_curated;
60            $pmid2key{$pmid} = $att_key;
61            $pmid2value{$pmid} = $value;
62  }  }
63    
64  #print "!!! $curated_journals <p>";  #Begin adding attributes that the curator specified
65  my @curated = split(/\;/, $curated_journals);  if (($add_pmid ne "") && ($add_pmid =~ /^\d+/)) {
66  foreach(@pmid_array) {  
67          next if /\D+/;          foreach my $to_add (@pmid_array) {
68          #print "pushing $_";                  #Check to see if the pmid is already in the attributes for this peg
69          push(@curated, "PUBMED_CURATED_RELEVANT|$_");                  #If it is then we exit
70          if($purpose eq 'peg') {                  next if ($to_add =~ /PMID/);
71            $pmid_to_peg{$_} = $purpose_peg;                  #print "ADD PMID is $to_add<p>";
72    
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    
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                            #print "Added to attributes as PUBMED_CURATED_RELEVANT, $name,$to_add, $add_title<p>";
88                            $pmid2whom{$to_add} = $name;
89                            $pmid2key{$to_add} = "PUBMED_CURATED_RELEVANT";
90                    }
91          }          }
92  }  }
93    
94    #Below conditions are for curated pubmed journals
95    
96  foreach (@curated) {  my @curated = split(/\;/, $curated_journals);
         my ($key, $pmid_curator) = split(/\|/, $_);  
         my $pmid = $pmid_curator;  
         $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";  
97    
98          next if ($key eq "PUBMED_NOT_CURATED");  foreach (@curated) {
99            my ($curated_key, $key_value) = split(/\|/, $_);
100            my $curated_pmid = $key_value;
101            $curated_pmid =~ s/\(.*\)//;
102    
103          my $curated_pegs = $pmid_to_peg{$pmid};          #SKIP if the PMID's KEY is not curated
104          my @pegs_array = split(/\s/,$curated_pegs);          next if ($curated_key =~ /\_NOT\_/);
105            #print "curated/label key is $curated_key pmid is $curated_pmid<p>";
106    
107          #print "IN $key $pmid_curator<p>";          my $value = &FigWebServices::SeedComponents::PubMed::pmid_to_title($curated_pmid);
108          foreach my $thepeg (@pegs_array) {          my $base_url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=";
109                  #print "$thepeg<p>";          my $url = "$base_url.$curated_pmid";
                 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  
110    
111                  foreach(@line) {          #If the pmid is not in the not/relevant hash, add it to the attribute. Also add it to the
112                      my @publication_list = @{$_};          #hash
                     my $peg = $publication_list[0];  
                     my $peg_key = $publication_list[1];  
                     my $peg_value =$publication_list[2];  
                     my $peg_url =$publication_list[3];  
                     my ($peg_curator,$peg_pmid,$peg_title) = split(/,/,$peg_value);  
113    
114                          #print "$pmid is $peg_curator vs $name";          if (! $pmid2key{$curated_pmid})
115            {
116                    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                    $fig->add_attribute($peg, $curated_key, "$name,$curated_pmid,$value", $url);
120                    $fig->add_attribute("Role:$role", "ROLE_FROM_PEG_RELEVANT",  "$curated_pmid\;$name\;$peg_relevant_value");
121                    $pmid2whom{$curated_pmid} = $name;
122                    $pmid2key{$curated_pmid} = $curated_key;
123    
124                          if(($peg_curator ne $name) && ($peg_key ne $key) && ($pmid eq $peg_pmid)){          last;
                                 #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);  
125                          }                          }
126    
127            #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                    $fig->delete_matching_attributes($peg,$pmid2key{$curated_pmid},"$pmid2whom{$curated_pmid}%");
133                    $fig->add_attribute($peg,$curated_key,"$name,$curated_pmid,$value",$url);
134    
135                    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                    #Update the hash
140                    $pmid2whom{$curated_pmid} = $name;
141                    $pmid2key{$curated_pmid} = $curated_key;
142                  }                  }
143          }          }
144    
 }  
145    
 print "Refresh protein.cgi page and press the Attribute button to see the changes<p>";  
146    
147    print "Please refresh protein page and press Attributes button to see the changes<p>";
148    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3