Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
receptor_file = sys.argv[2]
ligand_file = sys.argv[3]
steps = int(sys.argv[4])
configuration_file = sys.argv[5]
log.info("Starting file: %s" % starting_file)
log.info("Receptor: %s" % receptor_file)
log.info("Ligand: %s" % ligand_file)
log.info("Steps: %d" % steps)
log.info("Configuration file: %s" % configuration_file)
print
# Read structures (already in the center)
log.info("Reading %s receptor PDB file..." % receptor_file)
atoms, residues, chains = parse_complex_from_file(receptor_file)
receptor = Complex(chains, atoms)
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
log.info("Reading %s ligand PDB file..." % ligand_file)
atoms, residues, chains = parse_complex_from_file(ligand_file)
ligand = Complex(chains, atoms)
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
# Start from results positions
log.info("Reading calculated data from %s" % starting_file)
translations, rotations, luciferin, neighbors, vision_range, scoring = parse_output_file(starting_file)
num_glowworms = len(translations)
log.info("%d glowworms loaded" % num_glowworms)
adapter = DFIREAdapter(receptor, ligand)
scoring_function = DFIRE()
log.info("Loaded DFIRE scoring function")
parser.add_argument("receptor_structure", help="receptor structure", type=valid_file, metavar="receptor_structure")
# Ligand
parser.add_argument("ligand_structure", help="ligand structure", type=valid_file, metavar="ligand_structure")
# Lightdock output file
parser.add_argument("lightdock_output", help="lightdock output file", type=valid_file, metavar="lightdock_output")
# Solution to minimize
parser.add_argument("glowworm", help="glowworm to minimize", type=valid_integer_number)
# Scoring function
parser.add_argument("-s", "--scoring_function", help="scoring function used", dest="scoring_function")
args = parser.parse_args()
# Read receptor structure
structure = args.receptor_structure
log.info("Reading %s receptor PDB file..." % structure)
atoms, residues, chains = parse_complex_from_file(structure)
receptor = Complex(chains, atoms, residues, structure_file_name=structure)
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
# Read ligand structure
structure = args.ligand_structure
log.info("Reading %s ligand PDB file..." % structure)
atoms, residues, chains = parse_complex_from_file(structure)
ligand = Complex(chains, atoms, residues, structure_file_name=structure)
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
# Output file
translations, rotations, receptor_ids, ligand_ids, rec_extents, lig_extents = parse_output_file(args.lightdock_output)
# Destination path is the same as the lightdock output
destination_path = os.path.dirname(args.lightdock_output)
# If normal modes used, need to read them
structures = []
for structure in get_lightdock_structures(args.receptor_structures):
log.info("Reading %s receptor PDB file..." % structure)
atoms, residues, chains = parse_complex_from_file(structure)
structures.append({'atoms': atoms, 'residues': residues, 'chains': chains, 'file_name': structure})
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
receptor = Complex.from_structures(structures)
# Ligand
structures = []
for structure in get_lightdock_structures(args.ligand_structures):
log.info("Reading %s ligand PDB file..." % structure)
atoms, residues, chains = parse_complex_from_file(structure)
structures.append({'atoms': atoms, 'residues': residues, 'chains': chains, 'file_name': structure})
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
ligand = Complex.from_structures(structures)
# Output file
translations, rotations, receptor_ids, ligand_ids, \
rec_extents, lig_extents = parse_output_file(args.lightdock_output, num_anm_rec, num_anm_lig)
found_conformations = len(translations)
num_conformations = args.glowworms
if num_conformations > found_conformations:
log.warning("Number of conformations is bigger than found solutions (%s > %s)" % (num_conformations,
found_conformations))
log.warning("Clipping number of conformations to %s" % found_conformations)
num_conformations = found_conformations
# Destination path is the same as the lightdock output
destination_path = os.path.dirname(args.lightdock_output)
Parses command line arguments
"""
parser = argparse.ArgumentParser(prog='surface_density')
parser.add_argument("pdb1", help="PDB file for receptor structure")
parser.add_argument("pdb2", help="PDB file for ligand structure")
parser.add_argument("points", type=int, default=400, help="The number of points on the surface")
args = parser.parse_args()
return args
if __name__ == "__main__":
args = parse_command_line()
# Read receptor and calculate max radius
atoms, residues, chains = parse_complex_from_file(args.pdb1)
structure = Complex(chains, atoms, structure_file_name=args.pdb1)
distances_matrix = spatial.distance.squareform(spatial.distance.pdist(structure.representative()))
radius1 = np.max(distances_matrix)/2.
# Read ligand and calculate max radius
atoms, residues, chains = parse_complex_from_file(args.pdb2)
structure = Complex(chains, atoms, structure_file_name=args.pdb2)
distances_matrix = spatial.distance.squareform(spatial.distance.pdist(structure.representative()))
radius2 = np.max(distances_matrix)/2.
# Calculate the area of the sphere of radius (Rl + Rr)
density_area = (4*np.pi*(radius1+radius2)**2)/args.points
if density_area > MIN_SURFACE_DENSITY:
log.warning("Surface density is below recommended, please increase the number of points on the surface.")
print ';'.join([str(x) for x in [radius1, radius2, density_area]])
def from_structures(structures, representative_id=0):
return Complex(structures[representative_id]['chains'],
structures[representative_id]['atoms'],
structures[representative_id]['residues'],
structures[representative_id]['file_name'],
structures, representative_id)
log = LoggingManager.get_logger('diameter')
def parse_command_line():
parser = argparse.ArgumentParser(prog='calculate_diameter')
parser.add_argument("pdb", help="PDB file for structure to calculate maximum diameter")
args = parser.parse_args()
return args
if __name__ == "__main__":
args = parse_command_line()
atoms, residues, chains = parse_complex_from_file(args.pdb)
structure = Complex(chains, atoms, structure_file_name=args.pdb)
distances_matrix = spatial.distance.squareform(spatial.distance.pdist(structure.representative()))
ligand_max_diameter = np.max(distances_matrix)
print ligand_max_diameter
num_anm_rec = DEFAULT_NMODES_REC
num_anm_lig = DEFAULT_NMODES_LIG
if setup and setup['use_anm']:
num_anm_rec = setup['anm_rec']
num_anm_lig = setup['anm_lig']
# Read receptor
log.info("Reading %s receptor PDB file..." % args.receptor_pdb)
atoms, residues, chains = parse_complex_from_file(args.receptor_pdb)
receptor = Complex(chains, atoms)
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
# Read ligand
log.info("Reading %s ligand PDB file..." % args.ligand_pdb)
atoms, residues, chains = parse_complex_from_file(args.ligand_pdb)
ligand = Complex(chains, atoms)
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
try:
nm_path = os.path.abspath(os.path.dirname(args.receptor_pdb))
nmodes_rec = read_nmodes(os.path.join(nm_path, DEFAULT_REC_NM_FILE + '.npy'))
except:
nmodes_rec = None
try:
nm_path = os.path.abspath(os.path.dirname(args.ligand_pdb))
nmodes_lig = read_nmodes(os.path.join(nm_path, DEFAULT_LIG_NM_FILE + '.npy'))
except:
nmodes_lig = None
for step in xrange(0, args.steps+1):
try:
# Parse each stored step file
# Parse arguments
args = parse_command_line()
# Load setup configuration if provided
setup = get_setup_from_file(args.setup_file) if args.setup_file else None
num_anm_rec = DEFAULT_NMODES_REC
num_anm_lig = DEFAULT_NMODES_LIG
if setup and setup['use_anm']:
num_anm_rec = setup['anm_rec']
num_anm_lig = setup['anm_lig']
# Read receptor
log.info("Reading %s receptor PDB file..." % args.receptor_pdb)
atoms, residues, chains = parse_complex_from_file(args.receptor_pdb)
receptor = Complex(chains, atoms)
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
# Read ligand
log.info("Reading %s ligand PDB file..." % args.ligand_pdb)
atoms, residues, chains = parse_complex_from_file(args.ligand_pdb)
ligand = Complex(chains, atoms)
log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))
try:
nm_path = os.path.abspath(os.path.dirname(args.receptor_pdb))
nmodes_rec = read_nmodes(os.path.join(nm_path, DEFAULT_REC_NM_FILE + '.npy'))
except:
nmodes_rec = None
try:
nm_path = os.path.abspath(os.path.dirname(args.ligand_pdb))
nmodes_lig = read_nmodes(os.path.join(nm_path, DEFAULT_LIG_NM_FILE + '.npy'))