choderalab / perses

Experiments with expanded ensembles to explore chemical space
http://perses.readthedocs.io
MIT License
181 stars 51 forks source link

Cycle forming detection bug #453

Closed pgrinaway closed 6 years ago

pgrinaway commented 6 years ago

I was running a pair of CDK2 inhibitors (from the yaml example in the repo), and I got the traceback below. I think this is from the cycle forming/breaking detection code. Perhaps you have some insight as to why this might be @jchodera ?

  File "/home/pgrinaway/perses/scripts/setup_relative_calculation.py", line 46, in <module>
    fe_setup, ne_fep = relative_setup.run_setup(setup_options)
  File "/home/pgrinaway/anaconda3/lib/python3.6/site-packages/perses-0.1-py3.6.egg/perses/dispersed/relative_setup.py", line 736, in run_setup
    fe_setup = NonequilibriumFEPSetup(ligand_file, old_ligand_index, new_ligand_index, forcefield_files, protein_pdb_filename=protein_pdb_filename, receptor_mol2_filename=receptor_mol2, pressure=pressure, temperature=temperature, solvent_padding=solvent_padding_angstroms, solvate=solvate)
  File "/home/pgrinaway/anaconda3/lib/python3.6/site-packages/perses-0.1-py3.6.egg/perses/dispersed/relative_setup.py", line 162, in __init__
    self._complex_topology_proposal = self._complex_proposal_engine.propose(self._complex_system_old_solvated, self._complex_topology_old_solvated)
  File "/home/pgrinaway/anaconda3/lib/python3.6/site-packages/perses-0.1-py3.6.egg/perses/rjmc/topology_proposal.py", line 1366, in propose
    mol_atom_map = self._get_mol_atom_map(current_mol, proposed_mol, atom_expr=self.atom_expr, bond_expr=self.bond_expr, verbose=self.verbose, allow_ring_breaking=self._allow_ring_breaking)
  File "/home/pgrinaway/anaconda3/lib/python3.6/site-packages/perses-0.1-py3.6.egg/perses/rjmc/topology_proposal.py", line 1657, in _get_mol_atom_map
    matches = [m for m in matches if preserves_rings(m)]
  File "/home/pgrinaway/anaconda3/lib/python3.6/site-packages/perses-0.1-py3.6.egg/perses/rjmc/topology_proposal.py", line 1657, in <listcomp>
    matches = [m for m in matches if preserves_rings(m)]
  File "/home/pgrinaway/anaconda3/lib/python3.6/site-packages/perses-0.1-py3.6.egg/perses/rjmc/topology_proposal.py", line 1646, in preserves_rings
    if breaks_rings_in_transformation(oegraphmol_current, oegraphmol_proposed, pattern_to_target_map):
  File "/home/pgrinaway/anaconda3/lib/python3.6/site-packages/perses-0.1-py3.6.egg/perses/rjmc/topology_proposal.py", line 1631, in breaks_rings_in_transformation
    for cycle in enumerate_cycle_basis(molecule1):
  File "/home/pgrinaway/anaconda3/lib/python3.6/site-packages/perses-0.1-py3.6.egg/perses/rjmc/topology_proposal.py", line 1607, in enumerate_cycle_basis
    edge = g.edges[atom_index_1,atom_index_2]
TypeError: 'method' object is not subscriptable
pgrinaway commented 6 years ago

Oh, it looks like you need to do something like edge = g.edges()[atom_index_1,atom_index_2]

rather than

edge = g.edges[atom_index_1,atom_index_2]

pgrinaway commented 6 years ago

Oh, no, that's wrong...

pgrinaway commented 6 years ago

Looks like in a toy I can subscript the edges. Weird...

jchodera commented 6 years ago

I suspect either you have an older version of networkx installed or I used the old API accidentally in one or two places that weren't covered by tests.

jchodera commented 6 years ago
>>> import networkx as nx
>>> nx.__version__
'2.0'
>>> g = nx.Graph()
>>> g.add_edge(1,2)
>>> g.edges[1,2]
{}

Go ahead and close this if it's resolved by updating your networkx to >= 2.0.

pgrinaway commented 6 years ago

Sorry, lilac was being crazy slow. I'm trying this now. I think you're probably right about the version.

pgrinaway commented 6 years ago

I think this is resolved with networkx update.