Ejemplo n.º 1
0
def test_negative_residue_numbers_2jaj():
    mol = mdt.read(get_data_path('2jaj.pdb'))
    res = mol.chains['B'].residues[0]
    assert res.pdbindex == -4
    assert res.index == 272
    assert res.name == 'GLY-4'

    mread = mdt.read(mol.write('pdb'),
                     format='pdb')
    res = mread.chains['B'].residues[0]
    assert res.pdbindex == -4
    assert res.index == 272
    assert res.name == 'GLY-4'
def test_frame_to_molecule_conversion(precanned_trajectory):
    traj = precanned_trajectory

    f0_position = u.angstrom*[[1, 0, 0],
                              [0, 0, 0],
                              [0, 1, 0]]

    f2_position = u.angstrom*[[2, 0, 0],
                              [-1, 0, 0],
                              [-1, 1, 0]]

    f0 = traj.frames[0]
    mol = f0.as_molecule()
    assert mol.same_topology(traj.mol)
    assert (mol.positions == f0_position).all()
    assert mol.time == 0.0 * u.fs

    # test ability to directly write a frame
    readmol = mdt.read(f0.write('xyz'), format='xyz')
    np.testing.assert_allclose(readmol.positions.value_in(u.angstrom),
                               f0_position.value_in(u.angstrom))


    m2 = traj.frames[-1].as_molecule()
    assert m2.same_topology(mol)
    assert (m2.positions == f2_position).all()
    assert m2.time == 2.0 * u.fs
Ejemplo n.º 3
0
def test_disulfide_bond_detection_1hpk():
    mol = mdt.read(get_data_path('1hpk.pdb'))
    mol = mdt.interfaces.ambertools._prep_for_tleap(mol)
    for residx in (0, 21, 49, 61, 73, 78):
        residue = mol.residues[residx]
        assert residue.resname == 'CYX'
        assert residue.name[:3] == 'CYX'
Ejemplo n.º 4
0
def test_missing_terminal_atoms_3ac2():
    """ Tests that we can still detect terminal residues even if the peptide-bonded atoms
    are missing from the structure
    """
    mol = mdt.read(get_data_path('3ac2.pdb'))
    assert mol.chains['A'].n_terminal is not None
    assert mol.chains['A'].c_terminal is not None
def mol_from_sdf():
    return mdt.read("""
 OpenBabel02271712493D

 11 10  0  0  0  0  0  0  0  0999 V2000
    0.9114   -0.0615    0.0032 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.4168    1.3750    0.0264 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.9114    2.1503   -1.1831 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.5568   -0.5828   -0.8916 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.5460   -0.6043    0.8807 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.0053   -0.0987    0.0111 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.6785    1.3847    0.0446 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.7625    1.8663    0.9425 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.5568    1.6932   -2.1123 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.5460    3.1815   -1.1499 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.0053    2.1774   -1.2097 H   0  0  0  0  0  0  0  0  0  0  0  0
  2  1  1  0  0  0  0
  3  2  1  0  0  0  0
  4  1  1  0  0  0  0
  5  1  1  0  0  0  0
  6  1  1  0  0  0  0
  7  2  1  0  0  0  0
  8  2  1  0  0  0  0
  9  3  1  0  0  0  0
 10  3  1  0  0  0  0
 11  3  1  0  0  0  0
M  END
$$$$
""",
                    format='sdf')
