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
a79b7251
Unverified
Commit
a79b7251
authored
1 year ago
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
fix: identify biounit with string id
parent
f90a1db8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
actions/ost-compare-ligand-structures
+18
-22
18 additions, 22 deletions
actions/ost-compare-ligand-structures
actions/ost-compare-structures
+17
-22
17 additions, 22 deletions
actions/ost-compare-structures
with
35 additions
and
44 deletions
actions/ost-compare-ligand-structures
+
18
−
22
View file @
a79b7251
...
@@ -139,11 +139,11 @@ def _ParseArgs():
...
@@ -139,11 +139,11 @@ def _ParseArgs():
dest="model_biounit",
dest="model_biounit",
required=False,
required=False,
default=None,
default=None,
type=
int
,
type=
str
,
help=("Only has an effect if model is in mmcif format. By default, "
help=("Only has an effect if model is in mmcif format. By default, "
"the asymmetric unit (AU) is used for scoring. If there are "
"the asymmetric unit (AU) is used for scoring. If there are "
"biounits defined in the mmcif file, you can specify the "
"biounits defined in the mmcif file, you can specify the "
"
(0-based) index
of the one which should be used."))
"
ID (as a string)
of the one which should be used."))
parser.add_argument(
parser.add_argument(
"-rb",
"-rb",
...
@@ -151,11 +151,11 @@ def _ParseArgs():
...
@@ -151,11 +151,11 @@ def _ParseArgs():
dest="reference_biounit",
dest="reference_biounit",
required=False,
required=False,
default=None,
default=None,
type=
int
,
type=
str
,
help=("Only has an effect if reference is in mmcif format. By default, "
help=("Only has an effect if reference is in mmcif format. By default, "
"the asymmetric unit (AU) is used for scoring. If there are "
"the asymmetric unit (AU) is used for scoring. If there are "
"biounits defined in the mmcif file, you can specify the "
"biounits defined in the mmcif file, you can specify the "
"
(0-based) index
of the one which should be used."))
"
ID (as a string)
of the one which should be used."))
parser.add_argument(
parser.add_argument(
"-ft",
"-ft",
...
@@ -317,7 +317,7 @@ def _GetStructureFormat(structure_path, sformat=None):
...
@@ -317,7 +317,7 @@ def _GetStructureFormat(structure_path, sformat=None):
f"file {structure_path}.")
f"file {structure_path}.")
def _LoadStructure(structure_path, sformat, fault_tolerant, bu_id
x
):
def _LoadStructure(structure_path, sformat, fault_tolerant, bu_id):
"""Read OST entity either from mmCIF or PDB.
"""Read OST entity either from mmCIF or PDB.
The returned structure has structure_path attached as structure name
The returned structure has structure_path attached as structure name
...
@@ -329,24 +329,20 @@ def _LoadStructure(structure_path, sformat, fault_tolerant, bu_idx):
...
@@ -329,24 +329,20 @@ def _LoadStructure(structure_path, sformat, fault_tolerant, bu_idx):
ost.PushVerbosityLevel(ost.LogLevel.Error)
ost.PushVerbosityLevel(ost.LogLevel.Error)
# Load the structure
# Load the structure
if sformat == "mmcif":
if sformat == "mmcif":
if bu_id
x
is not None:
if bu_id is not None:
cif_entity, cif_seqres, cif_info = \
cif_entity, cif_seqres, cif_info = \
io.LoadMMCIF(structure_path, info=True, seqres=True,
io.LoadMMCIF(structure_path, info=True, seqres=True,
fault_tolerant=fault_tolerant)
fault_tolerant=fault_tolerant)
if len(cif_info.biounits) == 0:
for biounit in cif_info.biounits:
raise RuntimeError(f"No biounit found - requested index"
if biounit.id == bu_id:
f" {bu_idx}.")
entity = ost.mol.alg.CreateBU(cif_entity, biounit)
elif bu_idx < 0:
if not entity.IsValid():
raise RuntimeError(f"Invalid biounit - requested index {bu_idx}, "
raise IOError(
f"must be a positive integer or 0.")
"Provided file does not contain valid entity.")
elif bu_idx >= len(cif_info.biounits):
break
raise RuntimeError(f"Invalid biounit - requested index {bu_idx}, "
else:
f"must be < {len(cif_info.biounits)}.")
raise RuntimeError(f"No biounit found with ID '{bu_id}'.")
biounit = cif_info.biounits[bu_idx]
entity = ost.mol.alg.CreateBU(cif_entity, biounit)
if not entity.IsValid():
raise IOError(
"Provided file does not contain valid entity.")
else:
else:
entity = io.LoadMMCIF(structure_path,
entity = io.LoadMMCIF(structure_path,
fault_tolerant = fault_tolerant)
fault_tolerant = fault_tolerant)
...
@@ -594,13 +590,13 @@ def _Main():
...
@@ -594,13 +590,13 @@ def _Main():
sformat=args.reference_format)
sformat=args.reference_format)
reference = _LoadStructure(args.reference,
reference = _LoadStructure(args.reference,
sformat=reference_format,
sformat=reference_format,
bu_id
x
=args.reference_biounit,
bu_id=args.reference_biounit,
fault_tolerant = args.fault_tolerant)
fault_tolerant = args.fault_tolerant)
model_format = _GetStructureFormat(args.model,
model_format = _GetStructureFormat(args.model,
sformat=args.model_format)
sformat=args.model_format)
model = _LoadStructure(args.model,
model = _LoadStructure(args.model,
sformat=model_format,
sformat=model_format,
bu_id
x
=args.model_biounit,
bu_id=args.model_biounit,
fault_tolerant = args.fault_tolerant)
fault_tolerant = args.fault_tolerant)
# Load ligands
# Load ligands
...
...
This diff is collapsed.
Click to expand it.
actions/ost-compare-structures
+
17
−
22
View file @
a79b7251
...
@@ -141,11 +141,11 @@ def _ParseArgs():
...
@@ -141,11 +141,11 @@ def _ParseArgs():
dest="model_biounit",
dest="model_biounit",
required=False,
required=False,
default=None,
default=None,
type=
int
,
type=
str
,
help=("Only has an effect if model is in mmcif format. By default, "
help=("Only has an effect if model is in mmcif format. By default, "
"the asymmetric unit (AU) is used for scoring. If there are "
"the asymmetric unit (AU) is used for scoring. If there are "
"biounits defined in the mmcif file, you can specify the "
"biounits defined in the mmcif file, you can specify the "
"
(0-based) index
of the one which should be used."))
"
ID (as a string)
of the one which should be used."))
parser.add_argument(
parser.add_argument(
"-rb",
"-rb",
...
@@ -153,11 +153,11 @@ def _ParseArgs():
...
@@ -153,11 +153,11 @@ def _ParseArgs():
dest="reference_biounit",
dest="reference_biounit",
required=False,
required=False,
default=None,
default=None,
type=
int
,
type=
str
,
help=("Only has an effect if reference is in mmcif format. By default, "
help=("Only has an effect if reference is in mmcif format. By default, "
"the asymmetric unit (AU) is used for scoring. If there are "
"the asymmetric unit (AU) is used for scoring. If there are "
"biounits defined in the mmcif file, you can specify the "
"biounits defined in the mmcif file, you can specify the "
"
(0-based) index
of the one which should be used."))
"
ID (as a string)
of the one which should be used."))
parser.add_argument(
parser.add_argument(
"-rna",
"-rna",
...
@@ -563,7 +563,7 @@ def _GetStructureFormat(structure_path, sformat=None):
...
@@ -563,7 +563,7 @@ def _GetStructureFormat(structure_path, sformat=None):
raise Exception(f"Unknown/unsupported file format found for "
raise Exception(f"Unknown/unsupported file format found for "
f"file {structure_path}.")
f"file {structure_path}.")
def _LoadStructure(structure_path, sformat, fault_tolerant, bu_id
x
):
def _LoadStructure(structure_path, sformat, fault_tolerant, bu_id):
"""Read OST entity either from mmCIF or PDB.
"""Read OST entity either from mmCIF or PDB.
The returned structure has structure_path attached as structure name
The returned structure has structure_path attached as structure name
...
@@ -575,24 +575,19 @@ def _LoadStructure(structure_path, sformat, fault_tolerant, bu_idx):
...
@@ -575,24 +575,19 @@ def _LoadStructure(structure_path, sformat, fault_tolerant, bu_idx):
ost.PushVerbosityLevel(ost.LogLevel.Error)
ost.PushVerbosityLevel(ost.LogLevel.Error)
# Load the structure
# Load the structure
if sformat == "mmcif":
if sformat == "mmcif":
if bu_id
x
is not None:
if bu_id is not None:
cif_entity, cif_seqres, cif_info = \
cif_entity, cif_seqres, cif_info = \
io.LoadMMCIF(structure_path, info=True, seqres=True,
io.LoadMMCIF(structure_path, info=True, seqres=True,
fault_tolerant=fault_tolerant)
fault_tolerant=fault_tolerant)
if len(cif_info.biounits) == 0:
for biounit in cif_info.biounits:
raise RuntimeError(f"No biounit found - requested index"
if biounit.id == bu_id:
f" {bu_idx}.")
entity = ost.mol.alg.CreateBU(cif_entity, biounit)
elif bu_idx < 0:
if not entity.IsValid():
raise RuntimeError(f"Invalid biounit - requested index {bu_idx}, "
raise IOError(
f"must be a positive integer or 0.")
"Provided file does not contain valid entity.")
elif bu_idx >= len(cif_info.biounits):
break
raise RuntimeError(f"Invalid biounit - requested index {bu_idx}, "
else:
f"must be < {len(cif_info.biounits)}.")
raise RuntimeError(f"No biounit found with ID '{bu_id}'.")
biounit = cif_info.biounits[bu_idx]
entity = ost.mol.alg.CreateBU(cif_entity, biounit)
if not entity.IsValid():
raise IOError(
"Provided file does not contain valid entity.")
else:
else:
entity = io.LoadMMCIF(structure_path,
entity = io.LoadMMCIF(structure_path,
fault_tolerant = fault_tolerant)
fault_tolerant = fault_tolerant)
...
@@ -870,13 +865,13 @@ def _Main():
...
@@ -870,13 +865,13 @@ def _Main():
sformat=args.reference_format)
sformat=args.reference_format)
reference = _LoadStructure(args.reference,
reference = _LoadStructure(args.reference,
sformat=reference_format,
sformat=reference_format,
bu_id
x
=args.reference_biounit,
bu_id=args.reference_biounit,
fault_tolerant = args.fault_tolerant)
fault_tolerant = args.fault_tolerant)
model_format = _GetStructureFormat(args.model,
model_format = _GetStructureFormat(args.model,
sformat=args.model_format)
sformat=args.model_format)
model = _LoadStructure(args.model,
model = _LoadStructure(args.model,
sformat=model_format,
sformat=model_format,
bu_id
x
=args.model_biounit,
bu_id=args.model_biounit,
fault_tolerant = args.fault_tolerant)
fault_tolerant = args.fault_tolerant)
out = _Process(model, reference, args, model_format, reference_format)
out = _Process(model, reference, args, model_format, reference_format)
...
...
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