Commit e950cb10 authored by eric pellegrini's avatar eric pellegrini

MDANSE MDANSE works at a command line level: the analysis has to be

reintroduced now
parent e90cede4
......@@ -101,8 +101,8 @@ class MainClass1(object):
:Example:
>>> import template
>>> a = template.MainClass1()
>>> import Template
>>> a = Template.MainClass1()
>>> a.function1(1,1,1)
2
......
#!/bin/sh
rm -rf Documentation
sphinx-apidoc -o ../Documentation -F --separate -d 5 -H nMoldyn -A "B. Aoun & G. Goret & E. Pellegrini, G.R. Kneller" -V 4.0 -R 4.0 ../nMOLDYN/
mkdir Documentation
cp doc_utils/conf_html.py ../Documentation/conf.py
sphinx-apidoc -o ./Documentation -F --separate -d 5 -H MDANSE -A "B. Aoun & G. Goret & E. Pellegrini" -V 1.0 -R 1.0 ../MDANSE/
cp conf_html.py ./Documentation/conf.py
cp doc_utils/nMoldyn_logo.png ../Documentation/_static/
cp mdanse_logo.png ./Documentation/_static/
sphinx-build -b html ../Documentation ../Documentation/_build/html/
sphinx-build -b html ./Documentation ./Documentation/_build/html/
......
......@@ -8,5 +8,5 @@ sphinx-apidoc -o . -F --separate -d 5 -H mdanse -A "G. Goret, B. Aoun & E. Pel
cp conf_help.py conf.py
cp layout.html _templates/
cp nMoldyn_logo.png _static/
cp mdanse_logo.png _static/
sphinx-build -b htmlhelp ./ ./Help/
# -*- coding: utf-8 -*-
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
# nMoldyn documentation build configuration file, created by Gael Goret
# on Fri Feb 28 10:35:22 2014.
#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 (at your option) any later version.
#
# This file is execfile()d with the current directory set to its containing dir.
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 30, 2015
@author: goret
'''
import sys, os
#
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
......@@ -41,17 +61,17 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'nMoldyn'
copyright = u'2014, G. Goret & B. Aoun & E. Pellegrini'
project = u'MDANSE'
copyright = u'2015, G. Goret & B. Aoun & E. Pellegrini'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '4.0'
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '4.0'
release = '1.0'
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
......@@ -65,12 +85,9 @@ inheritance_graph_attrs = dict(rankdir="TB", size='""')
inheritance_node_attrs = dict(color='lightblue', style='filled')
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
......@@ -80,23 +97,18 @@ html_theme_options = {'sidebarwidth':250}#, 'nosidebar':True}
html_show_copyright = False
# Output file base name for HTML help builder.
htmlhelp_basename = 'mdanseDoc'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
#pdf_documents = [
# ('index', 'nMoldyn', u'nMoldyn Documentation',
# ('index', 'MDANSE', u'MDANSE Documentation',
# u'B. Aoun & G. Goret & E. Pellegrini, G.R. Kneller'),
#]
exclude_patterns = ['MDANSE.Externals**', 'MDANSE.__pkginfo__']
members_to_watch = ['class']
......@@ -104,13 +116,11 @@ members_to_watch = ['class']
def flag_onthefly(app, what, name, obj, options, lines):
if(what in members_to_watch):
# and modify the docstring so the rendered output is highlights the omission
if lines:
lines.insert(0,' **Description:**\n\n\n')
if lines:
lines.insert(0,' **Description:**\n\n\n')
# lines.insert(0,' .. inheritance-diagram:: %s\n'%name.split('.')[-1])
# lines.insert(0,'**inheritance-diagram:**\n\n')
def autodoc_skip_member(app, what, name, obj, skip, options):
if what in ['method','attribut','function','exception']:
......@@ -130,5 +140,3 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
def setup(app):
app.connect('autodoc-skip-member', autodoc_skip_member)
app.connect('autodoc-process-docstring', flag_onthefly)
# -*- coding: utf-8 -*-
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
# nMoldyn documentation build configuration file, created by Gael Goret
# on Fri Feb 28 10:35:22 2014.
#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 (at your option) any later version.
#
# This file is execfile()d with the current directory set to its containing dir.
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 30, 2015
@author: goret
'''
import sys, os
#
......@@ -17,7 +37,7 @@ import sys, os
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.append(os.path.abspath('../nMOLDYN'))
sys.path.append(os.path.abspath('../MDANSE'))
# -- General configuration -----------------------------------------------------
......@@ -41,23 +61,23 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'nMoldyn'
copyright = u'2014, B. Aoun & G. Goret & E. Pellegrini, G.R. Kneller'
project = u'MDANSE'
copyright = u'2014, B. Aoun & G. Goret & E. Pellegrini'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '4.0'
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '4.0'
release = '1.0'
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_patterns = ['Externals','_build', '**Tests**']
exclude_patterns = ['MDANSE.Externals','_build', '**Tests**']
html_logo = '_static/nMoldyn_logo.png'
html_logo = '_static/mdanse_logo.png'
inheritance_graph_attrs = dict(size='""')
......@@ -69,8 +89,6 @@ inheritance_node_attrs = dict(color='lightblue', style='filled')
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
......@@ -78,55 +96,37 @@ pygments_style = 'sphinx'
html_theme = "nature"
html_theme_options = {'sidebarwidth':250}#, 'nosidebar':True}
# Output file base name for HTML help builder.
htmlhelp_basename = 'nMoldyndoc'
htmlhelp_basename = 'MDANSE_doc'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'nMoldyn.tex', u'nMoldyn Documentation',
('index', 'MDANSE.tex', u'MDANSE Documentation',
u'B. Aoun \\& G. Goret \\& E. Pellegrini, G.R. Kneller', 'manual'),
]
#pdf_documents = [
# ('index', 'nMoldyn', u'nMoldyn Documentation',
# u'B. Aoun & G. Goret & E. Pellegrini, G.R. Kneller'),
#]
pdf_documents = [('index', 'MDANSE', u'MDANSE Documentation', u'B. Aoun & G. Goret & E. Pellegrini'),]
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'nmoldyn', u'nMoldyn Documentation',
[u'B. Aoun & G. Goret & E. Pellegrini, G.R. Kneller'], 1)
]
man_pages = [('index', 'MDANSE', u'MDANSE Documentation', u'B. Aoun & G. Goret & E. Pellegrini'),]
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'nMoldyn', u'nMoldyn Documentation',
u'B. Aoun & G. Goret & E. Pellegrini, G.R. Kneller', 'nMoldyn', 'One line description of project.',
'Miscellaneous'),
]
texinfo_documents = [('index', 'MDANSE', u'MDANSE Documentation',u'B. Aoun & G. Goret & E. Pellegrini','MDANSE', 'One line description of project.','Miscellaneous'),]
exclude_patterns = ['nMOLDYN.Externals**', 'nMOLDYN.nMOLDYN.__pkginfo__']
exclude_patterns = ['MDANSE.Externals**', 'MDANSE.__pkginfo__']
members_to_watch = ['class']
def flag_onthefly(app, what, name, obj, options, lines):
from MDANSE import REGISTRY
for kls in REGISTRY["job"].values():
kls.__doc__ += kls.configurators.build_doc()
if(what in members_to_watch):
# and modify the docstring so the rendered output is highlights the omission
if lines:
......@@ -134,7 +134,7 @@ def flag_onthefly(app, what, name, obj, options, lines):
lines.insert(0,' .. inheritance-diagram:: %s\n'%name.split('.')[-1])
lines.insert(0,'**inheritance-diagram:**\n\n')
def setup(app):
app.connect('autodoc-process-docstring', flag_onthefly)
#!/bin/sh
cd ../Tests/
coverage run --source=../nMOLDYN/ ../Tests/AllTests.py
coverage html --omit=../nMOLDYN/Externals/*,../nMOLDYN/GUI/*,../nMOLDYN/Framework/Plugins/*,../nMOLDYN/Framework/ConfiguratorWidgets/*
\ No newline at end of file
coverage run --source=../MDANSE/ ../Tests/AllTests.py
coverage html --omit=../MDANSE/Externals/*,../MDANSE/GUI/*,../MDANSE/Framework/Plugins/*,../MDANSE/Framework/ConfiguratorWidgets/*
......@@ -49,7 +49,7 @@ EXTENSIONS = [Extension('distance_histogram',
setup (name = "nMolDyn_Extensions",
version = "0.1",
setup (name = "MDANSE_Extensions",
version = "1.0",
ext_modules = EXTENSIONS,
cmdclass = {'build_ext': build_ext})
......@@ -3,11 +3,11 @@ include LICENCE
recursive-include Extensions/qhull_lib *.h *c *.pxd
recursive-include nMOLDYN/GUI/Resources/Icons *.png
recursive-include MDANSE/GUI/Resources/Icons *.png
include nMOLDYN/Data/elements_database.csv
include MDANSEData/elements_database.csv
include nMOLDYN/Data/Atoms/*
include MDANSE/Data/Atoms/*
recursive-include UserData *
......
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#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 (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 30, 2015
@author: pellegrini
'''
import optparse
import textwrap
class IndentedHelp(optparse.IndentedHelpFormatter):
'''This class modify slightly the help formatter of the optparse.OptionParser class.
This allows to take into account the line feed properly.
@note: code taken as it is from an implementation made by Tim Chase
(http://groups.google.com/group/comp.lang.python/browse_thread/thread/6df6e6b541a15bc2/09f28e26af0699b1)
'''
def format_description(self, description):
if not description:
return ""
desc_width = self.width - self.current_indent
indent = " "*self.current_indent
bits = description.split('\n')
formatted_bits = [textwrap.fill(bit,desc_width,initial_indent=indent,subsequent_indent=indent) for bit in bits]
result = "\n".join(formatted_bits) + "\n"
return result
def format_option(self, option):
result = []
opts = self.option_strings[option]
opt_width = self.help_position - self.current_indent - 2
if len(opts) > opt_width:
opts = "%*s%s\n" % (self.current_indent, "", opts)
indent_first = self.help_position
else: # start help on same line as opts
opts = "%*s%-*s " % (self.current_indent, "", opt_width, opts)
indent_first = 0
result.append(opts)
if option.help:
help_text = self.expand_default(option)
# Everything is the same up through here
help_lines = []
for para in help_text.split("\n"):
help_lines.extend(textwrap.wrap(para, self.help_width))
# Everything is the same after here
result.append("%*s%s\n" % (indent_first, "", help_lines[0]))
result.extend(["%*s%s\n" % (self.help_position, "", line) for line in help_lines[1:]])
elif opts[-1] != "\n":
result.append("\n")
return "".join(result)
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#goret[at]ill.fr
#aoun[at]ill.fr
#
#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 (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 30, 2015
@author: pellegrini
'''
import abc
import inspect
import os
class _Meta(type):
'''
......@@ -17,14 +51,11 @@ class _Meta(type):
class ClassRegistry(abc.ABCMeta):
'''
Metaclass that registers the subclasses of bases classes.
Metaclass that registers the subclasses of all the base classes used in MDANSE framework.
The internal registry is defined as a nested dictionary whose keys
are the |type| class attribute of the base classes and values another dictionary
whose keys are the |type| class attribute of the subclasses and values are the corresponding
class instances.
Hence any base or child class that does not define |type| class attribute will not be resgistered.
The subclasses are stored internally in a nested dictionary whose primary key
is the 'type' class attribute of the base class they are inheriting from and secondary key is
their own 'type' class attribute.
'''
__metaclass__ = _Meta
......@@ -38,8 +69,11 @@ class ClassRegistry(abc.ABCMeta):
Constructor of a class metaclassed by ClassFactory
:param name: the name of the class to be built by this metaclass
:type name: str
:param bases: the base classes of the class to be built by this metaclass
:type bases: tuple
:param namespace: the attributes and methods of the class to be built by this metaclass
:type namespace: dict
'''
super(ClassRegistry, self).__init__(name, bases, namespace)
......@@ -51,11 +85,11 @@ class ClassRegistry(abc.ABCMeta):
return
metaClass = namespace.get("__metaclass__", None)
if metaClass is ClassRegistry:
ClassRegistry.__interfaces.append(self)
if (ClassRegistry._registry.has_key(typ)):
return
ClassRegistry.__interfaces.append(self)
ClassRegistry._registry[typ] = {}
else:
......@@ -64,22 +98,21 @@ class ClassRegistry(abc.ABCMeta):
if issubclass(self, interface):
ClassRegistry._registry[interface.type][typ] = self
break
@classmethod
def info(cls, interface):
'''
Returns informations about the subclasses of a given base class stored in the registry.
:param cls: the ClassRegsitry instance
:type cls: ClassRegistry
:param interface: the name of base class of whom information about its subclasses is requested
:type interface: str
'''
if not cls._registry.has_key(interface):
return "The interface " + interface + " is not registered"
import inspect
import os
# Dictionnay whose keys are the package names and values and list of (job name, job path) stored in the corresponding package.
packages = {}
......@@ -98,6 +131,8 @@ class ClassRegistry(abc.ABCMeta):
# If no package could be found, guess a name using the directory name of the module file.
if modPackage is None:
modPackage = os.path.split(os.path.dirname(modFilename))[1]
modPackage = modPackage.split(".")[-1]
# Update the packages dictionary.
if packages.has_key(modPackage):
......@@ -120,3 +155,14 @@ class ClassRegistry(abc.ABCMeta):
return contents
@classmethod
def get_interfaces(cls):
'''
Returns the interfaces that are currently registered.
:param cls: the ClassRegsitry instance
:type cls: ClassRegistry
'''
return sorted(cls._registry.keys())
\ No newline at end of file
import cPickle
import os
from MMTK.Biopolymers import defineAminoAcidResidue, defineNucleicAcidResidue
from MMTK.PDB import defineMolecule
from MDANSE import PLATFORM
from MDANSE.Core.Error import Error
from MDANSE.Core.Singleton import Singleton
class MMTKDefinitionsError(Error):
pass
class MMTKDefinitions(dict):
__metaclass__ = Singleton
_path = os.path.join(PLATFORM.application_directory(),"mmtk_definitions")
_types = ['amino_acid','molecule','nucleic_acid']
def add(self, name, typ, databaseName):
if type not in self._types:
raise MMTKDefinitionsError('The type %r is not a valid MMTK definition type. It must be one of %s' % (str(name),MMTKDefinitions._types))
try:
if typ == 'molecule':
defineMolecule(name,databaseName)
elif typ == 'amino_acid':
defineAminoAcidResidue(databaseName,name)
elif typ == 'nucleic_acid':
defineNucleicAcidResidue(databaseName,name)
except ValueError as e:
raise MMTKDefinitions(str(e))
else:
self[name] = (typ,databaseName)
def load(self):
if not os.path.exists(MMTKDefinitions._path):
return
# Try to open the UD file.
try:
with open(MMTKDefinitions._path, "rb") as f:
mmtkDef = cPickle.load(f)
for name,(typ,databaseName) in mmtkDef.items():
self.add(name,typ,databaseName)
# If for whatever reason the pickle file loading failed do not even try to restore it
except:
raise MMTKDefinitionsError("The mmtk definitions file could not be loaded")
def save(self, path=None):
if path is None:
path = MMTKDefinitions._path
try:
f = open(path, "wb")
except IOError:
return
else:
cPickle.dump(self, f, protocol=2)
f.close()
MMTK_DEFINITIONS = MMTKDefinitions()
\ No newline at end of file
#MDANSE : Molecular Dynamics Analysis for Neutron Scattering Experiments
#------------------------------------------------------------------------------------------
#Copyright (C)
#2015- Eric C. Pellegrini Institut Laue-Langevin
#BP 156
#6, rue Jules Horowitz
#38042 Grenoble Cedex 9
#France
#pellegrini[at]ill.fr
#aoun[at]ill.fr
#goret[at]ill.fr
#
#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 (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Mar 26, 2015
@author: pellegrini
'''
import cPickle
import os
from MDANSE import PLATFORM
from MDANSE.Core.Error import Error
from MDANSE.Core.Singleton import Singleton
class UserDefinitionsError(Error):
pass
class UnicodeDict(dict):