Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import numpy as np
import os
from lightdock.constants import DEFAULT_LIGHTDOCK_PREFIX
from lightdock.scoring.functions import ScoringFunction, ModelAdapter
from lightdock.structure.model import DockingModel
from lightdock.scoring.sipper.data.energy import sipper_energy, res_to_index
import lightdock.scoring.sipper.c.sipper as csipper
from lightdock.util.logger import LoggingManager
from lightdock.constants import DEFAULT_CONTACT_RESTRAINTS_CUTOFF
log = LoggingManager.get_logger('sipper')
class SIPPERModel(DockingModel):
"""Prepares the structure necessary for the C-implementation of the SIPPER
scoring function
"""
def __init__(self, objects, coordinates, restraints, energy, indexes, atoms_per_residue,
oda=None, reference_points=None, n_modes=None):
super(SIPPERModel, self).__init__(objects, coordinates, restraints, reference_points)
self.energy = energy
self.indexes = indexes
self.atoms_per_residue = atoms_per_residue
self.oda = oda
self.n_modes = n_modes
def clone(self):
"""Creates a copy of the current model"""
return SIPPERModel(self.objects, self.coordinates.copy(), self.restraints, self.energy, self.indexes,
self.atoms_per_residue, self.oda, reference_points=self.reference_points.copy())
def _get_docking_model(self, molecule, restraints):
"""Builds a suitable docking model for this scoring function"""
# In model_objects we can store any coordinates object (atoms, beans, etc.)
model_objects = []
for residue in molecule.residues:
for rec_atom in residue.atoms:
model_objects.append(rec_atom)
try:
return DockingModel(model_objects, molecule.copy_coordinates(), restraints, n_modes=molecule.n_modes.copy())
except AttributeError:
return DockingModel(model_objects, molecule.copy_coordinates(), restraints)
rec_atom_type = rec_atom.residue_name + ' ' + rec_atom.name
if rec_atom_type in DFIRE2_ATOM_TYPES:
objects.append(DFIRE2Object(residue.number, DFIRE2_ATOM_TYPES[rec_atom_type]))
coordinates.append([rec_atom.x, rec_atom.y, rec_atom.z])
# Restraints support
res_id = "%s.%s.%s" % (rec_atom.chain_id, residue.name, str(residue.number))
if restraints and res_id in restraints:
try:
parsed_restraints[res_id].append(atom_index)
except:
parsed_restraints[res_id] = [atom_index]
atom_index += 1
try:
return DockingModel(objects, SpacePoints(coordinates), parsed_restraints, n_modes=molecule.n_modes.copy())
except AttributeError:
return DockingModel(objects, SpacePoints(coordinates), parsed_restraints)
cz /= float(count)
coordinates.append([cx, cy, cz])
tobi_residues.append(residue_index)
res_id = "%s.%s.%s" % (chain_id, residue.name, str(residue.number))
if restraints and res_id in restraints:
parsed_restraints[res_id] = []
except ValueError:
pass
except ZeroDivisionError:
continue
list_of_coordinates.append(SpacePoints(coordinates))
return DockingModel(tobi_residues, list_of_coordinates, parsed_restraints)
if count:
count = float(count)
coordinates.append([c_x / count, c_y / count, c_z / count])
res_id = "%s.%s.%s" % (chain_id, residue.name, str(residue.number))
if restraints and res_id in restraints:
parsed_restraints[res_id] = []
else:
residues_to_remove.append(res_index)
if len(residues_to_remove):
residues = [residue for res_index, residue in enumerate(residues) if
res_index not in residues_to_remove]
list_of_coordinates.append(SpacePoints(coordinates))
return DockingModel(residues, list_of_coordinates, parsed_restraints)
def _get_docking_model(self, molecule, restraints):
"""Builds a suitable docking model for this scoring function"""
# In model_objects we can store any coordinates object (atoms, beans, etc.)
model_objects = []
for residue in molecule.residues:
for rec_atom in residue.atoms:
model_objects.append(rec_atom)
try:
return DockingModel(model_objects, molecule.copy_coordinates(), restraints, n_modes=molecule.n_modes.copy())
except AttributeError:
return DockingModel(model_objects, molecule.copy_coordinates(), restraints)
for residue in molecule.residues:
for rec_atom in residue.atoms:
rec_atom_type = rec_atom.residue_name + ' ' + rec_atom.name
if rec_atom_type in DFIRE2_ATOM_TYPES:
objects.append(DFIRE2Object(residue.number, DFIRE2_ATOM_TYPES[rec_atom_type]))
coordinates.append([rec_atom.x, rec_atom.y, rec_atom.z])
# Restraints support
res_id = "%s.%s.%s" % (rec_atom.chain_id, residue.name, str(residue.number))
if restraints and res_id in restraints:
try:
parsed_restraints[res_id].append(atom_index)
except:
parsed_restraints[res_id] = [atom_index]
atom_index += 1
try:
return DockingModel(objects, SpacePoints(coordinates), parsed_restraints, n_modes=molecule.n_modes.copy())
except AttributeError:
return DockingModel(objects, SpacePoints(coordinates), parsed_restraints)
in_restraint = False
if restraints and res_id in restraints:
parsed_restraints[res_id] = []
in_restraint = True
for rec_atom in residue.atoms:
rec_atom_type = rec_atom.residue_name + rec_atom.name
rnuma = r3_to_numerical[rec_atom.residue_name]
anuma = atomnumber[rec_atom_type]
dfire_objects.append(DFIREObject(residue.index, rnuma, anuma))
if in_restraint:
parsed_restraints[res_id].append(atom_index)
atom_index += 1
try:
return DockingModel(dfire_objects, molecule.copy_coordinates(), parsed_restraints, n_modes=molecule.n_modes.copy())
except AttributeError:
return DockingModel(dfire_objects, molecule.copy_coordinates(), parsed_restraints)
from lightdock.scoring.functions import ScoringFunction, ModelAdapter
from lightdock.structure.model import DockingModel
import lightdock.scoring.cpydock.energy.c.cpydock as cpydock
import lightdock.scoring.cpydock.energy.parameters as parameters
from lightdock.util.logger import LoggingManager
import lightdock.scoring.cpydock.data.amber as amber
import lightdock.scoring.cpydock.data.vdw as vdw
import lightdock.scoring.cpydock.data.solvation as solvation
from lightdock.constants import DEFAULT_CONTACT_RESTRAINTS_CUTOFF
log = LoggingManager.get_logger('cpydock')
freesasa.setVerbosity(freesasa.silent)
class CPyDockModel(DockingModel):
"""Prepares the structure necessary for the C-implementation of the pyDock scoring function"""
def __init__(self, objects, coordinates, restraints, charges,
vdw_energy, vdw_radii, des_energy, des_radii, sasa, hydrogens,
reference_points=None, n_modes=None):
super(CPyDockModel, self).__init__(objects, coordinates, restraints, reference_points)
self.charges = charges
self.vdw_energy = vdw_energy
self.vdw_radii = vdw_radii
self.des_energy = des_energy
self.des_radii = des_radii
self.sasa = sasa
self.hydrogens = hydrogens
self.n_modes = n_modes
def clone(self):
"""Creates a copy of the current model"""
for rec_atom in residue.atoms:
rec_atom_type = rec_atom.residue_name + rec_atom.name
if rec_atom_type == 'MMBBJ':
try:
membrane[res_id].append(atom_index)
except KeyError:
membrane[res_id] = [atom_index]
rnuma = r3_to_numerical[rec_atom.residue_name]
anuma = atomnumber[rec_atom_type]
atoma = DFIREPotential.atom_res_trans[rnuma, anuma]
dfire_objects.append(atoma)
if in_restraint:
parsed_restraints[res_id].append(atom_index)
atom_index += 1
try:
return DockingModel(dfire_objects, molecule.copy_coordinates(), parsed_restraints, membrane, n_modes=molecule.n_modes.copy())
except AttributeError:
return DockingModel(dfire_objects, molecule.copy_coordinates(), parsed_restraints, membrane)