[Bio] / ModelEditor / pluginExample.py Repository:
ViewVC logotype

View of /ModelEditor/pluginExample.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Fri Jan 7 14:40:33 2005 UTC (15 years, 1 month ago) by efrank
Branch: MAIN
CVS Tags: post-st-migration2, pre-wxPython-2515-migration, post-st-migration
Changes since 1.3: +1 -1 lines
migration to new schematools generated classes.
new chemdb.
factor chem out of seed data factory
imporved configuration of modeleditor

################################################################################
# Model Editor Plug-in example
#
# ModelEditor plugins are registered via File->Add Plug-In drop down menu and
# are called by right clicking on a node in the Navigator panel and selecting
# the plug-in there.
#
# Plugins interface:
#    0. Required:   Make a class inheriting from KahModule, as below.
#    1. Required:   A method called process(). process() will be passed a
#                   RecoElem corresponding to the selected node and passed
#                   a configuration section (to get job params into the module).
#
#    3. Required:   A function called registerHook.  Use it as below to register
#                   _instances_ of your module.  You can register multiple instances
#                   of multiple modules.
#
# HISTORY:
#    28 May 04 efrank   First version
#    ?? Jul 04 efrank   Change to class based
#
# BUGS:
#
#  o In the near future, we will introduce a top-level item called DataManager.
#    At that time, the arg passed to process() will be an intance of DataManager.
#
#
################################################################################

from KahOM.RecoElem           import RecoElem
from KahApp.KahModule         import KahModule


#------------------------------------------------------------------------
def registerHook( register ):
#------------------------------------------------------------------------
    register( "Print Reactions", 
              "Prints Reactions",
              RxPrinter( "RxPrinter") )

    register( "Print Stoich Matrix",
              "Prints Stoichiometric Matrix",
              StoichPrinter( "StoichPrinter") )

    return

#------------------------------------------------------------------------
class RxPrinter( KahModule ):
#------------------------------------------------------------------------
    #------------------------------------------------------------------------
    def __init__( self, name ):
    #------------------------------------------------------------------------
        KahModule.__init__( self, name )


    #------------------------------------------------------------------------
    def process(self, theRecoElem, cfg ):
    #------------------------------------------------------------------------
        """
        Sample plug-in example.  Gathers all the reactions and prints them
        as strings.
        """

        print theRecoElem.getName()
        rxns = []
        theRecoElem.gatherReactions( rxns )

        for r in rxns:
            print r.asString()

        return


#------------------------------------------------------------------------
class StoichPrinter( KahModule ):
#------------------------------------------------------------------------
    #------------------------------------------------------------------------
    def __init__( self, name ):
    #------------------------------------------------------------------------
        KahModule.__init__( self, name )


    #------------------------------------------------------------------------
    def process(self, theRecoElem, cfg ):
    #------------------------------------------------------------------------
        """
        Sample plug-in example.  Gathers all the reactions and prints them
        as strings.
        """

        print "Stoichiometric Matrix for %s and descendents:" % (theRecoElem.getName())
        
        print theRecoElem.getStoichMatrix()
        return

	


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3