Giter VIP home page Giter VIP logo

topas_tools's Introduction

PyPI - Python Version PyPI DOI

Topas tools

These are set of small scripts and tools that were developed to help with structure refinement (of zeolites in particular) using the program TOPAS.

topasdiff

Topasdiff is a tool to generate nice looking difference maps. First, output the observed structure factors, and structure in cif format from Topas:

Out_fobs(fobs.hkl)
Out_CIF_STR(structure.cif)

Observed structure factors can be generated using this macro (add this to C:/topas5/local.inc):

macro Out_fobs(file)
{
   phase_out file load out_record out_fmt out_eqn
   {
       "%4.0f" = H;
       "%4.0f" = K;
       "%4.0f" = L;
       '"%4.0f" = M;
       "%12.4f\n" = (Iobs_no_scale_pks / M)^(0.5);
   }
}

Then to calculate the difference map, run the command:

topasdiff structure.cif --diff fobs.hkl

or use the GUI, accessible available via topasdiff.bat (Windows). The program will ask for the scale factor provided by TOPAS, and generates an input file for the program superflip (http://superflip.fzu.cz/). Superflip is then used to perform the fourier transform, and generates an .XPLOR file that can be visualized using Chimera or VESTA.

Note: There is a bug in Topas where the cif files it outputs cannot be read using CCTBX, because they lack the data header. A work-around is to open C:/topas5/topas.inc and modify all instances of:

Out_String("\ndata_")

by:

Out_String("\ndata_topas_cif_out")

topasdiff gui

cif2topas

cif2topas transforms a crystal structure into cif format into the corresponding TOPAS code.

Usage:

cif2topas structure.cif

fh2topas

fh2topas is a script that converts from Fenske-Hall z-matrix to TOPAS code

Usage:

fh2topas zmatrix.fh [n]

Here, n is an optional parameter to give the number of molecules to generate. fh2topas will automatically number them to avoid naming conflicts.

topasrestraints

topasrestraints is a tool that can help with the generation of bond and angle restraints for structure refinement of zeolites with TOPAS. First, generate all bonds by using the TOPAS instruction:

append_bond_lengths

to generate all bonds and angles, including their symmetry codes for the current structure. Copy everything between the curly brackets to a new file called bonds.txt, and run:

topasrestraints bonds.txt

This generates a file called restraints.out that contains the restraints that can be added to TOPAS. The script checks for all distances of 1.61 +- 0.4 Angstrom to identify T-O bonds. The program checks the connectivity for every atom, and reports if there is a problem (too many / not enough distances per T-atom). There is no check for symmetrically equivalent connections, so some restraints may be redundant.

stripcif

stripcif is a tool to clean a cif file from all extra metadata. Essentially it reads a cif file and writes it back to structure_simple.cif with just the cell parameters and atomic coordinates.

Usage:

stripcif structure.cif

expandcell

expandcell is a tool to take a cif file and expand the axes along different directions to form a supercell.

For example:

expandcell structure.cif -z2

will write a cif in P1 the z axis doubled. You can then use a tool like PLATON to find the right symmetry for this structure (if needed). You can use:

expandcell structure.cif -z2 -s SPGR --shift X Y Z

to force the new a new symmetry on the output. Here SPGR is the space group suggested by platon, and --shift X Y Z is the suggested origin shift.

The option -e can be used to exclude elements from the result.

make_superflip

This is a very simple tool that asks a couple of questions and writes an input file for superflip.

Usage:

make_superflip

Requirements

Installation

  1. Install miniconda (pick the one suitable for your platform, Python version does not matter here).

  2. Install using:

conda create -n topas_tools -c conda-forge cctbx-base
conda activate topas_tools
pip install topas_tools

Or use the environment file:

conda env create -f environment.yml
conda activate topas_tools
pip install -e .

(note that every time you want to use topas_tools, you must always activate the environment using conda activate topas_tools)

topas_tools's People

Contributors

stefsmeets avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

topas_tools's Issues

Upload to pypi

It would be nice if the code could be installed via pip.

error in topasdiff

Hi there

I am getting the error below. Any thoughts ?

I am also adding my structure.cif and

image

structure.cif

data_topas_cif_out
_chemical_name_mineral ??
_cell_length_a 10.008(16)
_cell_length_b 10.008(16)
_cell_length_c 10.008(16)
_cell_angle_alpha 90
_cell_angle_beta 90
_cell_angle_gamma 90
_cell_volume 1003(5)
_symmetry_space_group_name_H-M Fm3m
loop_
	_symmetry_equiv_pos_as_xyz
	 'x, y, z '
	 '-x, -y, z '
	 '-x, -z, -y '
	 '-x, -z, y '
	 '-x, z, -y '
	 '-x, z, y '
	 '-x, y, -z '
	 '-x, y, z '
	 '-y, -x, -z '
	 '-y, -x, z '
	 '-y, -z, -x '
	 '-y, -z, x '
	 '-y, z, -x '
	 '-y, z, x '
	 '-y, x, -z '
	 '-y, x, z '
	 '-z, -x, -y '
	 '-z, -x, y '
	 '-z, -y, -x '
	 '-z, -y, x '
	 '-z, y, -x '
	 '-z, y, x '
	 '-z, x, -y '
	 '-z, x, y '
	 'z, -x, -y '
	 'z, -x, y '
	 'z, -y, -x '
	 'z, -y, x '
	 'z, y, -x '
	 'z, y, x '
	 'z, x, -y '
	 'z, x, y '
	 'y, -x, -z '
	 'y, -x, z '
	 'y, -z, -x '
	 'y, -z, x '
	 'y, z, -x '
	 'y, z, x '
	 'y, x, -z '
	 'y, x, z '
	 'x, -y, -z '
	 'x, -y, z '
	 'x, -z, -y '
	 'x, -z, y '
	 'x, z, -y '
	 'x, z, y '
	 'x, y, -z '
	 '-x, -y, -z '
	 'x+1/2, y+1/2, z '
	 '-x+1/2, -y+1/2, z '
	 '-x+1/2, -z+1/2, -y '
	 '-x+1/2, -z+1/2, y '
	 '-x+1/2, z+1/2, -y '
	 '-x+1/2, z+1/2, y '
	 '-x+1/2, y+1/2, -z '
	 '-x+1/2, y+1/2, z '
	 '-y+1/2, -x+1/2, -z '
	 '-y+1/2, -x+1/2, z '
	 '-y+1/2, -z+1/2, -x '
	 '-y+1/2, -z+1/2, x '
	 '-y+1/2, z+1/2, -x '
	 '-y+1/2, z+1/2, x '
	 '-y+1/2, x+1/2, -z '
	 '-y+1/2, x+1/2, z '
	 '-z+1/2, -x+1/2, -y '
	 '-z+1/2, -x+1/2, y '
	 '-z+1/2, -y+1/2, -x '
	 '-z+1/2, -y+1/2, x '
	 '-z+1/2, y+1/2, -x '
	 '-z+1/2, y+1/2, x '
	 '-z+1/2, x+1/2, -y '
	 '-z+1/2, x+1/2, y '
	 'z+1/2, -x+1/2, -y '
	 'z+1/2, -x+1/2, y '
	 'z+1/2, -y+1/2, -x '
	 'z+1/2, -y+1/2, x '
	 'z+1/2, y+1/2, -x '
	 'z+1/2, y+1/2, x '
	 'z+1/2, x+1/2, -y '
	 'z+1/2, x+1/2, y '
	 'y+1/2, -x+1/2, -z '
	 'y+1/2, -x+1/2, z '
	 'y+1/2, -z+1/2, -x '
	 'y+1/2, -z+1/2, x '
	 'y+1/2, z+1/2, -x '
	 'y+1/2, z+1/2, x '
	 'y+1/2, x+1/2, -z '
	 'y+1/2, x+1/2, z '
	 'x+1/2, -y+1/2, -z '
	 'x+1/2, -y+1/2, z '
	 'x+1/2, -z+1/2, -y '
	 'x+1/2, -z+1/2, y '
	 'x+1/2, z+1/2, -y '
	 'x+1/2, z+1/2, y '
	 'x+1/2, y+1/2, -z '
	 '-x+1/2, -y+1/2, -z '
	 'x+1/2, y, z+1/2 '
	 '-x+1/2, -y, z+1/2 '
	 '-x+1/2, -z, -y+1/2 '
	 '-x+1/2, -z, y+1/2 '
	 '-x+1/2, z, -y+1/2 '
	 '-x+1/2, z, y+1/2 '
	 '-x+1/2, y, -z+1/2 '
	 '-x+1/2, y, z+1/2 '
	 '-y+1/2, -x, -z+1/2 '
	 '-y+1/2, -x, z+1/2 '
	 '-y+1/2, -z, -x+1/2 '
	 '-y+1/2, -z, x+1/2 '
	 '-y+1/2, z, -x+1/2 '
	 '-y+1/2, z, x+1/2 '
	 '-y+1/2, x, -z+1/2 '
	 '-y+1/2, x, z+1/2 '
	 '-z+1/2, -x, -y+1/2 '
	 '-z+1/2, -x, y+1/2 '
	 '-z+1/2, -y, -x+1/2 '
	 '-z+1/2, -y, x+1/2 '
	 '-z+1/2, y, -x+1/2 '
	 '-z+1/2, y, x+1/2 '
	 '-z+1/2, x, -y+1/2 '
	 '-z+1/2, x, y+1/2 '
	 'z+1/2, -x, -y+1/2 '
	 'z+1/2, -x, y+1/2 '
	 'z+1/2, -y, -x+1/2 '
	 'z+1/2, -y, x+1/2 '
	 'z+1/2, y, -x+1/2 '
	 'z+1/2, y, x+1/2 '
	 'z+1/2, x, -y+1/2 '
	 'z+1/2, x, y+1/2 '
	 'y+1/2, -x, -z+1/2 '
	 'y+1/2, -x, z+1/2 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 '
	 'y, z+1/2, -x+1/2 '
	 'y, z+1/2, x+1/2 '
	 'y, x+1/2, -z+1/2 '
	 'y, x+1/2, z+1/2 '
	 'x, -y+1/2, -z+1/2 '
	 'x, -y+1/2, z+1/2 '
	 'x, -z+1/2, -y+1/2 '
	 'x, -z+1/2, y+1/2 '
	 'x, z+1/2, -y+1/2 '
	 'x, z+1/2, y+1/2 '
	 'x, y+1/2, -z+1/2 '
	 '-x, -y+1/2, -z+1/2 '
loop_
_atom_site_label
_atom_site_type_symbol
_atom_site_symmetry_multiplicity
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy
_atom_site_B_iso_or_equiv
Cu Cu   4 0.5 0.5 0.5 1 0.6
Fe Fe   4 0 0 0 1 3.2
N N  24 0.30612 0 0 1 2.6
C C  24 0.19168 0 0 1 2.6

fobs.hkl

   1   1   1      0.0034
   2   0   0      0.0479
   2   2   0      0.0236
   2   2   2      0.0037
   3   1   1      0.0029
   3   3   1      0.0021
   3   3   3      0.0016
   4   0   0      0.0456
   4   2   0      0.0271
   4   2   2      0.0130
   4   4   0      0.0289
   4   4   2      0.0171
   4   4   4      0.0190
   5   1   1      0.0052
   5   3   1      0.0043
   5   3   3      0.0037
   5   5   1      0.0053
   5   5   3      0.0047
   5   5   5      0.0052
   6   0   0      0.0345
   6   2   0      0.0233
   6   2   2      0.0132
   6   4   0      0.0240
   6   4   2      0.0158
   6   4   4      0.0170
   6   6   0      0.0205
   6   6   2      0.0142
   6   6   4      0.0152
   6   6   6      0.0138
   7   1   1      0.0040
   7   3   1      0.0036
   7   3   3      0.0033
   7   5   1      0.0043
   7   5   3      0.0040
   7   5   5      0.0044
   7   7   1      0.0038
   7   7   3      0.0037
   7   7   5      0.0039
   7   7   7      0.0036
   8   0   0      0.0183
   8   2   0      0.0117
   8   2   2      0.0056
   8   4   0      0.0131
   8   4   2      0.0078
   8   4   4      0.0093
   8   6   0      0.0122
   8   6   2      0.0077
   8   6   4      0.0089
   8   6   6      0.0085
   8   8   0      0.0069
   8   8   2      0.0037
   8   8   4      0.0049
   8   8   6      0.0050
   8   8   8      0.0027
   9   1   1      0.0045
   9   3   1      0.0042
   9   3   3      0.0041
   9   5   1      0.0045
   9   5   3      0.0043
   9   5   5      0.0043
   9   7   1      0.0040
   9   7   3      0.0039
   9   7   5      0.0039
   9   7   7      0.0036
   9   9   1      0.0039
   9   9   3      0.0038
   9   9   5      0.0038
   9   9   7      0.0035
   9   9   9      0.0033
  10   0   0      0.0177
  10   2   0      0.0131
  10   2   2      0.0088
  10   4   0      0.0137
  10   4   2      0.0097
  10   4   4      0.0105
  10   6   0      0.0124
  10   6   2      0.0092
  10   6   4      0.0098
  10   6   6      0.0091
  10   8   0      0.0082
  10   8   2      0.0057
  10   8   4      0.0064
  10   8   6      0.0061
  10   8   8      0.0041
  10  10   0      0.0085
  10  10   2      0.0066
  10  10   4      0.0069
  10  10   6      0.0065
  11   1   1      0.0040
  11   3   1      0.0039
  11   3   3      0.0038
  11   5   1      0.0040
  11   5   3      0.0038
  11   5   5      0.0038
  11   7   1      0.0036
  11   7   3      0.0035
  11   7   5      0.0035
  11   7   7      0.0032
  11   9   1      0.0035
  11   9   3      0.0034
  11   9   5      0.0034
  11   9   7      0.0031
  11  11   1      0.0032
  11  11   3      0.0031
  12   0   0      0.0104
  12   2   0      0.0074
  12   2   2      0.0046
  12   4   0      0.0081
  12   4   2      0.0055
  12   4   4      0.0063
  12   6   0      0.0077
  12   6   2      0.0054
  12   6   4      0.0061
  12   6   6      0.0058
  12   8   0      0.0051
  12   8   2      0.0033
  12   8   4      0.0040
  12   8   6      0.0040
  12  10   0      0.0057
  12  10   2      0.0043
  13   1   1      0.0037
  13   3   1      0.0036
  13   3   3      0.0035
  13   5   1      0.0035
  13   5   3      0.0034
  13   5   5      0.0034
  13   7   1      0.0033
  13   7   3      0.0032
  13   7   5      0.0031
  13   9   1      0.0031
  14   0   0      0.0075
  14   2   0      0.0056
  14   2   2      0.0037
  14   4   0      0.0061
  14   4   2      0.0044
  14   4   4      0.0049
  14   6   0      0.0058
  14   6   2      0.0043
  14   6   4      0.0047
  15   1   1      0.0034
  15   3   1      0.0033
  15   3   3      0.0032
  15   5   1      0.0032

Pandas / CCTBX compatbility

There seem to be some compatibility issues with the most recent versions of CCTBX / pandas.

  • cif2topas structure.cif bugs out with TypeError: unsupported format string passed to special_op_simlified_term.__format__
  • topasdiff structure.cif --diff fobs.hkl gives TypeError: Index(...) must be called with a collection of some kind, <cctbx_aray_family_flex_ext.miller_index object at ... was passed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.