-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Stereoisomer Enumeration #21
Conversation
easydock/database.py
Outdated
def get_isomers(mol): | ||
opts = StereoEnumerationOptions(tryEmbedding=True,maxIsomers=32,rand=0xf00d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_isomers
should be added to arguments and elevated to the level of script arguments (argparse arguments) with the default value 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add please spaces after the commas
easydock/database.py
Outdated
if bond.GetStereo() == Chem.BondStereo.STEREOANY: | ||
bond.SetStereo(Chem.rdChem.BondStereo.STEREONONE) | ||
isomers = tuple(EnumerateStereoisomers(mol,options=opts)) | ||
return isomers | ||
|
||
def init_db(db_fname, input_fname, prefix=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_isomers
should be added to arguments with the default value 1
easydock/database.py
Outdated
isomers = get_isomers(mol) | ||
for stereo_index, stereo_mol in enumerate(isomers): | ||
smi = Chem.MolToSmiles(stereo_mol, isomericSmiles=True) | ||
if prefix: | ||
mol_name = f'{prefix}-{mol_name}' | ||
if mol_is_3d(mol): | ||
data_mol.append((mol_name, stereo_index, smi, Chem.MolToMolBlock(stereo_mol))) | ||
else: | ||
data_smi.append((mol_name, stereo_index, smi)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if prefix:
mol_name = f'{prefix}-{mol_name}'
if mol_is_3d(mol):
data_mol.append((mol_name, 0, smi, Chem.MolToMolBlock(stereo_mol)))
else:
isomers = get_isomers(mol, max_isomers=max_isomers)
for stereo_index, stereo_mol in enumerate(isomers):
smi = Chem.MolToSmiles(stereo_mol, isomericSmiles=True)
data_smi.append((mol_name, stereo_index, smi))
- Enumeration is only needed if input is not a 3D molecule
- I added
max_isomers
to input arguments - I added 0 as a default
stereo_id
value
I looked through the changes and made some particular notes. Below are more general ones;
|
I have edited some of the commits based on your suggestions. Is there any more edits that I have missed? |
easydock/database.py
Outdated
@@ -136,23 +139,38 @@ def restore_setup_from_db(db_fname): | |||
|
|||
return d, tmpfiles | |||
|
|||
def get_isomers(mol, max_isomers): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add please default value max_isomers=1
easydock/database.py
Outdated
|
||
def init_db(db_fname, input_fname, prefix=None): | ||
def init_db(db_fname, input_fname, max_isomers, prefix=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add please default value max_isomers=1
This will make the code more compatible with previous versions, because previously by default we generated one random stereoisomer
easydock/database.py
Outdated
if prefix: | ||
mol_name = f'{prefix}-{mol_name}' | ||
if mol_is_3d(mol): | ||
data_mol.append((mol_name, smi, Chem.MolToMolBlock(mol))) | ||
smi = Chem.MolToSmiles(mol, isomericSmiles=True) | ||
data_mol.append((mol_name, 0, smi, Chem.MolToMolBlock(stereo_mol))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should be mol
, not stereo_mol
easydock/database.py
Outdated
@@ -305,15 +324,16 @@ def add_protonation(db_fname, tautomerize=True, table_name='mols', add_sql=''): | |||
fd, output = tempfile.mkstemp() # use output file to avoid overflow of stdout in extreme cases | |||
try: | |||
for smi, _, mol_id in data_list: | |||
tmp.write(f'{smi}\t{mol_id}\n') | |||
tmp.write(f'{smi}\t{mol_id}\t{stereo_id}\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have to join mol_id and stereo_id, otherwise stereo_id may not become a part of a title of an output molecule
tmp.write(f'{smi}\t{mol_id}_{stereo_id}\n')
easydock/database.py
Outdated
for mol in Chem.SDMolSupplier(output, sanitize=False): | ||
if mol: | ||
mol_name = mol.GetProp('_Name') | ||
mol_name, stereo_id = mol.GetProp('_Name').rsplit(maxsplit=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be adjusted to the previous comment
mol_name, stereo_id = mol.GetProp('_Name').rsplit('_', 1)
easydock/run_dock.py
Outdated
@@ -173,6 +173,8 @@ def main(): | |||
help='number of cpus. This affects only docking on a single server.') | |||
parser.add_argument('-v', '--verbose', action='store_true', default=False, | |||
help='print progress to STDERR.') | |||
parser.add_argument('--max_isomers', metavar='N_STEREO', type=int, required=False, default=1, | |||
help='maximum number of isomers to enumerate. The default is set to 1.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please replace isomer with stereoisomer to be maximally explicit
After those comments will be fixed, I think we will test and accept the PR. Regarding replacement of chemaxon. I'll implement a generic interface which should enable easy integration of third-party protonation tools and you will be able to commit Dimorphite-DL. This will be really useful - #17. |
Alright, I have edited the naming. Can you check if that is alright before testing it? |
It looks OK, I do not see any issues for main functionality. It can be tested. The will be one more change required - |
It seems that everything works fine. Hope so) |
No description provided.