Skip to content

Unassigned current_directive when merging protein+ligand #1212

@davidlmobley

Description

@davidlmobley

Description

We were trying to use an experimental feature (via INTERCHANGE_EXPERIMENTAL) to merge a protein+ligand complex for simulation and encountered an issue where we get an UnboundLocalError: cannot access local variable 'current_directive' where it is not associated with a value; it's unclear what this means/how to fix.

Reproduction

Attached Jupyter notebook and input files. This comes from work of new student @kphuynh118 in my group so if additional files are needed she can likely provide.

GitHub doesn't want to let me to attach top/gro/sdf for some reason, so files are here on Dropbox

Output

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[11], line 2
      1 os.environ["INTERCHANGE_EXPERIMENTAL"]="1"
----> 2 protein_interchange = Interchange.from_gromacs("protein.top", "protein.gro")
      3 complex_interchange = protein_interchange + ligand_interchange

File ~/miniforge3/envs/drugcomp1/lib/python3.12/site-packages/openff/interchange/_experimental.py:35, in experimental.<locals>.wrapper(*args, **kwargs)
     26 if os.environ.get("INTERCHANGE_EXPERIMENTAL", "0") != "1":
     27     raise ExperimentalFeatureException(
     28         f"\n\tFunction or method {func.__name__} is experimental. This feature is not "
     29         "complete, not yet reliable, and/or needs more testing to be considered suitable "
   (...)
     32         "INTERCHANGE_EXPERIMENTAL=1.",
     33     )
---> 35 return func(*args, **kwargs)

File ~/miniforge3/envs/drugcomp1/lib/python3.12/site-packages/openff/interchange/components/interchange.py:875, in Interchange.from_gromacs(cls, topology_file, gro_file)
    871 from openff.interchange.interop.gromacs._import._import import from_files
    872 from openff.interchange.interop.gromacs._interchange import to_interchange
    874 return to_interchange(
--> 875     from_files(
    876         top_file=topology_file,
    877         gro_file=gro_file,
    878     ),
    879 )

File ~/miniforge3/envs/drugcomp1/lib/python3.12/site-packages/openff/interchange/_experimental.py:35, in experimental.<locals>.wrapper(*args, **kwargs)
     26 if os.environ.get("INTERCHANGE_EXPERIMENTAL", "0") != "1":
     27     raise ExperimentalFeatureException(
     28         f"\n\tFunction or method {func.__name__} is experimental. This feature is not "
     29         "complete, not yet reliable, and/or needs more testing to be considered suitable "
   (...)
     32         "INTERCHANGE_EXPERIMENTAL=1.",
     33     )
---> 35 return func(*args, **kwargs)

File ~/miniforge3/envs/drugcomp1/lib/python3.12/site-packages/openff/interchange/interop/gromacs/_import/_import.py:50, in from_files(top_file, gro_file, cls)
     46     current_directive = stripped[1:-1].strip()
     48     continue
---> 50 if current_directive == "defaults":
     51     (
     52         nonbonded_function,
     53         combination_rule,
   (...)
     56         coul_14,
     57     ) = _process_defaults(line)
     59     system = cls(
     60         nonbonded_function=nonbonded_function,
     61         combination_rule=combination_rule,
   (...)
     64         coul_14=coul_14,
     65     )

UnboundLocalError: cannot access local variable 'current_directive' where it is not associated with a value

Software versions

This is on OS X via a mamba install. @kphuynh118 can you add the output of conda list?

Metadata

Metadata

Assignees

Labels

gromacsrelating to GROMACS

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions