Reading and Writing Other File Formats¶
import cctkis assumed.
cctk was originally designed with Gaussian in mind, but has some limited support for other file formats. Please consider OpenBabel for more extensive file conversion needs.
cctk assumes the first line is the number of atoms, the second line is the title, and the third and subsequent lines are geometry specifications of the form
atom_symbol x_position y_position z_position.
Multiple structures per
xyzfile are not currently supported.
# read xyz path = "test/static/test_peptide.xyz" file = cctk.XYZFile.read_file(path) # file contents file.title == "peptide example" molecule = file.molecule # write xyz assert isinstance(molecule2, Molecule) XYZFile.write_molecule_to_file(filename, molecule2, title="title"):
Both single and multiple structures per
# read a single structure path = "test/static/dodecane.mol2" file = cctk.MOL2File.read_file(path) assert isinstance(file, cctk.MOL2File) ensemble = file.ensemble assert isinstance(ensemble, cctk.ConformationalEnsemble) len(ensemble) == 1 molecule = ensemble.molecules # read multiple structures path = "test/static/dodecane-csearch.mol2" file = cctk.MOL2File.read_file(path) assert isinstance(file, cctk.MOL2File) ensemble = file.ensemble assert isinstance(ensemble, cctk.ConformationalEnsemble) len(ensemble) == 597 # write one structure filename2 = "my_filename.mol2" cctk.MOL2File.write_molecule_to_file(filename2, molecule, title) # write multiple structures filename3 = "your_filename.mol2" cctk.MOL2File.write_ensemble_to_file(filename3, ensemble)
Truewill print progress to stdout.
For large files that contain only conformers, set
This will skip many consistency checks and avoid the redundant copying of many data structures. This speeds up performance by over 10x.
# faster reading of MOL2 files with conformers file = cctk.MOL2File.read_file(path, print_status_messages=False, contains_conformers=True)
Only reading is supported.
Both single and multiple structures are supported.
# read .mae file path = "test/static/dodecane_csearch-out.mae" file, pnames, pvals = cctk.MAEFile.read_file(path) assert isinstance(file, cctk.MAEFile) # file contents ensemble = file.ensemble assert isinstance(ensemble, cctk.ConformationalEnsemble) len(ensemble) == 597 len(pnames) == 597 len(pvals) == 597
Orca Input Files¶
In this recipe, we convert an
.xyzfile into an
.inpfile for Orca.
Only single geometries are supported.
read_path = "test/static/test_peptide.xyz" write_path = "test/static/test_peptide.inp" file = cctk.XYZFile.read_file(read_path) header = "! aug-cc-pVTZ aug-cc-pVTZ/C DLPNO-CCSD(T) TightSCF TightPNO MiniPrint\n%pal nproc 4 end\n%maxcore 4000\n%mdci\n density none\nend" cctk.OrcaFile.write_molecule_to_file(write_path, file.molecule, header)