コード例 #1
0
def create_DRY_cvs(normalize=True):
    active_traj = utils.load_pdb("3p0g")
    inactive_traj = utils.load_pdb("2rh1")
    q = "chainid 0 and protein and (resSeq 130 to 132)"
    active_DRY_rmsd = RmsdCV("rmsd-active-DRY", active_traj, q)
    inactive_DRY_rmsd = RmsdCV("rmsd-inactive-DRY", inactive_traj, q)
    if normalize:
        active_DRY_rmsd.normalize(trajs=[active_traj, inactive_traj])
        inactive_DRY_rmsd.normalize(trajs=[active_traj, inactive_traj])
    return active_DRY_rmsd, inactive_DRY_rmsd
コード例 #2
0
def create_loose_coupling_cvs(normalize=True):
    active_traj = utils.load_pdb("3p0g")
    inactive_traj = utils.load_pdb("2rh1")
    ligand_cv = LigandBindingCV(active_traj)
    connector_cv = ConnectorRegionCV(active_traj, inactive_traj)
    gprotein_cv = CADistanceCv("helix_63_dist(CA)", 131, 272)
    if normalize:
        ligand_cv.normalize(trajs=[active_traj, inactive_traj])
        connector_cv.normalize(trajs=[active_traj, inactive_traj])
        gprotein_cv.normalize(trajs=[active_traj, inactive_traj])
    return ligand_cv, connector_cv, gprotein_cv
コード例 #3
0
def create_5cvs(normalize=True, pbc=True):
    cvs = np.array([
        CADistanceCv("ALA76-CYS327", 76, 327, pbc),
        CADistanceCv("GLU268-LYS147", 268, 147, pbc),
        CADistanceCv("CYS327-LYS147", 327, 147, pbc),
        CADistanceCv("LEU115-LEU275", 115, 275, pbc),
        CADistanceCv("LYS267-PHE223", 267, 223, pbc)
    ])
    if normalize:
        active_traj = utils.load_pdb("3p0g")
        inactive_traj = utils.load_pdb("2rh1")
        # Note that the original CVs were normalized by a FreeMD trajectory and not just the reference structures.
        for cv in cvs:
            cv.normalize(trajs=[active_traj, inactive_traj])
    return cvs
コード例 #4
0
  def runSingle(self, x):
    prot = x[1] # x[2] is None
    prot_name = CleanName(prot[:-4])
    utils.load_pdb(prot, prot_name)

    rec_name = prot_name + '_R'
    lig_name = prot_name + '_L'

    eprint('cmd.select %s, %s & chain %s' % (
      rec_name, prot_name, '+'.join(self._test_rec_chains)))
    eprint('cmd.select %s, %s & chain %s' % (
      lig_name, prot_name, '+'.join(self._test_lig_chains)))
    cmd.select(rec_name, '%s & chain %s' %(
      prot_name, '+'.join(self._test_rec_chains)))
    cmd.select(lig_name, '%s & chain %s' %(
      prot_name, '+'.join(self._test_lig_chains)))

    rms = x[0].RMSDSep(rec_name, lig_name)
    return (prot_name, rms)
コード例 #5
0
  def runSingle(self, x):
    lig = x[1]
    lig_name = CleanName(lig[:-4]) # Remove the '.pdb'
    utils.load_pdb(lig, lig_name)


    # One case where these come together (SwarmDock).
    if x[2] == _REC_TOGETHER:
      return (lig_name, x[0].RMSDTog(lig_name))

    # Normal, separate function.
    rec = x[2]
    rec_name = CleanName(rec[:-4])
    if rec_name != 'pRp':
      utils.load_pdb(rec, rec_name)

    rms = x[0].RMSDSep(rec_name, lig_name)
    #print 'Finished, rms is %f' % rms
    return (lig_name, rms)
