[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.6, Tue Mar 20 18:15:29 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 $role = $cgi->param("functional_role");
22  my $server_name = $ENV{'SERVER_NAME'};  my $server_name = $ENV{'SERVER_NAME'};
23  my %pmid2title = ();  
 my %att_pmid_anno = ();  
 my %att_pmid_status = ();  
24    
25  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");  
26    
27  #Only allow the user to add to attributes if the user specify his/her name  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
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>";
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  if ($add_pmid ne "") {  foreach (@pubmed_r_attributes) {
45          $fig->add_attribute($peg, "JOURNAL_CURATED_BY_$name", "$add_pmid, $add_title", $add_url);          my @att_line = @{$_};
46          print "Added to attributes as JOURNAL_CURATED_BY_$name, $add_pmid, $add_title<p>";          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 @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    
64    #Begin adding attributes that the curator specified
65    if (($add_pmid ne "") && ($add_pmid =~ /^\d+/)) {
66    
67  my @curated = split(/\;/, $curated_journals);          foreach my $to_add (@pmid_array) {
68  my @journal_title = split(/\;/, $all_journals);                  #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                    #print "ADD PMID is $to_add<p>";
72    
73  #print "@curated<p>";                  if( $pmid2key{$to_add} ne "") {
74  my @attributes = $fig->get_attributes($peg);                          print "PMID:$to_add is already in the attribute database<p>";
75    
76  #Get what has been curated alreay. So we don't duplicate work.                  }
77  foreach (@attributes) {                  else {
78          my @entry = @{$_};                          my $add_title = &FigWebServices::SeedComponents::PubMed::pmid_to_title($to_add);
79          my ($peg, $key, $value, $url) = @entry;                          my $add_url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$to_add";
80          if ($key =~ m/CURATED/) {                          $fig->add_attribute($peg, "PUBMED_CURATED_RELEVANT", "$name,$to_add,$add_title", $add_url);
                 $key =~ m/(.*BY_)(.*)/;  
                 my $curation_name = $2;  
                 my ($attribute_pmid, @attribute_title) = split(/,/, $value);  
                 #print "-->$attribute_pmid<-->$curation_name<--<p>";  
81    
82                  #my $attribute_key = "$attribute_pmid"."_"."$curation_name";                          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                  $att_pmid_anno{$attribute_pmid} = $curation_name;                          #print "Added to attributes as PUBMED_CURATED_RELEVANT, $name,$to_add, $add_title<p>";
88                  my $key_no_name = $key;                          $pmid2whom{$to_add} = $name;
89                  $key_no_name =~ s/(_BY_.*)//;                          $pmid2key{$to_add} = "PUBMED_CURATED_RELEVANT";
                 $att_pmid_status{$attribute_pmid} = $key_no_name;  
                 #print "This line $key $attribute_pmid $key_no_name<p>";  
90          }          }
91  }  }
   
   
 # Put in values as id to journal title  
 foreach (@journal_title) {  
         my ($id, $title) = split(/\|/,$_);  
   
         $id =~ s/\(.*\)//;  
         $pmid2title{$id} = $title;  
   
92  }  }
93    
94    #Below conditions are for curated pubmed journals
95    
96  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);  
97    
98    foreach (@curated) {
99            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                    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            last;
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    
146    
147  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>";
148    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3