openff-toolkit icon indicating copy to clipboard operation
openff-toolkit copied to clipboard

Modify Antechamber source code to allow for keywords -ek maxcyc=0

Open khuddzu opened this issue 3 years ago • 4 comments

I would like to run the equivalent of the command line code below in openff.

antechamber -i l.pdb -fi pdb -o l.mol2 -fo mol2 -c bcc -ek “maxcyc=0”

I found this part of the assign_partial_charges function in ambertools_wrapper.py:

                # Compute desired charges
                # TODO: Add error handling if antechamber chokes
                short_charge_method = charge_method["antechamber_keyword"]
                subprocess.check_output(
                    [
                        "antechamber",
                        "-i",
                        "molecule.sdf",
                        "-fi",
                        "sdf",
                        "-o",
                        "charged.mol2",
                        "-fo",
                        "mol2",
                        "-pf",
                        "yes",
                        "-dr",
                        "n",
                        "-c",
                        short_charge_method,
                        "-nc",
                        str(net_charge),
                    ]
                )

I changed it to this:

                # Compute desired charges
                # TODO: Add error handling if antechamber chokes
                short_charge_method = charge_method["antechamber_keyword"]
                subprocess.check_output(
                        [
                            "antechamber",
                            "-i",
                            "molecule.sdf",
                            "-fi",
                            "sdf",
                            "-o",
                            "charged.mol2",
                            "-fo",
                            "mol2",
                            "-c",
                            short_charge_method,
                            "-ek",
                            "max_cyc=0"
                        ]
                    )

In terms of timing, which is my main issue, I am not seeing any change.Is this something you can help me with?

Thank you for all of your help. Best, Kate

khuddzu avatar Feb 16 '22 19:02 khuddzu

It should be noted, that when simply running in command line I do see a change in time with these keywords

khuddzu avatar Feb 16 '22 19:02 khuddzu

Hi @khuddzu ,

We've actually been experimenting with using maxcyc=0 in some cases as well. @connordavel jotted down some useful code snippets related to our previous work here: https://github.com/openforcefield/openff-toolkit/issues/1170#issuecomment-1016052595

I think you're on the right track. Looking at your code above, maybe the issue is that you modified the code to add max_cyc=0, whereas on the command line you specify maxcyc=0 (no underscore)?

j-wags avatar Feb 16 '22 21:02 j-wags

ah yes. sorry. I have since fixed this typo and it doesn't change anything.

I see in #1170 some one mentioned this function: Also, in our toolkit am1bccnosymspt

Edit 2: Ahh, this turns off optimization entirely, I don't think we have an api point in quacpac where we can optimize without restraints using openeye

^^ Is this function in openeye or openff? I cannot find in ambertools_wrapper.py

khuddzu avatar Feb 16 '22 21:02 khuddzu

Is this function in openeye or openff?

QuacPac is a package in OpenEye, so that won't apply to anything ambertools_wrapper.

The maxcyc=0 stuff in the linked issue would just be in the specific comment. I'm not familiar with the -ek commandline argument, but I assume it means "extra keyword" and so it should do what you're wanting.

I also just realized that it's possible that the file you're modifying isn't the one that's being run. If you want to make sure that you have control over the python source code that's getting loaded by the interpreter, consider making a development environment of the openFF toolkit.

j-wags avatar Feb 16 '22 21:02 j-wags

Stalled but we're generally not eager to modify the arguments in that antechamber call. Instead there are several workarounds to allow for more customizable behavior

https://github.com/openforcefield/openff-toolkit/issues/1533#issuecomment-1411286860

mattwthompson avatar Feb 02 '23 15:02 mattwthompson