def calcGNMfeatures(self, chain='all', env='chain', GNM_PRS=True): """Computes GNM-based features. :arg chain: chain identifier :type chain: str :arg env: environment model, i.e. ``'chain'``, ``'reduced'`` or ``'sliced'`` :type env: str :arg GNM_PRS: whether or not to compute features based on Perturbation Response Scanning analysis :type GNM_PRS: bool """ assert env in ['chain', 'reduced', 'sliced'] assert type(GNM_PRS) is bool # list of features to be computed features = ['GNM_MSF-'+env] if GNM_PRS: features += ['GNM_effectiveness-'+env, 'GNM_sensitivity-'+env] # compute features (if not precomputed) if chain == 'all': chain_list = self.chids else: chain_list = [chain, ] for chID in chain_list: d = self.feats[chID] if all([f in d for f in features]): continue try: gnm = self.calcGNM(chID, env=env) except Exception as e: if (isinstance(e, MemoryError)): msg = 'MemoryError' else: msg = str(e) for f in features: d[f] = msg LOGGER.warn(msg) continue key_msf = 'GNM_MSF-' + env if key_msf not in d: try: d[key_msf] = calcSqFlucts(gnm) except Exception as e: msg = str(e) d[key_msf] = msg LOGGER.warn(msg) key_eff = 'GNM_effectiveness-' + env if key_eff in features and key_eff not in d: key_sns = 'GNM_sensitivity-' + env try: prs_mtrx, eff, sns = calcPerturbResponse(gnm) d[key_eff] = eff d[key_sns] = sns except Exception as e: msg = str(e) d[key_eff] = msg d[key_sns] = msg LOGGER.warn(msg) return
def calcGNMfeatures(self, chain='all', env='chain', GNM_PRS=True): assert env in ['chain', 'reduced', 'sliced'] assert type(GNM_PRS) is bool # list of features to be computed features = ['GNM_MSF-' + env] if GNM_PRS: features += ['GNM_effectiveness-' + env, 'GNM_sensitivity-' + env] # compute features (if not precomputed) if chain == 'all': chain_list = self.chids else: chain_list = [ chain, ] for chID in chain_list: d = self.feats[chID] if all([f in d for f in features]): continue try: gnm = self.calcGNM(chID, env=env) except Exception as e: if (isinstance(e, MemoryError)): msg = 'MemoryError' else: msg = str(e) for f in features: d[f] = msg LOGGER.warn(msg) continue key_msf = 'GNM_MSF-' + env if key_msf not in d: try: d[key_msf] = calcSqFlucts(gnm) except Exception as e: msg = str(e) d[key_msf] = msg LOGGER.warn(msg) key_eff = 'GNM_effectiveness-' + env if key_eff in features and key_eff not in d: key_sns = 'GNM_sensitivity-' + env try: prs_mtrx, eff, sns = calcPerturbResponse(gnm) d[key_eff] = eff d[key_sns] = sns except Exception as e: msg = str(e) d[key_eff] = msg d[key_sns] = msg LOGGER.warn(msg) return
def get_perturbations(enm, n_modes=6): """ Calculates perturbation response based on an elastic network model Parameters ---------- enm n_modes number of modes to consider Returns ------- Effectiveness - how effective each residue is in perturbing other residues Sensitivity - how sensitive a residue is to perturbation by other residues """ _, effectiveness, sensitivity = pd.calcPerturbResponse(enm[:n_modes]) return effectiveness, sensitivity
def calcANMfeatures(self, chain='all', env='chain', ANM_PRS=True, stiffness=True, MBS=False): assert env in ['chain', 'reduced', 'sliced'] for k in ANM_PRS, stiffness, MBS: assert type(k) is bool # list of features to be computed features = ['ANM_MSF-' + env] if ANM_PRS: features += ['ANM_effectiveness-' + env, 'ANM_sensitivity-' + env] if MBS: features += ['MBS-' + env] if stiffness: features += ['stiffness-' + env] # compute features (if not precomputed) if chain == 'all': chain_list = self.chids else: chain_list = [ chain, ] for chID in chain_list: d = self.feats[chID] if all([f in d for f in features]): continue try: anm = self.calcANM(chID, env=env) except Exception as e: if (isinstance(e, MemoryError)): msg = 'MemoryError' else: msg = str(e) for f in features: d[f] = msg LOGGER.warn(msg) continue key_msf = 'ANM_MSF-' + env if key_msf not in d: try: d[key_msf] = calcSqFlucts(anm) except Exception as e: msg = str(e) d[key_msf] = msg LOGGER.warn(msg) key_eff = 'ANM_effectiveness-' + env if key_eff in features and key_eff not in d: key_sns = 'ANM_sensitivity-' + env try: prs_mtrx, eff, sns = calcPerturbResponse(anm) d[key_eff] = eff d[key_sns] = sns except Exception as e: msg = str(e) d[key_eff] = msg d[key_sns] = msg LOGGER.warn(msg) key_mbs = 'MBS-' + env if key_mbs in features and key_mbs not in d: try: pdb = self.getPDB() ca = pdb[chID].ca d[key_mbs] = calcMBS(anm, ca, cutoff=15.) except Exception as e: msg = str(e) d[key_mbs] = msg LOGGER.warn(msg) key_stf = 'stiffness-' + env if key_stf in features and key_stf not in d: try: pdb = self.getPDB() ca = pdb[chID].ca stiff_mtrx = calcMechStiff(anm, ca) d[key_stf] = np.mean(stiff_mtrx, axis=0) except Exception as e: msg = str(e) d[key_stf] = msg LOGGER.warn(msg) return
def calcANMfeatures(self, chain='all', env='chain', ANM_PRS=True, stiffness=True, MBS=False): """Computes ANM-based features. :arg chain: chain identifier :type chain: str :arg env: environment model, i.e. ``'chain'``, ``'reduced'`` or ``'sliced'`` :type env: str :arg ANM_PRS: whether or not to compute features based on Perturbation Response Scanning analysis :type ANM_PRS: bool :arg stiffness: whether or not to compute stiffness with MechStiff :type stiffness: bool :arg MBS: whether or not to compute Mechanical Bridging Score :type MBS: bool """ assert env in ['chain', 'reduced', 'sliced'] for k in ANM_PRS, stiffness, MBS: assert type(k) is bool # list of features to be computed features = ['ANM_MSF-'+env] if ANM_PRS: features += ['ANM_effectiveness-'+env, 'ANM_sensitivity-'+env] if MBS: features += ['MBS-'+env] if stiffness: features += ['stiffness-'+env] # compute features (if not precomputed) if chain == 'all': chain_list = self.chids else: chain_list = [chain, ] for chID in chain_list: d = self.feats[chID] if all([f in d for f in features]): continue try: anm = self.calcANM(chID, env=env) except Exception as e: if (isinstance(e, MemoryError)): msg = 'MemoryError' else: msg = str(e) for f in features: d[f] = msg LOGGER.warn(msg) continue key_msf = 'ANM_MSF-' + env if key_msf not in d: try: d[key_msf] = calcSqFlucts(anm) except Exception as e: msg = str(e) d[key_msf] = msg LOGGER.warn(msg) key_eff = 'ANM_effectiveness-' + env if key_eff in features and key_eff not in d: key_sns = 'ANM_sensitivity-' + env try: prs_mtrx, eff, sns = calcPerturbResponse(anm) d[key_eff] = eff d[key_sns] = sns except Exception as e: msg = str(e) d[key_eff] = msg d[key_sns] = msg LOGGER.warn(msg) key_mbs = 'MBS-' + env if key_mbs in features and key_mbs not in d: try: pdb = self.getPDB() ca = pdb[chID].ca d[key_mbs] = calcMBS(anm, ca, cutoff=15.) except Exception as e: msg = str(e) d[key_mbs] = msg LOGGER.warn(msg) key_stf = 'stiffness-' + env if key_stf in features and key_stf not in d: try: pdb = self.getPDB() ca = pdb[chID].ca stiff_mtrx = calcMechStiff(anm, ca) d[key_stf] = np.mean(stiff_mtrx, axis=0) except Exception as e: msg = str(e) d[key_stf] = msg LOGGER.warn(msg) return