Beispiel #1
0
def test_write_conect():
    pdb_out = 'out.pdb'
    pdb_fn = get_fn('1dwc.pdb')
    command = ['-i', pdb_fn, '-o', pdb_out]
    with tempfolder():
        pdb4amber.main(command)
        with open(pdb_out) as fh:
            assert 'ATOM   1196  SG  CYX H 148      55.729  28.382  19.687  1.00 10.07' in fh.read()
Beispiel #2
0
def test_strip_atoms():
    pdb_fn = get_fn('2igd/2igd.cif')
    pdb_out = 'out.pdb'
    command = ['-i', pdb_fn, '-o', pdb_out, '--strip', ':3-500']
    with tempfolder():
        pdb4amber.main(command)
        parm = pmd.load_file(pdb_out)
        assert len(parm.residues) == 2
Beispiel #3
0
def test_keep_all_model():
    orig_parm = pmd.download_PDB('1l2y')
    pdb_out = 'out.pdb'

    # default
    with tempfolder():
        pdb4amber.main(['1l2y', '--pdbid', '-o', pdb_out, '--model', '-1'])
        parm = pmd.load_file(pdb_out)
        assert parm.get_coordinates().shape == (38, 304, 3)
Beispiel #4
0
def test_constantph():
    option = '--constantph'
    pdb_out = 'out.pdb'
    command = ['-i', pdb_fn, '-o', pdb_out, option]

    with tempfolder():
        # just run to increase code coverage
        # we already test in another file
        pdb4amber.main(command)
Beispiel #5
0
def test_reduce_with_cif_input():
    option = '--reduce'
    pdb_fn = get_fn('2igd/2igd.cif')
    pdb_out = 'out.pdb'
    command = ['-i', pdb_fn, '-o', pdb_out, option]

    with tempfolder():
        pdb4amber.main(command)
        parm = pmd.load_file(pdb_out)
        atom_names = set(atom.name for atom in parm.atoms
                         if atom.atomic_number == 1)
        assert atom_names
Beispiel #6
0
def test_noh(tmpdir):
    inp_pdb = get_fn('nmr_struc_1.pdb')
    with tmpdir.as_cwd():
        parm_with_h = pmd.load_file(inp_pdb)
        assert len(parm_with_h.atoms) == 304
        assert len([
            atom for atom in parm_with_h.atoms if atom.atomic_number == 1
        ]) == 150
        pdb4amber.main([inp_pdb, '-y', '-o', 'out.pdb'])
        parm = pmd.load_file('out.pdb')
        assert not [atom for atom in parm.atoms if atom.atomic_number == 1]
        assert len(parm.atoms) == 154
Beispiel #7
0
def test_write_sslink():
    pdb_out = 'out.pdb'
    pdb_fn = get_fn('4lzt/4lzt_h.pdb')
    command = ['-i', pdb_fn, '-o', pdb_out]
    sslink_name = 'out_sslink'
    sslink_pair = [(6, 127), (30, 115), (64, 80), (76, 94)]

    with tempfolder():
        pdb4amber.main(command)
        with open(sslink_name) as fh:
            for index, line in enumerate(fh):
                id0, idx1 = [int(i) for i in line.split()]
                assert (id0, idx1) == sslink_pair[index]
Beispiel #8
0
def test_fetch_pdbid(tmpdir):
    ''' e.g: pdb4amber 1l2y --pdbid '''
    pdb_fn = '1l2y'

    with tmpdir.as_cwd():
        with patch('parmed.download_PDB') as mock_download:

            def effect(*args):
                return pmd.load_file(get_fn('1l2y.pdb'))

            mock_download.side_effect = effect
            pdb4amber.main(['1l2y', '--pdbid', '-o', 'out.pdb'])
            assert mock_download.called
Beispiel #9
0
def test_writing_renum():
    pdb_fn = get_fn('2igd/2igd_2_residues.pdb')
    pdb_out = 'out.pdb'
    command = [pdb_fn]
    expected_lines = """
MET     1    MET     1
PRO     3    PRO     2
    """.strip().split('\n')

    with tempfolder():
        pdb4amber.main(command)
        with open('stdout_renum.txt') as fh:
            output_lines = [line.strip() for line in fh.readlines()]
            assert expected_lines == output_lines
Beispiel #10
0
def test_write_model():
    fname = get_fn('1l2y.pdb')
    orig_parm = pmd.load_file(fname)
    pdb_out = 'out.pdb'

    # default
    with tempfolder():
        pdb4amber.main([fname, '-o', pdb_out])
        parm = pmd.load_file(pdb_out)
        assert parm.get_coordinates().shape == (1, 304, 3)

    # model 1
    with tempfolder():
        pdb4amber.main([fname, '-o', pdb_out, '--model', '1'])
        parm = pmd.load_file(pdb_out)
        assert parm.get_coordinates().shape == (1, 304, 3)
        np.testing.assert_almost_equal(parm.coordinates,
                                       orig_parm.get_coordinates()[0])

    # model 2
    model = 2
    with tempfolder():
        pdb4amber.main([fname, '-o', pdb_out, '--model', str(model)])
        parm = pmd.load_file(pdb_out)
        assert parm.get_coordinates().shape == (1, 304, 3)
        np.testing.assert_almost_equal(parm.coordinates,
                                       orig_parm.get_coordinates()[model - 1])

    # keep all models
    with tempfolder():
        pdb_out = 'out.pdb'
        pdb4amber.main([fname, '-o', pdb_out, '--model', '-1'])
        parm = pmd.load_file(pdb_out)
        assert parm.get_coordinates().shape == (38, 304, 3)