def cached_mol_from_sdf():
    return mdt.read("""
 OpenBabel02271712493D

 11 10  0  0  0  0  0  0  0  0999 V2000
    0.9114   -0.0615    0.0032 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.4168    1.3750    0.0264 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.9114    2.1503   -1.1831 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.5568   -0.5828   -0.8916 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.5460   -0.6043    0.8807 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.0053   -0.0987    0.0111 H   0  0  0  0  0  0  0  0  0  0  0  0
   -0.6785    1.3847    0.0446 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.7625    1.8663    0.9425 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.5568    1.6932   -2.1123 H   0  0  0  0  0  0  0  0  0  0  0  0
    0.5460    3.1815   -1.1499 H   0  0  0  0  0  0  0  0  0  0  0  0
    2.0053    2.1774   -1.2097 H   0  0  0  0  0  0  0  0  0  0  0  0
  2  1  1  0  0  0  0
  3  2  1  0  0  0  0
  4  1  1  0  0  0  0
  5  1  1  0  0  0  0
  6  1  1  0  0  0  0
  7  2  1  0  0  0  0
  8  2  1  0  0  0  0
  9  3  1  0  0  0  0
 10  3  1  0  0  0  0
 11  3  1  0  0  0  0
M  END
$$$$
""", format='sdf')
def test_compressed_write(bipyridine_xyz, tmpdir, suffix):
    # Note: compressed read is tested elsewhere when reading test data files
    path = pathlib.Path(native_str(tmpdir))
    dest = path / ('bipyr.xyz.' + suffix)
    bipyridine_xyz.write(dest)

    # don't use MDT's reader here! Need to make sure it's really gzip'd
    if suffix == 'gz':
        opener = gzip.open
    elif suffix == 'bz2':
        opener = bz2.BZ2File
    else:
        raise ValueError('Unrecognized suffix "%s"' % suffix)

    if PY2:
        mode = 'r'
    else:
        mode = 'rt'
        if suffix == 'bz2':
            opener = bz2.open

    with opener(str(dest), mode) as infile:
        content = infile.read()

    mol = mdt.read(content, format='xyz')
    assert mol.num_atoms == bipyridine_xyz.num_atoms
Ejemplo n.º 8
0
def test_compressed_write(bipyridine_xyz, tmpdir, suffix):
    # Note: compressed read is tested elsewhere when reading test data files
    path = pathlib.Path(native_str(tmpdir))
    dest = path / ('bipyr.xyz.' + suffix)
    bipyridine_xyz.write(dest)

    # don't use MDT's reader here! Need to make sure it's really gzip'd
    if suffix == 'gz':
        opener = gzip.open
    elif suffix == 'bz2':
        opener = bz2.BZ2File
    else:
        raise ValueError('Unrecognized suffix "%s"' % suffix)

    if PY2:
        mode = 'r'
    else:
        mode = 'rt'
        if suffix == 'bz2':
            opener = bz2.open

    with opener(str(dest), mode) as infile:
        content = infile.read()

    mol = mdt.read(content, format='xyz')
    assert mol.num_atoms == bipyridine_xyz.num_atoms
Ejemplo n.º 9
0
def test_missing_residues_xtal_2jaj():
    mol = mdt.read(get_data_path('2jaj.pdb'))

    missingres = mol.metadata.missing_residues

    for expected in MISSINGRES_2JAJ:
        assert missingres[expected[0]][expected[2]] == expected[1]
def test_write_file_to_buffer(bipyridine_smiles):
    mol = bipyridine_smiles
    buffer = native_str_buffer()
    mol.write(buffer, format='pdb')

    buffer.seek(0)
    newmol = mdt.read(buffer.getvalue(), format='pdb')
    assert mol.num_atoms == newmol.num_atoms
Ejemplo n.º 11
0
def test_write_file_to_buffer(bipyridine_smiles):
    mol = bipyridine_smiles
    buffer = native_str_buffer()
    mol.write(buffer, format='pdb')

    buffer.seek(0)
    newmol = mdt.read(buffer.getvalue(), format='pdb')
    assert mol.num_atoms == newmol.num_atoms
def test_amber_tleap():
    mol = mdt.read('../data/nuc.pdb')
    model = moldesign.methods.models.OpenMMPotential(implicit_solvent='obc',
                                                     cutoff=8.0 * u.angstrom,
                                                     force_field='ff14SB')
    mol.set_energy_model(model)
    result = mol.calculate(wait=True)
    assert 'potential_energy' in result and 'forces' in result
Ejemplo n.º 13
0
def test_topology_preserved_in_serialization(bipyridine_smiles, fmt):
    """ Test that bond topology is preserved even if it doesn't make sense from distances
    """
    mol = bipyridine_smiles.copy()  # don't screw up the fixture object
    mol.bond_graph[mol.atoms[3]][mol.atoms[5]] = 3
    mol.bond_graph[mol.atoms[5]][mol.atoms[3]] = 3
    mol.atoms[3].x += 10.0 * u.angstrom

    newmol = mdt.read(mol.write(format=fmt), format=fmt)
    assert mol.same_bonds(newmol, verbose=True)