コード例 #6
0
  def __init__(self, args):
    utils.load_pdb(args.gold_p, 'goldp')
    utils.load_pdb(args.test_p, 'testp')

    eprint('goldp & chain %s' % '+'.join(args.gold_rec_chains))
    cmd.create('pR', 'goldp & chain %s' % '+'.join(args.gold_rec_chains))
    cmd.create('pL', 'goldp & chain %s' % '+'.join(args.gold_lig_chains))
    cmd.create('pRp', 'testp & chain %s' % '+'.join(args.test_rec_chains))
    cmd.create('pLp', 'testp & chain %s' % '+'.join(args.test_lig_chains))
    eassert(cmd.count_atoms('pR') > 0, 'no atoms in gold:R')
    eassert(cmd.count_atoms('pL') > 0, 'no atoms in gold:L')
    eassert(cmd.count_atoms('pRp') > 0, 'no atoms in test:R')
    eassert(cmd.count_atoms('pLp') > 0, 'no atoms in test:L')
    for obj in cmd.get_names():
      eprint('obj is %s' % obj)
    self._gold_rec_chains = args.gold_rec_chains
    self._gold_lig_chains = args.gold_lig_chains
    self._test_rec_chains = args.test_rec_chains
    self._test_lig_chains = args.test_lig_chains

    self._test_confs = getRegexFiles(args.test_confs, args.input_fn)
コード例 #7
0
def RunSingleR(obj):
    rec = obj[1]
    rec_name = CleanName(rec[:-4])  # Remove the '.pdb'
    utils.load_pdb(rec, rec_name)
    if obj[3]:  # both
        bound_rms = obj[0].RMSDSep(rec_name,
                                   'pLp',
                                   also_separate=True,
                                   fail_on_error=False)
        unbound_rms = obj[0].RMSDSepSelf(rec_name,
                                         'pLp',
                                         also_separate=True,
                                         fail_on_error=False)
        return [
            bound_rms or [None, float('nan'), float('nan')], unbound_rms
            or [None, float('nan'), float('nan')]
        ]

    return obj[0].RMSDSep(rec_name,
                          obj[2],
                          also_separate=True,
                          fail_on_error=False)
コード例 #8
0
def RunSingleL(obj):
    lig = obj[2]
    lig_name = CleanName(lig[:-4])  # Remove the '.pdb'
    utils.load_pdb(lig, lig_name)
    if obj[3]:  # both
        bound_rms = obj[0].RMSDSep('pRp',
                                   lig_name,
                                   also_separate=True,
                                   fail_on_error=False)
        unbound_rms = obj[0].RMSDSepSelf('pRp',
                                         lig_name,
                                         also_separate=True,
                                         fail_on_error=False)
        return [
            bound_rms or [None, float('nan'), float('nan')], unbound_rms
            or [None, float('nan'), float('nan')]
        ]

    return obj[0].RMSDSep(obj[1],
                          lig_name,
                          also_separate=True,
                          fail_on_error=False)
コード例 #9
0
  def __init__(self, args):
    # Load the proteins.
    utils.load_pdb(args.gold_r, 'pR')
    utils.load_pdb(args.test_r, 'pRp')
    utils.load_pdb(args.gold_l, 'pL')
    utils.load_pdb(args.test_l, 'pLp')

    if args.prot_confs:
      self._lig_confs = getRegexFiles(args.prot_confs, args.input_fn)
      self._rec_confs = [_REC_TOGETHER] * len(self._lig_confs)
    else:
      self._lig_confs = getRegexFiles(args.lig_confs, args.input_fn)
      if args.rec_confs:
        self._rec_confs = getRegexFiles(args.rec_confs, args.input_fn)
      else:
        self._rec_confs = ['pRp.pdb'] * len(self._lig_confs)
コード例 #10
0
def create_COM_distance_cv(id_prefix,
                           res1,
                           res2,
                           res1_atom,
                           res2_atom,
                           normalize=True):
    active_traj = utils.load_pdb("3p0g")
    inactive_traj = utils.load_pdb("2rh1")
    if res1_atom == "CA" and res2_atom == "CA":
        # Optimization
        cv = CADistanceCv(id_prefix + "(CA-CA)", res1, res2)
    elif res1_atom == None and res2_atom == None:
        cv = COMDistanceCv(id_prefix + "(COM)",
                           "protein and resSeq " + str(res1),
                           "protein and resSeq " + str(res2))
    else:
        cv = COMDistanceCv(
            id_prefix + "({}-{})".format(res1_atom, res2_atom),
            "protein and resSeq {} and name {}".format(res1, res1_atom),
            "protein and resSeq {} and name {}".format(res2, res2_atom))
    if normalize:
        cv.normalize(trajs=[active_traj, inactive_traj])
    return cv
