bioexcel / biobb_chemistry

Biobb_chemistry is the Biobb module collection to perform chemistry over molecular dynamics simulations.
https://mmb.irbbarcelona.org/biobb/
Apache License 2.0
4 stars 1 forks source link

Simultaneous use of -h and -p flags produces unexpected behaviour #9

Closed PabloNA97 closed 2 months ago

PabloNA97 commented 2 months ago

When using biobb_add_hydrogens, one can select to add hydrogens at a certain ph. The final command that is executed is:

obabel <input> -O <output> -p 7.4 -h -gen3d -xh

However, openbabel issues a warning regarding the use of both h and p flags simultaneously:

*** Open Babel Warning in DoTransformations Both -p and -h options are set. All implicit hydrogens (-h) will be added without considering pH.

I think the h flag should be only included if the user is not requesting a specific ph. Modifying line 123 in babel_add_hydrogens.py would solve this:

# adding all H if not p: hydrogens = '-h'

Versions:

gbayarri commented 2 months ago

Hi @PabloNA97 , the variable hydrogens is already added only in case p doesn't exist (see the if below the line you propose to modify):

# checking pH
p = get_ph(self.ph, out_log)

# adding H
hydrogens = '-h'

# adding pH
ph = ''
if p:
    ph = '-p ' + p
    instructions_list.append(ph)
else:
    instructions_list.append(hydrogens)
PabloNA97 commented 2 months ago

Hi @gbayarri, you are right! I went too quickly over this. Thank you for taking a look :)

Not sure why I was able to get that warning, maybe I tampered with my own environment while adding the format options.

gbayarri commented 2 months ago

Maybe it is because you are using the -xh flag that is (yet) not included in the biobb?

PabloNA97 commented 2 months ago

I don't think so, the command:

obabel <input> -O <output> -p 7.4 -gen3d -xh

works well for me. The issue appears only when using both '-h' and '-p' options at the same time:

obabel <input> -O <output> -p 7.4 -h -gen3d -xh

You are clearly not running into this problem in babel_add_hydrogens as either one option or the other are active. So we can consider the issue closed. Best guess I have is that adding the format flag '-xh' I messed up the lines you mentioned. Thank you @gbayarri and sorry for the confusion!