Ejemplo n.º 14
0
def test_topology_preserved_in_serialization(bipyridine_smiles, fmt):
    """ Test that bond topology is preserved even if it doesn't make sense from distances
    """
    if fmt != 'pkl':
        pytest.xfail("We are currently unable to get an unambiguous representation of a molecular "
                     "sructure with ANY current file formats or parsers.")
    mol = bipyridine_smiles.copy()  # don't screw up the fixture object
    mol.bond_graph[mol.atoms[3]][mol.atoms[5]] = 3
    mol.bond_graph[mol.atoms[5]][mol.atoms[3]] = 3
    mol.atoms[3].x += 10.0 * u.angstrom

    newmol = mdt.read(mol.write(format=fmt), format=fmt)
    assert mol.same_bonds(newmol, verbose=True)
def test_topology_preserved_in_serialization(bipyridine_smiles, fmt):
    """ Test that bond topology is preserved even if it doesn't make sense from distances
    """
    if fmt != 'pkl':
        pytest.xfail(
            "We are currently unable to get an unambiguous representation of a molecular "
            "sructure with ANY current file formats or parsers.")
    mol = bipyridine_smiles.copy()  # don't screw up the fixture object
    mol.bond_graph[mol.atoms[3]][mol.atoms[5]] = 3
    mol.bond_graph[mol.atoms[5]][mol.atoms[3]] = 3
    mol.atoms[3].x += 10.0 * u.angstrom

    newmol = mdt.read(mol.write(format=fmt), format=fmt)
    assert mol.same_bonds(newmol, verbose=True)
Ejemplo n.º 16
0
def test_numeric_residue_name_1PYN():
    """ The ligand in this residue is named "941", which causes a little trickiness
    """
    import parmed

    mol = mdt.read(get_data_path('1pyn.pdb'))
    ligand = mdt.Molecule(mol.residues[283])

    params = mdt.parameterize(ligand, charges='gasteiger')
    params.lib.put('/tmp/tmp.lib')

    contents = parmed.load_file('/tmp/tmp.lib')
    assert len(contents) == 1
    assert contents.keys()[0] == '941'
Ejemplo n.º 17
0
def test_split_chains_3p3k():
    mol = mdt.read(get_data_path('3p3k.pdb.gz'))
    assert mol.num_chains == 1  # not really testing this, just for sanity's sake

    newmol = mdt.split_chains(mol)
    assert newmol.num_chains == 3

    assert newmol.chains['A'] is newmol.chains[0]
    assert newmol.chains['A'].type == 'protein'

    assert newmol.chains['B'] is newmol.chains[1]
    assert newmol.chains['B'].type == 'protein'

    assert newmol.chains['C'] is newmol.chains[2]
    assert newmol.chains['C'].type == 'water'
def test_split_chains_3p3k():
    mol = mdt.read(get_data_path('3p3k.pdb'))
    assert mol.num_chains == 1  # not really testing this, just for sanity's sake

    newmol = mdt.split_chains(mol)
    assert newmol.num_chains == 3

    assert newmol.chains['A'] is newmol.chains[0]
    assert newmol.chains['A'].type == 'protein'

    assert newmol.chains['B'] is newmol.chains[1]
    assert newmol.chains['B'].type == 'protein'

    assert newmol.chains['C'] is newmol.chains[2]
    assert newmol.chains['C'].type == 'water'
def mol_from_xyz():
    return mdt.read("""43
    c1.pdb
    C         -1.21700        1.04300        2.45300
    C         -0.14200        0.18700        2.19500
    C         -0.31600       -0.99500        1.46200
    C         -1.59800       -1.33100        1.02200
    C         -2.68200       -0.48500        1.28100
    C         -2.50400        0.70500        1.98200
    O         -3.53000        1.57400        2.25000
    O         -1.13200        2.21500        3.14700
    C          0.14200        2.61500        3.63500
    C          0.86700       -1.90600        1.12900
    C          1.10600       -1.99700       -0.40500
    O          2.06900       -1.52700        1.78600
    O          1.81300       -0.81200       -0.83600
    C          1.98100       -3.18300       -0.81100
    O          2.18000       -3.27400       -2.21400
    C          1.18300        0.32500       -1.28900
    C          0.13100        0.33800       -2.23300
    C         -0.38800        1.56800       -2.65400
    C          0.15900        2.77500       -2.20100
    C          1.23000        2.75900       -1.31000
    C          1.72800        1.53500       -0.85900
    O         -0.31100       -0.88000       -2.70600
    C         -1.43500       -0.90100       -3.58200
    H          0.84400        0.42500        2.57000
    H         -1.77600       -2.25500        0.47700
    H         -3.67600       -0.75700        0.93200
    H         -4.35900        1.18400        1.93700
    H         -0.03000        3.54300        4.18500
    H          0.84500        2.80900        2.81200
    H          0.56300        1.86400        4.31600
    H          0.63600       -2.91500        1.49500
    H          0.14200       -2.06200       -0.91500
    H          2.51900       -0.89500        1.20400
    H          1.52900       -4.10700       -0.41600
    H          2.97500       -3.07900       -0.36800
    H          1.34400       -3.10100       -2.67400
    H         -1.20600        1.60000       -3.36300
    H         -0.25300        3.71600       -2.56000
    H          1.68000        3.68900       -0.97300
    H          2.55900        1.49100       -0.16100
    H         -1.60900       -1.95000       -3.81500
    H         -1.22800       -0.35800       -4.51600
    H         -2.32500       -0.48000       -3.09700
    """,
                    format='xyz')
def cached_mol_from_xyz():
    return mdt.read("""43
    c1.pdb
    C         -1.21700        1.04300        2.45300
    C         -0.14200        0.18700        2.19500
    C         -0.31600       -0.99500        1.46200
    C         -1.59800       -1.33100        1.02200
    C         -2.68200       -0.48500        1.28100
    C         -2.50400        0.70500        1.98200
    O         -3.53000        1.57400        2.25000
    O         -1.13200        2.21500        3.14700
    C          0.14200        2.61500        3.63500
    C          0.86700       -1.90600        1.12900
    C          1.10600       -1.99700       -0.40500
    O          2.06900       -1.52700        1.78600
    O          1.81300       -0.81200       -0.83600
    C          1.98100       -3.18300       -0.81100
    O          2.18000       -3.27400       -2.21400
    C          1.18300        0.32500       -1.28900
    C          0.13100        0.33800       -2.23300
    C         -0.38800        1.56800       -2.65400
    C          0.15900        2.77500       -2.20100
    C          1.23000        2.75900       -1.31000
    C          1.72800        1.53500       -0.85900
    O         -0.31100       -0.88000       -2.70600
    C         -1.43500       -0.90100       -3.58200
    H          0.84400        0.42500        2.57000
    H         -1.77600       -2.25500        0.47700
    H         -3.67600       -0.75700        0.93200
    H         -4.35900        1.18400        1.93700
    H         -0.03000        3.54300        4.18500
    H          0.84500        2.80900        2.81200
    H          0.56300        1.86400        4.31600
    H          0.63600       -2.91500        1.49500
    H          0.14200       -2.06200       -0.91500
    H          2.51900       -0.89500        1.20400
    H          1.52900       -4.10700       -0.41600
    H          2.97500       -3.07900       -0.36800
    H          1.34400       -3.10100       -2.67400
    H         -1.20600        1.60000       -3.36300
    H         -0.25300        3.71600       -2.56000
    H          1.68000        3.68900       -0.97300
    H          2.55900        1.49100       -0.16100
    H         -1.60900       -1.95000       -3.81500
    H         -1.22800       -0.35800       -4.51600
    H         -2.32500       -0.48000       -3.09700
    """, format='xyz')
