Skip to content
Snippets Groups Projects
Commit 54219aeb authored by Bienchen's avatar Bienchen Committed by BIOPZ-Johner Niklaus
Browse files

Refurbished documentation for meld, fixed doctest issues

parent edba24b9
Branches
Tags
No related merge requests found
......@@ -16,7 +16,8 @@ include(PROMOD3)
set(PROMOD3_VERSION_MAJOR 0)
set(PROMOD3_VERSION_MINOR 1)
set(PROMOD3_VERSION_PATCH 0)
set(PROMOD3_VERSION_STRING ${PROMOD3_VERSION_MAJOR}.${PROMOD3_VERSION_MINOR}.${PROMOD3_VERSION_PATCH})
set(PROMOD3_VERSION_STRING ${PROMOD3_VERSION_MAJOR}.${PROMOD3_VERSION_MINOR})
set(PROMOD3_VERSION_STRING ${PROMOD3_VERSION_STRING}.${PROMOD3_VERSION_PATCH})
option(DISABLE_DOCUMENTATION "Do not build documentation" OFF)
option(DISABLE_DISABLE_DOCTEST "Do not check examples in documentation" OFF)
......@@ -85,6 +86,11 @@ if(NOT EIGEN3_FOUND)
message(FATAL_ERROR "Eigen3 is essential for building ${PROJECT_NAME}.")
endif()
# This is somewhat experimental: Checking if Boost is compiled with the same
# Python version used for Promod3. The very same macro is disabled in OST so
# it may fail at some point.
promod3_match_boost_python_version(${PYTHON_LIBRARIES})
# basic environment
include_directories(${Boost_INCLUDE_DIRS}
${OST_INCLUDE_DIR}
......
This diff is collapsed.
......@@ -31,7 +31,10 @@ set(_SPHINX_CONF_SUBST_DICT PROMOD3_VERSION_MAJOR="${PROMOD3_VERSION_MAJOR}"
OST_ROOT="${OST_ROOT}"
OST_DOC_URL="${OST_DOC_URL}"
LIB_DIR="${LIB_DIR}")
set(_CONF_SUBST_DICT -DINPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in -DOUT_FILE=${_SPHINX_CONF_PY})
set(_CONF_SUBST_DICT -DINPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in)
list(APPEND _CONF_SUBST_DICT -DOUT_FILE=${_SPHINX_CONF_PY})
foreach(_subst ${_SPHINX_CONF_SUBST_DICT})
list(APPEND _CONF_SUBST_DICT -D${_subst})
endforeach()
......@@ -45,7 +48,8 @@ add_custom_command(OUTPUT ${_SPHINX_CONF_PY}
foreach(_rst_file ${_DOC_RST_FILES})
add_custom_command(OUTPUT "${_RST_SOURCE_DIR}/${_rst_file}"
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_rst_file}"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${_rst_file}" "${_RST_SOURCE_DIR}/${_rst_file}")
COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/${_rst_file}" "${_RST_SOURCE_DIR}/${_rst_file}")
set(_RST_DEPS ${_RST_DEPS} "${_RST_SOURCE_DIR}/${_rst_file}")
endforeach()
# care for a changelog file, if given
......@@ -53,12 +57,13 @@ if(DEFINED PM3_DOC_CHANGELOG)
# copy to different file name
add_custom_command(OUTPUT "${_RST_SOURCE_DIR}/changelog.rst"
MAIN_DEPENDENCY "${PM3_DOC_CHANGELOG}"
COMMAND ${CMAKE_COMMAND} -E copy "${PM3_DOC_CHANGELOG}" "${_RST_SOURCE_DIR}/changelog.rst")
COMMAND ${CMAKE_COMMAND} -E copy
"${PM3_DOC_CHANGELOG}" "${_RST_SOURCE_DIR}/changelog.rst")
set(_RST_DEPS ${_RST_DEPS} "${_RST_SOURCE_DIR}/changelog.rst")
endif()
# iterate list of ALL modules registered by pymod()/ add_doc_source()
foreach(mod ${PM3_MODULES})
foreach(mod ${PM3_PY_MS})
# only modules with dedicated rst files are considered for documentation, so
# we check if a list PM3_RST_{module name} exists (filled by add_doc_source()
# the following sets up copying for *.rst files only
......@@ -98,7 +103,8 @@ set(_SPHINX_INDEX_HTML "${_SPHINX_HTML_DIR}/index.html")
add_custom_command(OUTPUT ${_SPHINX_INDEX_HTML}
MAIN_DEPENDENCY "${_SPHINX_CONF_PY}"
DEPENDS ${_RST_DEPS} ${_DOC_MODULE_DEPS}
COMMAND ${SPHINX_BINARY} -b html -c "${_RST_SOURCE_DIR}" "${_RST_SOURCE_DIR}" "${_SPHINX_HTML_DIR}")
COMMAND ${SPHINX_BINARY} -b html -c "${_RST_SOURCE_DIR}"
"${_RST_SOURCE_DIR}" "${_SPHINX_HTML_DIR}")
add_custom_target(html DEPENDS ${_SPHINX_INDEX_HTML})
# man target
......@@ -108,7 +114,8 @@ set(_SPHINX_MAN "${_SPHINX_MAN_DIR}/promod3.1")
add_custom_command(OUTPUT ${_SPHINX_MAN}
MAIN_DEPENDENCY "${_SPHINX_CONF_PY}"
DEPENDS ${_RST_DEPS} ${_DOC_MODULE_DEPS}
COMMAND ${SPHINX_BINARY} -b man -c "${_RST_SOURCE_DIR}" "${_RST_SOURCE_DIR}" "${_SPHINX_MAN_DIR}")
COMMAND ${SPHINX_BINARY} -b man -c "${_RST_SOURCE_DIR}"
"${_RST_SOURCE_DIR}" "${_SPHINX_MAN_DIR}")
add_custom_target(man DEPENDS ${_SPHINX_MAN})
# doc target, registered with all
......@@ -120,14 +127,17 @@ add_dependencies(doc man)
set(_SPHINX_DOCTEST_DIR "${CMAKE_CURRENT_BINARY_DIR}/doctest")
file(MAKE_DIRECTORY ${_SPHINX_DOCTEST_DIR})
add_custom_target(doctest
COMMAND ${SPHINX_BINARY} -b doctest -c "${_RST_SOURCE_DIR}" "${_RST_SOURCE_DIR}" "${_SPHINX_DOCTEST_DIR}"
DEPENDS "${_SPHINX_CONF_PY}" ${_RST_DEPS} ${_DOC_MODULE_DEPS})
COMMAND ${SPHINX_BINARY} -b doctest -c "${_RST_SOURCE_DIR}"
"${_RST_SOURCE_DIR}" "${_SPHINX_DOCTEST_DIR}"
DEPENDS "${_SPHINX_CONF_PY}" ${_RST_DEPS} ${_DOC_MODULE_DEPS}
${PM3_PYMODULES} ${PM3_UNIT_TEST_DATA})
# linkcheck target
set(_SPHINX_LINKCHECK_DIR "${CMAKE_CURRENT_BINARY_DIR}/linkcheck")
file(MAKE_DIRECTORY ${_SPHINX_LINKCHECK_DIR})
add_custom_target(linkcheck
COMMAND ${SPHINX_BINARY} -b linkcheck -c "${_RST_SOURCE_DIR}" "${_RST_SOURCE_DIR}" "${_SPHINX_LINKCHECK_DIR}"
COMMAND ${SPHINX_BINARY} -b linkcheck -c "${_RST_SOURCE_DIR}"
"${_RST_SOURCE_DIR}" "${_SPHINX_LINKCHECK_DIR}"
DEPENDS "${_SPHINX_CONF_PY}" ${_RST_DEPS} ${_DOC_MODULE_DEPS})
# register doctest & linkcheck with check
......@@ -147,6 +157,3 @@ endif()
install(DIRECTORY ${_SPHINX_HTML_DIR} DESTINATION "share/promod3")
# install man pages
install(DIRECTORY ${_SPHINX_MAN_DIR} DESTINATION "share/promod3")
# doctest & linkcheck goes into check, once its created, depend on rst
# what about extratcting stuff from code? -> autofunction
......@@ -211,7 +211,7 @@ def CheckPythonCode(filepath):
import_re = re.compile('import\s+\*')
lno = 1
for line in fh:
line = line.strip()
line = line.rstrip(os.linesep)
TestLineWidthExit(line, lno, filepath)
m_line = re.match('([^#]*)', line)
ex_line = m_line.group(1)
......@@ -228,7 +228,7 @@ def CheckRest(filepath):
fh = open(filepath, "U")
lno = 1
for line in fh:
line = line.strip()
line = line.rstrip(os.linesep)
TestLineWidthExit(line, lno, filepath)
lno += 1
......@@ -236,7 +236,7 @@ def CheckCmake(filepath):
fh = open(filepath, "U")
lno = 1
for line in fh:
line = line.strip()
line = line.rstrip(os.linesep)
TestLineWidthExit(line, lno, filepath)
lno += 1
......@@ -244,7 +244,7 @@ def CheckShellScript(filepath):
fh = open(filepath, "U")
lno = 1
for line in fh:
line = line.strip()
line = line.rstrip(os.linesep)
TestLineWidthExit(line, lno, filepath)
lno += 1
......@@ -252,7 +252,7 @@ def CheckCCode(filepath):
fh = open(filepath, "U")
lno = 1
for line in fh:
line = line.strip()
line = line.rstrip(os.linesep)
TestLineWidthExit(line, lno, filepath)
lno += 1
### FUNCTIONS - END
......
set(MELD_RST
index.rst
rawmodel.rst
)
add_doc_source(NAME meld RST ${MELD_RST})
......@@ -2,12 +2,98 @@
================================================================================
.. module:: promod3.meld
:synopsis: Coordinate modeling and sampling
:synopsis: Raw Coordinate Model
.. currentmodule:: promod3.meld
Functionality to build raw (pseudo) models based on a sequence alignment.
Here is an example of how to build a model from an alignment and a structure.
.. testcode:: meld
:hide:
import os
import tempfile
from ost import io
from promod3 import meld
aln = io.LoadAlignment('../tests/meld/data/raw-modeling/seq.fasta')
template_structure = io.LoadPDB('../tests/meld/data/raw-modeling/gly.pdb',
restrict_chains='A')
aln.AttachView(1, template_structure.Select('peptide=true'))
result = meld.BuildRawModel(aln)
(fh, fn) = tempfile.mkstemp(suffix='.pdb')
io.SavePDB(result.model, fn)
os.remove(fn)
.. doctest:: meld
from ost import io
from promod3 import meld
aln = io.LoadAlignment('seq.fasta')
template_structure = io.LoadPDB('gly.pdb', restrict_chains='A')
aln.AttachView(1, template_structure.Select('peptide=true'))
result = meld.BuildRawModel(aln)
io.SavePDB(result.model, 'model.pdb')
Raw Coordinate Modeling API
--------------------------------------------------------------------------------
.. function:: BuildRawModel(alignment, calpha_only=False)
BuildRawModel(alignments, calpha_only=False)
Builds a raw (pseudo) model from the alignment. Can either take a single
alignment handle or an alignment handle list. Every list item is treated as a
single chain in the final raw model.
This is a basic protein core modeling algorithm that copies backbone
coordinates based on the sequence alignment. For matching residues, the
side chain coordinates are also copied. Gaps are ignored. Hydrogen an
deuterium atoms are not copied into the model.
The function tries to reuse as much as possible from the template. Modified
residues are treated as follows:
- Selenium methionine residues are converted to methionine
- Side chains which contain all atoms of the parent amino acid, e.g.
phosphoserine are copied as a whole with the modifications stripped off.
Residue numbers are set such that missing residue in gaps are honoured and
subsequent loop modeling can insert new residues without having to
renumber.
This module contains functions and classes to build raw-models for protein
structures from templates.
The returned :class:`RawModelingResult` stores the obtained raw model as well
as information about insertions and deletions in the gaps list.
:param calpha_only: If true, only Calpha atoms will be copied. Side chains
and other backbone atoms are completely ignored.
:raises: A :exc:`RuntimeError` when the second sequence does not have an
attached structure
.. class:: RawModelingResult
Holds the result of raw model building. Incredibly minimalistic for now. Will
most likely grow a few more members over time to, e.g. to store a detailed
report.
.. attribute:: model
The resulting model.
:type: :class:`~ost.mol.EntityHandle`
.. attribute:: gaps
List of gaps in the model that could not be copied from the template. These
gaps may be the result of insertions/deletions in the alignment or due to
missing or incomplete backbone coordinates in the template structure.
:type: :class:`StructuralGapList`
.. toctree::
:maxdepth: 2
rawmodel
.. LocalWords: currentmodule promod aln AttachView BuildRawModel pdb calpha
.. LocalWords: RawModelingResult StructuralGapList
Raw Coordinate Modeling
================================================================================
.. currentmodule:: sm.meld
Introduction
--------------------------------------------------------------------------------
Contains function to build raw (pseudo) models based on a sequence alignment. Here is an example of how to build a model from an alignment and a structure.
.. code-block:: python
from promod3 import meld
aln=io.LoadAlignment('parwise.fasta')
template_structure=io.LoadPDB('1ake.pdb', restrict_chains='A')
aln.AttachView(1, template_structure.Select('peptide=true'))
result=meld.BuildRawModel(aln)
io.SavePDB(result.model, 'model.pdb')
print 'remaining gaps:'
for gap in result.gaps:
print ' * %s' % str(gap)
Raw Coordinate Modeling API
--------------------------------------------------------------------------------
.. function:: BuildRawModel(alignment, calpha_only=False)
BuildRawModel(alignments, calpha_only=False)
Builds a raw (pseudo) model from the alignment.
Can either take a single alignment handle or an alignment handle list.
Every list item is treated as a single chain in the final raw model.
This is a basic protein core modeling algorithm that copies backbone
coordinates based on the sequence alignment. For matching residues, the
sidechain coordinates are also copied. Gaps are ignored. Hydrogen an deuterium
atoms are not copied into the model.
The function tries to reuse as much as possible from the template. Modified
residues are treated as follows:
- Selenium methionine residues are converted to methionines
- Sidechains which contain all atoms of the parent amino acid, e.g.
phosphoserine are copied as a whole with the modifications stripped off.
Residue numbers are set such that missing residue in gaps are honored and
subsequent loop modeling can insert new residues without having to
renumber.
The returned :class:`RawModelingResult` stores the obtained raw model as well
as information about insertions and deletions in the gaps list.
:param calpha_only: If true, only Calpha atoms will be copied. Sidechains and
other backbone atoms are completely ignored.
:raises: A :exc:`RuntimeError` when the second sequence does not have an
attached structure
.. class:: RawModelingResult
Holds the result of raw model building. Incredibly minimalistic for now. Will
most likely grow a few more members over time to, e.g. to store a detailed
report.
.. attribute:: model
The resulting model.
:type: :class:`~ost.mol.EntityHandle`
.. attribute:: gaps
List of gaps in the model that could not be copied from the template. These
gaps may be the result of insertions/deletions in the alignment or due to
missing or incomplete backbone coordinates in the template structure.
:type: :class:`StructuralGapList`
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment