def test_load_pdbs_fail_rec(testdir): system = "1a4r" ligname = os.path.join(system, f"{system}_ligand.pdb") recname = os.path.join(system, f"{system}_FAIL.pdb") with pytest.raises(Exception): system = loaders.load_pdbs(ligname, recname, testdir)
def test_select(testdir, system, distance, n_ligand, n_receptor): """ Selection compared with PyMol selection: sele byres PROTEIN within DISTANCE of LIGAND """ ligname = os.path.join(system, f"{system}_ligand.pdb") recname = os.path.join(system, f"{system}_protein.pdb") system = loaders.load_pdbs(ligname, recname, testdir) atoms, coordinates = loaders.select(system, distance) assert len(atoms) == n_ligand + n_receptor assert coordinates.shape == (n_ligand + n_receptor, 3)
def test_load_pdbs(testdir, system, n_ligand, n_receptor): ligname = os.path.join(system, f"{system}_ligand.pdb") recname = os.path.join(system, f"{system}_protein.pdb") ulig = mda.Universe(os.path.join(testdir, ligname)) urec = mda.Universe(os.path.join(testdir, recname)) assert len(ulig.atoms) == n_ligand assert len(urec.atoms) == n_receptor system = loaders.load_pdbs(ligname, recname, testdir) assert len(system.atoms) == n_ligand + n_receptor lig = system.select_atoms("resname LIG") assert len(lig.atoms) == n_ligand
def test_select_removeHs(testdir, system, distance, n_ligand, n_receptor): """ Selection compared with PyMol selection: sele byres PROTEIN within DISTANCE of LIGAND Hydrogen atoms were counted by hand and removed (H* does not select 1HD1 while *H* also selects CH2). """ ligname = os.path.join(system, f"{system}_ligand.pdb") recname = os.path.join(system, f"{system}_protein.pdb") system = loaders.load_pdbs(ligname, recname, testdir) atoms, coordinates = loaders.select(system, distance, removeHs=True) # assert len(atoms) == n_ligand + n_receptor assert coordinates.shape == (n_ligand + n_receptor, 3)
# Load and apply atom to index mapping with amap amap = utils.load_amap(args.amap) n_species = len(amap) # Load AEVComputer and model AEVC = utils.loadAEVC(args.aev) model = utils.loadmodel(args.model) AEVC.to(device) model.to(device) with open(args.gradfile, "r") as f: for line in tqdm.tqdm(f): label, recfile, ligfile = line.split() system = loaders.load_pdbs(ligfile, recfile, args.datapaths) # Select ligand and residues # TODO: Unify selections selection = system.select_atoms( f"(byres (around {args.distance} (resname LIG))) or (resname LIG)" ) if args.removeHs: mask = selection.elements != "H" sel_idxs = selection.ix[mask] elements = selection.elements[mask] coordinates = selection.positions[mask] else: