Skip to content

Commit

Permalink
Fix voxels to use updated features; fix CATHAPI updated data_stores
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli Draizen authored and Eli Draizen committed Oct 26, 2023
1 parent 7d6964d commit 61dfe21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
35 changes: 17 additions & 18 deletions Prop3D/common/voxels.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

from Prop3D.common.LocalStructure import LocalStructure
from Prop3D.common.ProteinTables import vdw_radii, vdw_aa_radii
from Prop3D.common.features import atom_features_by_category, number_of_features, \
default_atom_features, default_residue_features
from Prop3D.common.features import all_features

class LocalVoxelizedStructure(LocalStructure):
"""DEPRECATED use DistributedVoxelizedStructure. Maintined for legacy code.
Expand Down Expand Up @@ -190,7 +189,7 @@ def map_atoms_to_voxel_space(self, truth_residues=None,
predicting_features = isinstance(self.predict_features, (list, tuple))


nFeatures = number_of_features(
nFeatures = all_features.number_of_features(
only_aa=only_aa,
only_atom=only_atom,
non_geom_features=non_geom_features,
Expand Down Expand Up @@ -257,7 +256,7 @@ def map_atoms_to_voxel_space(self, truth_residues=None,
use_deepsite_features=use_deepsite_features)

if self.replace_na:
features = features.fillna(default_atom_features)
features = features.fillna(all_features.default_atom_features)

features = features.astype(float)

Expand Down Expand Up @@ -370,7 +369,7 @@ def map_residues_to_voxel_space(self, truth_residues=None, include_full_protein=
raise

if self.replace_na:
features = features.fillna(default_residue_features)
features = features.fillna(all_features.default_residue_features)

for residue_grid in self.get_vdw_grid_coords_for_residue(residue):
residue_grid = tuple(residue_grid.tolist())
Expand Down Expand Up @@ -432,7 +431,7 @@ def get_atoms_and_features(self, truth_residues=None,
non_binding_site_atoms = []


nFeatures = number_of_features(
nFeatures = all_features.number_of_features(
only_aa=only_aa,
only_atom=only_atom,
non_geom_features=non_geom_features,
Expand Down Expand Up @@ -589,10 +588,10 @@ def get_features_for_atom(self, atom, only_aa=False, only_atom=False,

elif only_aa and use_deepsite_features:
feats = features[
atom_features_by_category["get_residue"] + \
atom_features_by_category["get_deepsite_features"] + \
atom_features_by_category["get_charge_and_electrostatics"][1:3] +\
atom_features_by_category["get_evolutionary_conservation_score"][-1:]]
all_features.atom_features_by_category["get_residue"] + \
all_features.atom_features_by_category["get_deepsite_features"] + \
all_features.atom_features_by_category["get_charge_and_electrostatics"][1:3] +\
all_features.atom_features_by_category["get_evolutionary_conservation_score"][-1:]]

if warn_if_buried:
return feats, is_buried
Expand All @@ -601,32 +600,32 @@ def get_features_for_atom(self, atom, only_aa=False, only_atom=False,

if use_deepsite_features:
feats = features[
atom_features_by_category["get_deepsite_features"] + \
atom_features_by_category["get_charge_and_electrostatics"][1:3] +\
atom_features_by_category["get_evolutionary_conservation_score"][-1:]]
all_features.atom_features_by_category["get_deepsite_features"] + \
all_features.atom_features_by_category["get_charge_and_electrostatics"][1:3] +\
all_features.atom_features_by_category["get_evolutionary_conservation_score"][-1:]]
if warn_if_buried:
return feats, is_buried
else:
return feats

if only_atom:
feats = features[atom_features_by_category["get_atom_type"]]
feats = features[all_features.atom_features_by_category["get_atom_type"]]
if warn_if_buried:
return feats, is_buried
else:
return feats

elif only_aa:
feats = features[atom_features_by_category["get_residue"]]
feats = features[all_features.atom_features_by_category["get_residue"]]
if warn_if_buried:
return feats, is_buried
else:
return feats
elif non_geom_features:
feats = features[
atom_features_by_category["get_element_type"] + \
atom_features_by_category["get_charge_and_electrostatics"] +\
atom_features_by_category["get_hydrophobicity"] +\
all_features.atom_features_by_category["get_element_type"] + \
all_features.atom_features_by_category["get_charge_and_electrostatics"] +\
all_features.atom_features_by_category["get_hydrophobicity"] +\
[float(is_buried)]]
if warn_if_buried:
return feats, is_buried
Expand Down
6 changes: 3 additions & 3 deletions Prop3D/parsers/cath.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import html
import pandas as pd
from io import StringIO
from pathlib import Path

from Prop3D.generate_data.data_stores import data_stores
from Prop3D.parsers.json import JSONApi, WebService
from Prop3D.parsers.container import Container

class CATHApi(JSONApi):
def __init__(self, cath_store=None, work_dir=None, download=True, max_attempts=2, job=None):
if cath_store is None:
assert job is not None
cath_store = data_stores(job).cath_api_service
ds = f"file:{Path.cwd().absolute()}/" if job is None else job
cath_store = data_stores(ds).cath_api_service
super().__init__("https://www.cathdb.info/version/v4_3_0/",
cath_store, work_dir=work_dir, download=download, clean=False,
max_attempts=max_attempts)
Expand Down

0 comments on commit 61dfe21

Please sign in to comment.