Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
83e3c246
Commit
83e3c246
authored
7 years ago
by
Rafal Gumienny
Browse files
Options
Downloads
Patches
Plain Diff
feat: SCHWED-3119 Basic QS action
parent
3d08ffad
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
actions/CMakeLists.txt
+1
-1
1 addition, 1 deletion
actions/CMakeLists.txt
actions/ost-qs-score
+117
-0
117 additions, 0 deletions
actions/ost-qs-score
with
118 additions
and
1 deletion
actions/CMakeLists.txt
+
1
−
1
View file @
83e3c246
add_custom_target
(
actions ALL
)
add_custom_target
(
actions ALL
)
ost_action_init
()
ost_action_init
()
#
ost_action(
awesome-action
actions)
ost_action
(
ost-qs-score
actions
)
This diff is collapsed.
Click to expand it.
actions/ost-qs-score
0 → 100644
+
117
−
0
View file @
83e3c246
"""Calculate Quaternary Structure score (QS-score) between two complexes.
"""
import os
import sys
import argparse
import ost
from ost.io import LoadPDB, LoadMMCIF
from ost import PushVerbosityLevel
from ost.mol.alg import qsscoring
def _ParseArgs():
"""Parse command-line arguments."""
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description=__doc__,
prog="ost qs-score")
parser.add_argument(
'-v',
'--verbosity',
type=int,
default=3,
help="Set verbosity level.")
parser.add_argument(
"-m",
"--model",
dest="model",
required=True,
help=("Path to the model file."))
parser.add_argument(
"-r",
"--reference",
dest="reference",
required=True,
help=("Path to the reference file."))
parser.add_argument(
"-c",
"--chain-mapping",
nargs="+",
type=lambda x: x.split(":"),
dest="chain_mapping",
help=("Mapping of chains between the model and the reference. "
"Each separate mapping consist of key:value pairs where key "
"is the chain name in model and value is the chain name in "
"reference."))
opts = parser.parse_args()
if opts.chain_mapping is not None:
try:
opts.chain_mapping = dict(opts.chain_mapping)
except ValueError:
raise ValueError("Cannot parse chain mapping into dictionary. The "
"correct format is: key:value.")
return opts
def _ReadStructureFile(path):
"""Safely read structure file into OST entity.
The functin can read both PDB and mmCIF files.
:param path: Path to the file.
:type path: :class:`str`
:returns: Entity
:rtype: :class:`~ost.mol.EntityHandle`
"""
if not os.path.isfile(path):
raise IOError("%s is not a file" % path)
try:
ent = LoadPDB(path, profile="SLOPPY")
except IOError:
try:
ent = LoadMMCIF(path, profile="SLOPPY")
except IOError as err:
raise err
return ent
def _Main():
"""Do the magic."""
opts = _ParseArgs()
PushVerbosityLevel(opts.verbosity)
#
# Read the input files
ost.LogInfo("Reading model from %s" % opts.model)
model = _ReadStructureFile(opts.model)
ost.LogInfo("Reading reference from %s" % opts.reference)
reference = _ReadStructureFile(opts.reference)
#
# Perform scoring
try:
qs_scorer = qsscoring.QSscorer(reference,
model)
if opts.chain_mapping is not None:
ost.LogInfo(
"Using custom chain mapping: %s" % str(opts.chain_mapping))
qs_scorer.chain_mapping = opts.chain_mapping
ost.LogScript('QSscore:', str(qs_scorer.global_score))
ost.LogScript('Chain mapping used:', str(qs_scorer.chain_mapping))
except qsscoring.QSscoreError as ex:
# default handling: report failure and set score to 0
ost.LogError('QSscore failed:', str(ex))
if __name__ == '__main__':
# make script 'hot'
unbuffered = os.fdopen(sys.stdout.fileno(), 'w', 0)
sys.stdout = unbuffered
_Main()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment