Exemplo n.º 1
0
    def test_wrong_ff_fail(self):
        qlib = QLib("amber", ignore_errors=True)
        with pytest.raises(QLibError):
            qlib.read_ffld("data/ace_ash_nma.ffld11", None)

        qlib = QLib("oplsaa", ignore_errors=True)
        with pytest.raises(QLibError):
            qlib.read_amber_lib("data/ff-amber14/lib/amino12.lib")
        with pytest.raises(QLibError):
            qlib.read_prepin_impropers("data/ff-amber14/lib/amino12.lib")
        with pytest.raises(QLibError):
            qlib.read_mol2("data/all_amino_acids.mol2")
Exemplo n.º 2
0
    def read_amber_conversion(self):
        qlib = QLib("amber")
        qlib.read_amber_lib("data/ff-amber14/amber12_mod.lib")
        qlib.read_amber_lib("data/ff-amber14/arn.lib")
        qlib.read_prepin_impropers("data/ff-amber14/prep/amino12.in")
        qlib.read_prepin_impropers("data/ff-amber14/arn.prepi")

        # remove head from ACE and tail from NME
        cons = qlib.residue_dict["ACE"].connections
        cons = [con for con in cons if "head" not in con]
        qlib.residue_dict["ACE"].connections = cons

        cons = qlib.residue_dict["NME"].connections
        cons = [con for con in cons if "tail" not in con]
        qlib.residue_dict["NME"].connections = cons

        assert qlib.get_string() in open("data/qamber14.lib").read()
Exemplo n.º 3
0
def test_ff14sb_conversion():
    # Amber14FF to Qamber14
    #
    # Convert Amber14 lib (+prepin for impropers) and parm+frcmod to Q lib/prm
    # Load the structure 'all_amino_acids.pdb' and build the topology
    # Check the total bonding energy contributions and number of bonding terms
    # and compare the library and parameter set with official qamber14.
    #
    qal = QLib("amber")
    qap = QPrm("amber", ignore_errors=True)  # duplicates
    qal.read_amber_lib("data/ff-amber14/amber12_mod.lib")
    qal.read_amber_lib("data/ff-amber14/arn.lib")
    qal.read_prepin_impropers("data/ff-amber14/prep/amino12.in")
    qal.read_prepin_impropers("data/ff-amber14/arn.prepi")
    qap.read_amber_parm("data/ff-amber14/parm/parm10.dat")
    qap.read_amber_frcmod("data/ff-amber14/parm/frcmod.ff14SB")

    # add options to parameters
    for line in """\
name                           Q-Amber14SB
type                           AMBER
vdw_rule                       arithmetic !vdW combination rule (geometric or arithmetic)
scale_14                       0.8333 ! electrostatic 1-4 scaling factor
switch_atoms                   off
improper_potential             periodic
improper_definition            explicit\
""".splitlines():
        lf = line.split()
        qap.options[lf[0]] = " ".join(lf[1:])

    # remove head from ACE and tail from NME
    cons = qal.residue_dict["ACE"].connections
    cons = [con for con in cons if "head" not in con]
    qal.residue_dict["ACE"].connections = cons

    cons = qal.residue_dict["NME"].connections
    cons = [con for con in cons if "tail" not in con]
    qal.residue_dict["NME"].connections = cons

    qas1 = QStruct("data/all_amino_acids.pdb", "pdb", ignore_errors=True)
    qat = QTopology(qal, qap, qas1)
    q_tors = sum([len(list(tor.prm.get_prms())) for tor in qat.torsions])

    assert len(qat.bonds) == 464
    assert len(qat.angles) == 829
    assert len(qat.torsions) == 1221
    assert q_tors == 1950
    assert len(qat.impropers) == 102

    be = sum([bond.calc()[0] for bond in qat.bonds])
    ae = sum([ang.calc()[0] for ang in qat.angles])
    te = sum([tor.calc()[0] for tor in qat.torsions])
    ie = sum([imp.calc()[0] for imp in qat.impropers])

    assert is_close(be, 181.2572830)
    assert is_close(ae, 212.8539304)
    assert is_close(te, 417.2919960)
    assert is_close(ie, 22.8171235)

    # compare with official lib
    qa14_lib = open("data/qamber14.lib", "r").read()
    qa14_prm = open("data/qamber14.prm", "r").read()

    assert qal.get_string() in qa14_lib
    assert qap.get_string() in qa14_prm
Exemplo n.º 4
0
 def test_read_prepin_impropers_fail(self):
     # no residues in library
     qlib = QLib("amber")
     with pytest.raises(QLibError):
         qlib.read_amber_lib("data/ff-amber14/prep/amino12.in")
Exemplo n.º 5
0
 def test_read_mol2_fail(self):
     # no residues found
     qlib = QLib("amber")
     with pytest.raises(QLibError):
         qlib.read_amber_lib("data/ff-amber14/parm/parm10.dat")
Exemplo n.º 6
0
    for dup in dups:
        logger.info("Overwritten: {}".format(dup))


#
# Amber14FF to Qamber14
#
# Convert Amber14 lib (+prepin for impropers) and parm+frcmod to Q lib/prm
# Load all_amino_acids.pdb and all_amino_acids.mol2 and build topology
# separately.
#
# ignore_errors=True is needed because frcmod.ff14SB overwrites some parameters
#
qal = QLib("amber")
qap = QPrm("amber", ignore_errors=True)
qal.read_amber_lib("../Amber/ff-amber14/amber12_mod.lib")
qal.read_amber_lib("../Amber/ff-amber14/arn.lib")
qal.read_prepin_impropers("../Amber/ff-amber14/prep/amino12.in")
qal.read_prepin_impropers("../Amber/ff-amber14/arn.prepi")
log_dups(qap.read_amber_parm("../Amber/ff-amber14/parm/parm10.dat"))
log_dups(qap.read_amber_parm("../Amber/ff-amber14/parm/parm10.dat"))
log_dups(qap.read_amber_frcmod("../Amber/ff-amber14/parm/frcmod.ff14SB"))

# add options to parameters
for line in """name		Q-Amber14SB
type		AMBER
vdw_rule    arithmetic !vdW combination rule (geometric or arithmetic)
scale_14	0.8333 ! electrostatic 1-4 scaling factor
switch_atoms	off
improper_potential	periodic
improper_definition explicit""".splitlines():