コード例 #11
0
def get_nodes_ordering(graph, options):
    if options.pdb:
        res = []
        pdb = load_pdb(options.pdb)
        graph_nodes = set(graph.nodes())
        for c in pdb.get_chains():
            for r in c:
                node_id = c.id + str(r.get_id()[1]) + r.get_id()[2].strip()
                if node_id in graph_nodes:
                    res.append(node_id)
        return res
    else:

        def nodes_ordering(x):
            m = re.match("^(.)([0-9]+)(.*)$", x)
            if m:
                return (m.group(1), int(m.group(2)), m.group(3))
            else:
                return (x[0], x[1:], "")

        return sorted(graph.nodes(), key=nodes_ordering)
コード例 #12
0
                        default=False,
                        help='Print quite a bit of output',
                        action='store_true')

    return parser


def main():
    try:
        args = get_parser().parse_args()
    except SystemExit, ext:
        return

    # Print the output from this.
    utils._VERBOSE = 1
    utils.load_pdb(args.gold_r, 'pR')
    utils.load_pdb(args.test_r, 'pRp')
    utils.load_pdb(args.gold_l, 'pL')
    utils.load_pdb(args.test_l, 'pLp')

    if args.verbose:
        print('Using verbose output')
        utils._VERBOSE = 1
    else:
        utils._VERBOSE = 0

    alnr = PyMolAligner('pR', 'pRp', 'pL', 'pLp', args.dist)

    print(alnr)

コード例 #13
0
    pLList = get_test_structures(args.test_l, args.test_l_files)
    if len(pRList) != 0:
        pRp = pRList[0]
    if len(pLList) != 0:
        pLp = pLList[0]

    # We want to do something a bit different if --both is specified.
    if args.both:
        pRp = args.test_r
        pLp = args.test_l
        pRList = get_test_structures(None, args.test_r_files)
        pLList = get_test_structures(None, args.test_l_files)
        if utils._VERBOSE:
            print('pRList is %d, pLList is %d' % (len(pRList), len(pLList)))

    utils.load_pdb(pR, 'pR')
    utils.load_pdb(pRp, 'pRp')
    utils.load_pdb(pL, 'pL')
    utils.load_pdb(pLp, 'pLp')

    alnr = PyMolAligner('pR', 'pRp', 'pL', 'pLp', args.dist)

    # Test with a single one because Pool hides traceback.
    if utils._VERBOSE:
        if len(pRList) != 0:
            rms = RunSingleR((alnr, pRList[0], 'pLp', args.both))
            prot = pRList[0]
        else:
            rms = RunSingleL((alnr, 'pRp', pLList[0], args.both))
            prot = pLList[0]
        if rms:
