[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.1 - (download) (annotate)
Fri Sep 8 20:38:31 2006 UTC (13 years, 8 months ago) by hwang
Branch: MAIN
Gives information that an attribute have been added

#/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;

my $curated_journals = $cgi->param("listOfItems");
my $all_journals = $cgi->param("all_journals");
my $peg = $cgi->param ("peg");
my $name  = $cgi->param ("master");
my $server_name = $ENV{'SERVER_NAME'};
my %pmid2title = ();
my %att_pmid_anno = ();
my %att_pmid_status = ();

my $add_pmid = $cgi->param ("PMID");
my $add_date = $cgi->param ("date");
my $add_title = $cgi->param ("title");
my $add_url = $cgi->param ("url");

#Only allow the user to add to attributes if the user specify his/her name
if (($name eq "Name") || ($name eq "")) {

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


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>";
}



my @curated = split(/\;/, $curated_journals);
my @journal_title = split(/\;/, $all_journals);

#print "@curated<p>";
my @attributes = $fig->get_attributes($peg);

#Get what has been curated alreay. So we don't duplicate work.
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>";
	}
}


# Put in values as id to journal title
foreach (@journal_title) {
	my ($id, $title) = split(/\|/,$_);
 
	$id =~ s/\(.*\)//;
	$pmid2title{$id} = $title;
	
}


foreach (@curated) {
	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);		
	
	}
}

print "Please refresh protein page and press Attributes button to see the changes<p>";


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3