From cfb041e7016cdb0d6e5f64ebf8fb63ee2bc23c5d Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Fri, 9 Nov 2018 16:02:48 +0100
Subject: [PATCH] The user can now add profiles to the build-model action

---
 actions/doc/index.rst  | 24 +++++++++++++++++++++++-
 actions/pm-build-model |  5 ++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/actions/doc/index.rst b/actions/doc/index.rst
index 6f997647..56a0e2a5 100644
--- a/actions/doc/index.rst
+++ b/actions/doc/index.rst
@@ -20,7 +20,7 @@ with
 .. code-block:: console
 
   $ pm build-model [-h] (-f <FILE> | -c <FILE> | -j <OBJECT>|<FILE>)
-                   (-p <FILE> | -e <FILE>) [-o <FILENAME>]
+                   (-p <FILE> | -e <FILE>) [-s <FILE>] [-o <FILENAME>]
 
 Example usage:
 
@@ -105,6 +105,28 @@ sequence names are:
 Example: ``... -p data/2jlp.pdb.gz``, where the pdb file has chains ``A``,
 ``B``, ``C`` and the template sequence is named ``2jlp.A|55``.
 
+
+You can optionally specify sequence profiles to be added (``-s``) and linked 
+to the corresponding target sequences. This has an impact on loop scoring with 
+the database approach. 
+The profiles can be provided as plain files or gzipped. Following file 
+extensions are understood: .hhm, .hhm.gz, .pssm, .pssm.gz.
+
+* The profiles are mapped based on exact matches towards the gapless
+  target sequences from the provided alignment files, 
+  i.e. one profile is mapped to several chains in case of homo-oligomers
+
+* Every profile must have a unique sequence to avoid ambiguities
+
+* All or nothing - You cannot provide profiles for only a subset of
+  target sequences
+
+Example usage:
+
+.. code-block:: console
+
+  $ pm build-model -f aln.fasta -p tpl.pdb -s prof.hhm
+
 Possible exit codes of the action:
 
 - 0: all went well
diff --git a/actions/pm-build-model b/actions/pm-build-model
index 1dcd882c..f7155293 100755
--- a/actions/pm-build-model
+++ b/actions/pm-build-model
@@ -23,6 +23,7 @@ ost.PushVerbosityLevel(2)
 parser = pm3argparse.PM3ArgumentParser(__doc__, action=True)
 parser.AddAlignment()
 parser.AddStructure(attach_views=True)
+parser.AddProfile()
 parser.AssembleParser()
 parser.add_argument('-o', '--model-file', metavar='<FILENAME>', type=str,
                     default='model.pdb', help='File to store model coordinates'+
@@ -43,11 +44,13 @@ for aln in opts.alignments:
     for i in range(1, aln.GetCount()):
         ost.mol.alg.AssignSecStruct(aln.GetSequence(i).GetAttachedView())
 
-
 # model it
 try:
     # get raw model
     mhandle = modelling.BuildRawModel(opts.alignments)
+    # add profiles if any
+    if len(opts.profiles) > 0:
+        modelling.SetSequenceProfiles(mhandle, opts.profiles)
     # build final model
     final_model = modelling.BuildFromRawModel(mhandle)
 except Exception as ex:
-- 
GitLab