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)
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)
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)
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)
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)
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
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)
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)
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)
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)
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
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)
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:
# -*- 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)
# -*- 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)