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

View of /FigWebServices/save_to_attributes.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Tue Nov 28 20:11:41 2006 UTC (13 years, 6 months ago) by hwang
Branch: MAIN
Changes since 1.1: +74 -65 lines
Changed curation of attributes since there is now an attribute server.
Changed code to allow functional roles to access attributes

#/usr/bin/perl
use FIG;
use strict;
use CGI;
use FigWebServices::SeedComponents::PubMed;

my $cgi =  new CGI;
my $fig =  new FIG;

print $cgi->header;
my @params = $cgi->param;

#curated_journals are journals decided to be relevant or notrelevant by the annotators
#all_journals are the original list of journals

my $curated_journals = $cgi->param("listOfItems");
my $all_publications = $cgi->param("all_publications");
my $peg = $cgi->param ("listOfPeg");
my $purpose = $cgi->param ("purpose");
my $purpose_peg = $cgi->param ("purpose_peg");
my $name  = $cgi->param ("master");
my $server_name = $ENV{'SERVER_NAME'};
my %pmid_to_peg = ();
my %uniq_pegs = ();
my $add_pmid = $cgi->param ("PMID");
my @pmid_array = split(/\s/, $add_pmid);

#Check to see if the user specify his/her name. If not, then the page exits 
if (($name eq "Name") || ($name eq "")) {

	print "You must specify your name. <p>";
	print "Press the back button <p>";
	exit;
}


	
my @pmid_pegs = split(/\;/,$peg);
foreach (@pmid_pegs){
	my($pmid,$thepegs) = split(/-/,$_);
	$pmid_to_peg{$pmid} = $thepegs;
	$uniq_pegs{$pmid} = $pmid;
	#print "$_<p>";
}

#print "!!! $curated_journals <p>";
my @curated = split(/\;/, $curated_journals);
foreach(@pmid_array) {
	next if /\D+/;
	#print "pushing $_";
	push(@curated, "PUBMED_CURATED_RELEVANT|$_");
	if($purpose eq 'peg') {
	  $pmid_to_peg{$_} = $purpose_peg;
	}
}


foreach (@curated) {
	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";	
 
	next if ($key eq "PUBMED_NOT_CURATED");

	my $curated_pegs = $pmid_to_peg{$pmid};	
	my @pegs_array = split(/\s/,$curated_pegs);

	#print "IN $key $pmid_curator<p>";
	foreach my $thepeg (@pegs_array) {
		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	

		foreach(@line) {
		    my @publication_list = @{$_};
		    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);			
			
			#print "$pmid is $peg_curator vs $name";
			
			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);		
			}

		}
    	}
		
}

print "Refresh protein.cgi page and press the Attribute button to see the changes<p>";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3