This is the new server for GMOD.org. Please let us know if you notice anything weird while it's getting broken in.

TableEdit

From GMOD
Jump to: navigation, search

Genome community annotation with a MediaWiki wiki

Ecoliwiki is providing detailed gene reports in a community editable form. One goal for this with GMOD is to integrate annotations made in MediaWiki with a Chado database for better comprehensive genome data management. MediaWiki is a widely used wiki package and the one that backs the GMOD site, Ecoliwiki, and Wikipedia). MediaWiki is also included in the Community Annotation System.

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. Users who have editing privileges can add rows and columns, rename headings, and change the style of the headings row using a GUI, rather than MediaWiki's table markup, which can be a challenge to read and update.

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 utilities.

Here is a code snippet from a wrapper script

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

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
# 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();
}
?>

Table Edit at Hackathon 2007

Making the Table Editor more useful and integrating it better with other GMOD tools was our goal for the wiki part of Hackathon 2007. See Possible TableEdit/Wiki hackathon projects for more.

TableEdit Chado round trip

Integration with Chado will require that TableEdit tables reflect data from an underlying Chado, and also that changes made in a TableEdit table be saved back to the underlying Chado. In both directions there are issues about how to handle situations where the modifications on one end might cause loss or corruption of data in the other.

Chado2TableEdit

This would involve:

  • Something triggering a Chado query that would generate a view or join with sufficient information to determine the desired page, table (box) and row to be added or updated.
  • Creating an IFALT file for loading into the wiki via the TableEdit loader system.
  • Instantiating a box and TableEdit as in the EcoliWiki example above, and saving the table back to the page.

Based on our already being able to do table insertion, row creation, row updates, and row deletion, this should be a relatively simple task of getting middleware to have Chado provide data in a form that the TableEdit can use.

TableEdit2Chado

This would involve:

  • Passing a request to the TableEdit/Wiki system to identify tables/rows with information needed to populate/update fields in Chado.
  • Returning the data in a format that can be transformed to something Chado [[middleware can use.

This is a specific case of the general problem discussed at the Jan 2007 GMOD workshop - how to transform data to update Chado where the structure of the incoming data has to be manipulated to fit the Chado schema.

Bidirectional issues

Some issues to discuss:

  • If the desired table does not already exist, should it be created, or should the process throw an error?
  • how should the system check for whether a row should be updated or created?
  • how should we pass these requests and send confirmation messages to and from remote servers (i.e can we do this as a web service?). This would allow interaction with non-PHP middleware (highly desirable!).

TableEdit IntraWiki Interaction

Two or more tables in a wiki could be interconnected so that updating the Table in page A triggers an update of the table in page B. Use case: GO annotations on wiki pages. If round-trips work, this should fall out of the code needed. It may then be possible to couple tables without an intermediate trip to Chado.

Restricting search to Tables

This one is relatively simple and we might have a prototype before the 2007 Hackathon - modify the wiki search system to restrict searching to a particular class of tables or fields.

AJAX

There are many places where the TableEdit system would benefit from the addition of AJAX.

  • General elimination of reloads
  • Autocomplete fields
  • other?

Other TableEdit enhancements

Many of the items above do not require changes to the core TableEdit extension. But we can do that too during the 2007 Hackathon, if there's time. Some possible things to add or change

  • recovery of data from old wiki revisions
  • change to store the data in the wiki page in a more compact form.
  • change how deleted rows are handled to allow restoration
  • other?