[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.6 - (download) (annotate)
Tue Mar 20 18:15:29 2007 UTC (12 years, 7 months ago) by hwang
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, rast_rel_2008_06_18, myrast_rel40, rast_rel_2008_06_16, mgrast_dev_05262011, rast_rel_2008_12_18, mgrast_dev_04082011, rast_rel_2008_07_21, rast_rel_2010_0928, rast_2008_0924, mgrast_version_3_2, mgrast_dev_12152011, rast_rel_2008_04_23, mgrast_dev_06072011, rast_rel_2008_09_30, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, rast_rel_2011_0119, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, rast_rel_2008_10_09, mgrast_dev_04012011, rast_release_2008_09_29, mgrast_rel_2008_0806, mgrast_rel_2008_0923, mgrast_rel_2008_0919, rast_rel_2009_07_09, rast_rel_2010_0827, mgrast_rel_2008_1110, myrast_33, rast_rel_2011_0928, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, mgrast_dev_04052011, mgrast_dev_02222011, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, rast_rel_2008_08_07, HEAD
Changes since 1.5: +16 -5 lines
Add in routines that save the attributes to ROLE_FROM_PEG_CURATED_RELEVANT

#/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 ("purpose_peg");
my $name  = $cgi->param ("master");
my $role = $cgi->param("functional_role");
my $server_name = $ENV{'SERVER_NAME'};


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;
}
#print "$peg<p>";
#print $curated_journals;
 
my @pubmed_r_attributes = $fig->get_attributes($peg, "PUBMED_CURATED_RELEVANT");
my %pmid2whom=();
my %pmid2key=();
my %pmid2value =();

foreach (@pubmed_r_attributes) {
	my @att_line = @{$_};
	my ($peg, $att_key, $value, $url) = @att_line; 
	my ($who_curated, $pmid, undef)  = split(/\,/, $value);
	$pmid2whom{$pmid} = $who_curated;
	$pmid2key{$pmid} = $att_key;	
	$pmid2value{$pmid} = $value;
}

my @pubmed_nr_attributes = $fig->get_attributes($peg, "PUBMED_CURATED_NOTRELEVANT");
my %hash_nr=();
foreach (@pubmed_nr_attributes) {
	my @att_line = @{$_};
	my ($peg, $att_key, $value, $url) = @att_line; 
	my ($who_curated, $pmid, undef)  = split(/\,/, $value);
	$pmid2whom{$pmid} = $who_curated;
	$pmid2key{$pmid} = $att_key;
	$pmid2value{$pmid} = $value;
}

#Begin adding attributes that the curator specified
if (($add_pmid ne "") && ($add_pmid =~ /^\d+/)) {

	foreach my $to_add (@pmid_array) { 
		#Check to see if the pmid is already in the attributes for this peg
		#If it is then we exit
		next if ($to_add =~ /PMID/);
		#print "ADD PMID is $to_add<p>";
				
		if( $pmid2key{$to_add} ne "") {
			print "PMID:$to_add is already in the attribute database<p>";
		
		}
		else {
			my $add_title = &FigWebServices::SeedComponents::PubMed::pmid_to_title($to_add);
			my $add_url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$to_add";	
			$fig->add_attribute($peg, "PUBMED_CURATED_RELEVANT", "$name,$to_add,$add_title", $add_url);	

		        my $output_table = &FigWebServices::SeedComponents::PubMed::get_author_date_title($to_add); 
			my ($id, $author, $date, $title) = split(/\;/, $output_table);
			my $peg_relevant_value = "$author\;$date\;$title";
			$fig->add_attribute("Role:$role", "ROLE_FROM_PEG_RELEVANT",  "$to_add\;$name\;$peg_relevant_value");

        		#print "Added to attributes as PUBMED_CURATED_RELEVANT, $name,$to_add, $add_title<p>";
			$pmid2whom{$to_add} = $name;
			$pmid2key{$to_add} = "PUBMED_CURATED_RELEVANT";			
		}
	}
}

#Below conditions are for curated pubmed journals

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

foreach (@curated) {
	my ($curated_key, $key_value) = split(/\|/, $_);
	my $curated_pmid = $key_value;
	$curated_pmid =~ s/\(.*\)//;

	#SKIP if the PMID's KEY is not curated
	next if ($curated_key =~ /\_NOT\_/);
	#print "curated/label key is $curated_key pmid is $curated_pmid<p>";
	
	my $value = &FigWebServices::SeedComponents::PubMed::pmid_to_title($curated_pmid);
	my $base_url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=";
	my $url = "$base_url.$curated_pmid";

	#If the pmid is not in the not/relevant hash, add it to the attribute. Also add it to the 
	#hash

	if (! $pmid2key{$curated_pmid}) 
	{	
	        my $output_table = &FigWebServices::SeedComponents::PubMed::get_author_date_title($curated_pmid); 
		my ($id, $author, $date, $title) = split(/\;/, $output_table);
		my $peg_relevant_value = "$author\;$date\;$title";
		$fig->add_attribute($peg, $curated_key, "$name,$curated_pmid,$value", $url);		
		$fig->add_attribute("Role:$role", "ROLE_FROM_PEG_RELEVANT",  "$curated_pmid\;$name\;$peg_relevant_value");
		$pmid2whom{$curated_pmid} = $name;
		$pmid2key{$curated_pmid} = $curated_key;			

	last;
	}

	#If the keys are the same, but the person is different - 
	# delete the old attribute
	if ( $curated_key ne $pmid2key{$curated_pmid}
	)  {
		my $delete_url = $url;
		$fig->delete_matching_attributes($peg,$pmid2key{$curated_pmid},"$pmid2whom{$curated_pmid}%");
		$fig->add_attribute($peg,$curated_key,"$name,$curated_pmid,$value",$url);			
		
	        my $output_table = &FigWebServices::SeedComponents::PubMed::get_author_date_title($curated_pmid); 
		my ($id, $author, $date, $title) = split(/\;/, $output_table);
		my $peg_relevant_value = "$author\;$date\;$title";
		$fig->add_attribute("Role:$role", "ROLE_FROM_PEG_RELEVANT",  "$curated_pmid\;$name\;$peg_relevant_value");
		#Update the hash
		$pmid2whom{$curated_pmid} = $name;
		$pmid2key{$curated_pmid} = $curated_key;
		}
	}

	

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


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3