From 1632bc3efad51638f7cc65a2ac5a8589e65b1204 Mon Sep 17 00:00:00 2001 From: preecej Date: Wed, 6 Jul 2011 22:15:00 +0000 Subject: [PATCH] Changed name of import file from PS_* to paw_* svn path=/; revision=110 --- preecej/semantic_wiki/forms/Annotation.wiki | 40 +++--- ...ForImport.pl => paw_TransformForImport.pl} | 116 ++++++++++-------- .../semantic_wiki/templates/Annotation.wiki | 15 ++- 3 files changed, 98 insertions(+), 73 deletions(-) rename preecej/semantic_wiki/{PS_TransformForImport.pl => paw_TransformForImport.pl} (73%) diff --git a/preecej/semantic_wiki/forms/Annotation.wiki b/preecej/semantic_wiki/forms/Annotation.wiki index 464eb3a..012dc1b 100644 --- a/preecej/semantic_wiki/forms/Annotation.wiki +++ b/preecej/semantic_wiki/forms/Annotation.wiki @@ -17,9 +17,6 @@ __NOTOC__ {{{for template|Annotation}}} {| class="formtable" -! Accession ID: -| {{{field|Accession ID}}} -|- ! Species Name: | {{{field|Species Name}}} |- @@ -27,21 +24,28 @@ __NOTOC__ | {{{field|Species ID}}} |- ! Gene Symbol: -| {{#if: - {{#ask:[[Category:Provenance]][[Is Associated With Annotation::~{{PAGENAME}}/Provenance]] +| {{#if: {{#ask: [[Is Provenance::~Annotation:1/Provenance*]] [[Is Associated With Field::Gene Symbol]] [[Is Associated With Template::Annotation]] - |?is_Provenance - }} - |{{{field|Gene Symbol|restricted}}} - |{{{field|Gene Symbol}}} - }} + |?has_Provenance + }} + |{{{field|Gene Symbol|restricted}}} + |{{{field|Gene Symbol}}} + }} |- ! Gene Name: | {{{field|Gene Name}}} |- ! Gene Synonyms: -| synonym code here... +| {{#if: {{#ask:[[Category:Gene_Synonyms]][[Is Associated With Annotation::{{PAGENAME}} ]] }} + | {{#ask:[[Is Gene Synonym Pair::~{{PAGENAME}}/Gene_Synonyms]] + | ?is_Gene_Synonym + | headers=hide + | mainlabel=- + | format=list + }} {{#formlink:form=Gene_Synonyms|link text=Edit|link type=button|target={{PAGENAME}}/Gene_Synonyms }} + | {{#formlink:form=Gene_Synonyms|link text=Add Synonyms|link type=button|query string=Gene_Synonyms[Annotation Page]={{PAGENAME}}&super_page={{PAGENAME}} }} +}} |- ! Gene Type: | {{{field|Gene Type}}} @@ -50,15 +54,14 @@ __NOTOC__ | {{{field|EC Numbers|list|delimiter=,}}} |- ! Chromosome: -| {{#if: - {{#ask:[[Category:Provenance]][[Is Associated With Annotation::~{{PAGENAME}}/Provenance]] +| {{#if: {{#ask: [[Is Provenance::~Annotation:1/Provenance*]] [[Is Associated With Field::Chromosome]] [[Is Associated With Template::Annotation]] - |?is_Provenance - }} - |{{{field|Chromosome|restricted}}} - |{{{field|Chromosome}}} - }} + |?has_Provenance + }} + |{{{field|Chromosome|restricted}}} + |{{{field|Chromosome}}} + }} |- ! Has Phenotype: | {{{field|Has Phenotype}}} @@ -91,6 +94,7 @@ __NOTOC__ | Add, edit, or remove ontology references {{#formlink:form=Ontological_References|link text=here|target={{PAGENAME}}/Ontologies }}. {{#ask:[[Is Ontological Reference::~{{PAGENAME}}/Ontologies*]] | mainlabel=- + |? from_Ontology |? has_Term_ID |? has_Term_Name |? has_Aspect diff --git a/preecej/semantic_wiki/PS_TransformForImport.pl b/preecej/semantic_wiki/paw_TransformForImport.pl similarity index 73% rename from preecej/semantic_wiki/PS_TransformForImport.pl rename to preecej/semantic_wiki/paw_TransformForImport.pl index 6d5fc5c..4fe3392 100644 --- a/preecej/semantic_wiki/PS_TransformForImport.pl +++ b/preecej/semantic_wiki/paw_TransformForImport.pl @@ -11,13 +11,13 @@ Plant Semantics Import Transformation Script =head1 DESCRIPTION Transform external gene annotation data into an XML document readable -by the MediaWiki extension DataTransfer (Special:ImportXML) feature. -Also generates appropriate provenance of data based on header of +by the MediaWiki extension DataTransfer (Special:ImportXML) feature, +including subpages. Also generates appropriate provenance of data based on header of import file. =head1 USAGE -PS_TransformForImport.pl -i INPUT_FILE -t TYPE -o OUTPUT_FILE +PS_TransformForImport.pl -i INPUT_FILE -t TYPE -o OUTPUT_FILE -v -d =head1 OPTIONS @@ -29,32 +29,48 @@ PS_TransformForImport.pl -i INPUT_FILE -t TYPE -o OUTPUT_FILE =head1 DEPENDENCIES -Requires that the input files contain two headers: the first will hold -the provenance information associated with the imported data, and the -second will specify the template and field names for the annotation -data. +Requires that the input file contain at least two headers: the first +will hold the provenance information associated with the imported +data, and all following headers will specify the templates and field +names for the annotation data. -=head2 Provenance Header Format Example +The main templates pertain to Annotations, Sources, and Publications. +Other templates are to be used for subsidiary reference data +(i.e. gene synonyms, external references, ontology terms, +and sequence data). - [Provenance] +=head2 Source Header Format Example + + [Source] Source Date Time Stamp=Apr 2 2008 Source Database=Oryzabase Source Version=rel. 10 Source URI=http://www.shigen.nig.ac.jp/rice/oryzabase/ Source File=http://www.shigen.nig.ac.jp/rice/oryzabase/genes/... -=head2 Data Header Format Example (field separator may also be a tab) +=head2 Data Header Format Examples + + NOTE: The field separator may also be a tab instead, but must be + employed consistently across the entire file. [Format] - Template=Gene + Template=Annotation Fields=Species Name,Gene Symbol,Gene Name,Chromosome,Gene Type,Accession ID [Data] val1,val2,val3,... " " " + [Format] + Template=Publication + Fields=Publication,Publication ID,Publication Title,...,Accession ID + [Data] + val1,val2,val3,... + " + " + " - NOTE: One of the fields MUST be named "Accession ID" for the + NOTE: One of the fields in each format MUST be named "Accession ID" for the tracking of provenance. =head1 AUTHOR @@ -96,15 +112,15 @@ my $input_file = $path; my $output_file = $path; # data storage -my %provenance; +my %source; my $template_name; my @field_names; my @field_data; my $xml; my $output_data; -my $prov_title_seed = 3; -my $annot_title_seed = 1563; +my $prov_title_seed = 2; +my $annot_title_seed = 3; # --------------------------------------------------------------------------- # functions @@ -134,7 +150,7 @@ sub init system "clear"; print "\n" . "------------------------------------------------------------\n" - . "------- Plant Semantics Import Transformation Script -------\n" + . "-- Planteome Annotation Wiki Import Transformation Script --\n" . "------------------------------------------------------------\n" . "\n" . "Input File: $input_file\n" @@ -150,7 +166,7 @@ sub init } -# read, parse, and store provenance, template, and annotations +# read, parse, and store source, template, and annotations # --------------------------------------------------------------------------- sub import_data { @@ -159,7 +175,7 @@ sub import_data # open file open(INPUT_FILE,$input_file) or die("Could not open input file."); - # read in the provenance data + # read in the source data my $count = 0; while () { @@ -168,11 +184,11 @@ sub import_data chomp $line; my $data_val = (split('=',$line))[1]; switch ($count) { - case 2 { $provenance{'SourceDateTimeStamp'} = $data_val; } - case 3 { $provenance{'SourceDatabase'} = $data_val; } - case 4 { $provenance{'SourceVersion'} = $data_val; } - case 5 { $provenance{'SourceURI'} = $data_val; } - case 6 { $provenance{'SourceFile'} = $data_val; } + case 2 { $source{'SourceDateStamp'} = $data_val; } + case 3 { $source{'SourceDatabase'} = $data_val; } + case 4 { $source{'SourceVersion'} = $data_val; } + case 5 { $source{'SourceURI'} = $data_val; } + case 6 { $source{'SourceFile'} = $data_val; } case 8 { $template_name = $data_val; } case 9 { @field_names = split($file_del,$data_val); } else {;} @@ -207,9 +223,9 @@ sub import_data # --------------------------------------------------------------------------- sub show_input { - print "[Provenance]\n"; - foreach my $key (keys %provenance) { - print "$key: $provenance{$key}\n"; + print "[Source]\n"; + foreach my $key (keys %source) { + print "$key: $source{$key}\n"; } print "\n"; print "[Template]\n$template_name\n\n"; @@ -226,7 +242,7 @@ sub show_input } -# loop through the hash and build annotation data and provenance xml doc +# loop through the hash and build annotation data and source xml doc # --------------------------------------------------------------------------- sub write_xml { @@ -239,24 +255,24 @@ sub write_xml $xml = new XML::Smart($output_data, 'XML::Smart::Parser'); - # set root element, provenance page and elements + # set root element, source page and elements # (temp set of page title until moved to import extension) - $xml->{Pages}{Page} = {Title => "PROV:$prov_title_seed"}; + $xml->{Pages}{Page} = {Title => "Source:$prov_title_seed"}; $curr_node = $xml->{Pages}{Page}; - $curr_node->{Template} = {Name => 'Provenance'}; + $curr_node->{Template} = {Name => 'Source'}; $curr_node = $curr_node->{Template}; - $curr_node->{Field}[0] = {Name => 'Source Data Time Stamp'}; - $curr_node->{Field}[0]->content(0,$provenance{'SourceDateTimeStamp'}); + $curr_node->{Field}[0] = {Name => 'Source Date Stamp'}; + $curr_node->{Field}[0]->content(0,$source{'SourceDateStamp'}); $curr_node->{Field}[1] = {Name => 'Source Database'}; - $curr_node->{Field}[1]->content(0,$provenance{'SourceDatabase'}); + $curr_node->{Field}[1]->content(0,$source{'SourceDatabase'}); $curr_node->{Field}[2] = {Name => 'Source Version'}; - $curr_node->{Field}[2]->content(0,$provenance{'SourceVersion'}); + $curr_node->{Field}[2]->content(0,$source{'SourceVersion'}); $curr_node->{Field}[3] = {Name => 'Source URI'}; - $curr_node->{Field}[3]->content(0,$provenance{'SourceURI'}); + $curr_node->{Field}[3]->content(0,$source{'SourceURI'}); $curr_node->{Field}[4] = {Name => 'Source File'}; - $curr_node->{Field}[4]->content(0,$provenance{'SourceFile'}); + $curr_node->{Field}[4]->content(0,$source{'SourceFile'}); $curr_node = $curr_node->back->back; # return to node @@ -268,11 +284,11 @@ sub write_xml foreach my $row (@field_data) { # set up next annotation page - my $next_page = { Title => "PS:$next_page_title_id" }; + my $next_page = { Title => "Annotation:$next_page_title_id" }; push(@{$curr_node->{Page}}, $next_page); $curr_annot_node = $curr_node->{Page}( - "Title","eq","PS:$next_page_title_id"); + "Title","eq","Annotation:$next_page_title_id"); if ($debug) { print "Curr annot node: ".$curr_annot_node->path."\n";} @@ -280,18 +296,18 @@ sub write_xml $curr_annot_node = $curr_annot_node->{Template}; # set up next provenance page - my $next_page = { Title => "PS:$next_page_title_id/PROV" }; + my $next_page = { Title => "Annotation:$next_page_title_id/Provenance" }; push(@{$curr_node->{Page}}, $next_page); $curr_prov_node = $curr_node->{Page}( - "Title","eq","PS:$next_page_title_id/PROV"); + "Title","eq","Annotation:$next_page_title_id/Provenance"); if ($debug) {print "Curr prov node: " . $curr_prov_node->path . "\n"; } - $curr_prov_node->{Template} = {Name => 'Provenance_Reference_Data'}; + $curr_prov_node->{Template} = {Name => 'Provenance'}; $curr_prov_node = $curr_prov_node->{Template}; $curr_prov_node->{Field} = {Name => 'Annotation Page'}; - $curr_prov_node->{Field}->content(0,"PS:$next_page_title_id"); + $curr_prov_node->{Field}->content(0,"Annotation:$next_page_title_id"); $curr_prov_node = $curr_prov_node->back; my $field_ct = 0; # counter for field position in pages @@ -319,21 +335,21 @@ sub write_xml $field_ct++; # add a corresponding template to the annotation provenance page - my $next_prov_node = {Name => 'Provenance_Reference_Data_Repeater'}; + my $next_prov_node = {Name => 'Provenance_Repeater'}; push(@{$curr_prov_node->{Template}}, $next_prov_node); # grab the last template you added $curr_prov_node = @{$curr_prov_node->{Template}}[-1]; # assign the relevant provenance field data - $curr_prov_node->{Field}[0] = {Name => 'Provenance Page'}; - $curr_prov_node->{Field}[0]->content(0,"PROV:$prov_title_seed"); - $curr_prov_node->{Field}[1] = {Name => 'Accession ID'}; + $curr_prov_node->{Field}[0] = {Name => 'Source'}; + $curr_prov_node->{Field}[0]->content(0,"Provenance:$prov_title_seed"); + $curr_prov_node->{Field}[1] = {Name => 'Source Accession ID'}; $curr_prov_node->{Field}[1]->content(0,$curr_accession_id); - $curr_prov_node->{Field}[2] = {Name => 'Source Field'}; - $curr_prov_node->{Field}[2]->content(0,$key); - $curr_prov_node->{Field}[3] = {Name => 'Source Template'}; - $curr_prov_node->{Field}[3]->content(0,$template_name); + $curr_prov_node->{Field}[2] = {Name => 'Source Template'}; + $curr_prov_node->{Field}[2]->content(0,$template_name); + $curr_prov_node->{Field}[3] = {Name => 'Source Field'}; + $curr_prov_node->{Field}[3]->content(0,$key); $curr_prov_node = $curr_prov_node->back; } diff --git a/preecej/semantic_wiki/templates/Annotation.wiki b/preecej/semantic_wiki/templates/Annotation.wiki index 4e4e8b5..bfef2bb 100644 --- a/preecej/semantic_wiki/templates/Annotation.wiki +++ b/preecej/semantic_wiki/templates/Annotation.wiki @@ -3,7 +3,6 @@ This is the "Annotation" template. It should be called in the following format:
 {{Annotation
-|Accession ID=
 |Species Name=
 |Species ID=
 |Gene Symbol=
@@ -24,9 +23,6 @@ __NOTOC__
 = Annotation =
 
 {| class="wikitable"
-! Accession ID
-| [[Has Accession ID::{{{Accession ID|}}}]]
-|-
 ! Species Name
 | [[Has Species Name::{{{Species Name|}}}]]
 |-
@@ -40,7 +36,15 @@ __NOTOC__
 | [[Has Gene Name::{{{Gene Name|}}}]]
 |-
 ! Gene Synonyms
-| coming soon...
+| {{#if: {{#ask:[[Category:Gene_Synonyms]][[Is Associated With Annotation::{{PAGENAME}} ]] }}
+    | {{#ask:[[Is Gene Synonym Pair::~{{PAGENAME}}/Gene_Synonyms]]
+        | ?is_Gene_Synonym
+        | headers=hide
+        | mainlabel=-
+        | format=list
+    }}
+    | None available
+}}
 |-
 ! Gene Type
 | [[Has Gene Type::{{{Gene Type|}}}]]
@@ -81,6 +85,7 @@ __NOTOC__
 {{#if: {{#ask:[[Category:Ontological_References]][[Is Associated With Annotation::{{PAGENAME}} ]] }}
     | {{#ask:[[Is Ontological Reference::~{{PAGENAME}}/Ontologies]]
         | mainlabel=-
+        |? from_Ontology
         |? has_Term_ID
         |? has_Term_Name
         |? has_Aspect
-- 
2.34.1