Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mhucka committed Jun 23, 2016
2 parents cb1aca6 + 56fa11f commit c750c45
Show file tree
Hide file tree
Showing 628 changed files with 8,146 additions and 3,373 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ htmlcov
build/
dist/
.git/COMMIT_EDITMSG
TAGS
.idea/

23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ MOCCASIN

<img align="right" src="https://raw.githubusercontent.com/sbmlteam/moccasin/master/docs/project/logo/moccasin_logo_20151002/logo_128.png"> *MOCCASIN* stands for *"Model ODE Converter for Creating Automated SBML INteroperability"*. MOCCASIN is designed to convert certain basic forms of ODE simulation models written in MATLAB or Octave and translate them into [SBML](http://sbml.org) format. It thereby enables researchers to convert MATLAB models into an open and widely-used format in systems biology.

[![Build Status](https://travis-ci.org/sbmlteam/moccasin.svg?branch=master)](https://travis-ci.org/sbmlteam/moccasin) [![Coverage Status](https://coveralls.io/repos/sbmlteam/moccasin/badge.svg?branch=master)](https://coveralls.io/r/sbmlteam/moccasin?branch=master)
[![License](http://img.shields.io/:license-LGPL-blue.svg)](http://doge.LGPL-license.org) [![Latest version](https://img.shields.io/badge/Latest_version-1.1-brightgreen.svg)](http://shields.io) [![Build Status](https://travis-ci.org/sbmlteam/moccasin.svg?branch=master)](https://travis-ci.org/sbmlteam/moccasin) [![Coverage Status](https://coveralls.io/repos/sbmlteam/moccasin/badge.svg?branch=master)](https://coveralls.io/r/sbmlteam/moccasin?branch=master)

----
*Authors*: [Michael Hucka](http://www.cds.caltech.edu/~mhucka), [Sarah Keating](http://www.ebi.ac.uk/about/people/sarah-keating), and [Harold G&oacute;mez](http://www.bu.edu/computationalimmunology/people/harold-gomez/).
Expand All @@ -19,7 +19,20 @@ MOCCASIN
⚑ Recent news and activities
--------------------------

_December 2015_: we have been working on improving the MATLAB parser in MOCCASIN, to rectify limitations in the 1.0 release and expand the coverage of MATLAB constructs. This will lay the groundwork for being able to convert more MATLAB inputs, especially using the approach of converting to Numpy ([Pivotal Tracker item #91874850](https://www.pivotaltracker.com/story/show/91874850)). The updated MATLAB parser will constitute release 1.1 of MOCCASIN. (The Numpy translation will have to wait to a later release.)
_June 2016_: The MATLAB parser and the conversion code in MOCCASIN version 1.1 are considerably better than they were in last year's 1.0 release. The underlying parser now creates a more complete abstract syntax tree representation of the MATLAB input, and the converter also takes advantage of more syntactic features in XPP and BIOCHAM. The result is better conversions of larger and more complex models.


♥️ Please cite the MOCCASIN paper
---------------------------------

Article citations are **critical** for us to be able to continue support for MOCCASIN. If you use MOCCASIN and you publish papers about your software, we ask that you **please cite the MOCCASIN paper**:

<dl>
<dd>
Harold F. Gómez, Michael Hucka, Sarah M. Keating, German Nudelman, Dagmar Iber and Stuart C. Sealfon. <a href="http://bioinformatics.oxfordjournals.org/content/32/12/1905">MOCCASIN: converting MATLAB ODE models to SBML</a>. <i>Bioinformatics</i> (2016), 32(12): 1905-1906.
</dd>
</dl>


☀ Background
----------
Expand Down Expand Up @@ -73,7 +86,7 @@ Before installing MOCCASIN, you need to separately install the following softwar
* `libz-dev`
* `libbz2-dev`

* and [wxPython](http://wxpython.org/).
* and [wxPython](http://wxpython.org/). Note: wxPython is not fully supported for Python 3.4, even with [wxPython-Phoenix](http://wxpython.org/Phoenix/docs/html/index.html), and unfortunately, the MOCCASIN GUI uses features that are not available in wxPython-Phoenix. Consequently, **to use the GUI interface, you must use Python 2.7**. If you use the command-line interface for MOCCASIN, you can use Python 2.7 or 3.x.

Once that is done, you can download or clone the MOCCASIN source code base and then run

Expand All @@ -84,7 +97,7 @@ python setup.py install
► Using MOCCASIN
--------------

You can use MOCCASIN either via the command line or via the GUI interface. To start the MOCCASIN GUI, execute the Python command `moccasin/interfaces/moccasin_GUI.py` in the source directory, or the command `moccasin-GUI` in a shell/terminal. A screenshot of the GUI in action is shown below.
You can use MOCCASIN either via the command line or via the GUI interface. To start the MOCCASIN GUI, after installation (see above), execute the Python command `moccasin/interfaces/moccasin_GUI.py` in the MOCCASIN source directory, or the command `python -m moccasin-GUI` in a shell/terminal. A screenshot of the GUI in action is shown below.

<img src="https://raw.githubusercontent.com/sbmlteam/moccasin/develop/docs/project/examples/screenshot-01.jpg"
alt="MOCCASIN GUI" title="MOCCASIN GUI" align="center" />
Expand Down Expand Up @@ -116,7 +129,7 @@ The MOCCASIN logo was created by Randy Carlton (<[email protected]>).
☮ Copyright and license
---------------------

Copyright (C) 2014-2015 jointly by the California Institute of Technology (Pasadena, California, USA), the Icahn School of Medicine at Mount Sinai (New York, New York, USA), and Boston University (Boston, Massachusetts, USA).
Copyright (C) 2014-2016 jointly by the California Institute of Technology (Pasadena, California, USA), the Icahn School of Medicine at Mount Sinai (New York, New York, USA), and Boston University (Boston, Massachusetts, USA).

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or any later version.

Expand Down
2 changes: 1 addition & 1 deletion dev/file-headers/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# This software is part of MOCCASIN, the Model ODE Converter for Creating
# Automated SBML INteroperability. Visit https://github.com/sbmlteam/moccasin/.
#
# Copyright (C) 2014-2015 jointly by the following organizations:
# Copyright (C) 2014-2016 jointly by the following organizations:
# 1. California Institute of Technology, Pasadena, CA, USA
# 2. Icahn School of Medicine at Mount Sinai, New York, NY, USA
# 3. Boston University, Boston, MA, USA
Expand Down
2 changes: 1 addition & 1 deletion moccasin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The following is a summary of the subdirectories of this directory that contain
[matlab_parser](matlab_parser)
------------------------------

This subdirectory contains the MATLAB parser implementation. MATLAB is difficult to parse fully: the language is complex and idiosyncratic, and there is no complete definition of the MATLAB syntax rules. We did not attempt to develop a complete parser for MATLAB; instead, we leveraged the fact that MOCCASIN's input is already expected to be syntactically valid MATLAB (because users are converting working MATLAB code), and thus MOCCASIN's parser can be simpler and make more assumptions. The parser is creates an internal representation that is essentially an embellished Abstract Syntax Tree (AST). The current MOCCASIN parser implements a weak form of kind analysis ([Doherty et al., 2011](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.295.5052)) to infer whether a given construct of the form `name(arguments)` is a function call or a references to a matrix (which are syntactically identical in the MATLAB language).
This subdirectory contains the MATLAB parser implementation. MATLAB is difficult to parse fully: the language is complex and idiosyncratic, and there is no complete definition of the MATLAB syntax rules. We did not attempt to develop a complete parser for MATLAB; instead, we leveraged the fact that MOCCASIN's input is already expected to be syntactically valid MATLAB (because users are converting working MATLAB code), and thus MOCCASIN's parser can be simpler and make more assumptions. The parser is creates an internal representation that is essentially an embellished Abstract Syntax Tree (AST). The current MOCCASIN parser implements a weak form of kind analysis ([Doherty et al., 2011](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.295.5052)) to infer whether a given construct of the form `name(arguments)` is a function call or a references to a matrix (which are syntactically identical in the MATLAB language). The inferences are heuristic: there is a chance they are incorrect, though we tried to make the heuristic rules as safe as possible.

[converter](converter)
----------------------
Expand Down
5 changes: 3 additions & 2 deletions moccasin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# This software is part of MOCCASIN, the Model ODE Converter for Creating
# Automated SBML INteroperability. Visit https://github.com/sbmlteam/moccasin/.
#
# Copyright (C) 2014-2015 jointly by the following organizations:
# Copyright (C) 2014-2016 jointly by the following organizations:
# 1. California Institute of Technology, Pasadena, CA, USA
# 2. Icahn School of Medicine at Mount Sinai, New York, NY, USA
# 3. Boston University, Boston, MA, USA
Expand All @@ -20,4 +20,5 @@
# available online at https://github.com/sbmlteam/moccasin/.
# ------------------------------------------------------------------------- -->

from .version import __version__
from .version import __title__, __version__, __url__, __license__, \
__author__, __author_email__, __help_url__
6 changes: 4 additions & 2 deletions moccasin/converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# This software is part of MOCCASIN, the Model ODE Converter for Creating
# Automated SBML INteroperability. Visit https://github.com/sbmlteam/moccasin/.
#
# Copyright (C) 2014-2015 jointly by the following organizations:
# Copyright (C) 2014-2016 jointly by the following organizations:
# 1. California Institute of Technology, Pasadena, CA, USA
# 2. Icahn School of Medicine at Mount Sinai, New York, NY, USA
# 3. Boston University, Boston, MA, USA
Expand All @@ -21,4 +21,6 @@
# ------------------------------------------------------------------------- -->

from .converter import *

from .rewriter import *
from .recognizer import *
from .errors import *
200 changes: 200 additions & 0 deletions moccasin/converter/cleaner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
#!/usr/bin/env python
#
# @file cleaner.py
# @brief Remove some MATLAB content that we can't process.
# @author Michael Hucka
#
# <!---------------------------------------------------------------------------
# This software is part of MOCCASIN, the Model ODE Converter for Creating
# Automated SBML INteroperability. Visit https://github.com/sbmlteam/moccasin/.
#
# Copyright (C) 2014-2016 jointly by the following organizations:
# 1. California Institute of Technology, Pasadena, CA, USA
# 2. Icahn School of Medicine at Mount Sinai, New York, NY, USA
# 3. Boston University, Boston, MA, USA
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation. A copy of the license agreement is provided in the
# file named "COPYING.txt" included with this software distribution and also
# available online at https://github.com/sbmlteam/moccasin/.
# ------------------------------------------------------------------------- -->

import sys
sys.path.append('..')
from matlab_parser import *

# MatlabCleaner
#
# Some things, like calls to figure and plotting commands, are never anything
# we need to process in MOCCASIN. We can remove them from the input and save
# time and confusion in later processing steps.

_ignorable = [
'annotation'
'area',
'axes',
'axis',
'bar',
'bar3',
'bar3h',
'barh',
'box',
'caxis',
'celldisp',
'cellplot',
'cla',
'clc',
'clabel',
'clear',
'close',
'colorbar',
'colordef',
'colormap',
'coneplot',
'countour',
'countour3',
'countourc',
'countourf',
'countourslice',
'daspect',
'datetick',
'diary',
'disp',
'errorbar',
'etreeplot',
'ezcontour',
'ezcontourf',
'fcontour',
'figure',
'figurepalette',
'fill',
'fill3',
'format',
'fplot',
'fplot3',
'fprintf',
'fscanf',
'gca',
'gplot',
'grid',
'gtext',
'histcounts',
'histcounts2',
'histogram',
'histogram2',
'hold',
'legend',
'line',
'loglog',
'mesh',
'meshc',
'meshgrid',
'odeset',
'patch',
'pie',
'pie3',
'plot',
'plot3',
'plotmatrix'
'polaraxes',
'polarplot',
'print',
'printf',
'rectangle',
'refresh',
'rlim',
'rgbplot',
'scatter',
'scatter3',
'semilogx',
'semilogy',
'set',
'sprintf',
'stairs'
'stem',
'stem3',
'subplot',
'surf',
'surf2patch',
'surface',
'surfc',
'surfl',
'surfnorm',
'text',
'textlabel',
'thetalim',
'title',
'treelayout',
'unmesh',
'xlabel',
'xlim',
'ylabel',
'ylim',
'yyaxis',
'zlabel',
'zlim',
'zoom',
]


class MatlabCleaner(MatlabNodeVisitor):
def __init__(self):
super(MatlabCleaner, self).__init__()


def _push_context(self, newcontext):
self._context = newcontext


def _pop_context(self):
# Don't pop topmost context.
if self._context.parent and not self._context.topmost:
self._context = self._context.parent


def visit_Assignment(self, node):
# Catches assignments where the RHS is a call to something ignorable.
# The whole assignmet can be ignored in that case.
rhs = node.rhs
if (isinstance(rhs, FunCall) and isinstance(rhs.name, Identifier)
and rhs.name.name in _ignorable):
# Remove the assignment from the context too.
if (isinstance(node.lhs, Identifier)
and node.lhs in self._context.assignments):
self._context.assignments.pop(node.lhs)
return None
if rhs is None:
# This happens if something else has taken out the RHS already.
return None
return node


def visit_FunCall(self, node):
# This catches top-level calls to things like 'figure', 'plot', etc.
if isinstance(node.name, Identifier) and node.name.name in _ignorable:
return None
return node


def visit_FunDef(self, node):
# Push the new function context. Note that FunDef is unusual in having
# a node.context property -- other MatlabNodes don't.
self._push_context(node.context)
self._context.nodes = self.visit(self._context.nodes)
node.body = self._context.nodes
self._pop_context()
return node


def visit_For(self, node):
# We could potentially handle simple loops like "for x in 1:n" if we
# could determine the number of times the loop body should be
# executed. Right now, Moccasin is not smart enough to do that.
# Since it doesn't make sense to execute the loop an arbitrary number
# of times rather than the number of times in the user's Matlab code,
# we just ignore loops completely, and we tell people not to use
# loops.
node.expr = []
node.body = None
return None
Loading

0 comments on commit c750c45

Please sign in to comment.