Commit 3d448d62 authored by Pasc-Iv's avatar Pasc-Iv
Browse files

apply yapf

parent b0f03c9b
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import numpy as np
from deepchem.utils.typing import RDKitMol
from deepchem.feat.base_classes import MolecularFeaturizer


class SmilesToImage(MolecularFeaturizer):
  """Convert SMILES string to an image.

@@ -166,5 +167,7 @@ class SmilesToImage(MolecularFeaturizer):

    except IndexError:
      # With fixed res and img_size some molecules (e.g. long chains) may not fit.
      raise IndexError("The molecule does not fit into the image. Consider increasing img_size or res of the SmilesToImage featurizer.")
      raise IndexError(
          "The molecule does not fit into the image. Consider increasing img_size or res of the SmilesToImage featurizer."
      )
    return img
+12 −10
Original line number Diff line number Diff line
@@ -13,11 +13,12 @@ class TestSmilesToSeq(unittest.TestCase):
    """Setup."""
    pad_len = 5
    max_len = 35
    filename = os.path.join(
        os.path.dirname(__file__), "data", "chembl_25_small.csv")
    filename = os.path.join(os.path.dirname(__file__), "data",
                            "chembl_25_small.csv")
    char_to_idx = create_char_to_idx(filename, max_len=max_len)
    self.feat = SmilesToSeq(
        char_to_idx=char_to_idx, max_len=max_len, pad_len=pad_len)
    self.feat = SmilesToSeq(char_to_idx=char_to_idx,
                            max_len=max_len,
                            pad_len=pad_len)

  def test_smiles_to_seq_featurize(self):
    """Test SmilesToSeq featurization."""
@@ -43,7 +44,9 @@ class TestSmilesToImage(unittest.TestCase):
  def setUp(self):
    """Setup."""
    self.smiles = ["Cn1c(=O)c2c(ncn2C)n(C)c1=O", "CC(=O)N1CN(C(C)=O)C(O)C1O"]
    self.long_molecule_smiles = ["CCCCCCCCCCCCCCCCCCCC(=O)OCCCNC(=O)c1ccccc1SSc1ccccc1C(=O)NCCCOC(=O)CCCCCCCCCCCCCCCCCCC"]
    self.long_molecule_smiles = [
        "CCCCCCCCCCCCCCCCCCCC(=O)OCCCNC(=O)c1ccccc1SSc1ccccc1C(=O)NCCCOC(=O)CCCCCCCCCCCCCCCCCCC"
    ]

  def test_smiles_to_image(self):
    """Test default SmilesToImage"""
@@ -92,8 +95,7 @@ class TestSmilesToImage(unittest.TestCase):

  def test_smiles_to_image_long_molecule(self):
    """Test SmilesToImage for a molecule which does not fit the image"""
    featurizer = SmilesToImage(
               img_size=80,
    featurizer = SmilesToImage(img_size=80,
                               res=0.5,
                               max_len=250,
                               img_spec="std")