Skip to content

Commit

Permalink
drop: buildin logger
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoYinYing committed Aug 20, 2024
1 parent 90f731a commit 2bd81ad
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from Bio import PDB
import numpy as np
import time
import logging
from absl import logging
from helixfold.common.residue_constants import crystallization_aids, ligand_exclusion_list

# Type aliases:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import contextlib
import shutil
import logging
from absl import logging
import tempfile
import time
from typing import Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,21 @@ def _get_supported_formats(self) -> Tuple[str]:
return tuple(formats)

def _perform_conversion(self, input_type: str, input_value: str) -> Chem.Mol:
with tempfile.NamedTemporaryFile(suffix=".mol2") as temp_file:
with utils.timing(f'converting {input_type} to mol2: {input_value}'):
if input_type == 'smiles':
obabel_cmd = f"{self.obabel_bin} -:'{input_value}' -omol2 -O{temp_file.name} --gen3d"
if len(input_value)>60:
logging.warning(f'This takes a while ...')
else:
obabel_cmd = f"{self.obabel_bin} -i {input_type} {input_value} -omol2 -O{temp_file.name} --gen3d"
ret = subprocess.run(obabel_cmd, shell=True, capture_output=True, text=True)
mol = Chem.MolFromMol2File(temp_file.name, sanitize=False)
if '3D coordinate generation failed' in ret.stderr:
mol = generate_ETKDGv3_conformer(mol)
optimal_mol_wo_H = Chem.RemoveAllHs(mol, sanitize=False)
return optimal_mol_wo_H
with tempfile.NamedTemporaryFile(suffix=".mol2") as temp_file, utils.timing(f'converting {input_type} to mol2: {input_value}'):
if input_type == 'smiles':
obabel_cmd = f"{self.obabel_bin} -:'{input_value}' -omol2 -O{temp_file.name} --gen3d"
if len(input_value)>60:
logging.warning(f'This takes a while ...')
else:
obabel_cmd = f"{self.obabel_bin} -i {input_type} {input_value} -omol2 -O{temp_file.name} --gen3d"
logging.debug(f'Launching command: `{obabel_cmd}`')
ret = subprocess.run(obabel_cmd, shell=True, capture_output=True, text=True)
mol = Chem.MolFromMol2File(temp_file.name, sanitize=False)
if '3D coordinate generation failed' in ret.stderr:
mol = generate_ETKDGv3_conformer(mol)
optimal_mol_wo_H = Chem.RemoveAllHs(mol, sanitize=False)

return optimal_mol_wo_H

def _convert_to_mol(self, input_type: str, input_value: str) -> Chem.Mol:
if input_type not in self.supported_formats:
Expand Down
1 change: 0 additions & 1 deletion apps/protein_folding/helixfold3/helixfold/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import pickle
import pathlib
import shutil
import logging
import numpy as np
import shutil

Expand Down

0 comments on commit 2bd81ad

Please sign in to comment.