def __init__(self, lig_feature, env_feature): ftype_names = { Pharm.FeatureType.H_BOND_ACCEPTOR: 'HBA', Pharm.FeatureType.H_BOND_DONOR: 'HBD', Pharm.FeatureType.POS_IONIZABLE: 'PI', Pharm.FeatureType.NEG_IONIZABLE: 'NI', Pharm.FeatureType.AROMATIC: 'AR', Pharm.FeatureType.HYDROPHOBIC: 'H', Pharm.FeatureType.X_VOLUME: 'XV' } lig_feature_type = ftype_names[Pharm.getType(lig_feature)] lig_residue_code = Biomol.getResidueCode( Pharm.getSubstructure(lig_feature).atoms[0]) lig_residue_number = Biomol.getResidueSequenceNumber( Pharm.getSubstructure(lig_feature).atoms[0]) lig_residue_chain = Biomol.getChainID( Pharm.getSubstructure(lig_feature).atoms[0]) env_feature_type = ftype_names[Pharm.getType(env_feature)] env_residue_code = Biomol.getResidueCode( Pharm.getSubstructure(env_feature).atoms[0]) env_residue_number = Biomol.getResidueSequenceNumber( Pharm.getSubstructure(env_feature).atoms[0]) env_residue_chain = Biomol.getChainID( Pharm.getSubstructure(env_feature).atoms[0]) self.interaction_type = '{}-{}'.format(lig_feature_type, env_feature_type) self.lig_residue = '{}_{}_{}'.format(lig_residue_code, lig_residue_number, lig_residue_chain) self.env_residue = '{}_{}_{}'.format(env_residue_code, env_residue_number, env_residue_chain) atoms = [] for atom in Pharm.getSubstructure(lig_feature).atoms: key_atom = '{}:{}'.format(Chem.getSymbol(atom), Biomol.getSerialNumber(atom)) atoms.append(key_atom) self.lig_atom = sorted(atoms, key=lambda k: int(k.split(':')[1])) atoms = [] for atom in Pharm.getSubstructure(env_feature).atoms: key_atom = '{}:{}'.format(Chem.getSymbol(atom), Biomol.getSerialNumber(atom)) atoms.append(key_atom) self.env_atom = sorted(atoms, key=lambda k: int(k.split(':')[1]))
def generate_key(ftr): first_atom = Pharm.getSubstructure(ftr).atoms[0] base = str(ftype_names[Pharm.getType(ftr)]) + '[' + str( Biomol.getResidueCode(first_atom)) + '_' + str( Biomol.getResidueSequenceNumber(first_atom)) + '_' + str( Biomol.getChainID(first_atom)) atoms_list = [] for a in Pharm.getSubstructure(ftr).atoms: if Biomol.hasSerialNumber(a) == False: continue atom_id = str(Biomol.getSerialNumber(a)) atoms_list.append(atom_id) atom_key = "" for k in sorted(atoms_list, key=natural_sort_key, reverse=True): atom_key += '_' + k key = base + atom_key + ']' return key