示例#1
0
文件: rdf.py 项目: chemfiles/cfiles
def OH_rdf_partial(output):
    '''Oxygen-Hydrogen rdf for half of the trajectory'''
    out, err = cfiles(
        "rdf",
        "--steps", "::2",
        "-c", "15",
        "-p", "150",
        "-s", "pairs: name(#1) O and name(#2) H",
        TRAJECTORY, "-o", output
    )
    assert(out == "")
    assert(err == "")

    data = read_rdf(output)
    check_oh_rdf(data)

    out, err = cfiles(
        "rdf",
        "--steps", ":50",
        "-c", "15",
        "-p", "150",
        "-s", "pairs: name(#1) H and name(#2) O",
        TRAJECTORY, "-o", output
    )
    assert(out == "")
    assert(err == "")

    data = read_rdf(output)
    check_ho_rdf(data)
示例#2
0
def OH_rdf_partial():
    '''Oxygen-Hydrogen rdf for half of the trajectory'''
    out, err = cfiles(
        "rdf",
        "--steps", "::2",
        "-c", "15",
        "-p", "150",
        "-s", "pairs: name(#1) O and name(#2) H",
        TRAJECTORY, "-o", OUTPUT
    )
    assert(out == "")
    assert(err == "")

    data = read_rdf(OUTPUT)
    check_oh_rdf(data)

    out, err = cfiles(
        "rdf",
        "--steps", ":50",
        "-c", "15",
        "-p", "150",
        "-s", "pairs: name(#1) H and name(#2) O",
        TRAJECTORY, "-o", OUTPUT
    )
    assert(out == "")
    assert(err == "")

    data = read_rdf(OUTPUT)
    check_oh_rdf(data)
示例#3
0
def correlations(output):
    output_corr = output + ".autocorr"
    out, err = cfiles(
        "hbonds",
        "--guess-bonds",
        "-c", "15",
        TRAJECTORY, "-o", output,
        "--autocorrelation", output_corr
    )
    assert(out == "")
    assert(err == "")

    # This is only a regression test, checking that the right output is
    # generated.
    expected = os.path.join(
        os.path.dirname(__file__), "data", "water.hbonds.autocorrelation.dat"
    )
    with open(output_corr) as actual:
        with open(expected) as expected:
            for line in actual:
                expected_line = expected.readline()
                if line.startswith("#"):
                    continue
                step, value = map(float, line.split())
                exp_step, exp_value = map(float, expected_line.split())
                assert(step == exp_step)
                assert(abs((value - exp_value) / value) < 1e-3)

    os.unlink(output_corr)
示例#4
0
文件: hbonds.py 项目: lscalfi/cfiles
def hbonds():
    out, err = cfiles("hbonds", "--guess-bonds", "-c", "15", TRAJECTORY, "-o",
                      OUTPUT)
    assert (out == "")
    assert (err == "")

    data, indexes = read_data(OUTPUT)
    check_angles(data)
    check_hbonds(indexes)
示例#5
0
def angles(selection, output):
    out, err = cfiles(
        "angles", "--guess-bonds", "-c", "15", "-s", selection, TRAJECTORY, "-o", output
    )
    assert out == ""
    assert err == ""

    data = read_data(output)
    check_angles(data)
示例#6
0
def density(selection):
    out, err = cfiles("density", "-c", "24:24:25.458:90:90:120", "--max=20",
                      "--points=200", "--radial=Z", "-s", selection,
                      TRAJECTORY, "-o", OUTPUT)
    assert (out == "")
    assert (err == "")

    data = read_data(OUTPUT)
    check_density(data)
    return data
示例#7
0
文件: rdf.py 项目: ljx0305/cfiles
def OH_rdf_all():
    '''Oxygen-Hydrogen rdf for the whole trajectory'''
    out, err = cfiles("rdf", "-c", "15", "-p", "150", "-s",
                      "pairs: name(#1) O and name(#2) H", TRAJECTORY, "-o",
                      OUTPUT)
    assert (out == "")
    assert (err == "")

    data = read_rdf(OUTPUT)
    check_oh_rdf(data)

    out, err = cfiles("rdf", "-c", "15", "-p", "150", "-s",
                      "pairs: name(#1) H and name(#2) O", TRAJECTORY, "-o",
                      OUTPUT)
    assert (out == "")
    assert (err == "")

    data = read_rdf(OUTPUT)
    check_ho_rdf(data)
