pychemia.io package

Routines to import and export atomic structures. Currently supported are ASCII, CIF and XYZ

Submodules

pychemia.io.ascii module

Module for support V_sim ascii fileformat Contains routines to load .ascii files and create pychemia Structure objects and to save back to .ascii files

This code was originally created for ASE

pychemia.io.ascii.cell_to_reduced(full)[source]

Transforms the given matrix full into a reduced array used by V_Sim to store box definition.

translated from src/coreTools/toolMatrix.c subroutine tool_matrix_reducePrimitiveVectors

pychemia.io.ascii.load(filep)[source]

Read an V_sim .ascii file and returns a pychemia Structure object

Args:
filep: (string) Path to a .ascii file or an
actual file-like object
Returns:
struct: (object) A pychemia Structure object
pychemia.io.ascii.save(struct, filep, cartesian=True, long_format=True, angdeg=False)[source]

Saves a pychemia Structure object in V_sim .ascii fileformat in the simplest way, i.e. using all defaults with no optional keywords. In the first line we add the number of atoms, as this is used by certain code

pychemia.io.cif module

Several routines to read and write CIF files

class pychemia.io.cif.CIF(data)[source]

Bases: object

block_from_string(string)[source]
static from_file(filename)[source]
static from_string(string)[source]
split_data()[source]
class pychemia.io.cif.CIFStructure(cif_blocks, title=None)[source]

Bases: object

get_lattice()[source]

Generate the lattice from the provided lattice parameters. In the absence of all six lattice parameters, the crystal system and necessary parameters are parsed

get_symmetry_operations()[source]
pychemia.io.cif.cif_expand(path, dirname=None, verbose=False)[source]

Split a multi-structure CIF file and return a directory with all the CIFs in separated files

Parameters:
  • path – Path to the file that contain multi-structure
  • dirname – Path to the directory where the extracted CIFs will be located, by default it will be the same location of the original file and the name of the directory will be the name of the ‘filename’ without extension
  • verbose – Print some extra info

:rtype : str

pychemia.io.cif.get_singlecifs(dirname, verbose=False)[source]

Recursively explores a directory searching for .cif files, determines if they are single or multi-structure, expand those multi and return a list of single-strcuture cif files

Parameters:
  • dirname – (str) Directory to read CIFS
  • verbose – (bool) Verbosity of routine
Returns:

pychemia.io.cif.get_space_group_symop_operation_xyz(filename)[source]
pychemia.io.cif.is_multistructure(path, verbose=False)[source]

Read a filename in path and returns True if the CIF contains several structures

pychemia.io.xyz module

pychemia.io.xyz.load(filename)[source]
pychemia.io.xyz.save(structure, filename)[source]