choderalab / yank

An open, extensible Python framework for GPU-accelerated alchemical free energy calculations.
http://getyank.org
MIT License
181 stars 72 forks source link

ValueError: attempt to get argmin of an empty sequence for p #380

Closed spadavec closed 8 years ago

spadavec commented 8 years ago

With the latest version of YANK, running the p-xylene-implicit example, via:

yank prepare binding amber --setupdir=setup --ligand="resname BEN" --store=output --iterations=1000 --restraints=harmonic --gbsa=OBC2 --temperature=300*kelvin --verbose

Results in the following error:

Traceback (most recent call last):
  File "/Users/FFF/anaconda/bin/yank", line 9, in <module>
    load_entry_point('yank==0.9.0', 'console_scripts', 'yank')()
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/cli.py", line 105, in main
    dispatched = getattr(commands, command).dispatch(args)
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/commands/prepare.py", line 40, in dispatch
    return dispatch_binding(args)
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/commands/prepare.py", line 254, in dispatch_binding
    utils.config_root_logger(verbose, log_file_path=os.path.join(store_dir, 'prepare.log'))
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/utils.py", line 128, in config_root_logger
    file_handler = logging.FileHandler(log_file_path)
  File "/Users/FFF/anaconda/lib/python2.7/logging/__init__.py", line 905, in __init__
    StreamHandler.__init__(self, self._open())
  File "/Users/FFF/anaconda/lib/python2.7/logging/__init__.py", line 935, in _open
    stream = open(self.baseFilename, self.mode)
IOError: [Errno 2] No such file or directory: '/Users/FFF/anaconda/pkgs/yank/examples/p-xylene-implicit/output/prepare.log'

To get around this, if you mkdir "output" in the same directory, and re-run the above command, the new error becomes:

2016-06-01 00:20:02,601: reading phase complex: 
2016-06-01 00:20:02,602: prmtop: setup/complex.prmtop
2016-06-01 00:20:02,602: inpcrd: setup/complex.inpcrd
2016-06-01 00:20:02,972: reading phase solvent: 
2016-06-01 00:20:02,973: prmtop: setup/solvent.prmtop
2016-06-01 00:20:02,973: inpcrd: setup/solvent.inpcrd
2016-06-01 00:20:03,000: TOTAL ATOMS      :      2621
2016-06-01 00:20:03,000: receptor         :      2621
2016-06-01 00:20:03,000: ligand           :         0
2016-06-01 00:20:03,000: phases: ['complex-implicit', 'solvent-implicit']
2016-06-01 00:20:03,000: systems: ['complex-implicit', 'solvent-implicit']
2016-06-01 00:20:03,001: positions: ['complex-implicit', 'solvent-implicit']
2016-06-01 00:20:03,001: atom_indices: ['complex-implicit', 'solvent-implicit']
2016-06-01 00:20:03,001: thermodynamic_state: <ThermodynamicState object, temperature = 300 K, pressure = 1 atm>
2016-06-01 00:20:03,266: Creating receptor-ligand restraints...
Traceback (most recent call last):
  File "/Users/FFF/anaconda/bin/yank", line 9, in <module>
    load_entry_point('yank==0.9.0', 'console_scripts', 'yank')()
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/cli.py", line 105, in main
    dispatched = getattr(commands, command).dispatch(args)
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/commands/prepare.py", line 40, in dispatch
    return dispatch_binding(args)
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/commands/prepare.py", line 336, in dispatch_binding
    yank.create(phases, systems, positions, atom_indices, thermodynamic_state)
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/yank.py", line 231, in create
    self._create_phase(phase, systems[phase], positions[phase], atom_indices[phase], thermodynamic_state, protocols=protocols)
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/yank.py", line 328, in _create_phase
    restraints = HarmonicReceptorLigandRestraint(thermodynamic_state, reference_system, reference_positions, atom_indices['receptor'], atom_indices['ligand'])
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/restraints.py", line 104, in __init__
    self.restrained_ligand_atom = self._closestAtomToCentroid(self.coordinates, self.ligand_atoms)
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/yank-0.9.0-py2.7-macosx-10.5-x86_64.egg/yank/restraints.py", line 389, in _closestAtomToCentroid
    closest_atom = int(np.argmin(distances))
  File "/Users/FFF/anaconda/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 1028, in argmin
    return argmin(axis, out)

This is run on OSX 10.11.13 using YANK 0.9.0

jchodera commented 8 years ago

Thanks for catching this! We must have missed it in our automated testing of examples, which I notice doesn't have a badge on the front page. I'll add the badge.

@andrrizzi : Can you see if the setup pipeline is trying to create prepare.log before the output store directory is created? If so, we should move up creation of the output store to earlier in the setup process.

We should also convert this example over to the new YAML format. We should probably leave one or two examples of the old CLI format, but steer people toward the new format. Can you tackle that once you have the fellowship in?

andrrizzi commented 8 years ago

@spadavec, thanks for catching this! I can't actually see the new error. The last two lines I see in the log are

  File "/Users/FFF/anaconda/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 1028, in argmin
    return argmin(axis, out)

the description of the error should be after that.

Can you see if the setup pipeline is trying to create prepare.log before the output store directory is created?

If I remember correctly, with the command line interface we always had to create the output directory manually. All the run.sh scripts should have a mkdir output directive before calling yank prepare. The YAML setup pipeline creates the folder for you correctly.

Can you tackle that once you have the fellowship in?

Of course!

andrrizzi commented 8 years ago

By the way, I think with the new alchemy, the command line interface should not be used anymore. The default value of softcore_beta is 1.0, the default alchemical path does not annihilate electrostatic interactions before the sterics, and there is no way to change that through a CLI option.

jchodera commented 8 years ago

OK! Should we fully remove the CLI for yank setup or just add a "This option has been deprecated, please use the YAML" version for now?

jchodera commented 8 years ago

Alternatively, we could add the deprecation warning and have this option generate a YAML file you can use that matches recommended parameters.

andrrizzi commented 8 years ago

I would add the deprecation warning for now because the YAML pipeline is currently not flexible enough to completely substitute the CLI.

and have this option generate a YAML file you can use that matches recommended parameters

Great idea! I'll open a new issue to discuss this.

andrrizzi commented 8 years ago

The error comes up because the DSL string passed is --ligand="resname BEN" instead of --ligand="resname MOL" (the resname must match the one in the pdb file for the system).

We need better error handling for this as pointed out in #383 .

jchodera commented 8 years ago

We can probably raise an informative exception if the DSL fails to match any atoms

andrrizzi commented 8 years ago

Closing this as it was only an error in the command parameters. The PR #389 adds a more informative error message.