Difference between revisions of "TableEdit"

From GMOD
Jump to: navigation, search
m (Table Edit)
m (Table Edit at EcoliWiki)
Line 20: Line 20:
  
 
== Table Edit at EcoliWiki ==
 
== 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.
+
In constructing the first release of [http://ecoliwiki.net/colipedia/ EcoliWiki], we built PHP scripts to load and/or update tables.  This involved writing functions that find the <tt>box_uid</tt> 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 [[Glossary#XML|XML]] load file for the wiki, or directly editing the page via [http://www.mediawiki.org/wiki/Manual:Maintenance_scripts#List_of_maintenance_scripts MediaWiki's command line utilities].
  
 
Here is a code snippet from a wrapper script
 
Here is a code snippet from a wrapper script
Line 36: Line 36:
 
         }
 
         }
 
  }</php>
 
  }</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.
+
<tt>test_modify.php</tt> 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
 
<php><?php
 
# example for modifying box without rebuilding the whole page.  This example does not use metadata matching or conflict catching
 
# example for modifying box without rebuilding the whole page.  This example does not use metadata matching or conflict catching
Line 56: Line 56:
 
}
 
}
 
?></php>
 
?></php>
 +
 
== Table Edit at Hackathon 2007 ==
 
== Table Edit at Hackathon 2007 ==
 
Making the Table Editor more useful and integrating it better with other GMOD tools is our goal for the wiki part of Hackathon 2007.  To elaborate on the suggestions on [[Talk:Hackathon_2007_info#Possible_TableEdit.2FWiki_hackathon_projects]]
 
Making the Table Editor more useful and integrating it better with other GMOD tools is our goal for the wiki part of Hackathon 2007.  To elaborate on the suggestions on [[Talk:Hackathon_2007_info#Possible_TableEdit.2FWiki_hackathon_projects]]

Revision as of 16:45, 16 May 2008

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, a widely used wiki package (and the one backing both the GMOD site and Wikipedia). 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 <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

Making the Table Editor more useful and integrating it better with other GMOD tools is our goal for the wiki part of Hackathon 2007. To elaborate on the suggestions on Talk:Hackathon_2007_info#Possible_TableEdit.2FWiki_hackathon_projects

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.
  • 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 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 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?