From d4d32ad4b3bce355807b80134f949c0a31949cda Mon Sep 17 00:00:00 2001 From: James Graham <J.A.Graham@soton.ac.uk> Date: Wed, 4 May 2016 14:25:22 +0100 Subject: [PATCH] Added documentation RST files to repo Added some more doc strings --- doc/source/index.rst | 2 +- doc/source/modules.rst | 7 +++++++ doc/source/pycgtool.bondset.rst | 7 +++++++ doc/source/pycgtool.forcefield.rst | 7 +++++++ doc/source/pycgtool.frame.rst | 7 +++++++ doc/source/pycgtool.interface.rst | 7 +++++++ doc/source/pycgtool.mapping.rst | 7 +++++++ doc/source/pycgtool.parsers.cfg.rst | 7 +++++++ doc/source/pycgtool.parsers.rst | 17 ++++++++++++++++ doc/source/pycgtool.rst | 30 ++++++++++++++++++++++++++++ doc/source/pycgtool.util.rst | 7 +++++++ doc/source/pycgtool.warnings.rst | 7 +++++++ pycgtool.py | 2 +- pycgtool/bondset.py | 31 +++++++++++++++++++++++++++++ pycgtool/interface.py | 16 +++++++++++++++ 15 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 doc/source/modules.rst create mode 100644 doc/source/pycgtool.bondset.rst create mode 100644 doc/source/pycgtool.forcefield.rst create mode 100644 doc/source/pycgtool.frame.rst create mode 100644 doc/source/pycgtool.interface.rst create mode 100644 doc/source/pycgtool.mapping.rst create mode 100644 doc/source/pycgtool.parsers.cfg.rst create mode 100644 doc/source/pycgtool.parsers.rst create mode 100644 doc/source/pycgtool.rst create mode 100644 doc/source/pycgtool.util.rst create mode 100644 doc/source/pycgtool.warnings.rst diff --git a/doc/source/index.rst b/doc/source/index.rst index 0eb5352..f9d409e 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -13,7 +13,7 @@ Contents: members -Indices and tables +Indexes ================== * :ref:`genindex` diff --git a/doc/source/modules.rst b/doc/source/modules.rst new file mode 100644 index 0000000..cb57cae --- /dev/null +++ b/doc/source/modules.rst @@ -0,0 +1,7 @@ +pycgtool +======== + +.. toctree:: + :maxdepth: 4 + + pycgtool diff --git a/doc/source/pycgtool.bondset.rst b/doc/source/pycgtool.bondset.rst new file mode 100644 index 0000000..6d1777e --- /dev/null +++ b/doc/source/pycgtool.bondset.rst @@ -0,0 +1,7 @@ +pycgtool.bondset module +======================= + +.. automodule:: pycgtool.bondset + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/pycgtool.forcefield.rst b/doc/source/pycgtool.forcefield.rst new file mode 100644 index 0000000..a25ef72 --- /dev/null +++ b/doc/source/pycgtool.forcefield.rst @@ -0,0 +1,7 @@ +pycgtool.forcefield module +========================== + +.. automodule:: pycgtool.forcefield + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/pycgtool.frame.rst b/doc/source/pycgtool.frame.rst new file mode 100644 index 0000000..f231e7f --- /dev/null +++ b/doc/source/pycgtool.frame.rst @@ -0,0 +1,7 @@ +pycgtool.frame module +===================== + +.. automodule:: pycgtool.frame + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/pycgtool.interface.rst b/doc/source/pycgtool.interface.rst new file mode 100644 index 0000000..a724d24 --- /dev/null +++ b/doc/source/pycgtool.interface.rst @@ -0,0 +1,7 @@ +pycgtool.interface module +========================= + +.. automodule:: pycgtool.interface + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/pycgtool.mapping.rst b/doc/source/pycgtool.mapping.rst new file mode 100644 index 0000000..7beba67 --- /dev/null +++ b/doc/source/pycgtool.mapping.rst @@ -0,0 +1,7 @@ +pycgtool.mapping module +======================= + +.. automodule:: pycgtool.mapping + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/pycgtool.parsers.cfg.rst b/doc/source/pycgtool.parsers.cfg.rst new file mode 100644 index 0000000..07faee1 --- /dev/null +++ b/doc/source/pycgtool.parsers.cfg.rst @@ -0,0 +1,7 @@ +pycgtool.parsers.cfg module +=========================== + +.. automodule:: pycgtool.parsers.cfg + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/pycgtool.parsers.rst b/doc/source/pycgtool.parsers.rst new file mode 100644 index 0000000..e1fea8b --- /dev/null +++ b/doc/source/pycgtool.parsers.rst @@ -0,0 +1,17 @@ +pycgtool.parsers package +======================== + +Submodules +---------- + +.. toctree:: + + pycgtool.parsers.cfg + +Module contents +--------------- + +.. automodule:: pycgtool.parsers + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/pycgtool.rst b/doc/source/pycgtool.rst new file mode 100644 index 0000000..3375064 --- /dev/null +++ b/doc/source/pycgtool.rst @@ -0,0 +1,30 @@ +pycgtool package +================ + +Subpackages +----------- + +.. toctree:: + + pycgtool.parsers + +Submodules +---------- + +.. toctree:: + + pycgtool.bondset + pycgtool.forcefield + pycgtool.frame + pycgtool.interface + pycgtool.mapping + pycgtool.util + pycgtool.warnings + +Module contents +--------------- + +.. automodule:: pycgtool + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/pycgtool.util.rst b/doc/source/pycgtool.util.rst new file mode 100644 index 0000000..973651b --- /dev/null +++ b/doc/source/pycgtool.util.rst @@ -0,0 +1,7 @@ +pycgtool.util module +==================== + +.. automodule:: pycgtool.util + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/pycgtool.warnings.rst b/doc/source/pycgtool.warnings.rst new file mode 100644 index 0000000..cc5e32b --- /dev/null +++ b/doc/source/pycgtool.warnings.rst @@ -0,0 +1,7 @@ +pycgtool.warnings module +======================== + +.. automodule:: pycgtool.warnings + :members: + :undoc-members: + :show-inheritance: diff --git a/pycgtool.py b/pycgtool.py index c14f0f9..0e9695e 100755 --- a/pycgtool.py +++ b/pycgtool.py @@ -13,7 +13,7 @@ def main(args, config): """ Main function of the program PyCGTOOL. - Performs the complete AA->CG mapping and outputs a GROMACS forcefield directory. + Performs the complete AA->CG mapping and outputs a files dependent on given input. :param args: Arguments from argparse :param config: Configuration dictionary diff --git a/pycgtool/bondset.py b/pycgtool/bondset.py index f6c3381..e678bd4 100644 --- a/pycgtool/bondset.py +++ b/pycgtool/bondset.py @@ -128,15 +128,35 @@ class BondSet: self._create_angles(mol.name, options.generate_dihedrals) def get_bond_lengths(self, mol, with_constr=False): + """ + Return list of all bond lengths in molecule. May include constraints. + + :param mol: Molecule name to return bonds for + :param with_constr: Include constraints? + :return: List of bonds + """ if with_constr: return [bond for bond in self._molecules[mol] if len(bond.atoms) == 2] else: return [bond for bond in self._molecules[mol] if len(bond.atoms) == 2 and bond.fconst < self._fconst_constr_threshold] def get_bond_length_constraints(self, mol): + """ + Return list of all bond length constraints in molecule. + + :param mol: Molecule name to return bonds for + :return: List of bonds + """ return [bond for bond in self._molecules[mol] if len(bond.atoms) == 2 and bond.fconst >= self._fconst_constr_threshold] def get_bond_angles(self, mol, exclude_triangle=True): + """ + Return list of all bond angles in molecule. + + :param mol: Molecule name to return bonds for + :param exclude_triangle: Exclude angles that are part of a triangle? + :return: List of bonds + """ angles = [bond for bond in self._molecules[mol] if len(bond.atoms) == 3] if exclude_triangle: @@ -154,6 +174,12 @@ class BondSet: return angles def get_bond_dihedrals(self, mol): + """ + Return list of all bond dihedrals in molecule. + + :param mol: Molecule name to return bonds for + :return: List of bonds + """ return [bond for bond in self._molecules[mol] if len(bond.atoms) == 4] def _create_angles(self, mol, gen_dihedrals=False): @@ -326,6 +352,11 @@ class BondSet: angle_default_fc=self._angle_default_fc) def dump_values(self, target_number=100000): + """ + Output measured bond values to files for length, angles and dihedrals. + + :param target_number: Approx number of sample measurements to output. If None, all samples will be output + """ def transpose(bond_list): """ Transpose a list of bonds containing values and slice to provide target number of rows. diff --git a/pycgtool/interface.py b/pycgtool/interface.py index de10647..97ba5a7 100644 --- a/pycgtool/interface.py +++ b/pycgtool/interface.py @@ -1,3 +1,6 @@ +""" +This module contains classes for interaction at the terminal. +""" import collections import curses import curses.textpad @@ -7,8 +10,16 @@ import time class Options: """ Class to hold program options not specified at the initial command line. + + Values can be queried by indexing as a dictionary or by attribute. Iterable. """ def __init__(self, default, args=None): + """ + Create Options instance from iterable of keys and default values. + + :param default: Iterable of key, default value pairs (e.g. list of tuples) + :param args: Optional program arguments from Argparse, will be displayed in interactive mode + """ self._dict = collections.OrderedDict() for key, val in default: try: @@ -221,6 +232,11 @@ class Progress: return self def __next__(self): + """ + Allow iteration over Progress while testing prewhile and postwhile conditions. + + :return: Iteration number + """ if self._postwhile is not None and self._its > 0 and not self._postwhile(): self._stop() -- GitLab