Skip to content

Commit

Permalink
force_env in aux_classifier as well
Browse files Browse the repository at this point in the history
  • Loading branch information
luponzo86 committed Mar 30, 2019
1 parent 9931047 commit 1042591
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rhapsody/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def rhapsody(input_obj, classifier, aux_classifier=None,
if aux_classifier is not None:
# compute additional predictions from a subset of features
try:
r.calcAuxPredictions(aux_classifier)
r.calcAuxPredictions(aux_classifier, force_env=force_env)
r.printPredictions(format="both",
filename='rhapsody-predictions-full.txt')
except Exception as e:
Expand Down
10 changes: 9 additions & 1 deletion rhapsody/rhapsody.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,21 @@ def calcPredictions(self):
self.predictions = p
return self.predictions

def calcAuxPredictions(self, aux_clsf):
def calcAuxPredictions(self, aux_clsf, force_env=None):
assert self.predictions is not None, 'Primary predictions not found.'
assert self.featMatrix is not None, 'Features not computed.'
assert force_env in [None, 'chain', 'reduced', 'sliced']
# import feature subset
clsf_dict = pickle.load(open(aux_clsf, 'rb'))
LOGGER.info('Auxiliary Random Forest classifier imported.')
feat_subset = tuple(clsf_dict['features'])
if force_env is not None:
# force a given ENM environment model
for i, f in enumerate(feat_subset):
if f in RHAPSODY_FEATS['PDB'] and \
(f.startswith('ANM') or f.startswith('GNM')):
old_env = f.split('-')[-1]
feat_subset[i] = f.replace(old_env, force_env)
assert all(f in self.featSet for f in feat_subset), \
'The new set of features must be a subset of the original one.'
# reduce original feature matrix
Expand Down

0 comments on commit 1042591

Please sign in to comment.