Controlling the running Metannogen instance by Web Apps or external Programs

Figure: Interprocess communication of Metannogen clients with Web applications or desktop applications via http-ports. A network is reconstructed with a graphical pathway drawing program and exproted as SBML. Simultaneously annotations are added by curators in Metannogen. Metannogen as well as the graphical program can control each other. Finally, the resulting SBML file is generated by inserting the annotations.
Interprocess Communication
Metannogen can talk with other applications and Web services which allows to use Metannogen as a helper application.
If Metannogen is started with the option "-port=portnumber" then it may work as a client of Web pages and application. The underlying mechanism is that it is listening to the port10117 for incomming commands.

For demonstration, you can start Metannogen by clicking metannogen.php. Try the following shell commands.
echo listObjects=R00014 | telnet localhost 10117
or
echo metaboliteStructure=C05125 | telnet localhost 10117
or
echo openOrCreateDataset=R00014 | telnet localhost 10117

MS-Windows When I tested this telnet method under Windows-XP SP2 I found that the telnet command does not work properly. It allows to enter the command like "listObjects=R00014" manually over the keyboard. But it does not allow piping text from the echo command. Recommendation: Use a Cygwin shell rather than the CMD.EXE shell.


Emacs:The following Emacs-Lisp lines define three commands for Emacs to open a dataset, to view a metabolite structure and to open an object in a browsable tree. The commands act on the token under the cursor:
        (defun word-under-cursor(&optional delimL delimR)
        "The word under the cursor"
        (interactive) 
        (if (search-backward-regexp (or delimL "[^A-Za-z0-9_]")  nil t)  (forward-char) (beginning-of-buffer))
        
        (setq word-under-cursor-begin  (point)) 
        (if (search-forward-regexp  (or delimR "[^A-Za-z0-9_]") nil t) (backward-char) (end-of-buffer))
        
        (setq word-under-cursor-end  (point)) 
        (buffer-substring  word-under-cursor-begin  word-under-cursor-end   )
        )
        
        (defun MetannogenDataset() 
        (interactive) 
        (shell-command  (concat "echo 'openDataset=" (word-under-cursor) "' | telnet localhost 10117 "))
        )
        (defun MetannogenMetaboliteStructure() 
        (interactive) 
        (shell-command  (concat "echo 'metaboliteStructure=" (word-under-cursor "[ \r\t\n]" "[ \r\t\n]" ) "' | telnet localhost 10117 "))
        )
        (defun MetannogenList() 
        (interactive) 
        (shell-command (concat "echo 'listObjects=" (word-under-cursor "[ \r\t\n]" "[ \r\t\n]" ) "' | telnet localhost 10117 "))
        )
      
Above primitive telnet well explains the basics and can be used for testing. But it does not provide all required functions for inter-app-communication. The following features may be required:
  1. Start Metannogen
  2. Metannogen can tell the application to activate/highlight network components.
  3. The App can notification Metannogen about changes of the network.
Full featured communication is described for two cases:
  1. Communication with a Web Service Web service.
  2. Communication with an program application Program application.