Esempio n. 1
0
def map_function(data_tuple, featurizer):
    featurizer = NNScoreComplexFeaturizer()
    ind, ligand_pdb, protein_pdb = data_tuple
    print("Mapping on ind %d" % ind)
    print("ind, type(ligand_pdb), type(protein_pdb): %s " % str(
        (ind, type(ligand_pdb), type(protein_pdb))))
    return featurizer.featurize_complexes([ligand_pdb], [protein_pdb])
Esempio n. 2
0
def map_function(data_tuple, featurizer):
  featurizer = NNScoreComplexFeaturizer()
  ind, ligand_pdb, protein_pdb = data_tuple
  print("Mapping on ind %d" % ind)
  print("ind, type(ligand_pdb), type(protein_pdb): %s " %
        str((ind, type(ligand_pdb), type(protein_pdb))))
  return featurizer.featurize_complexes([ligand_pdb], [protein_pdb])
Esempio n. 3
0
  def setUp(self):
    """
    Create internal featurizer.
    """
    self.nnscore_featurizer = NNScoreComplexFeaturizer()
    ### 3zso comes from PDBBind-CN
    _3zso_protein_pdb_file = os.path.join(data_dir(), "3zso_protein.pdb")
    with open(_3zso_protein_pdb_file) as f:
      _3zso_protein_pdb = f.readlines()

    # The ligand is also specified by pdbbind
    _3zso_ligand_pdb_file = os.path.join(data_dir(), "3zso_ligand_hyd.pdb")
    with open(_3zso_ligand_pdb_file) as f:
      _3zso_ligand_pdb = f.readlines()

    self.test_cases = [("3zso", _3zso_ligand_pdb, _3zso_protein_pdb)]
Esempio n. 4
0
class TestNNScoreComplexFeaturizer(unittest.TestCase):
  """
  Test NNScoreComplexFeaturizer.
  """

  def setUp(self):
    """
    Create internal featurizer.
    """
    self.nnscore_featurizer = NNScoreComplexFeaturizer()
    ### 3zso comes from PDBBind-CN
    _3zso_protein_pdb_file = os.path.join(data_dir(), "3zso_protein.pdb")
    with open(_3zso_protein_pdb_file) as f:
      _3zso_protein_pdb = f.readlines()

    # The ligand is also specified by pdbbind
    _3zso_ligand_pdb_file = os.path.join(data_dir(), "3zso_ligand_hyd.pdb")
    with open(_3zso_ligand_pdb_file) as f:
      _3zso_ligand_pdb = f.readlines()

    self.test_cases = [("3zso", _3zso_ligand_pdb, _3zso_protein_pdb)]

  def testNNScore(self):
    """
    Run simple tests with NNScore.
    """
    # Currently, just verifies that nothing crashes.
    for _, ligand_pdb, protein_pdb in self.test_cases:
      _ = self.nnscore_featurizer.featurize_complexes(
          [ligand_pdb], [protein_pdb])
Esempio n. 5
0
    def test_singletask_mlp_NNScore_regression_API(self):
        """Test of singletask MLP NNScore regression API."""
        splittype = "scaffold"
        compound_featurizers = []
        complex_featurizers = [NNScoreComplexFeaturizer()]
        input_transforms = ["normalize", "truncate"]
        output_transforms = ["normalize"]
        task_types = {"label": "regression"}
        model_params = {
            "nb_hidden": 10,
            "activation": "relu",
            "dropout": .5,
            "learning_rate": .01,
            "momentum": .9,
            "nesterov": False,
            "decay": 1e-4,
            "batch_size": 5,
            "nb_epoch": 2,
            "init": "glorot_uniform",
            "nb_layers": 1,
            "batchnorm": False
        }

        input_file = "nnscore_example.pkl.gz"
        protein_pdb_field = "protein_pdb"
        ligand_pdb_field = "ligand_pdb"
        train_dataset, test_dataset = self._featurize_train_test_split(
            splittype,
            compound_featurizers,
            complex_featurizers,
            input_transforms,
            output_transforms,
            input_file,
            task_types.keys(),
            protein_pdb_field=protein_pdb_field,
            ligand_pdb_field=ligand_pdb_field)
        model_params["data_shape"] = train_dataset.get_data_shape()

        model = SingleTaskDNN(task_types, model_params)
        self._create_model(train_dataset, test_dataset, model)
Esempio n. 6
0
print("About to load dataset form disk.")
dataset = load_from_disk(dataset_file)
print("Loaded dataset.")

grid_featurizer = GridFeaturizer(voxel_width=16.0,
                                 feature_types="voxel_combined",
                                 voxel_feature_types=[
                                     "ecfp", "splif", "hbond", "pi_stack",
                                     "cation_pi", "salt_bridge"
                                 ],
                                 ecfp_power=9,
                                 splif_power=9,
                                 parallel=True,
                                 flatten=True)
compound_featurizers = [CircularFingerprint(size=1024)]
complex_featurizers = [grid_featurizer, NNScoreComplexFeaturizer()]

#Make a directory in which to store the featurized complexes.
base_dir = "../../../grid_nnscore_circular_features"
if not os.path.exists(base_dir):
    os.makedirs(base_dir)
data_dir = os.path.join(base_dir, "data")
if not os.path.exists(data_dir):
    os.makedirs(data_dir)

featurized_samples_file = os.path.join(data_dir, "featurized_samples.joblib")

feature_dir = os.path.join(base_dir, "features")
if not os.path.exists(feature_dir):
    os.makedirs(feature_dir)