Difference between revisions of "TableEdit"

From GMOD
Jump to: navigation, search
(Table Edit in Action)
Line 3: Line 3:
 
[http://ecoliwiki.net/dev/index.php/Main_Page Ecoliwiki]  is providing detailed gene reports in a community editable form.  One goal for this with GMOD is to integrate the Wikipedia annotations with a Chado database for better comprehensive genome data management.
 
[http://ecoliwiki.net/dev/index.php/Main_Page Ecoliwiki]  is providing detailed gene reports in a community editable form.  One goal for this with GMOD is to integrate the Wikipedia annotations with a Chado database for better comprehensive genome data management.
  
=Table Edit=
+
==Table Edit==
 
Ecoliwiki's [http://ecoliwiki.net/dev/index.php/Special:TableEdit Table Edit] is the core for this gene-oriented community annotation database.  TableEdit provides a somewhat more friendly way to edit simple tables in mediawiki. TableEdit tables show up in a page with their own Edit link, which calls this page. Users who have editing privileges can then add rows and columns, rename headings, and change the style of the headings row.
 
Ecoliwiki's [http://ecoliwiki.net/dev/index.php/Special:TableEdit Table Edit] is the core for this gene-oriented community annotation database.  TableEdit provides a somewhat more friendly way to edit simple tables in mediawiki. TableEdit tables show up in a page with their own Edit link, which calls this page. Users who have editing privileges can then add rows and columns, rename headings, and change the style of the headings row.
  
==Source code==
+
===Source code===
 
The TableEdit code is at http://www.mediawiki.org/wiki/Extension:TableEdit
 
The TableEdit code is at http://www.mediawiki.org/wiki/Extension:TableEdit
  
 
[[Category:GMOD_Components]]
 
[[Category:GMOD_Components]]
 
[[Category:MOD_User_Interfaces]]
 
[[Category:MOD_User_Interfaces]]
 +
 +
The basic infrastructure is based on two PHP object classes, WikiBox and TableEdit.  The WikiBox object class is defined by class.WikiBox.php in the TableEdit distribution. 
 +
=== Object classes ===
 +
====WikiBox====
 +
A wikiBox object consists of a series of attributes that control the behavior and appearance of the table and a collection of row objects that hold the actual data.  The WikiBox also has methods to manipulate rows, serialize and unserialize its contents, and for interacting with the mySQL database that controls the tables.
 +
====wikiBoxRow====
 +
A wikiBoxRow object holds the actual data.  This is also defined in class.wikiBox.php.  The wikiBoxRow has methods for loading and saving etc.
 +
====TableEdit====
 +
class TableEdit is defined in SpecialTableEdit.body.php and is an extension of the MediaWiki SpecialPage class.  However, it can be invoked without generating a special page to handle interactions between wikiBoxes and Article objects in Mediawiki.
 +
 +
== Table Edit at EcoliWiki ==
 +
In constructing the first release of EcoliWiki, we built PHP scripts to load and/or update tables.  This involved writing functions that find the box_uid of tables of specific types on specific pages, looking for the rows that needed updating, creating them if they did not already exist, and either incorporating the table markup into an XML load file for the wiki, or directly editing the page via MediaWiki's command line utilties.
 +
 +
Here is a code snippet from a wrapper script
 +
<php>foreach ($genes as $gene){
 +
        $gene_count++;
 +
        $gene_name = $gene['feature_name'];
 +
 +
        # require something that finds the desired page and table and edits it
 +
        require "$bot_dir/colimod_colipedia/modify_tables/test_modify.php";
 +
        if ($box){
 +
                $tableEdit = new TableEdit();
 +
                $title = Title::newFromID($box->page_uid);
 +
                $tableEdit->save_to_page($title, $box);
 +
                unset($box);
 +
        }
 +
}</php>
 +
test_modify.php corrected a typo introduced by an earlier load, where a double || was needed instead of a single | after a PMID.  The metadata is data associated with a row that is not displayed on the page.  I use this to identify rows that have been used to store a particular kind of content.  In this case, it's rows in an allele table that describe the availability of knockouts from a strain collection from Hirotada Mori's lab.
 +
<php><?php
 +
# example for modifying box without rebuilding the whole page.  This example does not use metadata matching or conflict catching
 +
$page_name = "$gene_name:Gene_Product(s)";
 +
$template = "Gene_allele_table";
 +
echo "$page_name\t $template\n";
 +
$box_id = get_wikibox_id($page_name, $template);
 +
$box_uid = get_wikibox_uid($box_id);
 +
$box = new wikiBox();
 +
$box->box_uid = $box_uid;
 +
$box->template = $template;
 +
$box->set_from_DB();
 +
$metadata = 'keio';
 +
$uid = 0;
 +
$rows = get_wikibox_rows($box, $uid, $metadata);
 +
foreach ($rows as $index=>$row){
 +
      $box->rows[$index]->row_data = preg_replace("/16738554\|\[/","16738554||[", $box->rows[$index]->row_data);
 +
        $box->rows[$index]->db_save_row();
 +
}
 +
?></php>
 +
== Table Edit at Hackathon 2007 ==

Revision as of 03:42, 13 August 2007

Genome community annotation with a Wikipedia wiki

Ecoliwiki is providing detailed gene reports in a community editable form. One goal for this with GMOD is to integrate the Wikipedia annotations with a Chado database for better comprehensive genome data management.

Table Edit

Ecoliwiki's Table Edit is the core for this gene-oriented community annotation database. TableEdit provides a somewhat more friendly way to edit simple tables in mediawiki. TableEdit tables show up in a page with their own Edit link, which calls this page. Users who have editing privileges can then add rows and columns, rename headings, and change the style of the headings row.

Source code

The TableEdit code is at http://www.mediawiki.org/wiki/Extension:TableEdit

The basic infrastructure is based on two PHP object classes, WikiBox and TableEdit. The WikiBox object class is defined by class.WikiBox.php in the TableEdit distribution.

Object classes

WikiBox

A wikiBox object consists of a series of attributes that control the behavior and appearance of the table and a collection of row objects that hold the actual data. The WikiBox also has methods to manipulate rows, serialize and unserialize its contents, and for interacting with the mySQL database that controls the tables.

wikiBoxRow

A wikiBoxRow object holds the actual data. This is also defined in class.wikiBox.php. The wikiBoxRow has methods for loading and saving etc.

TableEdit

class TableEdit is defined in SpecialTableEdit.body.php and is an extension of the MediaWiki SpecialPage class. However, it can be invoked without generating a special page to handle interactions between wikiBoxes and Article objects in Mediawiki.

Table Edit at EcoliWiki

In constructing the first release of EcoliWiki, we built PHP scripts to load and/or update tables. This involved writing functions that find the box_uid of tables of specific types on specific pages, looking for the rows that needed updating, creating them if they did not already exist, and either incorporating the table markup into an XML load file for the wiki, or directly editing the page via MediaWiki's command line utilties.

Here is a code snippet from a wrapper script <php>foreach ($genes as $gene){

       $gene_count++;
       $gene_name = $gene['feature_name'];
       # require something that finds the desired page and table and edits it
       require "$bot_dir/colimod_colipedia/modify_tables/test_modify.php";
        if ($box){
               $tableEdit = new TableEdit();
               $title = Title::newFromID($box->page_uid);
               $tableEdit->save_to_page($title, $box);
               unset($box);
       }
}</php>

test_modify.php corrected a typo introduced by an earlier load, where a double || was needed instead of a single | after a PMID. The metadata is data associated with a row that is not displayed on the page. I use this to identify rows that have been used to store a particular kind of content. In this case, it's rows in an allele table that describe the availability of knockouts from a strain collection from Hirotada Mori's lab. <php><?php

  1. example for modifying box without rebuilding the whole page. This example does not use metadata matching or conflict catching

$page_name = "$gene_name:Gene_Product(s)"; $template = "Gene_allele_table"; echo "$page_name\t $template\n"; $box_id = get_wikibox_id($page_name, $template); $box_uid = get_wikibox_uid($box_id); $box = new wikiBox(); $box->box_uid = $box_uid; $box->template = $template; $box->set_from_DB(); $metadata = 'keio'; $uid = 0; $rows = get_wikibox_rows($box, $uid, $metadata); foreach ($rows as $index=>$row){

      $box->rows[$index]->row_data = preg_replace("/16738554\|\[/","16738554||[", $box->rows[$index]->row_data);
       $box->rows[$index]->db_save_row();

} ?></php>

Table Edit at Hackathon 2007