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
6c3fccbd
Unverified
Commit
6c3fccbd
authored
1 year ago
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
feat: SCHWED-5954 add unassigned ligands to action
parent
5295fcb7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
actions/ost-compare-ligand-structures
+75
-40
75 additions, 40 deletions
actions/ost-compare-ligand-structures
with
75 additions
and
40 deletions
actions/ost-compare-ligand-structures
+
75
−
40
View file @
6c3fccbd
...
@@ -193,6 +193,15 @@ def _ParseArgs():
...
@@ -193,6 +193,15 @@ def _ParseArgs():
action="store_true",
action="store_true",
help=("Use RMSD for ligand assignment."))
help=("Use RMSD for ligand assignment."))
parser.add_argument(
"-u",
"--unassigned",
dest="unassigned",
default=False,
action="store_true",
help=("Report unassigned ligands in the output together with assigned "
"ligands."))
parser.add_argument(
parser.add_argument(
"--lddt-pli",
"--lddt-pli",
dest="lddt_pli",
dest="lddt_pli",
...
@@ -354,6 +363,7 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
...
@@ -354,6 +363,7 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
substructure_match=args.substructure_match,
substructure_match=args.substructure_match,
global_chain_mapping=args.global_chain_mapping,
global_chain_mapping=args.global_chain_mapping,
rmsd_assignment=args.rmsd_assignment,
rmsd_assignment=args.rmsd_assignment,
unassigned=args.unassigned,
radius=args.radius,
radius=args.radius,
lddt_pli_radius=args.lddt_pli_radius,
lddt_pli_radius=args.lddt_pli_radius,
lddt_lp_radius=args.lddt_lp_radius,
lddt_lp_radius=args.lddt_lp_radius,
...
@@ -367,8 +377,8 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
...
@@ -367,8 +377,8 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
# Replace model ligand by path
# Replace model ligand by path
if len(model_ligands) == len(scorer.model_ligands):
if len(model_ligands) == len(scorer.model_ligands):
# Map ligand => path
# Map ligand => path
model_ligands_map = {k: v for k, v in zip(
scorer.model_ligands,
model_ligands_map = {k
.hash_code
: v for k, v in zip(
args.model_ligands)}
scorer.model_ligands,
args.model_ligands)}
out["model_ligands"] = args.model_ligands
out["model_ligands"] = args.model_ligands
elif len(model_ligands) < len(scorer.model_ligands):
elif len(model_ligands) < len(scorer.model_ligands):
# Multi-ligand SDF files were given
# Multi-ligand SDF files were given
...
@@ -384,7 +394,7 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
...
@@ -384,7 +394,7 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
"(%d) than given (%d)" % (
"(%d) than given (%d)" % (
len(scorer.model_ligands), len(model_ligands)))
len(scorer.model_ligands), len(model_ligands)))
else:
else:
model_ligands_map = {l: _QualifiedResidueNotation(l)
model_ligands_map = {l
.hash_code
: _QualifiedResidueNotation(l)
for l in scorer.model_ligands}
for l in scorer.model_ligands}
out["model_ligands"] = list(model_ligands_map.values())
out["model_ligands"] = list(model_ligands_map.values())
...
@@ -392,8 +402,8 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
...
@@ -392,8 +402,8 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
# Replace reference ligand by path
# Replace reference ligand by path
if len(reference_ligands) == len(scorer.target_ligands):
if len(reference_ligands) == len(scorer.target_ligands):
# Map ligand => path
# Map ligand => path
reference_ligands_map = {k: v for k, v in zip(
scorer.target_ligands,
reference_ligands_map = {k
.hash_code
: v for k, v in zip(
args.reference_ligands)}
scorer.target_ligands,
args.reference_ligands)}
out["reference_ligands"] = args.reference_ligands
out["reference_ligands"] = args.reference_ligands
elif len(reference_ligands) < len(scorer.target_ligands):
elif len(reference_ligands) < len(scorer.target_ligands):
# Multi-ligand SDF files were given
# Multi-ligand SDF files were given
...
@@ -410,53 +420,78 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
...
@@ -410,53 +420,78 @@ def _Process(model, model_ligands, reference, reference_ligands, args):
len(scorer.target_ligands), len(reference_ligands)))
len(scorer.target_ligands), len(reference_ligands)))
else:
else:
reference_ligands_map = {l: _QualifiedResidueNotation(l)
reference_ligands_map = {l
.hash_code
: _QualifiedResidueNotation(l)
for l in scorer.target_ligands}
for l in scorer.target_ligands}
out["reference_ligands"] = list(reference_ligands_map.values())
out["reference_ligands"] = list(reference_ligands_map.values())
if not (args.lddt_pli or args.rmsd):
ost.LogWarning("No score selected, output will be empty.")
else:
out["unassigned_model_ligands"] = {}
for chain, unassigned_residues in scorer.unassigned_model_ligands.items():
for resnum, unassigned in unassigned_residues.items():
mdl_lig = scorer.model.FindResidue(chain, resnum)
out["unassigned_model_ligands"][model_ligands_map[
mdl_lig.hash_code]] = unassigned
out["unassigned_reference_ligands"] = {}
for chain, unassigned_residues in scorer.unassigned_target_ligands.items():
for resnum, unassigned in unassigned_residues.items():
trg_lig = scorer.target.FindResidue(chain, resnum)
out["unassigned_reference_ligands"][reference_ligands_map[
trg_lig.hash_code]] = unassigned
if args.lddt_pli:
if args.lddt_pli:
out["lddt_pli"] = {}
out["lddt_pli"] = {}
for chain, lddt_pli_results in scorer.lddt_pli_details.items():
for chain, lddt_pli_results in scorer.lddt_pli_details.items():
for _, lddt_pli in lddt_pli_results.items():
for resnum, lddt_pli in lddt_pli_results.items():
model_key = model_ligands_map[lddt_pli["model_ligand"]]
if args.unassigned and lddt_pli["unassigned"]:
lddt_pli["reference_ligand"] = reference_ligands_map[
mdl_lig = scorer.model.FindResidue(chain, resnum)
lddt_pli.pop("target_ligand")]
model_key = model_ligands_map[mdl_lig.hash_code]
lddt_pli["model_ligand"] = model_key
else:
transform_data = lddt_pli["transform"].data
model_key = model_ligands_map[lddt_pli["model_ligand"].hash_code]
lddt_pli["transform"] = [transform_data[i:i + 4]
lddt_pli["reference_ligand"] = reference_ligands_map[
for i in range(0, len(transform_data),
lddt_pli.pop("target_ligand").hash_code]
4)]
lddt_pli["model_ligand"] = model_key
lddt_pli["bs_ref_res"] = [_QualifiedResidueNotation(r) for r in
transform_data = lddt_pli["transform"].data
lddt_pli["bs_ref_res"]]
lddt_pli["transform"] = [transform_data[i:i + 4]
lddt_pli["bs_ref_res_mapped"] = [_QualifiedResidueNotation(r) for r in
for i in range(0, len(transform_data),
lddt_pli["bs_ref_res_mapped"]]
4)]
lddt_pli["bs_mdl_res_mapped"] = [_QualifiedResidueNotation(r) for r in
lddt_pli["bs_ref_res"] = [_QualifiedResidueNotation(r) for r in
lddt_pli["bs_mdl_res_mapped"]]
lddt_pli["bs_ref_res"]]
lddt_pli["inconsistent_residues"] = ["%s-%s" %(
lddt_pli["bs_ref_res_mapped"] = [_QualifiedResidueNotation(r) for r in
_QualifiedResidueNotation(x), _QualifiedResidueNotation(y)) for x,y in lddt_pli[
lddt_pli["bs_ref_res_mapped"]]
"inconsistent_residues"]]
lddt_pli["bs_mdl_res_mapped"] = [_QualifiedResidueNotation(r) for r in
lddt_pli["bs_mdl_res_mapped"]]
lddt_pli["inconsistent_residues"] = ["%s-%s" %(
_QualifiedResidueNotation(x), _QualifiedResidueNotation(y)) for x,y in lddt_pli[
"inconsistent_residues"]]
out["lddt_pli"][model_key] = lddt_pli
out["lddt_pli"][model_key] = lddt_pli
if args.rmsd:
if args.rmsd:
out["rmsd"] = {}
out["rmsd"] = {}
for chain, rmsd_results in scorer.rmsd_details.items():
for chain, rmsd_results in scorer.rmsd_details.items():
for _, rmsd in rmsd_results.items():
for _, rmsd in rmsd_results.items():
model_key = model_ligands_map[rmsd["model_ligand"]]
if args.unassigned and rmsd["unassigned"]:
rmsd["reference_ligand"] = reference_ligands_map[
mdl_lig = scorer.model.FindResidue(chain, resnum)
rmsd.pop("target_ligand")]
model_key = model_ligands_map[mdl_lig.hash_code]
rmsd["model_ligand"] = model_key
else:
transform_data = rmsd["transform"].data
model_key = model_ligands_map[rmsd["model_ligand"].hash_code]
rmsd["transform"] = [transform_data[i:i + 4]
rmsd["reference_ligand"] = reference_ligands_map[
for i in range(0, len(transform_data), 4)]
rmsd.pop("target_ligand").hash_code]
rmsd["bs_ref_res"] = [_QualifiedResidueNotation(r) for r in
rmsd["model_ligand"] = model_key
rmsd["bs_ref_res"]]
transform_data = rmsd["transform"].data
rmsd["bs_ref_res_mapped"] = [_QualifiedResidueNotation(r) for r in
rmsd["transform"] = [transform_data[i:i + 4]
rmsd["bs_ref_res_mapped"]]
for i in range(0, len(transform_data), 4)]
rmsd["bs_mdl_res_mapped"] = [_QualifiedResidueNotation(r) for r in
rmsd["bs_ref_res"] = [_QualifiedResidueNotation(r) for r in
rmsd["bs_mdl_res_mapped"]]
rmsd["bs_ref_res"]]
rmsd["inconsistent_residues"] = ["%s-%s" %(
rmsd["bs_ref_res_mapped"] = [_QualifiedResidueNotation(r) for r in
_QualifiedResidueNotation(x), _QualifiedResidueNotation(y)) for x,y in rmsd[
rmsd["bs_ref_res_mapped"]]
"inconsistent_residues"]]
rmsd["bs_mdl_res_mapped"] = [_QualifiedResidueNotation(r) for r in
rmsd["bs_mdl_res_mapped"]]
rmsd["inconsistent_residues"] = ["%s-%s" %(
_QualifiedResidueNotation(x), _QualifiedResidueNotation(y)) for x,y in rmsd[
"inconsistent_residues"]]
out["rmsd"][model_key] = rmsd
out["rmsd"][model_key] = rmsd
return out
return out
...
...
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