示例#8
0
def hbonds(output):
    out, err = cfiles(
        "hbonds",
        "--guess-bonds",
        "-c", "15",
        TRAJECTORY, "-o", output
    )
    assert(out == "")
    assert(err == "")

    indexes = read_data(output)
    check_hbonds(indexes)
示例#9
0
文件: rdf.py 项目: chemfiles/cfiles
def oxygen_rdf_all(output):
    '''Oxygen rdf for the whole trajectory'''
    out, err = cfiles(
        "rdf",
        "-c", "15",          # Set cell
        "-p", "150",         # Use 150 points in the histogram
        "-s", "name O",      # Compute rdf between O
        TRAJECTORY, "-o", output
    )
    assert(out == "")
    assert(err == "")

    data = read_rdf(output)
    check_oxygen_rdf(data)
示例#10
0
def oxygen_rdf_all():
    '''Oxygen rdf for the whole trajectory'''
    out, err = cfiles(
        "rdf",
        "-c", "15",          # Set cell
        "-p", "150",         # Use 150 points in the histogram
        "-s", "name O",      # Compute rdf between O
        TRAJECTORY, "-o", OUTPUT
    )
    assert(out == "")
    assert(err == "")

    data = read_rdf(OUTPUT)
    check_oxygen_rdf(data)
示例#11
0
def density(selection, output):
    out, err = cfiles(
        "density",
        "-c", "24:24:25.458:90:90:120",
        "--max=20",
        "--points=200",
        "--radial=Z",
        "-s", selection,
        TRAJECTORY, "-o", output
    )
    assert(out == "")
    assert(err == "")

    data = read_data(output)
    check_density(data)
    return data
示例#12
0
            pass
        with open(self.name + ".pdb", "w") as fd:
            fd.write(PDB_CONTENT)

    def __exit__(self, type, value, traceback):
        try:
            os.unlink(self.name + ".pdb")
        except OSError:
            pass
        try:
            os.unlink(self.name + ".xyz")
        except OSError:
            pass


if __name__ == '__main__':
    filename = "convert"
    with isolate_files(filename):
        out, err = cfiles("convert", filename + ".pdb", filename + ".xyz")
        assert (out == "")
        assert (err == "")
        with open(filename + ".xyz") as fd:
            assert (fd.read() == XYZ_CONTENT)
    with isolate_files(filename):
        out, err = cfiles("convert", filename + ".pdb", filename + ".xyz",
                          "--selection", 'atoms: type O')
        assert (out == "")
        assert (err == "")
        with open(filename + ".xyz") as fd:
            assert (fd.read() == XYZ_SEL_CONTENT)
示例#13
0
    def __exit__(self, type, value, traceback):
        try:
            os.unlink(self.name + ".pdb")
        except OSError:
            pass
        try:
            os.unlink(self.name + ".xyz")
        except OSError:
            pass


if __name__ == '__main__':
    filename = "convert"

    with isolate_files(filename):
        out, err = cfiles("convert", filename + ".pdb", filename + ".xyz")
        assert(out == "")
        assert(err == "")
        with open(filename + ".xyz") as fd:
            assert(fd.read() == XYZ_CONTENT)

    with isolate_files(filename):
        out, err = cfiles(
            "convert",
            filename + ".pdb",
            filename + ".xyz",
            "--selection", 'atoms: type O'
        )
        assert(out == "")
        assert(err == "")
        with open(filename + ".xyz") as fd:
示例#14
0
# -*- coding: utf8 -*-
from testrun import cfiles

if __name__ == '__main__':
    stdout, stderr = cfiles("--version")

    assert (stderr == "")
    assert ("version" in stdout)
    assert ("using chemfiles" in stdout)

    stdout, stderr = cfiles("-V")

    assert (stderr == "")
    assert ("version" in stdout)
    assert ("using chemfiles" in stdout)
示例#15
0
# -*- coding: utf8 -*-
from testrun import cfiles


if __name__ == '__main__':
    stdout, stderr = cfiles("--version")

    assert(stderr == "")
    assert("version" in stdout)
    assert("using chemfiles" in stdout)

    stdout, stderr = cfiles("-V")

    assert(stderr == "")
    assert("version" in stdout)
    assert("using chemfiles" in stdout)