cry is an R package to make it easier dealing with crystallographic
data. The package includes functions to read/write data from/to some of
the file mostly used in software for structural crystallography. Current
entry include the
readMTZ function to read MTZ files (see
CCP4) and the corresponding
readSF_CIF to read files in CIF
formats (Crystallographic Information Framework, see IUCr
page). Users are welcome to suggest
inclusions of different (not currently available) formats they might
need for specific tasks and/or analysis.
cry includes also several functions to perform the most common and routine crystallographic calculations, many of them involving crystallographic symmetry. The main purpose of these functions is to enable users to investigate specific issues without having to resort to external packages and thus carrying the analysis through without having to abandon the R platform.
You can install the released version of crone from CRAN with:
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("jfoadi/cry")
This is a simple example in which a CIF file containing structure factors is read and a part of its data used for statistical analysis. The file is included as example file in cry and is called 1dei-sf.cif. The first task is to import the data in R.
# Load cry package library(cry) # Save CIF data in a named list datadir <- system.file("extdata",package="cry") filename <- file.path(datadir,"1dei-sf.cif") lCIF <- readSF_CIF(filename)
The newly-created R object, a list called
lCIF, contains all that is
included in the CIF file, but within a structure that can be used within
R for various analyses. The components of this list can be readily
explored using the common R functions
# What's containe in lCIF? names(lCIF) #>  "HEADER" "SYMM" "REFL" # What's the header? class(lCIF$HEADER) # It's a list #>  "list" # Is it a named list? names(lCIF$HEADER) # Yes #>  "ENTRY" "CELL" "WAVELENGTHID" "WAVELENGTH" "HIGH_RES" #>  "LOW_RES" "SGN" "HALL" "HM" # What's the space group name for this crystal structure? print(lCIF$HEADER$HM) #>  "P 21 21 21" # What's the space group number corresponding to P 21 21 21? # Use one of cry's functions xHM <- lCIF$HEADER$HM translate_SG(xHM,SG_in="xHM",SG_out="number")$msg #>  19 # ... and the unit cell parameters? cpars <- c(lCIF$HEADER$CELL$A$VAL,lCIF$HEADER$CELL$B$VAL, lCIF$HEADER$CELL$C$VAL,lCIF$HEADER$CELL$ALPHA$VAL, lCIF$HEADER$CELL$BETA$VAL,lCIF$HEADER$CELL$GAMMA$VAL) print(cpars) #>  57.4 56.3 23.0 90.0 90.0 90.0 # The unit cell belongs to the orthorombic system, # as it should be, due to symmetry (cry function) print(crystal_system(gn=19)) #>  "ORTHOROMBIC"
The most important bit in the CIF file are the observed reflections
(coming from x-ray diffraction of one or more crystals). They are
contained in the named list
REFL. All CIF files have a
reporting the specific observed quantity and a field
STD reporting the
corresponding experimental error. Not always the last one is available.
VAL field is an R data frame that makes these data suitable to
further analysis within R. The
STD field mirrors
VAL, but with the
experimental errors counterparts, if available, otherwise it is
as in the case here reported.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.