Beispiel #11
0
def test_amber_compatible_residues(tmpdir):
    option = '--amber-compatible-residues'
    pdb_in = get_fn('3orn.pdb')
    pdb_out = 'out.pdb'
    command = ['-i', pdb_in, '-o', pdb_out, option]

    with tmpdir.as_cwd():
        pdb4amber.main(command)
        parm = pmd.load_file(pdb_out)
        res_names = set(res.name for res in parm.residues)
        assert res_names == {
            'ALA', 'ARG', 'ASN', 'ASP', 'CYS', 'GLN', 'GLU', 'GLY', 'HIS',
            'HOH', 'ILE', 'LEU', 'LYS', 'MET', 'MG', 'PHE', 'PRO', 'SER',
            'THR', 'TRP', 'TYR', 'VAL'
        }
Beispiel #12
0
def test_prot_only():
    option = '--pro'
    pdb_out = 'out.pdb'
    command = ['-i', pdb_fn, '-o', pdb_out, option]

    with tempfolder():
        orig_parm = pmd.load_file(pdb_fn)
        res_names = set(res.name for res in orig_parm.residues)
        assert 'NO3' in res_names
        assert 'HOH' in res_names

        pdb4amber.main(command)
        parm = pmd.load_file(pdb_out)
        res_names = set(res.name for res in parm.residues)
        assert 'NO3' not in res_names
        assert 'HOH' not in res_names
Beispiel #13
0
def test_no_hydrogen():
    option = '--nohyd'
    pdb_out = 'out.pdb'
    command = ['-i', pdb_fn, '-o', pdb_out, option]

    with tempfolder():
        orig_parm = pmd.load_file(pdb_fn)
        atom_names = set(atom.name for atom in orig_parm.atoms
                         if atom.atomic_number == 1)
        assert atom_names

        pdb4amber.main(command)
        parm = pmd.load_file(pdb_out)
        atom_names = set(atom.name for atom in parm.atoms
                         if atom.atomic_number == 1)
        assert not atom_names
Beispiel #14
0
def test_not_write_sslink_conect_record():
    pdb_out = 'out.pdb'
    pdb_fn = get_fn('4lzt/4lzt_h.pdb')
    sslink_name = 'out_sslink'

    # has conect
    with tempfolder():
        command = ['-i', pdb_fn, '-o', pdb_out]
        pdb4amber.main(command)
        with open(pdb_out) as fh:
            assert 'CONECT' in fh.read()

    # no conect
    with tempfolder():
        command = ['-i', pdb_fn, '-o', pdb_out, '--no-conect']
        pdb4amber.main(command)
        with open(pdb_out) as fh:
            assert 'CONECT' not in fh.read()
Beispiel #15
0
def test_dry():
    option = '--dry'
    pdb_out = 'out.pdb'
    command = ['-i', pdb_fn, '-o', pdb_out, option]

    with tempfolder():
        orig_parm = pmd.load_file(pdb_fn)
        resnames = set(res.name for res in orig_parm.residues)
        assert resnames.intersection(WATER_NAMES)

        pdb4amber.main(command)
        parm = pmd.load_file(pdb_out)
        resnames = set(res.name for res in parm.residues)
        assert not resnames.intersection(WATER_NAMES)

        # water
        water_parm = pmd.load_file('out_water.pdb')
        assert set(res.name for res in water_parm.residues) == {'HOH'}
Beispiel #16
0
def test_write_model():
    orig_parm = pmd.download_PDB('1l2y')
    pdb_out = 'out.pdb'

    # default
    with tempfolder():
        pdb4amber.main(['1l2y', '--pdbid', '-o', pdb_out])
        parm = pmd.load_file(pdb_out)
        assert parm.get_coordinates().shape == (1, 304, 3)

    # model 1
    with tempfolder():
        pdb4amber.main(['1l2y', '--pdbid', '-o', pdb_out, '--model', '1'])
        parm = pmd.load_file(pdb_out)
        assert parm.get_coordinates().shape == (1, 304, 3)
        np.testing.assert_almost_equal(parm.coordinates,
                                       orig_parm.get_coordinates()[0])

    # model 2
    model = 2
    with tempfolder():
        pdb4amber.main(['1l2y', '--pdbid', '-o', pdb_out, '--model',
            str(model)
        ])
        parm = pmd.load_file(pdb_out)
        assert parm.get_coordinates().shape == (1, 304, 3)
        np.testing.assert_almost_equal(parm.coordinates,
                                       orig_parm.get_coordinates()[model - 1])