Ejemplo n.º 21
0
def test_frame_to_molecule_conversion(precanned_trajectory):
    traj = precanned_trajectory

    f0_position = u.angstrom * [[1, 0, 0], [0, 0, 0], [0, 1, 0]]

    f2_position = u.angstrom * [[2, 0, 0], [-1, 0, 0], [-1, 1, 0]]

    f0 = traj.frames[0]
    mol = f0.as_molecule()
    assert mol.same_topology(traj.mol)
    assert (mol.positions == f0_position).all()
    assert mol.time == 0.0 * u.fs

    # test ability to directly write a frame
    readmol = mdt.read(f0.write('xyz'), format='xyz')
    np.testing.assert_allclose(readmol.positions.value_in(u.angstrom),
                               f0_position.value_in(u.angstrom))

    m2 = traj.frames[-1].as_molecule()
    assert m2.same_topology(mol)
    assert (m2.positions == f2_position).all()
    assert m2.time == 2.0 * u.fs
Ejemplo n.º 22
0
def pdb_3ac2():
    return mdt.read(get_data_path('3ac2.pdb.bz2'))
Ejemplo n.º 23
0
def test_missing_atoms_3b5x():
    mol = mdt.read(get_data_path('3b5x.cif.bz2'))
    assert mol.num_chains == 2
    assert mol.num_atoms == 1144
    assert mol.num_residues == 1144
def bipyridine_sdf():
    return mdt.read(get_data_path('bipyridine.sdf'))
Ejemplo n.º 25
0
def pdb_1pyn():
    return mdt.read(get_data_path('1pyn.pdb.gz'))
Ejemplo n.º 26
0
def pdb_2jaj_roundtrip(pdb_2jaj):
    return mdt.read(pdb_2jaj.write('pdb'), format='pdb')
Ejemplo n.º 27
0
def pdb_1hpk_roundtrip(pdb_1hpk):
    return mdt.read(pdb_1hpk.write('pdb'), format='pdb')
def propane_pdb():
    return mdt.read(get_data_path('propane.pdb'))
def pdb1yu8():
    return mdt.read(get_data_path('1yu8.pdb'))
def bipyridine_mol2():
    return mdt.read(get_data_path('bipyridine.mol2'))
def protein():
    return mdt.read(helpers.get_data_path('3aid.pdb.gz'))
def mmcif_1kbu():
    return mdt.read(get_data_path('1KBU.cif.bz2'))
Ejemplo n.º 33
0
def pdb_3ac2_roundtrip(pdb_3ac2):
    return mdt.read(pdb_3ac2.write('pdb'), format='pdb')
def protease_cif():
    return mdt.read(get_data_path('3aid.cif.bz2'))
Ejemplo n.º 35
0
def pdb_1hpk():
    return mdt.read(get_data_path('1hpk.pdb'))
def nucleic():
    # ACTG.pdb contains a molecule generated using mdt.build_dna('ACTG')
    mol = mdt.read(get_data_path('ACTG.pdb'))
    return mol
Ejemplo n.º 37
0
def pdb_2jaj():
    return mdt.read(get_data_path('2jaj.pdb.gz'))
def pdb3aid():
    mol = mdt.read(get_data_path('3aid.pdb.gz'))
    return mol
Ejemplo n.º 39
0
def test_missing_residues_nmr_5b7a():
    mol = mdt.read(get_data_path('5b7a.pdb.bz2'))
    missingres = mol.metadata.missing_residues
    for expected in MISSINGRES_5B7A:
        assert missingres[expected[0]][expected[2]] == expected[1]
    assert mol.metadata.description == 'STRUCTURES OF HUMAN SUMO'
Ejemplo n.º 40
0
def pdb_1pyn_roundtrip(pdb_1pyn):
    return mdt.read(pdb_1pyn.write('pdb'), format='pdb')
def protease_pdb():
    return mdt.read(get_data_path('3aid.pdb.gz'))
Ejemplo n.º 42
0
def test_single_chain_2p8w():
    mol = mdt.read(get_data_path('2p8w.cif.bz2'))
    assert mol.num_chains == 3
    assert mol.chains['C'].num_residues == 1
    assert mol.chains['C'].residues['GNP843'].num_atoms == 32
def bipyridine_xyz():
    return mdt.read(get_data_path('bipyridine.xyz'))
def test_read_from_buffer():
    s = native_str("2\nmy xyz file\n H  1.0 1.0 1.0\n H 1.0 2.0 1.0\n")
    buffer = native_str_buffer(s)
    h2 = mdt.read(buffer, format='xyz')
    assert h2.num_atoms == 2