From 940efe8ede7bf49e1f1f19d395eca626ca68a2c6 Mon Sep 17 00:00:00 2001 From: Gerardo Tauriello <gerardo.tauriello@unibas.ch> Date: Thu, 10 Dec 2015 14:58:30 +0100 Subject: [PATCH] refactor - move rawmodel to modelling --- CHANGELOG | 1 + CMakeLists.txt | 2 +- actions/doc/index_dev.rst | 2 +- actions/pm-build-rawmodel | 4 +- doc/contributing.rst | 4 +- doc/developers.rst | 2 +- doc/gettingstarted.rst | 2 +- loop/pymod/__init__.py | 10 +-- loop/pymod/export_monte_carlo.cc | 1 - loop/src/CMakeLists.txt | 2 +- loop/src/backbone_loop_score.hh | 2 +- loop/src/loop_candidate.hh | 2 +- loop/src/monte_carlo_sampler.hh | 2 +- loop/src/monte_carlo_scorer.hh | 2 +- {rawmodel => modelling}/CMakeLists.txt | 0 modelling/doc/CMakeLists.txt | 5 ++ {rawmodel => modelling}/doc/index.rst | 26 ++++---- modelling/pymod/CMakeLists.txt | 16 +++++ modelling/pymod/__init__.py | 5 ++ {rawmodel => modelling}/pymod/_closegaps.py | 61 +++++++++--------- {rawmodel => modelling}/pymod/export_gap.cc | 6 +- .../pymod/export_gap_extender.cc | 4 +- {rawmodel => modelling}/pymod/export_model.cc | 4 +- .../pymod/wrap_modelling.cc | 2 +- {rawmodel => modelling}/src/CMakeLists.txt | 10 +-- {rawmodel => modelling}/src/gap.cc | 2 +- {rawmodel => modelling}/src/gap.hh | 6 +- {rawmodel => modelling}/src/gap_extender.cc | 8 +-- {rawmodel => modelling}/src/gap_extender.hh | 8 +-- {rawmodel => modelling}/src/model.cc | 2 +- {rawmodel => modelling}/src/model.hh | 6 +- modelling/tests/CMakeLists.txt | 25 +++++++ .../tests/data}/1mcg.pdb | 0 .../tests/data}/2dbs.pdb | 0 .../tests/data}/cbeta.fasta | 0 .../tests/data}/cbeta.pdb | 0 .../tests/data}/compounds.chemlib | Bin .../tests/data}/del.fasta | 0 .../loop => modelling/tests/data}/ext.pdb | 0 .../tests/data}/gly.pdb | 0 .../tests/data}/ins.fasta | 0 .../tests/data}/sep.fasta | 0 .../tests/data}/sep.pdb | 0 .../tests/data}/seq.fasta | 0 .../tests/data}/ter.fasta | 0 .../tests/test_close_gaps.py | 34 +++++----- .../tests/test_gap_extension.py | 8 +-- .../tests/test_modelling.py | 46 ++++++------- pipeline/pymod/CMakeLists.txt | 2 +- pipeline/pymod/run_engine.py | 32 ++++----- pipeline/tests/test_run_engine.py | 6 +- rawmodel/doc/CMakeLists.txt | 5 -- rawmodel/pymod/CMakeLists.txt | 16 ----- rawmodel/pymod/__init__.py | 5 -- rawmodel/tests/CMakeLists.txt | 25 ------- sidechain/pymod/_reconstruct_sidechains.py | 2 + 56 files changed, 209 insertions(+), 206 deletions(-) rename {rawmodel => modelling}/CMakeLists.txt (100%) create mode 100644 modelling/doc/CMakeLists.txt rename {rawmodel => modelling}/doc/index.rst (94%) create mode 100644 modelling/pymod/CMakeLists.txt create mode 100644 modelling/pymod/__init__.py rename {rawmodel => modelling}/pymod/_closegaps.py (92%) rename {rawmodel => modelling}/pymod/export_gap.cc (90%) rename {rawmodel => modelling}/pymod/export_gap_extender.cc (91%) rename {rawmodel => modelling}/pymod/export_model.cc (95%) rename rawmodel/pymod/wrap_rawmodel.cc => modelling/pymod/wrap_modelling.cc (83%) rename {rawmodel => modelling}/src/CMakeLists.txt (54%) rename {rawmodel => modelling}/src/gap.cc (98%) rename {rawmodel => modelling}/src/gap.hh (97%) rename {rawmodel => modelling}/src/gap_extender.cc (93%) rename {rawmodel => modelling}/src/gap_extender.hh (88%) rename {rawmodel => modelling}/src/model.cc (99%) rename {rawmodel => modelling}/src/model.hh (98%) create mode 100644 modelling/tests/CMakeLists.txt rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/1mcg.pdb (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/2dbs.pdb (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/cbeta.fasta (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/cbeta.pdb (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/compounds.chemlib (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/del.fasta (100%) rename {rawmodel/tests/data/loop => modelling/tests/data}/ext.pdb (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/gly.pdb (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/ins.fasta (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/sep.fasta (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/sep.pdb (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/seq.fasta (100%) rename {rawmodel/tests/data/raw-modeling => modelling/tests/data}/ter.fasta (100%) rename {rawmodel => modelling}/tests/test_close_gaps.py (83%) rename {rawmodel => modelling}/tests/test_gap_extension.py (87%) rename rawmodel/tests/test_raw_modeling.py => modelling/tests/test_modelling.py (73%) delete mode 100644 rawmodel/doc/CMakeLists.txt delete mode 100644 rawmodel/pymod/CMakeLists.txt delete mode 100644 rawmodel/pymod/__init__.py delete mode 100644 rawmodel/tests/CMakeLists.txt diff --git a/CHANGELOG b/CHANGELOG index 9c9ba86d..b50334fa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,5 +19,6 @@ Changes in Release 0.2 Changes in Release 0.3 (to be released) ------------------------------------------------------------------------------- * merged argcheck into the helper module + * rawmodel renamed to modelling and including high-level modelling functions .. LocalWords: Changelog reStructuredText changelog txt diff --git a/CMakeLists.txt b/CMakeLists.txt index f27f785a..36e9b1a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,7 +103,7 @@ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ## e.g. add_subdirectory(src), subdirs have their own CMakeLists.txt add_subdirectory(config) add_subdirectory(core) -add_subdirectory(rawmodel) +add_subdirectory(modelling) add_subdirectory(sidechain) add_subdirectory(loop) add_subdirectory(pipeline) diff --git a/actions/doc/index_dev.rst b/actions/doc/index_dev.rst index d392fe26..d88a7075 100644 --- a/actions/doc/index_dev.rst +++ b/actions/doc/index_dev.rst @@ -363,4 +363,4 @@ Unit Test Actions API .. LocalWords: userlevel RunExitStatusTest testExit ost testutils RunTests .. LocalWords: stdout stderr testcode nobytecode testsetup actiontest os .. LocalWords: getcwd pardir builtin testoutput NORMALIZE WHITESPACE API -.. LocalWords: rawmodel autoclass +.. LocalWords: autoclass diff --git a/actions/pm-build-rawmodel b/actions/pm-build-rawmodel index 464dd164..a6d8f2c1 100755 --- a/actions/pm-build-rawmodel +++ b/actions/pm-build-rawmodel @@ -1,6 +1,6 @@ import os, argparse from ost import io -from promod3 import rawmodel +from promod3 import modelling from promod3.core import helper ### CHANGELOG - START @@ -67,7 +67,7 @@ aln = io.LoadAlignment(opts.alignment_file) # how can we do multi-whatever things? aln.AttachView(1, tpl.CreateFullView()) -result = rawmodel.BuildRawModel(aln) +result = modelling.BuildRawModel(aln) io.SavePDB(result.model, opts.model_file) if not os.path.isfile(opts.model_file): helper.MsgErrorAndExit("Failed to write model file '%s'." % opts.model_file, 5) diff --git a/doc/contributing.rst b/doc/contributing.rst index 451b6f71..d47ca142 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -517,7 +517,7 @@ top level :file:`CMakeLists.txt`: ## e.g. add_subdirectory(src), subdirs have their own CMakeLists.txt add_subdirectory(config) add_subdirectory(core) - add_subdirectory(rawmodel) + add_subdirectory(modelling) add_subdirectory(sidechains) add_subdirectory(loop) add_subdirectory(scripts) @@ -830,7 +830,7 @@ contributions to web pages using |project|. .. LocalWords: unittest TestCase nameattr testcode staticmethod builtin cp .. LocalWords: SomethingTests testFileExistsFalse testutils RunTests DQMEAN .. LocalWords: pre API inline CMake hh ProMod Bienchen OST OPENSTRUCTURE os -.. LocalWords: mol alg conop QMEAN KIC eigen eigenvectors Lapack rawmodel +.. LocalWords: mol alg conop QMEAN KIC eigen eigenvectors Lapack .. LocalWords: OpenStructure ost pylint chmod sys pyc dont bytecode args .. LocalWords: AwesomeActionTests ActionTestCase kwargs testExit getcwd .. LocalWords: RunExitStatusTest DoAwesomeActionTests pardir mainattr alot diff --git a/doc/developers.rst b/doc/developers.rst index dff31849..c467ed1e 100644 --- a/doc/developers.rst +++ b/doc/developers.rst @@ -13,7 +13,7 @@ Contents: core/setcompoundschemlib core/index pipeline/index - rawmodel/index + modelling/index loop/index sidechain/index actions/index_dev diff --git a/doc/gettingstarted.rst b/doc/gettingstarted.rst index 070ac0fe..696d3827 100644 --- a/doc/gettingstarted.rst +++ b/doc/gettingstarted.rst @@ -41,7 +41,7 @@ Modelling pipeline Commonly, your input is a template structure and an alignment of the template to the desired target sequence. The modelling steps then are: -- Build a raw model from the template (see :func:`~promod3.rawmodel.BuildRawModel` function) +- Build a raw model from the template (see :func:`~promod3.modelling.BuildRawModel` function) - Perform loop modelling to close all gaps (see :mod:`~promod3.loop` module) - Reconstruct sidechains (see :mod:`~promod3.sidechain` module) - Minimize energy of final model using molecular mechanics diff --git a/loop/pymod/__init__.py b/loop/pymod/__init__.py index c95bece0..afe579e8 100644 --- a/loop/pymod/__init__.py +++ b/loop/pymod/__init__.py @@ -5,21 +5,21 @@ from _loop import * # not the best style, but as long as we only have a single function in # __init__.py lets ignore this flaw... if there are more general functions # coming up, start sth like a 'base.py' and import here properly -def SetupBackboneScorer(raw_model): +def SetupBackboneScorer(mhandle): '''Get a scorer for medling with backbones. This one is already tailored towards a certain modelling job. - :param raw_model: The raw model this scorer should be dedicated to. - :type raw_model: :class:`~promod3.rawmodel.ModellingHandle` + :param mhandle: The modelling handle this scorer should be dedicated to. + :type mhandle: :class:`~promod3.modelling.ModellingHandle` :return: A scorer instance. :rtype: :class:`~promod3.loop.BackboneLoopScorer` ''' scorer = LoadBackboneLoopScorer() seqres = list() - for s in raw_model.seqres: + for s in mhandle.seqres: seqres.append(s.GetString()) scorer.Initialize(seqres) - scorer.SetEnvironment(raw_model.model) + scorer.SetEnvironment(mhandle.model) return scorer diff --git a/loop/pymod/export_monte_carlo.cc b/loop/pymod/export_monte_carlo.cc index 2938c720..ce4a3f23 100644 --- a/loop/pymod/export_monte_carlo.cc +++ b/loop/pymod/export_monte_carlo.cc @@ -8,7 +8,6 @@ #include <promod3/loop/monte_carlo_scorer.hh> #include <promod3/loop/monte_carlo_sampler.hh> #include <promod3/loop/monte_carlo_closer.hh> -#include <promod3/rawmodel/gap.hh> using namespace promod3; using namespace promod3::loop; diff --git a/loop/src/CMakeLists.txt b/loop/src/CMakeLists.txt index ce925776..eb2d6980 100644 --- a/loop/src/CMakeLists.txt +++ b/loop/src/CMakeLists.txt @@ -47,5 +47,5 @@ backbone_relaxer.cc ) module(NAME loop HEADERS ${LOOP_HEADERS} SOURCES ${LOOP_SOURCES} DEPENDS_ON - promod3_core promod3_rawmodel promod3_sidechain LINK ${OST_LIBRARIES} ${BOOST_LIBRARIES} ${LAPACK_LIBRARIES}) + promod3_core promod3_modelling promod3_sidechain LINK ${OST_LIBRARIES} ${BOOST_LIBRARIES} ${LAPACK_LIBRARIES}) diff --git a/loop/src/backbone_loop_score.hh b/loop/src/backbone_loop_score.hh index 56ce6db2..af6a4dc6 100644 --- a/loop/src/backbone_loop_score.hh +++ b/loop/src/backbone_loop_score.hh @@ -6,7 +6,7 @@ #include <ost/geom/vecmat3_op.hh> #include <ost/mol/view_op.hh> #include <promod3/loop/backbone.hh> -#include <promod3/rawmodel/gap.hh> +#include <promod3/modelling/gap.hh> #include <promod3/loop/dynamic_spatial_organizer.hh> #include <boost/shared_ptr.hpp> diff --git a/loop/src/loop_candidate.hh b/loop/src/loop_candidate.hh index da784743..273ede5e 100644 --- a/loop/src/loop_candidate.hh +++ b/loop/src/loop_candidate.hh @@ -3,7 +3,7 @@ #include <promod3/loop/backbone.hh> #include <promod3/loop/frag_db.hh> -#include <promod3/rawmodel/gap.hh> +#include <promod3/modelling/gap.hh> #include <promod3/loop/monte_carlo.hh> #include <promod3/loop/flame.hh> #include <promod3/loop/backbone_loop_score.hh> diff --git a/loop/src/monte_carlo_sampler.hh b/loop/src/monte_carlo_sampler.hh index dcfa4754..196f3dc1 100644 --- a/loop/src/monte_carlo_sampler.hh +++ b/loop/src/monte_carlo_sampler.hh @@ -11,7 +11,7 @@ #include <ost/mol/residue_handle.hh> #include <ost/mol/atom_handle.hh> -#include <promod3/rawmodel/gap.hh> +#include <promod3/modelling/gap.hh> #include <promod3/loop/backbone.hh> #include <promod3/loop/torsion_sampler.hh> #include <promod3/core/message.hh> diff --git a/loop/src/monte_carlo_scorer.hh b/loop/src/monte_carlo_scorer.hh index f46e1ae4..0785fe3e 100644 --- a/loop/src/monte_carlo_scorer.hh +++ b/loop/src/monte_carlo_scorer.hh @@ -6,7 +6,7 @@ #include <ost/mol/mol.hh> -#include <promod3/rawmodel/gap.hh> +#include <promod3/modelling/gap.hh> #include <promod3/loop/backbone_loop_score.hh> diff --git a/rawmodel/CMakeLists.txt b/modelling/CMakeLists.txt similarity index 100% rename from rawmodel/CMakeLists.txt rename to modelling/CMakeLists.txt diff --git a/modelling/doc/CMakeLists.txt b/modelling/doc/CMakeLists.txt new file mode 100644 index 00000000..082558a1 --- /dev/null +++ b/modelling/doc/CMakeLists.txt @@ -0,0 +1,5 @@ +set(MODELLING_RST +index.rst +) + +add_doc_source(NAME modelling RST ${MODELLING_RST}) diff --git a/rawmodel/doc/index.rst b/modelling/doc/index.rst similarity index 94% rename from rawmodel/doc/index.rst rename to modelling/doc/index.rst index b36f700a..390a66d7 100644 --- a/rawmodel/doc/index.rst +++ b/modelling/doc/index.rst @@ -1,10 +1,10 @@ -:mod:`~promod3.rawmodel` - Protein Modelling +:mod:`~promod3.modelling` - Protein Modelling ================================================================================ -.. module:: promod3.rawmodel +.. module:: promod3.modelling :synopsis: Protein Modelling -.. currentmodule:: promod3.rawmodel +.. currentmodule:: promod3.modelling High-level functionality for protein modelling. Commonly, your input is a template structure and an alignment of the template to @@ -48,32 +48,32 @@ Modelling API The returned :class:`ModellingHandle` stores the obtained raw model as well as information about insertions and deletions in the gaps list. - .. testcode:: rawmodel + .. testcode:: modelling :hide: import os import tempfile from ost import io - from promod3 import rawmodel + from promod3 import modelling - aln = io.LoadAlignment('../tests/rawmodel/data/raw-modeling/seq.fasta') - template_structure = io.LoadPDB('../tests/rawmodel/data/raw-modeling/gly.pdb', + aln = io.LoadAlignment('../tests/modelling/data/seq.fasta') + template_structure = io.LoadPDB('../tests/modelling/data/gly.pdb', restrict_chains='A') aln.AttachView(1, template_structure.Select('peptide=true')) - result = rawmodel.BuildRawModel(aln) + result = modelling.BuildRawModel(aln) (fh, fn) = tempfile.mkstemp(suffix='.pdb') io.SavePDB(result.model, fn) os.remove(fn) - .. doctest:: rawmodel + .. doctest:: modelling from ost import io - from promod3 import rawmodel + from promod3 import modelling aln = io.LoadAlignment('seq.fasta') template_structure = io.LoadPDB('gly.pdb', restrict_chains='A') aln.AttachView(1, template_structure.Select('peptide=true')) - result = rawmodel.BuildRawModel(aln) + result = modelling.BuildRawModel(aln) io.SavePDB(result.model, 'model.pdb') :param alignment: Single alignment handle for raw model. @@ -135,7 +135,7 @@ Modelling Handle class .. class:: ModellingHandle Handles the result for structure model building and provides high-level methods - to turn an initial raw model (see :func:`~promod3.rawmodel.BuildRawModel`) + to turn an initial raw model (see :func:`~promod3.modelling.BuildRawModel`) into a complete protein model by removing any existing gaps. .. attribute:: model @@ -336,7 +336,7 @@ False if no new extension possible. :rtype: :class:`bool` .. LocalWords: currentmodule promod aln AttachView BuildRawModel pdb calpha -.. LocalWords: ModellingHandle StructuralGapList rawmodel Modelling os ost +.. LocalWords: ModellingHandle StructuralGapList modelling Modelling os ost .. LocalWords: testcode tempfile io LoadAlignment LoadPDB fh fn doctest API .. LocalWords: modelling phosphoserine param exc RuntimeError automethod .. LocalWords: CloseSmallDeletions diff --git a/modelling/pymod/CMakeLists.txt b/modelling/pymod/CMakeLists.txt new file mode 100644 index 00000000..9c8e1260 --- /dev/null +++ b/modelling/pymod/CMakeLists.txt @@ -0,0 +1,16 @@ +set(MODELLING_CPP +wrap_modelling.cc +export_model.cc +export_gap.cc +export_gap_extender.cc +) + +set(MODELLING_PYMOD + __init__.py + _closegaps.py +) + +pymod(NAME modelling + CPP ${MODELLING_CPP} + PY ${MODELLING_PYMOD} + DEPENDS_ON core_pymod) diff --git a/modelling/pymod/__init__.py b/modelling/pymod/__init__.py new file mode 100644 index 00000000..f71871e7 --- /dev/null +++ b/modelling/pymod/__init__.py @@ -0,0 +1,5 @@ +""" +Initialise the modelling module. +""" +from _modelling import * +from _closegaps import * diff --git a/rawmodel/pymod/_closegaps.py b/modelling/pymod/_closegaps.py similarity index 92% rename from rawmodel/pymod/_closegaps.py rename to modelling/pymod/_closegaps.py index 6792787e..f32d39f9 100644 --- a/rawmodel/pymod/_closegaps.py +++ b/modelling/pymod/_closegaps.py @@ -5,7 +5,7 @@ as argument. import ost #pylint: disable=no-name-in-module -from . import _rawmodel as rawmodel +from . import _modelling as modelling from promod3 import loop def CloseSmallDeletions(mhandle, scorer, extension_steps=9, clash_thresh=1.0, @@ -23,31 +23,31 @@ def CloseSmallDeletions(mhandle, scorer, extension_steps=9, clash_thresh=1.0, .. testcode:: closesmalldel :hide: - from promod3 import rawmodel + from promod3 import modelling from promod3 import loop - tpl = ost.io.LoadPDB('../tests/rawmodel/data/raw-modeling/gly.pdb') + tpl = ost.io.LoadPDB('../tests/modelling/data/gly.pdb') aln = ost.seq.CreateAlignment(ost.seq.CreateSequence('trg', 'GGG-GGG'), ost.seq.CreateSequence('tpl', 'GGGAGGG')) aln.AttachView(1, tpl.CreateFullView()) - mhandle = rawmodel.BuildRawModel(aln) + mhandle = modelling.BuildRawModel(aln) assert len(mhandle.gaps) == 1 scorer = loop.SetupBackboneScorer(mhandle) - rawmodel.CloseSmallDeletions(mhandle, scorer) + modelling.CloseSmallDeletions(mhandle, scorer) assert len(mhandle.gaps) == 0 .. doctest:: closesmalldel import ost - from promod3 import rawmodel + from promod3 import modelling from promod3 import loop tpl = ost.io.LoadPDB('gly.pdb') aln = ost.io.LoadAlignment('seq.fasta') aln.AttachView(1, tpl.CreateFullView()) - mhandle = rawmodel.BuildRawModel(aln) + mhandle = modelling.BuildRawModel(aln) scorer = loop.SetupBackboneScorer(mhandle) - rawmodel.CloseSmallDeletions(mhandle, scorer) + modelling.CloseSmallDeletions(mhandle, scorer) :param mhandle: Modelling handle on which to apply change. :type mhandle: :class:`ModellingHandle` @@ -96,7 +96,7 @@ def CloseSmallDeletions(mhandle, scorer, extension_steps=9, clash_thresh=1.0, # the gap, we get the backbone to be stretched. If no more extension # is possible, break out. On first successful relaxation for an # extension, we successfully stop. - extender = rawmodel.GapExtender(current_gap) + extender = modelling.GapExtender(current_gap) for _ in range(extension_steps): if not extender.Extend(): break @@ -141,7 +141,7 @@ def CloseSmallDeletions(mhandle, scorer, extension_steps=9, clash_thresh=1.0, scorer.SetEnvironment(\ bb_list, current_gap.before.GetNumber().GetNum()) - rawmodel.ClearGaps(mhandle, current_gap) + modelling.ClearGaps(mhandle, current_gap) success = True break @@ -164,29 +164,29 @@ def MergeGapsByDistance(mhandle, distance): .. testcode:: mergegapsbydist :hide: - from promod3 import rawmodel + from promod3 import modelling - tpl = ost.io.LoadPDB('../tests/rawmodel/data/raw-modeling/1mcg.pdb') + tpl = ost.io.LoadPDB('../tests/modelling/data/1mcg.pdb') aln = ost.seq.CreateAlignment(ost.seq.CreateSequence('trg', 'DDFAGDTKNLGHN'), ost.seq.CreateSequence('tpl', 'NN----A----LF')) aln.AttachView(1, tpl.CreateFullView()) - mhandle = rawmodel.BuildRawModel(aln) + mhandle = modelling.BuildRawModel(aln) assert len(mhandle.gaps) == 2 - rawmodel.MergeGapsByDistance(mhandle, 0) + modelling.MergeGapsByDistance(mhandle, 0) assert len(mhandle.gaps) == 1 .. doctest:: mergegapsbydist import ost - from promod3 import rawmodel + from promod3 import modelling tpl = ost.io.LoadPDB('1mcg.pdb') aln = ost.io.LoadAlignment('1mcg_aln.fasta') aln.AttachView(1, tpl.CreateFullView()) - mhandle = rawmodel.BuildRawModel(aln) - rawmodel.MergeGapsByDistance(mhandle, 0) + mhandle = modelling.BuildRawModel(aln) + modelling.MergeGapsByDistance(mhandle, 0) :param mhandle: Modelling handle on which to apply change. :type mhandle: :class:`ModellingHandle` @@ -223,7 +223,7 @@ def MergeGapsByDistance(mhandle, distance): - current_gap.after.GetNumber().GetNum() if dist <= distance: # gaps are close enough, combine! combine! - rawmodel.MergeGaps(mhandle, i) + modelling.MergeGaps(mhandle, i) ost.LogVerbose("Merged gap %s and %s into %s" % \ (current_gap, next_gap, mhandle.gaps[i])) try_again = True @@ -241,36 +241,36 @@ def FillLoopsByDatabase(mhandle, scorer, fragment_db, structure_db, .. testcode:: fillloopsbydb :hide: - from promod3 import rawmodel + from promod3 import modelling from promod3 import loop - tpl = ost.io.LoadPDB('../tests/rawmodel/data/raw-modeling/2dbs.pdb') + tpl = ost.io.LoadPDB('../tests/modelling/data/2dbs.pdb') aln = ost.seq.CreateAlignment( ost.seq.CreateSequence('trg', 'TLNGFTVPAGNTLV--LNPDKGATVTMA'), ost.seq.CreateSequence('tpl', 'NGGTLLIPNGTYHFLGIQMKSNVHIRVE')) aln.AttachView(1, tpl.CreateFullView()) - mhandle = rawmodel.BuildRawModel(aln) + mhandle = modelling.BuildRawModel(aln) assert len(mhandle.gaps) == 1 scorer = loop.SetupBackboneScorer(mhandle) - rawmodel.FillLoopsByDatabase(mhandle, scorer, loop.LoadFragDB(), + modelling.FillLoopsByDatabase(mhandle, scorer, loop.LoadFragDB(), loop.LoadStructureDB(), loop.LoadTorsionSamplerCoil()) assert len(mhandle.gaps) == 0 .. doctest:: fillloopsbydb - from promod3 import rawmodel + from promod3 import modelling from promod3 import loop tpl = io.LoadPDB('2dbs.pdb') aln = ost.io.LoadAlignment('2dbs.fasta') aln.AttachView(1, tpl.CreateFullView()) - mhandle = rawmodel.BuildRawModel(aln) + mhandle = modelling.BuildRawModel(aln) scorer = loop.SetupBackboneScorer(mhandle) - scorer = rawmodel.FillLoopsByDatabase(mhandle, scorer, loop.LoadFragDB(), + scorer = modelling.FillLoopsByDatabase(mhandle, scorer, loop.LoadFragDB(), loop.LoadStructureDB(), loop.LoadTorsionSamplerCoil()) @@ -355,7 +355,7 @@ def FillLoopsByDatabase(mhandle, scorer, fragment_db, structure_db, # get info on current gap actual_gap = mhandle.gaps[gap_idx].Copy() actual_length = actual_gap.length - actual_extender = rawmodel.GapExtender(actual_gap) + actual_extender = modelling.GapExtender(actual_gap) min_before_resnum = 100000000000 max_after_resnum = -100000000000 actual_candidates = list() @@ -481,7 +481,7 @@ def FillLoopsByDatabase(mhandle, scorer, fragment_db, structure_db, actual_chain_idx) ost.LogVerbose("Resolved %s by filling %s" % \ (str(actual_gap), str(actual_extended_gaps[idx_a]))) - next_gap = rawmodel.ClearGaps(mhandle, actual_extended_gaps[idx_a]) + next_gap = modelling.ClearGaps(mhandle, actual_extended_gaps[idx_a]) if next_gap == -1: break else: @@ -491,11 +491,12 @@ def FillLoopsByDatabase(mhandle, scorer, fragment_db, structure_db, gap_idx += 1 return scorer -__all__ = ['CloseSmallDeletions', 'MergeGapsByDistance', - 'FillLoopsByDatabase'] +# these methods will be exported into module +__all__ = ('CloseSmallDeletions', 'MergeGapsByDistance', + 'FillLoopsByDatabase',) # LocalWords: modeling stereochemically param idx init -# LocalWords: py ost pylint rawmodel promod CloseSmallDeletions testcode +# LocalWords: py ost pylint modelling promod CloseSmallDeletions testcode # LocalWords: fillloopsbydb tpl aln trg TLNGFTVPAGNTLV LNPDKGATVTMA mhandle # LocalWords: NGGTLLIPNGTYHFLGIQMKSNVHIRVE AttachView CreateFullView len # LocalWords: BuildRawModel SetupBackboneScorer FillLoopsByDatabase doctest diff --git a/rawmodel/pymod/export_gap.cc b/modelling/pymod/export_gap.cc similarity index 90% rename from rawmodel/pymod/export_gap.cc rename to modelling/pymod/export_gap.cc index 27192da4..71df386b 100644 --- a/rawmodel/pymod/export_gap.cc +++ b/modelling/pymod/export_gap.cc @@ -1,13 +1,13 @@ #include <boost/python.hpp> #include <boost/python/suite/indexing/vector_indexing_suite.hpp> -#include <promod3/rawmodel/gap.hh> +#include <promod3/modelling/gap.hh> using namespace ost; using namespace boost::python; -using namespace promod3::rawmodel; +using namespace promod3::modelling; namespace{ - promod3::rawmodel::StructuralGap WrapGetItem(promod3::rawmodel::StructuralGapList& l, int i){ + promod3::modelling::StructuralGap WrapGetItem(promod3::modelling::StructuralGapList& l, int i){ return l.at(i); } } diff --git a/rawmodel/pymod/export_gap_extender.cc b/modelling/pymod/export_gap_extender.cc similarity index 91% rename from rawmodel/pymod/export_gap_extender.cc rename to modelling/pymod/export_gap_extender.cc index 3f9e1448..ee56ba8a 100644 --- a/rawmodel/pymod/export_gap_extender.cc +++ b/modelling/pymod/export_gap_extender.cc @@ -1,9 +1,9 @@ #include <boost/python.hpp> -#include <promod3/rawmodel/gap_extender.hh> +#include <promod3/modelling/gap_extender.hh> using namespace ost; using namespace boost::python; -using namespace promod3::rawmodel; +using namespace promod3::modelling; namespace{ diff --git a/rawmodel/pymod/export_model.cc b/modelling/pymod/export_model.cc similarity index 95% rename from rawmodel/pymod/export_model.cc rename to modelling/pymod/export_model.cc index 7cce1771..daee7499 100644 --- a/rawmodel/pymod/export_model.cc +++ b/modelling/pymod/export_model.cc @@ -1,9 +1,9 @@ #include <boost/python.hpp> #include <boost/python/suite/indexing/vector_indexing_suite.hpp> -#include <promod3/rawmodel/model.hh> +#include <promod3/modelling/model.hh> using namespace boost::python; -using namespace promod3::rawmodel; +using namespace promod3::modelling; ModellingHandle (*BuildRawModelHandle)(const ost::seq::AlignmentHandle&, bool, diff --git a/rawmodel/pymod/wrap_rawmodel.cc b/modelling/pymod/wrap_modelling.cc similarity index 83% rename from rawmodel/pymod/wrap_rawmodel.cc rename to modelling/pymod/wrap_modelling.cc index b2d88e81..ebfa07ba 100644 --- a/rawmodel/pymod/wrap_rawmodel.cc +++ b/modelling/pymod/wrap_modelling.cc @@ -4,7 +4,7 @@ void export_gap(); void export_model(); void export_gap_extender(); -BOOST_PYTHON_MODULE(_rawmodel) +BOOST_PYTHON_MODULE(_modelling) { export_gap(); export_model(); diff --git a/rawmodel/src/CMakeLists.txt b/modelling/src/CMakeLists.txt similarity index 54% rename from rawmodel/src/CMakeLists.txt rename to modelling/src/CMakeLists.txt index a1f86282..6abdad56 100644 --- a/rawmodel/src/CMakeLists.txt +++ b/modelling/src/CMakeLists.txt @@ -1,17 +1,17 @@ -set(RAWMODEL_SOURCES +set(MODELLING_SOURCES gap.cc gap_extender.cc model.cc ) -set(RAWMODEL_HEADERS +set(MODELLING_HEADERS gap.hh gap_extender.hh model.hh ) -module(NAME rawmodel - HEADERS ${RAWMODEL_HEADERS} - SOURCES ${RAWMODEL_SOURCES} +module(NAME modelling + HEADERS ${MODELLING_HEADERS} + SOURCES ${MODELLING_SOURCES} DEPENDS_ON promod3_core LINK ${OST_LIBRARIES} ${BOOST_LIBRARIES}) diff --git a/rawmodel/src/gap.cc b/modelling/src/gap.cc similarity index 98% rename from rawmodel/src/gap.cc rename to modelling/src/gap.cc index af3d103d..5a7016ee 100644 --- a/rawmodel/src/gap.cc +++ b/modelling/src/gap.cc @@ -5,7 +5,7 @@ using namespace ost::mol; using namespace ost; -namespace promod3 { namespace rawmodel { +namespace promod3 { namespace modelling { String StructuralGap::GetChainName() const { diff --git a/rawmodel/src/gap.hh b/modelling/src/gap.hh similarity index 97% rename from rawmodel/src/gap.hh rename to modelling/src/gap.hh index 86f85236..3c506a8c 100644 --- a/rawmodel/src/gap.hh +++ b/modelling/src/gap.hh @@ -1,10 +1,10 @@ -#ifndef PM3_RAWMODEL_GAP_HH -#define PM3_RAWMODEL_GAP_HH +#ifndef PM3_MODELLING_GAP_HH +#define PM3_MODELLING_GAP_HH #include <ost/mol/mol.hh> #include <promod3/core/message.hh> -namespace promod3 { namespace rawmodel { +namespace promod3 { namespace modelling { /// Describes a structural gap, i.e. a loop to be modeled. The gap may either be /// terminal or between two defined regions. The gap stores information of the diff --git a/rawmodel/src/gap_extender.cc b/modelling/src/gap_extender.cc similarity index 93% rename from rawmodel/src/gap_extender.cc rename to modelling/src/gap_extender.cc index acd1cef3..601f585f 100644 --- a/rawmodel/src/gap_extender.cc +++ b/modelling/src/gap_extender.cc @@ -1,19 +1,19 @@ -#include <promod3/rawmodel/gap_extender.hh> +#include <promod3/modelling/gap_extender.hh> using namespace ost::mol; using namespace ost; namespace{ - bool CompareScoredElements(const std::pair<promod3::rawmodel::StructuralGap,Real>& a, - const std::pair<promod3::rawmodel::StructuralGap,Real>& b){ + bool CompareScoredElements(const std::pair<promod3::modelling::StructuralGap,Real>& a, + const std::pair<promod3::modelling::StructuralGap,Real>& b){ return a.second < b.second; } } -namespace promod3{ namespace rawmodel{ +namespace promod3{ namespace modelling{ bool GapExtender::Extend() { diff --git a/rawmodel/src/gap_extender.hh b/modelling/src/gap_extender.hh similarity index 88% rename from rawmodel/src/gap_extender.hh rename to modelling/src/gap_extender.hh index c8656355..82d1bf6b 100644 --- a/rawmodel/src/gap_extender.hh +++ b/modelling/src/gap_extender.hh @@ -1,13 +1,13 @@ -#ifndef PM3_RAWMODEL_GAP_EXTENDER_HH -#define PM3_RAWMODEL_GAP_EXTENDER_HH +#ifndef PM3_MODELLING_GAP_EXTENDER_HH +#define PM3_MODELLING_GAP_EXTENDER_HH #include <ost/mol/mol.hh> #include <promod3/core/message.hh> -#include <promod3/rawmodel/gap.hh> +#include <promod3/modelling/gap.hh> #include <ost/mol/mol.hh> #include <algorithm> -namespace promod3 { namespace rawmodel { +namespace promod3 { namespace modelling { class GapExtender; class ScoringGapExtender; diff --git a/rawmodel/src/model.cc b/modelling/src/model.cc similarity index 99% rename from rawmodel/src/model.cc rename to modelling/src/model.cc index 6c6729bc..12379bca 100644 --- a/rawmodel/src/model.cc +++ b/modelling/src/model.cc @@ -17,7 +17,7 @@ using namespace ost; using namespace ost::seq; using namespace ost::conop; -namespace promod3 { namespace rawmodel { +namespace promod3 { namespace modelling { namespace { diff --git a/rawmodel/src/model.hh b/modelling/src/model.hh similarity index 98% rename from rawmodel/src/model.hh rename to modelling/src/model.hh index fa421338..f6fe2908 100644 --- a/rawmodel/src/model.hh +++ b/modelling/src/model.hh @@ -1,5 +1,5 @@ -#ifndef PM3_MODEL_HH -#define PM3_MODEL_HH +#ifndef PM3_MODELLING_MODEL_HH +#define PM3_MODELLING_MODEL_HH #include <ost/seq/alignment_handle.hh> #include <ost/seq/sequence_list.hh> @@ -8,7 +8,7 @@ #include "gap.hh" -namespace promod3 { namespace rawmodel { +namespace promod3 { namespace modelling { struct ModellingHandle { diff --git a/modelling/tests/CMakeLists.txt b/modelling/tests/CMakeLists.txt new file mode 100644 index 00000000..f879c051 --- /dev/null +++ b/modelling/tests/CMakeLists.txt @@ -0,0 +1,25 @@ +set(MODELLING_UNIT_TESTS + test_modelling.py + test_gap_extension.py + test_close_gaps.py +) + +set(MODELLING_TEST_DATA + data/ext.pdb + data/compounds.chemlib + data/gly.pdb + data/ter.fasta + data/sep.pdb + data/sep.fasta + data/seq.fasta + data/ins.fasta + data/del.fasta + data/cbeta.pdb + data/cbeta.fasta + data/1mcg.pdb + data/2dbs.pdb +) + +promod3_unittest(MODULE modelling + SOURCES "${MODELLING_UNIT_TESTS}" + DATA "${MODELLING_TEST_DATA}") diff --git a/rawmodel/tests/data/raw-modeling/1mcg.pdb b/modelling/tests/data/1mcg.pdb similarity index 100% rename from rawmodel/tests/data/raw-modeling/1mcg.pdb rename to modelling/tests/data/1mcg.pdb diff --git a/rawmodel/tests/data/raw-modeling/2dbs.pdb b/modelling/tests/data/2dbs.pdb similarity index 100% rename from rawmodel/tests/data/raw-modeling/2dbs.pdb rename to modelling/tests/data/2dbs.pdb diff --git a/rawmodel/tests/data/raw-modeling/cbeta.fasta b/modelling/tests/data/cbeta.fasta similarity index 100% rename from rawmodel/tests/data/raw-modeling/cbeta.fasta rename to modelling/tests/data/cbeta.fasta diff --git a/rawmodel/tests/data/raw-modeling/cbeta.pdb b/modelling/tests/data/cbeta.pdb similarity index 100% rename from rawmodel/tests/data/raw-modeling/cbeta.pdb rename to modelling/tests/data/cbeta.pdb diff --git a/rawmodel/tests/data/raw-modeling/compounds.chemlib b/modelling/tests/data/compounds.chemlib similarity index 100% rename from rawmodel/tests/data/raw-modeling/compounds.chemlib rename to modelling/tests/data/compounds.chemlib diff --git a/rawmodel/tests/data/raw-modeling/del.fasta b/modelling/tests/data/del.fasta similarity index 100% rename from rawmodel/tests/data/raw-modeling/del.fasta rename to modelling/tests/data/del.fasta diff --git a/rawmodel/tests/data/loop/ext.pdb b/modelling/tests/data/ext.pdb similarity index 100% rename from rawmodel/tests/data/loop/ext.pdb rename to modelling/tests/data/ext.pdb diff --git a/rawmodel/tests/data/raw-modeling/gly.pdb b/modelling/tests/data/gly.pdb similarity index 100% rename from rawmodel/tests/data/raw-modeling/gly.pdb rename to modelling/tests/data/gly.pdb diff --git a/rawmodel/tests/data/raw-modeling/ins.fasta b/modelling/tests/data/ins.fasta similarity index 100% rename from rawmodel/tests/data/raw-modeling/ins.fasta rename to modelling/tests/data/ins.fasta diff --git a/rawmodel/tests/data/raw-modeling/sep.fasta b/modelling/tests/data/sep.fasta similarity index 100% rename from rawmodel/tests/data/raw-modeling/sep.fasta rename to modelling/tests/data/sep.fasta diff --git a/rawmodel/tests/data/raw-modeling/sep.pdb b/modelling/tests/data/sep.pdb similarity index 100% rename from rawmodel/tests/data/raw-modeling/sep.pdb rename to modelling/tests/data/sep.pdb diff --git a/rawmodel/tests/data/raw-modeling/seq.fasta b/modelling/tests/data/seq.fasta similarity index 100% rename from rawmodel/tests/data/raw-modeling/seq.fasta rename to modelling/tests/data/seq.fasta diff --git a/rawmodel/tests/data/raw-modeling/ter.fasta b/modelling/tests/data/ter.fasta similarity index 100% rename from rawmodel/tests/data/raw-modeling/ter.fasta rename to modelling/tests/data/ter.fasta diff --git a/rawmodel/tests/test_close_gaps.py b/modelling/tests/test_close_gaps.py similarity index 83% rename from rawmodel/tests/test_close_gaps.py rename to modelling/tests/test_close_gaps.py index c4b0155f..d833591e 100644 --- a/rawmodel/tests/test_close_gaps.py +++ b/modelling/tests/test_close_gaps.py @@ -1,7 +1,7 @@ import unittest import ost from ost import io, seq -from promod3 import rawmodel +from promod3 import modelling from promod3 import loop # setting up an OST LogSink to capture messages @@ -25,18 +25,18 @@ class CloseGapsTests(unittest.TestCase): def testClosesmalldel(self): # check that very small gaps are closed - # create a rawmodel to work with (which actually is a bit dangerous: + # create a raw model to work with (which actually is a bit dangerous: # the PDB file has nothing to do with the alignment...) - tpl = io.LoadPDB('data/raw-modeling/gly.pdb') + tpl = io.LoadPDB('data/gly.pdb') # switch target and template in this alignment to get a deletion aln = seq.CreateAlignment(seq.CreateSequence('trg', 'GGG-GGG'), seq.CreateSequence('tpl', 'GGGAGGG')) aln.AttachView(1, tpl.CreateFullView()) - rmodel = rawmodel.BuildRawModel(aln) + rmodel = modelling.BuildRawModel(aln) self.assertEqual(len(rmodel.gaps), 1) # obtain the scorer scorer = loop.SetupBackboneScorer(rmodel) - rawmodel.CloseSmallDeletions(rmodel, scorer) + modelling.CloseSmallDeletions(rmodel, scorer) self.assertEqual(len(rmodel.gaps), 0) self.assertEqual(self.log.messages['VERBOSE'], ['Assigning MOL_IDs', @@ -47,15 +47,15 @@ class CloseGapsTests(unittest.TestCase): def testMergeGapsByDistance(self): # test that merging two close gaps works - tpl = io.LoadPDB('data/raw-modeling/1mcg.pdb') + tpl = io.LoadPDB('data/1mcg.pdb') aln = seq.CreateAlignment(seq.CreateSequence('trg', 'DDFAGDTKNLGHN'), seq.CreateSequence('tpl', 'NN----A----LF')) aln.AttachView(1, tpl.CreateFullView()) - rmodel = rawmodel.BuildRawModel(aln) + rmodel = modelling.BuildRawModel(aln) self.assertEqual(len(rmodel.gaps), 2) self.assertEqual(str(rmodel.gaps[0]), 'A.ASP2-(FAGD)-A.THR7') self.assertEqual(str(rmodel.gaps[1]), 'A.THR7-(KNLG)-A.HIS12') - rawmodel.MergeGapsByDistance(rmodel,0) + modelling.MergeGapsByDistance(rmodel,0) self.assertEqual(len(rmodel.gaps), 1) self.assertEqual(str(rmodel.gaps[0]), 'A.ASP2-(FAGDTKNLG)-A.HIS12') self.assertEqual(self.log.messages['VERBOSE'], @@ -68,38 +68,38 @@ class CloseGapsTests(unittest.TestCase): def testMergeGapsByDistanceBothTerminals(self): # test that we do not delete the whole thing for gaps at terminals - tpl = io.LoadPDB('data/raw-modeling/1mcg.pdb') + tpl = io.LoadPDB('data/1mcg.pdb') aln = seq.CreateAlignment(seq.CreateSequence('trg', 'DDFAGDTKNLGHN'), seq.CreateSequence('tpl', '----NNALF----')) aln.AttachView(1, tpl.CreateFullView()) - rmodel = rawmodel.BuildRawModel(aln) + rmodel = modelling.BuildRawModel(aln) self.assertEqual(len(rmodel.gaps), 2) - rawmodel.MergeGapsByDistance(rmodel,4) + modelling.MergeGapsByDistance(rmodel,4) self.assertEqual(len(rmodel.gaps), 2) def testMergeGapsByDistanceOneTerminal(self): # test that we do not delete the whole thing for gaps at terminals - tpl = io.LoadPDB('data/raw-modeling/1mcg.pdb') + tpl = io.LoadPDB('data/1mcg.pdb') aln = seq.CreateAlignment(seq.CreateSequence('trg', 'DDFAGDTKNLGHN'), seq.CreateSequence('tpl', 'NN----ALF----')) aln.AttachView(1, tpl.CreateFullView()) - rmodel = rawmodel.BuildRawModel(aln) + rmodel = modelling.BuildRawModel(aln) self.assertEqual(len(rmodel.gaps), 2) - rawmodel.MergeGapsByDistance(rmodel,2) + modelling.MergeGapsByDistance(rmodel,2) self.assertEqual(len(rmodel.gaps), 1) def testFillGapsByDatabase(self): # get rid of gaps by db - tpl = io.LoadPDB('data/raw-modeling/2dbs.pdb') + tpl = io.LoadPDB('data/2dbs.pdb') aln = seq.CreateAlignment( seq.CreateSequence('trg', 'TLNGFTVPAGNTLV--LNPDKGATVTMA'), seq.CreateSequence('tpl', 'NGGTLLIPNGTYHFLGIQMKSNVHIRVE')) aln.AttachView(1, tpl.CreateFullView()) - rmodel = rawmodel.BuildRawModel(aln) + rmodel = modelling.BuildRawModel(aln) self.assertEqual(len(rmodel.gaps), 1) scorer = loop.SetupBackboneScorer(rmodel) - rawmodel.FillLoopsByDatabase(rmodel, scorer, loop.LoadFragDB(), + modelling.FillLoopsByDatabase(rmodel, scorer, loop.LoadFragDB(), loop.LoadStructureDB(), loop.LoadTorsionSamplerCoil()) self.assertEqual(len(rmodel.gaps), 0) diff --git a/rawmodel/tests/test_gap_extension.py b/modelling/tests/test_gap_extension.py similarity index 87% rename from rawmodel/tests/test_gap_extension.py rename to modelling/tests/test_gap_extension.py index fecd7c3f..046446d3 100644 --- a/rawmodel/tests/test_gap_extension.py +++ b/modelling/tests/test_gap_extension.py @@ -1,15 +1,15 @@ import unittest -from promod3 import rawmodel +from promod3 import modelling from ost import io class GapExtension(unittest.TestCase): def testGapExtender(self): - ent = io.LoadPDB('data/loop/ext.pdb') + ent = io.LoadPDB('data/ext.pdb') chain = ent.chains[0] - gap = rawmodel.StructuralGap(chain.FindResidue(9), + gap = modelling.StructuralGap(chain.FindResidue(9), chain.FindResidue(11), 'X') - ext = rawmodel.GapExtender(gap) + ext = modelling.GapExtender(gap) self.assertEqual(str(gap), 'A.PRO9-(X)-A.TRP11') self.assertTrue(ext.Extend()) self.assertEqual(str(gap), 'A.THR8-(PX)-A.TRP11') diff --git a/rawmodel/tests/test_raw_modeling.py b/modelling/tests/test_modelling.py similarity index 73% rename from rawmodel/tests/test_raw_modeling.py rename to modelling/tests/test_modelling.py index 3be952b7..69c79bf9 100644 --- a/rawmodel/tests/test_raw_modeling.py +++ b/modelling/tests/test_modelling.py @@ -1,14 +1,14 @@ """ -Unit tests for rawmodel. +Unit tests for modelling. """ import unittest -from promod3 import rawmodel +from promod3 import modelling from ost import conop, seq, io, mol -class RawModelingTests(unittest.TestCase): +class ModellingTests(unittest.TestCase): def setUp(self): compound_lib = conop.CompoundLib.Load( - 'data/raw-modeling/compounds.chemlib') + 'data/compounds.chemlib') conop.SetDefaultLib(compound_lib) io.profiles['DEFAULT'].processor = conop.RuleBasedProcessor( compound_lib) @@ -17,23 +17,23 @@ class RawModelingTests(unittest.TestCase): # test that BuildRawModel throws exception when no view is attached aln = seq.CreateAlignment(seq.CreateSequence('A', 'acdef'), seq.CreateSequence('B', 'ac-ef')) - self.assertRaises(RuntimeError, rawmodel.BuildRawModel, aln) + self.assertRaises(RuntimeError, modelling.BuildRawModel, aln) def testModeledSequence(self): # test if the model has the sequence we want. - tpl = io.LoadPDB('data/raw-modeling/gly.pdb') - aln = io.LoadAlignment('data/raw-modeling/seq.fasta') + tpl = io.LoadPDB('data/gly.pdb') + aln = io.LoadAlignment('data/seq.fasta') aln.AttachView(1, tpl.CreateFullView()) - result = rawmodel.BuildRawModel(aln) + result = modelling.BuildRawModel(aln) seq1 = seq.SequenceFromChain('MODEL', result.model.chains[0]) self.assertEqual(seq1.string, aln.sequences[0].string) def testDeletion(self): # test if the result contains a "deletion" gap at the right spot. - tpl = io.LoadPDB('data/raw-modeling/gly.pdb') - aln = io.LoadAlignment('data/raw-modeling/del.fasta') + tpl = io.LoadPDB('data/gly.pdb') + aln = io.LoadAlignment('data/del.fasta') aln.AttachView(1, tpl.CreateFullView()) - result = rawmodel.BuildRawModel(aln) + result = modelling.BuildRawModel(aln) residues = result.model.residues self.assertEqual(len(result.gaps), 1) self.assertEqual(result.gaps[0].before, residues[2]) @@ -42,10 +42,10 @@ class RawModelingTests(unittest.TestCase): def testInsertion(self): # test if the result contains an "insertion" gap at the right spot. - tpl = io.LoadPDB('data/raw-modeling/gly.pdb') - aln = io.LoadAlignment('data/raw-modeling/ins.fasta') + tpl = io.LoadPDB('data/gly.pdb') + aln = io.LoadAlignment('data/ins.fasta') aln.AttachView(1, tpl.CreateFullView()) - result = rawmodel.BuildRawModel(aln) + result = modelling.BuildRawModel(aln) residues = result.model.residues self.assertEqual(len(result.gaps), 1) self.assertEqual(result.gaps[0].before, residues[1]) @@ -55,10 +55,10 @@ class RawModelingTests(unittest.TestCase): def testTer(self): # test if the result contains two terminal gaps, one at the beginning, # one at the end - tpl = io.LoadPDB('data/raw-modeling/gly.pdb') - aln = io.LoadAlignment('data/raw-modeling/ter.fasta') + tpl = io.LoadPDB('data/gly.pdb') + aln = io.LoadAlignment('data/ter.fasta') aln.AttachView(1, tpl.CreateFullView()) - result = rawmodel.BuildRawModel(aln) + result = modelling.BuildRawModel(aln) residues = result.model.residues self.assertEqual(len(result.gaps), 2) self.assertEqual(result.gaps[0].before, mol.ResidueHandle()) @@ -70,10 +70,10 @@ class RawModelingTests(unittest.TestCase): def testModified(self): # test if we correctly strip off modifications - tpl = io.LoadPDB('data/raw-modeling/sep.pdb') - aln = io.LoadAlignment('data/raw-modeling/sep.fasta') + tpl = io.LoadPDB('data/sep.pdb') + aln = io.LoadAlignment('data/sep.fasta') aln.AttachView(1, tpl.CreateFullView()) - result = rawmodel.BuildRawModel(aln) + result = modelling.BuildRawModel(aln) residues = result.model.residues self.assertEqual(len(residues), 1) self.assertEqual(len(residues[0].atoms), 6) @@ -86,10 +86,10 @@ class RawModelingTests(unittest.TestCase): def testInsertCBeta(self): # test if the dst residues contain cbeta, unless they are glycines - tpl = io.LoadPDB('data/raw-modeling/cbeta.pdb') - aln = io.LoadAlignment('data/raw-modeling/cbeta.fasta') + tpl = io.LoadPDB('data/cbeta.pdb') + aln = io.LoadAlignment('data/cbeta.fasta') aln.AttachView(1, tpl.CreateFullView()) - result = rawmodel.BuildRawModel(aln) + result = modelling.BuildRawModel(aln) residues = result.model.residues self.assertFalse(residues[0].FindAtom("CB").IsValid()) self.assertFalse(residues[1].FindAtom("CB").IsValid()) diff --git a/pipeline/pymod/CMakeLists.txt b/pipeline/pymod/CMakeLists.txt index 5ed2ecba..2d94a5b1 100644 --- a/pipeline/pymod/CMakeLists.txt +++ b/pipeline/pymod/CMakeLists.txt @@ -3,4 +3,4 @@ set(PIPELINE_PYMOD run_engine.py ) -pymod(NAME pipeline PY ${PIPELINE_PYMOD} DEPENDS_ON _rawmodel rawmodel_pymod) +pymod(NAME pipeline PY ${PIPELINE_PYMOD} DEPENDS_ON _modelling modelling_pymod) diff --git a/pipeline/pymod/run_engine.py b/pipeline/pymod/run_engine.py index a8e32b86..0acb61b2 100644 --- a/pipeline/pymod/run_engine.py +++ b/pipeline/pymod/run_engine.py @@ -4,16 +4,16 @@ import ost from promod3 import loop -from promod3 import rawmodel +from promod3 import modelling -def BuildFromRawModel(raw_model, structure_db=None, fragment_db=None, +def BuildFromRawModel(mhandle, structure_db=None, fragment_db=None, torsion_sampler=None, merge_distance=4): '''Build a model starting with a - :class:`RawModel <promod3.rawmodel.ModellingHandle>`. + :class:`raw model <promod3.modelling.ModellingHandle>`. - :param raw_model: The prepared template coordinates loaded with the input + :param mhandle: The prepared template coordinates loaded with the input alignment. - :type raw_model: :class:`~promod3.rawmodel.ModellingHandle` + :type mhandle: :class:`~promod3.modelling.ModellingHandle` :param structure_db: The structural database. Loads the default one shipped with |project| if omitted. @@ -49,34 +49,34 @@ def BuildFromRawModel(raw_model, structure_db=None, fragment_db=None, if torsion_sampler == None: torsion_sampler = loop.LoadTorsionSamplerCoil() - scorer = loop.SetupBackboneScorer(raw_model) + scorer = loop.SetupBackboneScorer(mhandle) # step 1: close small deletions in the raw model ost.LogVerbose("Trying to close small deletions (no. of gaps: %d)." % \ - len(raw_model.gaps)) - scorer = rawmodel.CloseSmallDeletions(raw_model, scorer) + len(mhandle.gaps)) + scorer = modelling.CloseSmallDeletions(mhandle, scorer) # step 2: simple handling of further gaps: merge, then fill from db for distance in range(merge_distance): # step 2a: Combine gaps living close to each other ost.LogVerbose("Trying to merge gaps (%d) with distance %d." % \ - (len(raw_model.gaps), distance)) - rawmodel.MergeGapsByDistance(raw_model, distance) - ost.LogVerbose("%d gap(s) left after merging.\n" % len(raw_model.gaps)+ + (len(mhandle.gaps), distance)) + modelling.MergeGapsByDistance(mhandle, distance) + ost.LogVerbose("%d gap(s) left after merging.\n" % len(mhandle.gaps)+ "Trying to fill loops by database") # step 2b: fit loops into the model - scorer = rawmodel.FillLoopsByDatabase(raw_model, scorer, fragment_db, + scorer = modelling.FillLoopsByDatabase(mhandle, scorer, fragment_db, structure_db, torsion_sampler, max_loops_to_search=30) ost.LogVerbose("%d gap(s) left after database search." % \ - len(raw_model.gaps)) - if len(raw_model.gaps) == 0: + len(mhandle.gaps)) + if len(mhandle.gaps) == 0: break - return raw_model.model + return mhandle.model __all__ = ('BuildProMod3Model') # LocalWords: BuildProMod ProMod sticked ost promod BuildFromRawModel param -# LocalWords: RawModel rtype bool LoadStructureDB LogVerbose LoadFragDB +# LocalWords: rtype bool LoadStructureDB LogVerbose LoadFragDB # LocalWords: LoadTorsionSamplerCoil SetupBackboneScorer # LocalWords: CloseSmallDeletions diff --git a/pipeline/tests/test_run_engine.py b/pipeline/tests/test_run_engine.py index ea131abf..17b1ada4 100644 --- a/pipeline/tests/test_run_engine.py +++ b/pipeline/tests/test_run_engine.py @@ -3,7 +3,7 @@ import os import ost from promod3 import pipeline -from promod3 import rawmodel +from promod3 import modelling class RunPipelineTests(unittest.TestCase): def testBuildFromRawModel(self): @@ -16,9 +16,9 @@ class RunPipelineTests(unittest.TestCase): template = ost.io.LoadPDB(os.path.join("data", "2l4k_B.pdb.gz")) aln = ost.io.LoadAlignment(os.path.join("data", "2l4k_B_aln.fasta")) aln.AttachView(1, template.Select('peptide=true')) - raw_model = rawmodel.BuildRawModel(aln) + mhandle = modelling.BuildRawModel(aln) # run the pipeline - self.assertTrue(pipeline.run_engine.BuildFromRawModel(raw_model)) + self.assertTrue(pipeline.run_engine.BuildFromRawModel(mhandle)) if __name__ == "__main__": from ost import testutils diff --git a/rawmodel/doc/CMakeLists.txt b/rawmodel/doc/CMakeLists.txt deleted file mode 100644 index 2f436174..00000000 --- a/rawmodel/doc/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(RAWMODEL_RST -index.rst -) - -add_doc_source(NAME rawmodel RST ${RAWMODEL_RST}) diff --git a/rawmodel/pymod/CMakeLists.txt b/rawmodel/pymod/CMakeLists.txt deleted file mode 100644 index 00f6f28f..00000000 --- a/rawmodel/pymod/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -set(RAWMODEL_CPP -wrap_rawmodel.cc -export_model.cc -export_gap.cc -export_gap_extender.cc -) - -set(RAWMODEL_PYMOD - __init__.py - _closegaps.py -) - -pymod(NAME rawmodel - CPP ${RAWMODEL_CPP} - PY ${RAWMODEL_PYMOD} - DEPENDS_ON core_pymod) diff --git a/rawmodel/pymod/__init__.py b/rawmodel/pymod/__init__.py deleted file mode 100644 index 78a1f850..00000000 --- a/rawmodel/pymod/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -""" -Initialise the rawmodel module. -""" -from _rawmodel import * -from _closegaps import * diff --git a/rawmodel/tests/CMakeLists.txt b/rawmodel/tests/CMakeLists.txt deleted file mode 100644 index d3005b81..00000000 --- a/rawmodel/tests/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -set(RAWMODEL_UNIT_TESTS - test_raw_modeling.py - test_gap_extension.py - test_close_gaps.py -) - -set(RAWMODEL_TEST_DATA - data/loop/ext.pdb - data/raw-modeling/compounds.chemlib - data/raw-modeling/gly.pdb - data/raw-modeling/ter.fasta - data/raw-modeling/sep.pdb - data/raw-modeling/sep.fasta - data/raw-modeling/seq.fasta - data/raw-modeling/ins.fasta - data/raw-modeling/del.fasta - data/raw-modeling/cbeta.pdb - data/raw-modeling/cbeta.fasta - data/raw-modeling/1mcg.pdb - data/raw-modeling/2dbs.pdb -) - -promod3_unittest(MODULE rawmodel - SOURCES "${RAWMODEL_UNIT_TESTS}" - DATA "${RAWMODEL_TEST_DATA}") diff --git a/sidechain/pymod/_reconstruct_sidechains.py b/sidechain/pymod/_reconstruct_sidechains.py index 33f029cc..fabd97e5 100644 --- a/sidechain/pymod/_reconstruct_sidechains.py +++ b/sidechain/pymod/_reconstruct_sidechains.py @@ -360,3 +360,5 @@ def Reconstruct(ent, keep_sidechains = False, build_disulfids = True, r.ApplyOnResidue(rh,True) +# these methods will be exported into module +__all__ = ('Reconstruct',) -- GitLab