Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
make the test work without target data, even when normalization is se…
Browse files Browse the repository at this point in the history
…t to True
  • Loading branch information
Coos Baakman committed Dec 19, 2023
1 parent 7b33837 commit 0c2af21
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
27 changes: 15 additions & 12 deletions deeprank/generate/NormalizeData.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,25 @@ def _extract_data(self):
self.parameters['features'][feat_types][name].add(
np.mean(mat), np.var(mat))

# get the target groups
target_group = f5.get(mol + '/targets')
mol_group = f5[mol]
if "targets" in mol_group:

# loop over all the targets
for tname, tval in target_group.items():
# get the target groups
target_group = mol_group["targets"]

# we skip the already computed target
if tname in self.skip_target:
continue
# loop over all the targets
for tname, tval in target_group.items():

# create a new item if needed
if tname not in self.parameters['targets']:
self.parameters['targets'][tname] = MinMaxParam()
# we skip the already computed target
if tname in self.skip_target:
continue

# create a new item if needed
if tname not in self.parameters['targets']:
self.parameters['targets'][tname] = MinMaxParam()

# update the value
self.parameters['targets'][tname].update(tval[()])
# update the value
self.parameters['targets'][tname].update(tval[()])

f5.close()

Expand Down
5 changes: 4 additions & 1 deletion deeprank/learn/DataSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,10 @@ def _read_norm(self):
mean, var)

# handle the target
if self.select_target is not None:
if self.select_target is not None and \
"targets" in data and \
self.select_target in data["targets"]:

minv = data['targets'][self.select_target].min
maxv = data['targets'][self.select_target].max
self.param_norm['targets'][self.select_target].update(minv)
Expand Down
11 changes: 5 additions & 6 deletions test/test_learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ def test_predict_without_target():
'number_of_points': [30,30,30],
'resolution': [1.,1.,1.],
'atomic_densities': atomic_densities,
}
}

environment = Environment(pdb_root="test/data/pdb", pssm_root="test/data/pssm")

variants = [PdbVariantSelection("101m", "A", 10, valine, cysteine,
protein_accession="P02144", protein_residue_number=10,
variant_class=VariantClass.BENIGN),
),
PdbVariantSelection("101m", "A", 8, glutamine, cysteine,
protein_accession="P02144",
variant_class=VariantClass.PATHOGENIC),
),
PdbVariantSelection("101m", "A", 9, glutamine, cysteine,
protein_accession="P02144", protein_residue_number=9,
variant_class=VariantClass.PATHOGENIC)]
)]
augmentation = 5

work_dir_path = mkdtemp()
Expand All @@ -64,8 +64,7 @@ def test_predict_without_target():

dataset = DataSet(hdf5_path, grid_info=grid_info,
select_feature='all',
select_target='target1',
normalize_features=False)
normalize_features=True)

eq_(len(dataset), len(variants) * (augmentation + 1))
ok_(dataset[0] is not None)
Expand Down

0 comments on commit 0c2af21

Please sign in to comment.