コード例 #14
0
def convert_parameters(
    source_directory="original/",
    source_crd="full.crds",
    source_top="full.topo",
    destination_directory="generated/",
    destination_crd="smirnoff.inpcrd",
    destination_top="smirnoff.prmtop",
    host_resname="MGO",
    guest_resname="BAM",
    atom_mapping=None,
    residue_mapping=None,
):

    create_pdb_with_conect(
        solvated_pdb=source_directory + source_crd,
        amber_prmtop=source_directory + source_top,
        output_pdb=destination_directory + "full.pdb",
    )

    prune_conect(input_pdb="full.pdb",
                 output_pdb="full_conect.pdb",
                 path=destination_directory)

    components = split_topology(file_name=destination_directory + "full.pdb")
    hg_topology = create_host_guest_topology(components,
                                             host_resname=host_resname,
                                             guest_resname=guest_resname)

    create_host_mol2(
        solvated_pdb=destination_directory + "full.pdb",
        amber_prmtop=source_directory + source_top,
        mask=host_resname,
        output_mol2=destination_directory + host_resname + ".mol2",
    )

    convert_mol2_to_sybyl_antechamber(
        input_mol2=destination_directory + host_resname + ".mol2",
        output_mol2=destination_directory + host_resname + "-sybyl.mol2",
        ac_doctor=True,
    )

    host = load_mol2(
        filename=destination_directory + host_resname + "-sybyl.mol2",
        name=host_resname,
        add_tripos=True,
    )
    guest = load_mol2(
        filename=source_directory + guest_resname.lower() + ".mol2",
        name=guest_resname,
        add_tripos=False,
    )
    check_unique_atom_names(host)
    check_unique_atom_names(guest)
    molecules = [host, guest]

    ff = ForceField("forcefield/smirnoff99Frosst.ffxml")
    system = ff.createSystem(
        hg_topology.topology,
        molecules,
        nonbondedCutoff=1.1 * unit.nanometer,
        ewaldErrorTolerance=1e-4,
    )

    hg_structure = pmd.openmm.topsystem.load_topology(hg_topology.topology,
                                                      system,
                                                      hg_topology.positions)

    check_bond_lengths(hg_structure, threshold=4)

    try:
        hg_structure.save(destination_directory + "hg.prmtop")
    except OSError:
        logging.warning(
            "Check if the host-guest parameter file already exists...")

    try:
        hg_structure.save(destination_directory + "hg.inpcrd")
    except OSError:
        logging.warning(
            "Check if the host-guest coordinate file already exists...")

    extract_water_and_ions(
        amber_prmtop=source_directory + source_top,
        amber_inpcrd=source_directory + source_crd,
        host_residue=":" + host_resname,
        guest_residue=":" + guest_resname,
        dummy=None,
        output_pdb=destination_directory + "water_ions.pdb",
    )

    create_water_and_ions_parameters(
        input_pdb="water_ions.pdb",
        output_prmtop="water_ions.prmtop",
        output_inpcrd="water_ions.inpcrd",
        dummy_atoms=True,
        path=destination_directory,
    )

    water_and_ions = pmd.amber.AmberParm(
        destination_directory + "water_ions.prmtop",
        xyz=destination_directory + "water_ions.inpcrd",
    )

    merged = mergeStructure(hg_structure, water_and_ions)

    try:
        merged.save(destination_directory + destination_top)
    except:
        logging.warning("Check if solvated parameter file already exists...")
    try:
        merged.save(destination_directory + destination_crd)
    except:
        logging.warning("Check if solvated coordinate file already exists...")

    reference = pmd.load_file(source_directory + source_top,
                              source_directory + source_crd)
    try:
        reference.save(destination_directory + "reference.pdb")
        reference.save(destination_directory + "reference.mol2")
    except OSError:
        logging.warning("Check if file exists...")
    target = pmd.load_file(destination_directory + destination_top,
                           destination_directory + destination_crd)
    try:
        target.save(destination_directory + "target.pdb")
        target.save(destination_directory + "target.mol2")
    except OSError:
        logging.warning("Check if file exists...")

    if not atom_mapping:
        reference_mol = load_mol2(destination_directory + "reference.mol2")
        target_mol = load_mol2(destination_directory + "target.mol2")

        atom_mapping = map_atoms(reference_mol, target_mol)

    if not residue_mapping:
        reference_mol = load_pdb(destination_directory + "reference.pdb")
        target_mol = load_pdb(destination_directory + "target.pdb")
        residue_mapping = map_residues(atom_mapping, reference_mol, target_mol)

    # for file in ["mini.in", "therm1.in", "therm2.in", "eqnpt.in", "mdin"]:
    #     rewrite_amber_input_file(
    #         reference_input=source_directory + file,
    #         target_input=destination_directory + file,
    #         reference_to_target_mapping=residue_mapping,
    #         dt_override=False,
    #         target_prmtop=merged,
    #     )

    # rewrite_restraints_file(
    #     reference_restraints=source_directory + "disang.rest",
    #     target_restraints=destination_directory + "disang.rest",
    #     reference_to_target_mapping=atom_mapping,
    # )

    # For some reason, this must come last, otherwise it gets removed again
    merged.box = reference.box
    try:
        os.remove(destination_directory + destination_top)
        os.remove(destination_directory + destination_crd)
    except OSError:
        pass
    merged.save(destination_directory + destination_crd)
    merged.save(destination_directory + destination_top)

    return atom_mapping, residue_mapping