Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Statistics for Structural Crystallography
Version:0.5.2
Date:2025-06-18
Description:Reading and writing of files in the most commonly used formats of structural crystallography. It includes functions to work with a variety of statistics used in this field and functions to perform basic crystallographic computing. References: D. G. Waterman, J. Foadi, G. Evans (2011) <doi:10.1107/S0108767311084303>.
License:GPL-2
LazyLoad:yes
RoxygenNote:7.3.2
VignetteBuilder:knitr
Encoding:UTF-8
Depends:R (≥ 4.5.0)
Imports:methods, zoo, ggplot2
Suggests:knitr, rmarkdown, markdown
URL:https://jfoadi.github.io/cry/
NeedsCompilation:no
Packaged:2025-06-19 17:08:28 UTC; james
Author:James Foadi [aut, cre], David Waterman [aut], Rita Giordano [aut], Kutumbarao Nidamarthi [aut]
Maintainer:James Foadi <james_foadi@yahoo.co.uk>
Repository:CRAN
Date/Publication:2025-06-19 18:40:02 UTC

Constructor for an S3 object of class "angle"

Description

Constructor for an S3 object of class "angle"

Usage

angle(ang, rad_flag = TRUE)

Arguments

ang

A real number, in degrees or radians depending on rad_flag.

rad_flag

A logical flag. If FALSE, the value is meant to be in radians.

Value

An object of class "angle" whose numerical value is always in degrees.

Examples

# Create an angle of 60 degreesang1 <- angle(60)class(ang1)

Mean and standard deviation in resolution shells.

Description

Calculates averages and standard deviations of the input vector quantity for allreflections, corresponding to shells of resolution.

Usage

avei_vs_res(nbin, resos, II = NULL, m = max(resos), M = min(resos))

Arguments

nbin

A positive integer. The number of resolution shells.

resos

A vector of real quantities. These are the resolutions (in angstroms)corresponding to the data vector, II. If the data vector is missing, the averageswill be computed just for resos.

II

A vector of real quantities. This is the key quantity whose averagesand standard deviations are calculated. IfII is set toNULL, resolutionsaverages and standard deviations will be the calculated quantities.

m

Minimum (highest) resolution (in angstroms). Data with resolution smaller than mwill be ignored when calculating the averages.

M

Maximum (lowest) resolution (in angstroms). Data with resolution larger than Mwill be ignored when calculating the averages.

Details

Binning is done with inverse resolutions in order to have lower resolutionscorrespond to small numbers and high resolutions to large numbers. The outputmids,ave andsd correspond to inverse resolutions.

Value

A named list of length 4.counts is a vector of integers, the number ofreflections in each resolution shell.mids is the representative inverse resolutionfor each resolution shell; the value is decided by the functionhist.aveis the average value in each resolution shell andsd is the corresponding standarddeviation.

Examples

datadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"1dei_phases.mtz")lmtz <- readMTZ(filename)hkl <- lmtz$reflections[,1:3]II <- lmtz$reflections[,4]cpars <- lmtz$header$CELLresos <- hkl_to_reso(hkl[,1],hkl[,2],hkl[,3],                     cpars[1],cpars[2],cpars[3],                     cpars[4],cpars[5],cpars[6])ltmp <- avei_vs_res(20,resos,II)plot(ltmp$mids,ltmp$ave,type="b",pch=16)

Constructor for an S3 object of class "bravais"

Description

There are 14 Bravais lattices. They are represented by a two-letter symbol:aP, mP, mS, oP, oS, oF, oI, tP, tI, hP, hR, cP, cF, cI

Usage

bravais(bt = NULL)

Arguments

bt

A two-letter character, denoting the Bravais type.

Value

An object of class "bravais". It is a named list of length 4. The first slot, "bt", isthe universally-used two-letter symbol. The second, third and fourth slots are, respectively,"cr_fam" (the corresponding crystal family), "cr_sys" (the corresponding crystal system) and"lt_sys" (the corresponding lattice system).

Examples

# mS is a monoclinic, face-centred Bravais latticebt <- bravais("mS")class(bt)bt[1:4]

S3 generic to compute cell volume

Description

The volume of a unit cell and a reciprocal unit cell can be calculated startingfrom specific objects, files, etc.

Usage

calculate_cell_volume(x, ...)

Arguments

x

An object used to select a method. Either an object of classunit_cell or an object of class rec_unit_cell.

...

Further arguments passed to or from other methods.

Value

V A real number. The volume (inangstroms^3 orangstroms^{-3}) of the input unit cell or reciprocalunit cell.

Examples

# Calculate the volume of a unit celluc <- unit_cell(20)V <- calculate_cell_volume(uc)# Calculate the volume of the corresponding reciprocal cellruc <- create_rec_unit_cell(uc)Vrec <- calculate_cell_volume(ruc)V*Vrec  # Should be 1!

Volume of a reciprocal unit cell (inangstroms^(-3))

Description

Method of the S3 generic class "calculate_cell_volume", to calculate thevolume, in reciprocal cubic angstroms, of the reciprocal unit cell correspondingto the input object of class "rec_unit_cell".

Usage

## S3 method for class 'rec_unit_cell'calculate_cell_volume(x, ...)

Arguments

x

An object of class "rec_unit_cell".

...

Additional arguments passed to the calculate_cell_volume methods

Value

A positive numeric, the volume in reciprocal cubic angstroms of thereciprocal unit cell corresponding to the input.

Examples

# Create a monoclinic cell and the corresponding reciprocalbt <- bravais("mP")uc <- create_unit_cell(bt)ruc <- create_rec_unit_cell(uc)# Calculate reciprocall cell volumecalculate_cell_volume(ruc)

Volume of a unit cell (in cubic angstroms)

Description

Method of the S3 generic class "calculate_cell_volume", to calculate thevolume, in cubic angstroms, of the unit cell corresponding to the inputobject of class "unit_cell".

Usage

## S3 method for class 'unit_cell'calculate_cell_volume(x, ...)

Arguments

x

An object of class "unit_cell".

...

Additional arguments passed to the calculate_cell_volume methods

Value

A positive numeric, the volume in cubic angstroms of the unit cellcorresponding to the input.

Examples

# Create a monoclinic cellbt <- bravais("mP")uc <- create_unit_cell(bt)print(uc)# Calculate cell volumecalculate_cell_volume(uc)

Change COLSRC date and time stamp

Description

Function to update thecreated column of the dataframeCOLSRC with current date and time.

Usage

change_COLSRC(hdr)

Arguments

hdr

A data frame. TheCOLSRC data frame includedin theheader component of the named listobtained withreadMTZ orreadMTZHeader.

Details

The COLSRC data frame of an MTZ header has a column calledcreated which displays the date and time at which theMTZ file data columns were created. When writing out amodified list obtained from reading an MTZ file, one mightwant to change thecreated column with the currentdate and time. Other specific types of change can be operatedby handling theCOLSRC data frame in an *ad hoc* manner.

Value

Thehdr input data frame with thecreatedcolumn of theCOLSRC data frame changed todisplay the current date and time.

Examples

# Read a sample MTZ filedatadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"1dei_phases.mtz")lMTZ <- readMTZ(filename)# Original COLSRCprint(lMTZ$header$COLSRC)# Update date and time stamplMTZ$header <- change_COLSRC(lMTZ$header)# New COLSRCprint(lMTZ$header$COLSRC)

Validity and compatibility of a cry object of class 'angle'

Description

An object of class 'angle' is a numeric with logical attribute "rad_flag".

Usage

check_angle_validity(x, message = FALSE)

Arguments

x

Object of class angle.

message

A logical variable. If TRUE, the functionprints a message on the errors, if any(default is FALSE, i.e. no message printed).

Value

ans A logical value. TRUE means that the input isa valid object of class 'angle'.

Examples

# Create an object of class anglex <- angle(80)# Check its validitycheck_angle_validity(x)# Modify the 'rad_flag' attributeattr(x,"rad_flag") <- 12.5# Check its validitycheck_angle_validity(x,TRUE)

Validity and compatibility of a cry object of class 'bravais'

Description

An object of class 'bravais' is a named list of length 4. The first slot, "bt", isthe universally-used two-letter symbol. The second, third and fourth slots are, respectively,"cr_fam" (the corresponding crystal family), "cr_sys" (the corresponding crystal system) and"lt_sys" (the corresponding lattice system).

Usage

check_bravais_validity(x, message = FALSE)

Arguments

x

Object of class 'bravais'.

message

A logical variable. If TRUE, the functionprints a message on the errors, if any(default is FALSE, i.e. no message printed).

Value

ans A logical value. TRUE means that the input isa valid object of class 'bravais'.

Examples

# Create an object of class 'bravais'x <- bravais("mP")# Check its validitycheck_bravais_validity(x,TRUE)

Validity and compatibility of a cry object of class 'cryst_symm'

Description

An object of class 'cryst_symm' is a named list of length 4. The first field is acharacter string, the second field is a3\times 3 array and the third and fourthfield are3 \times 1 arrays.

Usage

check_cryst_symm_validity(x, message = FALSE)

Arguments

x

Object of class 'cryst_symm'.

message

A logical variable. If TRUE, the functionprints a message on the errors, if any(default is FALSE, i.e. no message printed).

Value

ans A logical value. TRUE means that the input is a valid object of class'cryst_symm'.

Examples

# Create an object of class 'cryst_symm'x <- cryst_symm(15)# Check its validitycheck_cryst_symm_validity(x)# Now change a fieldx$PG[[1]] <- matrix(rep(0,times=9),ncol=3)# Check validity againcheck_cryst_symm_validity(x,TRUE)

Validity and compatibility of a cry object ofclass 'merged_reflections'

Description

An object of class 'merged_reflections' is a named list oflength 4:

ruc

An object of class "rec_unit_cell".

csym

An object of class "cryst_symm".

records

A data frame containing the data.

dtypes

A character vector containing thetype of data (Miller indices, structurefactors, etc).

Internal consistency must be displayed between the object'ruc' and the object 'csym' because groups of crystallographicsymmetries are compatible only with certain unit cells (and,accordingly, certain reciprocal cells).It is not possible to check consistency between dtypes andthe nature of data in each column of the data frame 'records',but a check about length of 'dtypes' and number of columns ispossible. Therefore, the user should pay attention to thenature of his/her data. Also, merged reflection data, havingto be compatible with crystal symmetry, have to display theappropriate systematic absences. Users interested in keepingsystematic absences in the object, might want to look at theobject of class "raw_reflections".

Usage

check_merged_reflections_validity(x, message = FALSE)

Arguments

x

Object of class 'merged_reflections'.

message

A logical variable. If TRUE, the functionprints a message on the errors, if any.

Value

ans A logical value. TRUE means that the input isa valid object of class'merged_reflections'.

Examples

# Create an object of class 'merged_reflections'# (default ara data associated with a cubic cell)x <- merged_reflections()# Check its validitycheck_merged_reflections_validity(x)# Now change reciprocal unit cell (to triclinic)uc <- unit_cell(10,20,30,30,50,70)ruc <- create_rec_unit_cell(uc)x$ruc <- ruc# Check validity againcheck_merged_reflections_validity(x)

Validity and compatibility of a cry object of class 'rec_unit_cell'

Description

An object of class 'rec_unit_cell' is a named list of length 6. The first three fields arenumeric, the last three of class 'angle'.

Usage

check_rec_unit_cell_validity(x, message = FALSE)

Arguments

x

Object of class 'rec_unit_cell'.

message

A logical variable. If TRUE, the functionprints a message on the errors, if any(default is FALSE, i.e. no message printed).

Value

ans A logical value. TRUE means that the input is avalid object of class'rec_unit_cell'.

Examples

# Create an object of class 'rec_unit_cell'x <- create_rec_unit_cell()# Check its validitycheck_rec_unit_cell_validity(x)# Now change a fieldx$alphar <- 123# Check validity againcheck_rec_unit_cell_validity(x,TRUE)

Validity and compatibility of a cry object of class 'unit_cell'

Description

An object of class 'unit_cell' is a named list of length 6. The first three fields arenumeric, the last three of class 'angle'.

Usage

check_unit_cell_validity(x, message = FALSE)

Arguments

x

Object of class 'unit_cell'.

message

A logical variable. If TRUE, the functionprints a message on the errors, if any(default is FALSE, i.e. no message printed).

Value

ans A logical value. TRUE means that the input is avalid object of class'unit_cell'.

Examples

# Create an object of class 'unit_cell'x <- create_unit_cell()# Check its validitycheck_unit_cell_validity(x)# Now change a fieldx$alpha <- 123# Check validity againcheck_unit_cell_validity(x,TRUE)

Validity and compatibility of cry objects

Description

Compatibility of cry objects The objects that can be created in cry are subject to issues ofcompatibility of the parameters forming them. For example, the unit cell of a cubic systemcannot have the a, b, c sides different from each other. The present function returns TRUE ifall parts composing the object are compatible with each other. Otherwise it returns FALSE andone or more warnings with details.

Usage

check_validity(x, y = NULL, message = FALSE)

Arguments

x

A first object of one of the new cry classes.

y

A second object of one of the new cry classes.

message

A logical variable. If TRUE, the functionprints a message on the errors, if any(default is FALSE, i.e. no message printed).

Details

The available checks for individual objects are:

The available checks for couple of objects are:

Value

ans A logical value. ans = TRUE means that either the parameters of the singleobject (if only one input is provided) are valid parameters, or that the two objects arecompatible with each other.

Examples

# Create a cubic cell with side 50uc <- create_unit_cell(50)# Create an object of class "cryst_symm"crsym <- cryst_symm("P m -3")# Are they compatible with each other?check_validity(uc,crsym,TRUE)

S3 generic to create merged_reflections objects

Description

The merged_reflections object can be created starting fromspecific objects, files, etc.

Usage

create_merged_reflections(ruc, ...)

Arguments

ruc

An object used to select a method.

...

Further arguments passed to or from other methods.

Value

mrefs An object of class "merged_reflections". It is a namedlist of length 4 whose names are:

ruc

An object of class "rec_unit_cell".

csym

An object of class "cryst_symm".

records

A data frame containing the data.

dtypes

A character vector containing thetype of data (Miller indices, structurefactors, etc).

Examples

# Create a default merged_reflections object (no arguments)mrefs <- create_merged_reflections()print(mrefs)# Create merged_reflections object from symmetrycsym <- cryst_symm("P 3")mrefs <- create_merged_reflections(csym=csym)print(mrefs)

Default method for generic "create_merged_reflections"

Description

This method is an alternative call to 'merged_reflections'..

Usage

## Default S3 method:create_merged_reflections(  ruc = NULL,  csym = NULL,  records = NULL,  dtypes = NULL,  ...)

Arguments

ruc

An object of class 'rec_unit_cell'.

csym

An object of class 'cryst_symm'.

records

A data frame containing all reflections comingfrom the x-ray data collection on the crystal. Thisdata frame must include at least the three Millerindices, H, K, L (of dtype "H").

dtypes

A character vector whose length is the same asthe number of columns in 'records'. One character (acapital letter) is associated with each type of data.For example, a Miller index is of dtype "H"; a structureamplitude is of dtype "F"; an anomalous difference is ofdtype "D"; etc (see details later).

...

Additional arguments passed to thecreate_merged_reflections methods.

Value

An object of class "merged_reflections". It is a namedlist of length 4 whose names are:

ruc

An object of class "rec_unit_cell".

csym

An object of class "cryst_symm".

records

A data frame containing the data.

dtypes

A character vector containing thetype of data (Miller indices, structurefactors, etc).

See Also

merged_reflections

Examples

# Create merged data for a cubic (10 angstrom) unit cell# of space group P 2 3. Data up to 5 angstroms resolutionmrefs <- create_merged_reflections()print(mrefs)

S3 generic to create rec_unit_cell objects

Description

The rec_unit_cell object can be created starting from specific objects, files, etc.

Usage

create_rec_unit_cell(ar, ...)

Arguments

ar

An object or objects used to select a method. These can bereciprocal unit cell parameters, an object of classrec_unit_cell, etc.

...

Further arguments passed to or from other methods.

Value

An object of class "rec_unit_cell". It is a named list of length 6 whoselast three slots are of "angle" class.

Examples

# Create a rec_unit_cell in default (no arguments)ruc <- create_rec_unit_cell()print(ruc)

Reciprocal unit cell starting from a Bravais symbol

Description

Method to create a "rec_unit_cell" object starting from a "bravais" object.The Bravais symbols indicate the 14 possible Bravais lattices. A fewexamples are "aP", "oF", etc. The cell parameters assigned are assignedrandomly, but are compatible with the Bravais lattice.

Usage

## S3 method for class 'bravais'create_rec_unit_cell(ar, ...)

Arguments

ar

An object of class "bravais".

...

Additional arguments passed to the create_rec_unit_cell methods

Value

An object of class "rec_unit_cell". It is a named list of length 6 whoselast three slots are of "angle" class.

Examples

# Create a "rec_unit_cell" object from a monoclinic primitive Bravais lattice# Cell parameters generated automatically.bt <- bravais("mP")ruc <- create_rec_unit_cell(bt)print(ruc)

Reciprocal unit cell from a 'cryst_symm' object

Description

Method to create an object of class "rec_unit_cell" startingfrom an object of class 'cryst_symm'.

Usage

## S3 method for class 'cryst_symm'create_rec_unit_cell(ar, ...)

Arguments

ar

An object of class 'cryst_symm'.

...

Additional arguments passed to thecreate_rec_unit_cell.

Details

The symmetry of a space group imposes constrains on theparameters of unit cells. For example, the cubic group P 2 3means that all cell sides have to be equal and all angleshave to be equal to 90 degrees. This function suggests theappropriate reciprocal cell compatible with the given spacegroup.

Value

An object of class "rec_unit_cell". It is a named listof length 6 whose last three slots are of class'angle'. The cell parameters are calculated from thoseof the corresponding unit cell. The default unit cellparameters are a=10, b=20, c=15, alpha=70, beta=80,gamma=100. When constrains due to symmetry arerequired, b and c might be equaled to a, alpha, betaand gamma might be set to 90, gamma might be set to120 and the three angles might be set equal to eachother.

Examples

# Symmetry "C 1 2/c 1"csym <- cryst_symm("C 1 2/c 1")# Reciprocal unit_cellruc <- create_rec_unit_cell(csym)print(ruc)

Default method for generic "create_rec_unit_cell"

Description

This method is an alternative call to "rec_unit_cell".

Usage

## Default S3 method:create_rec_unit_cell(  ar = NULL,  br = NULL,  cr = NULL,  aar = NULL,  bbr = NULL,  ccr = NULL,  ...)

Arguments

ar

A real number. One of the reciprocal unit cell's side lengths, in 1/angstroms.

br

A real number. One of the reciprocal unit cell's side lengths, in 1/angstroms.

cr

A real number. One of the reciprocal unit cell's side lengths, in 1/angstroms.

aar

A real number. One of the reciprocal unit cell's angles, in degrees.

bbr

A real number. One of the reciprocal unit cell's angles, in degrees.

ccr

A real number. One of the reciprocal unit cell's angles, in degrees.

...

Additional arguments passed to the create_rec_unit_cell methods

Value

An object of class "rec_unit_cell". It is a named list of length 6 whoselast three slots are of "angle" class.

See Also

rec_unit_cell

Examples

# Create a reciprocal cubic cell with side 1/50ruc <- create_rec_unit_cell(1/50)print(ruc)

Reciprocal unit cell starting from a unit cell

Description

Method to create an object of class "rec_unit_cell" starting from an object ofclass "unit_cell".

Usage

## S3 method for class 'unit_cell'create_rec_unit_cell(ar, ...)

Arguments

ar

An object of class "unit_cell".

...

Additional arguments passed to the create_rec_unit_cell methods

Value

An object of class "rec_unit_cell". It is a named list of length 6 whoselast three slots are of "angle" class.

Examples

# Create a "rec_unit_cell" object starting from a cubic cell objectuc <- unit_cell()print(uc)ruc <- create_rec_unit_cell(uc)print(ruc)

S3 generic to create unit_cell objects

Description

The unit_cell object can be created starting from specific objects, files, etc.

Usage

create_unit_cell(a, ...)

Arguments

a

An object or objects used to select a method. These can becell parameters, an object of class rec_unit_cell, etc.

...

Further arguments passed to or from other methods.

Value

An object of class "unit_cell". It is a named list of length 6 whoselast three slots are of class "angle".

Examples

# Create a unit_cell in default (no arguments)uc <- create_unit_cell()print(uc)

Unit cell starting from a Bravais symbol

Description

Method to create a "unit_cell" object starting from a "bravais" object.The Bravais symbols indicate the 14 possible Bravais lattices. A fewexamples are "aP", "oF", etc. The cell parameters assigned are assignedrandomly, but are compatible with the Bravais lattice.

Usage

## S3 method for class 'bravais'create_unit_cell(a, ...)

Arguments

a

An object of class "bravais".

...

Additional arguments passed to the create_unit_cell methods

Value

An object of class "unit_cell". It is a named list of length 6 whoselast three slots are of "angle" class.

Examples

# Create a "unit_cell" object from a monoclinic primitive Bravais lattice# Cell parameters generated automatically.bt <- bravais("mP")uc <- create_unit_cell(bt)print(uc)

Unit cell from a 'cryst_symm' object

Description

Method to create an object of class "unit_cell" startingfrom an object of class 'cryst_symm'.

Usage

## S3 method for class 'cryst_symm'create_unit_cell(a, ...)

Arguments

a

An object of class 'cryst_symm'.

...

Additional arguments passed to the create_unit_cell.

Details

The symmetry of a space group imposes constrains on theparameters of unit cells. For example, the cubic group P 2 3means that all cell sides have to be equal and all angleshave to be equal to 90 degrees. This function suggests theappropriate unit cell compatible with the given space group.

Value

An object of class "unit_cell". It is a named listof length 6 whose last three slots are of class'angle'. Default cell parameters are a=10, b=20, c=15,alpha=70, beta=80, gamma=100. When constrains due tosymmetry are required, b and c might be equaled to a,alpha, beta and gamma might be set to 90, gamma mightbe set to 120 and the three angles might be setequal to each other.

Examples

# Symmetry "C 1 2/c 1"csym <- cryst_symm("C 1 2/c 1")# Unit_celluc <- create_unit_cell(csym)print(uc)

Default method for generic "create_unit_cell"

Description

This method is an alternative call to "unit_cell".

Usage

## Default S3 method:create_unit_cell(  a = NULL,  b = NULL,  c = NULL,  aa = NULL,  bb = NULL,  cc = NULL,  ...)

Arguments

a

A real number. One of the unit cell's side lengths, in angstroms.

b

A real number. One of the unit cell's side lengths, in angstroms.

c

A real number. One of the unit cell's side lengths, in angstroms.

aa

A real number. One of the unit cell's angles, in degrees.

bb

A real number. One of the unit cell's angles, in degrees.

cc

A real number. One of the unit cell's angles, in degrees.

...

Additional arguments passed to the create_unit_cell methods

Value

An object of class "unit_cell". It is a named list of length 6 whoselast three slots are of "angle" class.

See Also

unit_cell

Examples

# Create a cubic cell with side 50uc <- create_unit_cell(50)print(uc)

Unit cell starting from a reciprocal unit cell

Description

Method to create an object of class "unit_cell" starting from an object ofclass "rec_unit_cell".

Usage

## S3 method for class 'rec_unit_cell'create_unit_cell(a, ...)

Arguments

a

An object of class "rec_unit_cell".

...

Additional arguments passed to the create_unit_cell methods

Value

An object of class "unit_cell". It is a named list of length 6 whoselast three slots are of "angle" class.

Examples

# Create a "unit_cell" object starting from a reciprocal cubic cell objectruc <- rec_unit_cell()print(ruc)uc <- create_unit_cell(ruc)print(uc)

Constructor for an S3 object of class "cryst_symm".

Description

This represents a crystallographic space group.

Usage

cryst_symm(SG = NULL, set = NULL)

Arguments

SG

A character string or an integer identifying the space group. There are 230used space group in crystallography and each one corresponds to a unique and so-calledextended Hermann-Mauguin symbol. An example is space group number 19, identified by theextended Hermann-Mauguin symbol "P 21 21 21". Several formats are possible and some of themare now rarely used. Attempts are made to transform the input into a correct Hermann-Mauguinsymbol, but if all fails, a warning is raised and the space group P 1 is assigned.

set

An integer defining which setting of many possible for the given space group. Somecrystallographic space groups can be implemented with small variants known as "settings".If the input SG is an extended Hermann-Mauguin symbol, set is ignored, as it is alreadyspecified by the xHM symbol.

Details

The constructor can be used with less than the full set of two input parameters,to create an object of class cryst_symm corresponding to space group P 1. If the inputstring is not recognised, a warning is raised and space group P 1 is assigned.

Value

An object of class "cryst_symm". It is a named list of length 4. The names are, "SG","PG", "T" and "C".

Examples

# The symplest symmetry: P 1crsym <- cryst_symm("P 1")print(crsym)# The second space group: P -1crsym <- cryst_symm(2)print(crsym)# Something more complicatedcrsym <- cryst_symm("P 21 21 21")print(crsym)

Crystal family corresponding to given space group.

Description

Crystal family corresponding to given space group.

Usage

crystal_family(gn)

Arguments

gn

A natural integer (1,2,3,...). the space group number.

Value

A character string, the name of the crystal family associatedwith the given space group. If the input integer does not correspondany existing space group, the function returns NULL and throws awarning.

Examples

# P1 is part of the TRICLINIC familycrystal_family(1)# The object returned is a stringcfam <- crystal_family(1)class(cfam)

Crystal system corresponding to given space group.

Description

Crystal system corresponding to given space group.

Usage

crystal_system(gn)

Arguments

gn

A natural integer (1,2,3,...). the space group number.

Value

A character string, the name of the crystal system associatedwith the given space group. If the input integer does not correspondany existing space group, the function returns NULL and throws awarning.

Examples

# P1 is part of the TRICLINIC systemcrystal_system(1)# The object returned is a stringcsys <- crystal_system(1)class(csys)

Deplete systematic absences

Description

Remove systematically-absent reflections from a data framein which Miller indices are in the first three columns.The systematically-absent reflections are determined by thespecific space group.

Usage

deplete_systematic_absences(hkl, SG)

Arguments

hkl

A data frame with first three columns H, K, Lcorresponding to the three Miller indices. This isnormally the 'record' data frame in an object ofclass "merged_reflections".

SG

A character. The extended Hermann-Mauguin symbolof the crystallographic space group.

Details

Crystallography symmetry forces constraints on data fromx-ray diffraction. One of these constraints consists in thefull cancellation of reflections with certain Miller indices.It is said that the reflection with that specific Miller indexis systematically absent. For example, in data correspondingto a crystal with space group C 2, general reflections like(h,k,l) must obey h+k=2n (even number). Thus, the Millerindices (2,3,1) are a systematic absence because 2+3=5 (odd).

Value

hkl The same data frame acquired from input, depletedof all systematic absences.

Examples

# C 2 monoclinic space groupSG <-"C 1 2 1"# Create an arbitrary cell compatible with C 2uc <- unit_cell(10,15,10,90,110,90)# Crete the related reciprocal cellruc <- create_rec_unit_cell(uc)# Create a full data frame of Miller indiceshkl <- expand.grid(H=-4:4,K=-4:4,L=-4:4)# Get rid of systematic absencesnew_hkl <- deplete_systematic_absences(hkl,SG)# Compare first 10 items of original and depleted arrayshkl[1:10,]new_hkl[1:10,]

Information on a specific space group

Description

Returns human-readable information on a specific input space group.

Usage

extract_symmetry_info(SG)

Arguments

SG

A character string. The extended Hermann-Mauguin symbol (e.g. 'P 1 1 21')

Details

Crystallographic symmetry is fundamental in crystallography. It affects the wayatoms are arranged in a unit cell, the pattern of reflections in reciprocal spaceand many other common occurrences in crystallography. This function returns a namedlist with human-readable character strings which detail key symmetry information.

Value

infostring A named list with fields corresponding to those in the CCP4 symmetrylibrary. The fields' name are:

Examples

# This is the full information for space group number 19, P 21 21 21SG <- translate_SG(19)$msgltmp <- extract_symmetry_info(SG)ltmp

Correct spelling for Herman-Mauguin space groups symbols

Description

The commonly-used spelling of a crystallographic space group does not match the correct definitiongiven by the Herman-Mauguin symbols which define all space groups in a unique and precise way. Thisfunction attempt to translate a tentative string into a possible Herman-Mauguin symbol, if it findsone. If the input string is already in the extended Herman-Mauguin form, the same string is returnedas output.

Usage

findHM(sym_xHM)

Arguments

sym_xHM

A character string. The space group symbol in its commonly-used spelling.

Value

SG A character string. The extended Hermann-Mauguin symbol (e.g. 'P 1 1 21').

Examples

# P21print(find("P 21"))# P -1print(find("P-1"))

Find specific space group setting

Description

Although a space group is uniquely defined, i.e. the symmetryoperations defining it are uniquely given, the choice ofvectors that defines a unit cell for that symmetry is notunique. The different choices are known as settings. Mostspace groups have only one setting, but it is possible to findspace groups with several settings. For example, "C 1 2/c 1"has 18 settings. The xHM symbol for setting 1 is"C 1 2/c 1", the symbol for setting 2 is "A 1 2/n 1", etc.

Usage

find_symm_setting(SG)

Arguments

SG

A character string indicating the extendedHermann-Mauguin symbol for the space group.

Value

set An integer equal to the specific settingcorresponding to the given xHM symbol.

Examples

# P2 (group number 4) has three settingsnsets <- find_symm_setting("P 1 2 1")print(nsets)

From fractional to orthogonal coordinates

Description

This function transforms any number of fractional coordinates(x_f,y_f,z_f),arranged as a vector or in a matrix or data frame, into the corresponding numberof orthogonal coordinates(x,y,z), arranged in the same format.

  1. ochoice = 1: X axis along a; Y axis normal to a, in the (a,b) plane;Z axis normal to X and Y (and therefore parallel toc*).

  2. ochoice = 2: this is also called "Cambridge setting". The X axis isalong a*; the Y axis lies in the (a*,b*) plane; the Zaxis is, consequently, along c.

Usage

frac_to_orth(xyzf, a, b, c, aa, bb, cc, ochoice = 1)

Arguments

xyzf

A vector orn\times 3 matrix or data frame of fractional crystal coordinates.

a

A real number. One of the unit cell's side lengths, in angstroms.

b

A real number. One of the unit cell's side lengths, in angstroms.

c

A real number. One of the unit cell's side lengths, in angstroms.

aa

A real number. One of the unit cell's angles, in degrees.

bb

A real number. One of the unit cell's angles, in degrees.

cc

A real number. One of the unit cell's angles, in degrees.

ochoice

A natural integer indicating the choice of orthogonal transformation.1 corresponds to the first choice and 2 to the second choice inGiacovazzo's book (seextal_mat01 andxtal_mat02).

Value

An\times 3 matrix or data frame of orthogonal coordinates correspondingto the fractional coordinates provided in the input.

Examples

# Matrix containing 3 fractional coordinatesxyzf <- matrix(c(0.1,0.2,0.3,0.2,0.6,0.7,0.15,0.28,0.55),ncol=3,byrow=TRUE)# Cartesian coordinatesxyz <- frac_to_orth(xyzf,10,30,20,90,90,90,1)

Symmetry operations in human readable form

Description

This function returns the full set of symmetry operations in human-readable form,each one as a character string starting with 'SYMM'. These are the common crystallographicsymmetry operations.

Usage

full_symm_strings(SG)

Arguments

SG

A character string. The extended Hermann-Mauguin symbol (e.g. 'P 1 1 21')

Value

Symm_string A character vector whose components are strings starting by 'SYMM'and containing the symmetry operations of the given group in human-readable form.

Examples

# P1 has only one symmetry operationSG <- "P 1"symm_string <- full_symm_strings(SG)print(symm_string)# P 21 21 21 is has many more operationsSG <- "P 21 21 21"symm_string <- full_symm_strings(SG)print(symm_string)

Generate Miller indices

Description

Function to create a data frame with complete set of Millerindices, up to a given resolution (in angstroms).

Usage

generate_miller(uc, SG, reso)

Arguments

uc

An object of class "unit_cell".

SG

A character string or a number indicating theextended Hermann-Mauguin symbol for the space group.

reso

A real number. The highest data resolution, inangstroms.

Details

Miller indices are named H, K, L in the data frame. Onlyvalues of (H,K,L) corresponding to a resolution d(h,k,l) >=reso (in angstroms), are included. The full list does notinclude systematic absences corresponding to the specificsymmetry of the crystal.

Value

hkl A data frame with columns H, K, L correspondingto the three Miller indices, and a columns Scorresponding to their inverse resolutions (inangstroms).

Examples

# C 2 monoclinic space groupSG <- "C 1 2 1"# Create an arbitrary cell compatible with C 2uc <- unit_cell(10,15,10,90,110,90)# Generate Miller indices to 5 angstroms resolutionreso <- 5hkl <- generate_miller(uc,SG,reso)# Display first 10 indiceshkl[1:10,]

Calculates resolution, given the Miller indices

Description

Calculates resolution, given the Miller indices

Usage

hkl_to_reso(h, k, l, a, b, c, aa, bb, cc)

Arguments

h

An integer, A Miller index.

k

An integer, A Miller index.

l

An integer, A Miller index.

a

A real number. One of the unit cell's side lengths, in angstroms.

b

A real number. One of the unit cell's side lengths, in angstroms.

c

A real number. One of the unit cell's side lengths, in angstroms.

aa

A real number. One of the unit cell's angles, in degrees.

bb

A real number. One of the unit cell's angles, in degrees.

cc

A real number. One of the unit cell's angles, in degrees.

Value

A positive, real number. The resolution associated with (h,k,l), in angstroms.

Examples

datadir <- system.file("extdata",package="cry")fname <- file.path(datadir,"1dei_phases.mtz")hdr <- readMTZHeader(fname,message=FALSE)ucell <- hdr$CELLreso1 <- hkl_to_reso(1,0,0,ucell[1],ucell[2],ucell[3],ucell[4],ucell[5],ucell[6])print(reso1)  # Low resolutionreso2 <- hkl_to_reso(20,20,20,ucell[1],ucell[2],ucell[3],ucell[4],ucell[5],ucell[6])reso2  # High resolution

Calculation of useful lattice parameters

Description

Calculation of useful lattice parameters

Usage

lattice_stuff(a, b, c, aa, bb, cc)

Arguments

a

A real number. One of the unit cell's side lengths, in angstroms.

b

A real number. One of the unit cell's side lengths, in angstroms.

c

A real number. One of the unit cell's side lengths, in angstroms.

aa

A real number. One of the unit cell's angles, in degrees.

bb

A real number. One of the unit cell's angles, in degrees.

cc

A real number. One of the unit cell's angles, in degrees.

Value

A named vector of real numbers and length 16. The names are:

Examples

datadir <- system.file("extdata",package="cry")fname <- file.path(datadir,"1dei_phases.mtz")hdr <- readMTZHeader(fname,message=FALSE)ucell <- hdr$CELLvtmp <- lattice_stuff(ucell[1],ucell[2],ucell[3],ucell[4],ucell[5],ucell[6])vtmp[1:3]vtmp[4:6]vtmp[7:9]vtmp[10:12]vtmp[13:15]vtmp[16]

Space group compatible with given cell

Description

This function returns the space group, among those compatiblewith the given unit cell, with the lowest symmetry groupnumber.

Usage

lowest_uc_compatible_SG(uc)

Arguments

uc

An object of class 'unit_cell'.

Details

A given unit cell is compatible with several symmetries.For example, a cell with different sides and differentangles, also different from 90 degrees, is compatible withthe triclinic lattice system, which corresponds to spacegroups P1 and P -1. A cell with different sides, alpha = 90,gamma=90 and beta different from 90, is compatible with themonoclinic lattice system, which corresponds to space groupsfrom number 3 ("P 1 2 1") to number 15 (C 1 2/c 1"). In thefirst case this function returns "P 1", while in the secondcase it returns "P 1 2 1".

Value

csym An object of class 'cryst_symm', correspondingto the selected, lowest symmetry.

Examples

# Monoclinic celluc <- unit_cell(10,20,15,90,110,90)# The selected space group is "P 1 2 1"csym <- lowest_uc_compatible_SG(uc)print(csym)

Constructor for an S3 object of class "merged_reflections".

Description

This represents scaled and merged x-ray data from one crystal.

Usage

merged_reflections(ruc = NULL, csym = NULL, records = NULL, dtypes = NULL)

Arguments

ruc

An object of class "rec_unit_cell" (which representsa reciprocal unit cell).

csym

An object of class "cryst_symm" (which representsa crystallographic symmetry group).

records

A data frame containing all reflections comingfrom the x-ray data collection on the crystal. Thisdata frame must include at least the three Millerindices, H, K, L (of dtype "H").

dtypes

A character vector whose length is the same asthe number of columns in 'records'. One character (acapital letter) is associated with each type of data.For example, a Miller index is of dtype "H"; a structureamplitude is of dtype "F"; an anomalous difference is ofdtype "D"; etc (see details later).

Details

If the constructor is used without arguments, the defaultobject created will be create reflections for a cubic crystalwith cell of side 10 angstroms, and symmetry P 2 3, up to 5angstroms resolution. The only available columnswill be of dtype "H", named H, K, L (the Miller indices), andof dtype "S", inverse resoluton, named S.

The possible dtypes are:

H

Miller index

S

Inverse resolution (1/angstroms)

J

Reflection intensity

F

Amplitude of a structure factor

D

Anomalous difference

Q

Standard deviation of J, F, D

G

Amplitude associated with a Friedel pair (F(+), F(-))

L

Standard deviation of G

K

Intensity associated with G (I(+), I(-))

M

Standard deviation of K

E

Amplitude of the normalised structure factors

P

Phase angle (in degrees)

W

Weight of some sort

A

Phase probability coefficients (Hendrickson-Lattman)

B

Batch number (from raw data)

I

Any other integer

R

Any other real

More values can become available in a future release.

Value

An object of class "merged_reflections". It is a namedlist of length 4 whose names are:

ruc

An object of class "rec_unit_cell".

csym

An object of class "cryst_symm".

records

A data frame containing the data.

dtypes

A character vector containing thetype of data (Miller indices, structurefactors, etc).

Examples

# Create an orthorombic (default) celluc <- unit_cell(10,30,15)# Create the related reciprocal cellruc <- create_rec_unit_cell(uc)# Create symmetry (P n c 2)csym <- cryst_symm(30)# Create a few records (these include syst. absences)records <- expand.grid(H=-2:2,K=-2:2,L=-2:2)print(length(records[,1]))# dtypes are all Hdtypes <- c("H","H","H")# Create merged_reflections object with H, K, L# Systematic absences have been eliminatedmrefs <- merged_reflections(ruc,csym,records,dtypes)print(length(mrefs$records[,1]))

Number of space group settings

Description

Although a space group is uniquely defined, i.e. the symmetry operations defining itis uniquely given, the choice of vectors that defines a unit cell for that symmetryis not unique. The different choices are known as settings. Most space groups have onlyone setting, but it is possible to find space groups with several settings. For example,"C 1 2/c 1" has 18 settings. While the xHM symbol for setting 1 is "C 1 2/c 1", thesymbol for setting 2 is "A 1 2/n 1", etc.

Usage

num_symm_settings(SG = NULL)

Arguments

SG

A character string or a number indicating the space group.

Value

nsett The number of setting for the given space group.

Examples

# P 1 21 1 (group number 4) has three settingsnum_symm_settings(4)# Find the extended Hermann-Mauguin symbolstranslate_SG(4,"number","xHM",1)$msgtranslate_SG(4,"number","xHM",2)$msgtranslate_SG(4,"number","xHM",3)$msg

List of matrices and vectors of a specific space group

Description

Returns3\times 3 matrices and3\times 1 vectors corresponding to point groupoperations, group translations and cell centring of a given space group.

Usage

op_xyz_list_to_matrix_list(op_xyz_list)

Arguments

op_xyz_list

A named list made of two vectors. The first vector, SYMOP, contains stringsdescribing the symmetry operators. The second vector, CENOP, contains strings describing thecentring of the unit cell.

Details

A crystallographic space group consists of a series of transformations on a point(x_f,y_f,z_f) in space that are mathematically implemented as the product ofa3\times 3 point-group matrix and the point fractional coordinates,(x_f,y_f,z_f),followed by a sum with a3\times 1 translation vector. The complete set of points thusproduced can be cloned into a new and shifted set translated of an amount represented by a3\times 1 centring vector.

Value

mat_ops_list A named list consisting of 3 lists. The first list, PG, contains3\times 3 point group matrices; the second list, T, contains the same number of3\times 1 translation vectors. The first matrix is always the identity matrix, the firsttranslation vector is always the null vector. The third list, C, consists of centering vectors;the first centering vector is always the null vector. To summarize, the output looks like thefollowing:

[[ [[I,M2,M3,...,Mn]] , [[O,V2,V3,...,Vn]] , [[O,C2,C3,...,Cm]] ]]where:I = identity 3X3 matrix0 = null 3X1 vectorM2,M3,...,Mn = point group 3X3 matricesV2,V3,...,Cn = translation 3X1 vectorsC2,C3,...,Cm = centering 3X1 vectors

Examples

# Symmetry operators for space group number 3, P 1 2 1SG <- "P 1 2 1"op_xyz_list <- syminfo_to_op_xyz_list(SG)mat_ops_list <- op_xyz_list_to_matrix_list(op_xyz_list)names(mat_ops_list)

Human-readable symmetry operator into matrix and vector

Description

Returns a3\times 3 matrix and3\times 1 vector corresponding to either asymmetry operator or a centering operator in human-readable, string form.

Usage

op_xyz_to_matrix(op_xyz)

Arguments

op_xyz

A symmetry or centering operation in the form of ahuman-readable string, e.g. -x+1/2,-y,z+1/2'.

Details

A string describing a symmetry or a centering operation has a format similar to, for instance,'-x+1/2,-y,z+1/2'. Such a string corresponds to the symmetry operation representedmathematically by the following matrix and vector:

\left(\begin{array}{rrr} -1 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 0 & 1 \end{array}\right)\quad,\quad \left(\begin{array}{r} 1/2 \\ 0 \\ 1/2 \end{array}\right)

Where symmetry operations in human-readable form are useful for the subjective reasoningin crystallography, their mathematical counterpart is needed for all practical calculations.

Value

mat_ops A named list including a3\times 3 matrix 'R' and a3\times 1 vector 'T'.

Examples

# Reflection and translationsop <- '-x,y+1/2,z'mat_ops <- op_xyz_to_matrix(sop)print(mat_ops)

From orthogonal to fractional coordinates

Description

This function transforms any number of orthogonal coordinates(x,y,z),arranged as a vector or in a matrix or data frame, into the corresponding numberof fractional coordinates(x_f,y_f,z_f), arranged in the same format.

  1. ochoice = 1: X axis along a; Y axis normal to a, in the (a,b) plane;Z axis normal to X and Y (and therefore parallel toc*).

  2. ochoice = 2: this is also called "Cambridge setting". The X axis isalong a*; the Y axis lies in the (a*,b*) plane; the Zaxis is, consequently, along c.

Usage

orth_to_frac(xyz, a, b, c, aa, bb, cc, ochoice = 1)

Arguments

xyz

A vector orn\times 3 matrix or data frame of orthogonal crystal coordinates.

a

A real number. One of the unit cell's side lengths, in angstroms.

b

A real number. One of the unit cell's side lengths, in angstroms.

c

A real number. One of the unit cell's side lengths, in angstroms.

aa

A real number. One of the unit cell's angles, in degrees.

bb

A real number. One of the unit cell's angles, in degrees.

cc

A real number. One of the unit cell's angles, in degrees.

ochoice

A natural integer indicating the choice of orthogonal transformation.1 corresponds to the first choice and 2 to the second choice inGiacovazzo's book (seextal_mat01 andxtal_mat02).

Value

An\times 3 matrix or data frame of fractional coordinates correspondingto the orthogonal coordinates provided in the input.

Examples

# Matrix containing 3 orthogonal coordinatesxyz <- matrix(c(5, 15, 10, 2, 10, 8, 1, 1, 1),ncol=3,byrow=TRUE)# Fractional coordinatesxyzf <- orth_to_frac(xyz,10,30,20,90,90,90,1)

Plot SHELXC log files

Description

Plot SHELXC log files

Usage

plot_SHELX(filename, filename_e, var, type, title_chart)

Arguments

filename

A data frame in output from{read_SHELX_log}.

filename_e

A data frame with the inverted hand from shelxe

var

the variable to be plotted vs the resolution

type

indicate the type of file, possible value are "shelxc","shelxd" and "shelxe".

title_chart

title of the chart.

Value

A graphical object from ggplot2 class that containsthe solution founded by SHELX log file.

Examples

datadir <- system.file("extdata",package="cry")## SHELXCshelxc_log <- file.path(datadir,"shelxc.log")shelxc <- read_SHELX_log(shelxc_log)plot_shelxc <- plot_SHELX(filename = shelxc, var = shelxc$I_sig,type = "shelxc", title_chart = "SHELXC")plot_shelxc## SHELXDshelxd_log <- file.path(datadir,"shelxd.log")shelxd <- read_SHELX_log(shelxd_log)plot_shelxd <- plot_SHELX(filename = shelxd, type = "shelxd",title_chart = "SHELXD")plot_shelxd## SHELXEfilename_i <- file.path(datadir,"shelxe_i.log")shelxe_i <- read_SHELX_log(filename_i)filename_o <- file.path(datadir,"shelxe_o.log")shelxe_o <- read_SHELX_log(filename_o)plot_shelxe <- plot_SHELX(filename = shelxe_i,filename_e = shelxe_o, type = "shelxe", title_chart = "SHELXE")plot_shelxe

Print method for an object of class "angle".

Description

The value is displayed in degrees

Usage

## S3 method for class 'angle'print(x, ...)

Arguments

x

An object of class "angle".

...

Additional arguments passed to the print methods

Value

Nothing. A message is displayed which includesinformation on the angle.

Examples

# Create an angle of 90 degrees using radiansang1 <- angle(pi/2,FALSE)# Display its valueprint(ang1)

Print method for an object of class "bravais".

Description

The Bravais lattice and related crystal family, crystal system and lattice systemare displayed.

Usage

## S3 method for class 'bravais'print(x, ...)

Arguments

x

An object of class "bravais".

...

Additional arguments passed to the print methods

Value

Nothing. A message is displayed which includesinformation on the Bravais lattice.

Examples

# Create a triclinic Bravais latticebt <- bravais()# Display its valueprint(bt)

Print method for an object of class "cryst_symm".

Description

xxx

Usage

## S3 method for class 'cryst_symm'print(x, ...)

Arguments

x

An object of class "cryst_symm".

...

Additional arguments passed to the print methods

Value

Nothing. A message is displayed which includesinformation on the crystallographic symmetry.

Examples

# Create an object of P 2 symmetrycrsym <- cryst_symm("P 2")# Display its valueprint(crsym)

Print method for an object of class "rec_unit_cell".

Description

The values are displayed in 1/angstroms and degrees

Usage

## S3 method for class 'rec_unit_cell'print(x, ...)

Arguments

x

An object of class "rec_unit_cell".

...

Additional arguments passed to the print methods

Value

Nothing. A message is displayed which includesinformation on the reciprocal unit cell.

Examples

# Create a cubic reciprocal unit cellruc <- rec_unit_cell(1/10,1/10,1/10,90,90,90)# Display its valueprint(ruc)

Print method for an object of class "unit_cell".

Description

The values are displayed in angstroms and degrees

The output includes details on the unit cell, the crystalsymmetry and the first 10 records (data).

Usage

## S3 method for class 'unit_cell'print(x, ...)## S3 method for class 'merged_reflections'print(x, ...)

Arguments

x

An object of class "merged_reflections".

...

Additional arguments passed to the print methods

Value

Nothing. A message is displayed which includesinformation on the unit cell.

Nothing. A message is displayed which includesinformation on the reflections contained in this objectand the crystal structure they relate to.

Examples

# Create a cubic unit celluc <- unit_cell(10,10,10,90,90,90)# Display its valueprint(uc)# Create a default 'merged_reflections' objectmrefs <- merged_reflections()# Display its valueprint(mrefs)

Reads and output a CIF file

Description

Reads and output a CIF file

Usage

readCIF(filename, message = FALSE)

Arguments

filename

A character string. The path to a valid CIF file.

message

A logical variable. If TRUE (default) the function printsa message highlighting what is included in the cif file.

Value

A named list. Each name correspond to a valid field in the cif.

Examples

datadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"AMS_DATA.cif")lCIF <- readCIF(filename)print(names(lCIF))print(lCIF$INTRO$CELL)print(lCIF$INTRO$HALL)print(lCIF$INTRO$HM)print(lCIF$SYMM)

Load an MTZ file

Description

Reads mtz files and store both header information andreflection data records in named lists. A third list isused, if the mtz file is an unmerged file, for storing batchheaders.

Usage

readMTZ(filename, message = FALSE)

Arguments

filename

A character string. The path to a valid mtzfile.

message

A logical variable. If TRUE thefunction prints a message highlighting dataincluded in the mtz file. Default value ismessage=FALSE.

Value

A named list of length 3. The first element iscalled "reflections" and is a dataframe with asmany columns as are included in the mtz file.The name of each column of the dataframe coincideswith the name of the corresponding column in the mtz.The second element is called "header" and is a namedlist in which each name correspond to a valid fieldin the mtz header (see details inreadMTZHeader).The third element is called"batch_header" and is a list with as many elements asthe number of batches (images) included in the mtzfile. Each list element is, itself, a named listincluding all the useful variables stored in batchheaders. If no batch headers are contained in the file(merged mtz), the batch_header element is NULL.

Examples

datadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"1dei_phases.mtz")ltmp <- readMTZ(filename)print(names(ltmp))print(class(ltmp$reflections))str(ltmp$reflections)print(class(ltmp$header))print(class(ltmp$batch_header))refs <- ltmp$reflectionsprint(colnames(refs))print(range(refs$H))

Reads and output an MTZ header

Description

An MTZ file is a binary file created to carry information onx-ray diffraction experiments on crystals. It includes x-raydiffraction data and information on the experiment and thecrystal.

Usage

readMTZHeader(filename, message = FALSE)

Arguments

filename

A character string. The path to a valid mtz file.

message

A logical variable. If TRUE the function printsa message highlighting what is included in the mtz header.Default value ismessage=FALSE.

Details

The function returns a named list whose components arethereflections, theheader and thebatch_header. Theheader is a named list whosecomponents are:

TITLE

A character string containing the title of theMTZ file.

NCOL

Number of columns in data framereflections.

CELL

A numeric vector of length 6, containing theunit cell parameters.

SORT

An integer vector of length 5, containing thesort order of the first 5 columns of data.

SYMINF

Un-named list with 6 components: the numberof symmetry operations (an integer), the number ofprimitive operations (an integer), the lattice type(a one-letter character), the space group number (aninteger), the space group name (a 10-letter characterstring) and the point group name (a 6-letter character).

RESO

Minimum and maximum data resolution, stored as{1/d^2}.

NDIF

Number of datasets whose reflection data arepresent in the file.

SYMM

A character vector whose length depends on thetype of symmetry. It describes the symmetry operations inhuman-readable format, International Tables style. Eachstring is 80 characters long.

PROJECT

A data frame whose rows provide an ID and aname (called "pname") for the projects for which the datacontained have been produced.

CRYSTAL

A data frame whose rows provide an ID and aname (called "pname") for the crystals for which the datacontained have been produced.

DATASET

A data frame whose rows provide an ID and aname (called "pname") for the datasets included in thereflections record.

DCELL

A data frame whose rows contain theCRYSTAL IDs and cell parameters of each crystalthat has contributed to the data in the reflections record.

DWAVEL

A data frame whose rows contain theDATASET IDs and the wavelength with which thereflection data were collected.

COLUMN

A data frame describing the type of dataincluded in the reflections record. The data frame includesthe labels for each column, the dtype (seemerged_reflections) for each column, min andmax values and theDATASET ID.

COLSRC

A data frame with three columns. The firstincludes the labels of each reflections record column. Thesecond includes a time stamp of when each data column wascreated. The third is the dataset ID as a string.

COLGRP

A character string vector where each componentis an 80-letters string describing the name and type ofdata.

HISTORY

A character string vector of variable length.Each component is an 80-letter string summarising the stepsthat lead to the current reflections record. HISTORY cancontain a maximum of 30 lines.

Value

A named list. Each name correspond to a valid field in the mtzheader (see details).

Examples

datadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"1dei_phases.mtz")ltmp <- readMTZHeader(filename)print(names(ltmp))print(ltmp$CELL)print(ltmp$SYMM)

Reads and output an CIF file

Description

Reads and output an CIF file

Usage

readSF_CIF(filename, message = FALSE)

Arguments

filename

A character string. The path to a valid CIF file.

message

A logical variable. If TRUE (default) the function printsa message highlighting what is included in the cif file.

Value

A named list. Each name correspond to a valid field in the SF cif.

Examples

datadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"1dei-sf.cif")lCIF <- readSF_CIF(filename)print(names(lCIF))print(lCIF$INTRO$CELL)print(lCIF$INTRO$HALL)print(lCIF$INTRO$HM)print(lCIF$REFL)

Load an XDS_ASCII file.

Description

Function to load XDS_ASCII.HKL files into a named list withthree components calledprocessing_info,headerandreflections (see details further down).

Usage

readXDS_ASCII(filename, message = FALSE)

Arguments

filename

A character string. The path to a validXDS ASCII file.

message

A logical variable. If TRUE (default) thefunction prints a message highlighting what isincluded in the xds header. Iffilename is not a valid XDSascii file, the function returns 'NULL' andprints out a warning message.

Details

This function reads in all data from an XDS_ASCII data fileand organises them into a named list. The list's name are:

processing_info

This list component includes threelogical variables, MERGE, FRIEDEL and PROFILE. TheirTRUE/FALSE value reflect features of the XDS_ASCIIfile connected with the specific processing performedto obtain the file itself(for more details seehttps://xds.mr.mpg.de/).

header

This list includes several components, likefor instance SPACE_GROUP_NUMBER orUNIT_CELL_CONSTANTS, which give informationson the crystal and the experiment generatingthe data.

reflections

This data.frame includes the actualexperimental data, i.e. the observationscollected during the X-ray diffractionexperiment on the crystal (or crystals).The number and type of columns can vary.

Value

A named list (see details).

Examples

# Load one of the XDS ASCII files included with# this distribution of crydatadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"xds00_ascii.hkl")ltmp <- readXDS_ASCII(filename,message=FALSE)print(names(ltmp))print(ltmp$reflections[1:5,])

Load an XDS_ASCII file's header.

Description

This function reads information from the header of anXDS_ASCII.HKL data file and organises it into a named listwith a variable number of components, according to the typeof XDS_ASCII.HKL file (see details inreadXDS_ASCII).

Usage

readXDS_ASCIIHeader(filename)

Arguments

filename

A character string. The path to a validXDS ASCII file.

Value

A named list. Each name correspond to a valid field inthe xds header. Iffilename is not a valid XDSascii file, the function returns 'NULL' and prints outa warning message.

Examples

# Load one of the XDS ASCII files included with# this distribution of crydatadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"xds00_ascii.hkl")ltmp <- readXDS_ASCIIHeader(filename)print(names(ltmp))

Reads and SHELXD log files

Description

Reads and SHELXD log files

Usage

read_SHELX_log(filename)

Arguments

filename

A character string. The path to a valid log file.

Value

A named list. Each name correspond to a valid field in the logheader.

Examples

datadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"shelxc.log")ltmp <- read_SHELX_log(filename)print(names(ltmp))

Reads and output an mmCIF file

Description

Reads and output an mmCIF file

Usage

readmm_CIF(filename, message = FALSE)

Arguments

filename

A character string. The path to a validCIF file.

message

A logical variable. If TRUE (default) thefunction prints a message highlightingwhat is included in the cif file.

Value

A named list. Each name correspond to a validfield in the cif.

Examples

datadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"3syu.cif")lCIF <- readmm_CIF(filename)print(names(lCIF))print(lCIF$HEADER$Entry)print(lCIF$HEADER$Symmtery)print(lCIF$HEADER$CELL)print(lCIF$EXP_DETAILS$CRYSTAL_CON$VAL)

Reads and output a CIF file for powder diffraction

Description

Reads and output a CIF file for powder diffraction

Usage

readpd_rtv(filename, message = FALSE)

Arguments

filename

A character string. The path to a valid CIF file.

message

A logical variable. If TRUE (default) the function printsa message highlighting what is included in the cif file.

Value

A named list. Each name correspond to a valid field in the powderdiffraction Rietveld processed CIF.

Examples

datadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"e-65-00i60-Isup2.rtv")lCIF <- readpd_rtv(filename)print(names(lCIF))print(lCIF$INTRO$CELL)print(lCIF$INTRO$HALL)print(lCIF$INTRO$HM)print(lCIF$REFL)

Reads and output an CIF file

Description

Reads and output an CIF file

Usage

readsm_REFL(filename, message = FALSE)

Arguments

filename

A character string. The path to a valid small moleculereflection file. Typically a hkl or an fcf file.

message

A logical variable. If TRUE (default) the function printsa message highlighting what is included in the cif file.

Value

A named list. Each name correspond to a valid field in the fcf or hkl file.

Examples

datadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"1dei-sf.cif")lCIF <- readsm_REFL(filename)print(names(lCIF))print(lCIF$INTRO$CELL)print(lCIF$SYMM)print(lCIF$REFL)

Constructor for an S3 object of class "rec_unit_cell.

Description

This represents a crystal reciprocal unit cell.

Usage

rec_unit_cell(  ar = NULL,  br = NULL,  cr = NULL,  aar = NULL,  bbr = NULL,  ccr = NULL)

Arguments

ar

A real number. One of the reciprocal unit cell's side lengths, in 1/angstroms.

br

A real number. One of the reciprocal unit cell's side lengths, in 1/angstroms.

cr

A real number. One of the reciprocal unit cell's side lengths, in 1/angstroms.

aar

A real number. One of the reciprocal unit cell's angles, in degrees.

bbr

A real number. One of the reciprocal unit cell's angles, in degrees.

ccr

A real number. One of the reciprocal unit cell's angles, in degrees.

Details

The constructor can be used with less than the full set of six input parameters,to create reciprocal unit cells for the cubic, tetragonal and orthogonal systems. Objectsof "rec_unit_cell" class can also be created with no parameters (default to a reciprocal cubiccell of side length 0.1 1/angstroms).

Value

An object of class "rec_unit_cell". It is a named list of length 6 whoselast three slots are of "angle" class.

Examples

# Create a monoclinic reciprocal unit cellruc <- unit_cell(0.115,0.033,0.077,90,120,90)print(ruc)# Create a cubic cell (default)ruc <- rec_unit_cell()print(ruc)# Create a reciprocal cubic cell with side 1/20ruc <- rec_unit_cell(1/20)print(ruc)# Create a reciprocal tetragonal unit cell with sides 1/20 and 1/60ruc <- rec_unit_cell(1/20,1/60)print(ruc)# Create a reciprocal orthogonal unit cellruc <- rec_unit_cell(1/40,1/15,1/30)print(ruc)

Operators of a specific space group in matrix form

Description

Returns3\times 3 matrices and3\times 1 vectors corresponding to point groupoperations, group translations and cell centring of a given space group.

Usage

syminfo_to_matrix_list(SG)

Arguments

SG

A character string. The extended Hermann-Mauguin symbol (e.g. 'P 1 1 21')

Details

A crystallographic space group consists of a series of transformations on a point(x_f,y_f,z_f) in space that are mathematically implemented as the product ofa3\times 3 point-group matrix and the point fractional coordinates,(x_f,y_f,z_f),followed by a sum with a3\times 1 translation vector. The complete set of points thusproduced can be cloned into a new and shifted set translated of an amount represented by a3\times 1 centring vector.

Value

mat_ops_list A named list consisting of 3 lists. The first list, PG, contains3\times 3 point group matrices; the second list, T, contains the same number of3\times 1 translation vectors. The first matrix is always the identity matrix, the firsttranslation vector is always the null vector. The third list, C, consists of centering vectors;the first centering vector is always the null vector. To summarize, the output looks like thefollowing:

[[ [[I,M2,M3,...,Mn]] , [[O,V2,V3,...,Vn]] , [[O,C2,C3,...,Cm]] ]]where:I = identity 3X3 matrix0 = null 3X1 vectorM2,M3,...,Mn = point group 3X3 matricesV2,V3,...,Cn = translation 3X1 vectorsC2,C3,...,Cm = centering 3X1 vectors

Examples

# Symmetry operators for space group number 4, P 1 21 1SG <- "P 1 21 1"mat_ops <- syminfo_to_matrix_list(SG)print(mat_ops)

Operators of a specific space group

Description

Returns human-readable symmetry operators corresponding to a specific input space group.

Usage

syminfo_to_op_xyz_list(SG)

Arguments

SG

A character string. The extended Hermann-Mauguin symbol (e.g. 'P 1 1 21')

Details

A crystallographic space group includes a set of symmetry operators that can be expressedlike operations on the (x,y,z) fractional coordinates of atoms in a unit cell. So, for example,The only operator associated with the space group P 1 is "x,y,z", while the four operatorsassociated with P 21 21 21 are "symop x,y,z", "symop -x+1/2,-y,z+1/2", "symop x+1/2,-y+1/2,-z","symop -x,y+1/2,-z+1/2".

Value

op_xyz_list A named list made of two vectors. The first vector, SYMOP, contains stringsdescribing the symmetry operators. The second vector, CENOP, contains strings describing thecentring of the unit cell.

Examples

# Symmetry operators for space group number 3, P 1 2 1SG <- "P 1 2 1"ltmp <- syminfo_to_op_xyz_list(SG)ltmp

Cell parameter constrains from symmetry

Description

This function returns a set of constrains, as string characterexpressions, imposed by the specific symmetry group on thegiven unit cell.

Usage

symm_to_cell_const(SG)

Arguments

SG

A character string indicating the extendedHermann-Mauguin symbol for the space group.

Details

Space group symmetry imposes certain constraints on thevalues that unit cell parameters can take. For example, thesymmetry represented by the monoclinic space group of extendedHermann-Mauguin symbol "P 1 2 1" is compatible with a unit cellin which alpha=gamma=90.

There is just a handful of constrains for unit cells. Here theyare indicated with the following set of specific strings:

Value

vcons A character vector. Each component is a string,like 'alpha=90' or 'a=b', that describes thetype of constrain to be applied to a unit cellof a crystal structure with given space groupsymmetry (see above).

Examples

# P 1 1 2 (group number 3) corresponds to setting 2SG <- translate_SG(3,set=2)# Constrains for this symmetrystmp <- symm_to_cell_const(SG)print(stmp)# R 3 (rombohedral setting)stmp <- symm_to_cell_const("R 3 :R")print(stmp)

Locate systematic absences

Description

Given an mX3 matrix of Miller indices, this function returnsthose indices corresponding to valid reflections, i.e. toreflections which are not systematic absences.

Usage

sysabs(hkl, SG)

Arguments

hkl

An mX3 matrix or a data frame whose rows are thethree integers corresponding to the Millerindices.

SG

A character. The extended Hermann-Mauguin symbolof the crystallographic space group.

Details

Crystallography symmetry forces constraints on data fromx-ray diffraction. One of these constraints consists in thefull cancellation of reflections with certain Miller indices.It is said that the reflection with that specific Miller indexis systematically absent. For example, in data correspondingto a crystal with space group C 2, general reflections like(h,k,l) must obey h+k=2n (even number). Thus, the Millerindices (2,3,1) are a systematic absence because 2+3=5 (odd).

Value

idx A vector of integers corresponding to theposition, in the arraymhkl, in which theMiller indices ARE NOT systematically absent.The position of systematically-absent reflectionscan be found using !idx.

Examples

# C 2 monoclinic space group (special setting)csym <- cryst_symm(15,set=5)print(csym$SG)# Create a full data frame of Miller indiceshkl <- expand.grid(H=-4:4,K=-4:4,L=-4:4)# Index corresponding to valid reflections# (not systematic absences)idx <- sysabs(hkl,csym$SG)# Indices for all reflectionsfulldx <- 1:length(hkl[,1])# Index corresponding to systematic absencesjdx <- fulldx[-idx]# A couple of systematic absenceshkl[jdx[1:2],]

cry theme for ggplot2

Description

cry theme for ggplot2

Usage

theme_cry()

Examples

## Not run:  plot_SHELX(obj_shelxc, var = obj_shelxc$Chi_sq, type = "shelxc", title_chart = "Chis ^2") + theme_cry## End(Not run)

Translation of space group symbols, numbers, etc.

Description

Function to find out space group symbol given number and vice-versa.

Usage

translate_SG(value, SG_in = "number", SG_out = "xHM", set = 1)

Arguments

value

A string or an integer number corresponding to the space groupbeing investigated.

SG_in

A string representing the space group format for the input.Possible values are:

  • 1) "number"

  • 2) "ccp4"

  • 3) "Hall"

  • 4) "xHM"

  • 5) "old"

SG_out

A string representing the space group format for the output.Possible values are:

  • 1) "number"

  • 2) "ccp4"

  • 3) "Hall"

  • 4) "xHM"

  • 5) "old"

set

Specific setting for the given space group. A number like 1,2,...It is used if for a same symbol there are more than one choice.

Details

This function returns either a number of a specific symbol corresponding to acrystallographic space group. The input is an integer number or a character symbolidentifying a specific space group. The output is, similarly, the correspondingcharacter symbol or number, according to what is specified in the input.Possible formats are:

If more than one setting is implied in an ambiguous way in the input value,then the first setting will be selected by default for the output value,unless argument "set" is set to another value.

Value

list_SG A named list with two fields. The first field, "msg", is acharacter string representing the space group format neededas output. Possible values are the same as those for SG_in.The second field, "ans", is TRUE only if a valid symbol for"msg" is found.

Examples

# Space Group P1 corresponds to number 1translate_SG(value=1,SG_in="number",SG_out="xHM")

Constructor for an S3 object of class "unit_cell.

Description

This represents a crystal unit cell.

Usage

unit_cell(a = NULL, b = NULL, c = NULL, aa = NULL, bb = NULL, cc = NULL)

Arguments

a

A real number. One of the unit cell's side lengths, in angstroms.

b

A real number. One of the unit cell's side lengths, in angstroms.

c

A real number. One of the unit cell's side lengths, in angstroms.

aa

A real number. One of the unit cell's angles, in degrees.

bb

A real number. One of the unit cell's angles, in degrees.

cc

A real number. One of the unit cell's angles, in degrees.

Details

The constructor can be used with less than the full set of six input parameters,to create unit cells for the cubic, tetragonal and orthogonal systems. Objectsof "unit_cell" class can also be created with no parameters (default to a cubiccell of side length 10 angstroms).

Value

An object of class "unit_cell". It is a named list of length 6 whoselast three slots are of "angle" class.

Examples

# Create a monoclinic unit celluc <- unit_cell(10,30,15,90,60,90)print(uc)# Create a cubic cell (default)uc <- unit_cell()print(uc)# Create a cubic cell with side 20uc <- unit_cell(20)print(uc)# Create a tetragonal unit cell with sides 20 and 60uc <- unit_cell(20,60)print(uc)# Create an orthogonal unit celluc <- unit_cell(40,15,30)print(uc)

Write data to an MTZ file

Description

Write reflections and experimental informationto an MTZ file

Usage

writeMTZ(reflections, header, filename, title = NULL, batch_header = NULL)

Arguments

reflections

A data frame containing all reflectionrecords in columns. This is usually derivedfrom modifications of a previously existingdata frame obtained usingreadMTZ.

header

A list whose components are other R objects. Thisis normally derived from the reading of anotherMTZ file usingreadMTZ. See furtherdetails atreadMTZHeader.

filename

A character string. The path to a valid mtzfile. If a file with the same name exists, itwill be deleted.

title

A character string. The character stringassociated with the TITLE keyword in an MTZ file.This feature makes it easy to quickly identify thedata file inCCP4programs. Default (NULL) is for the output fileto have the same title as the input file.

batch_header

A named list including information at datacollection time. This component is presentonly for raw (unmerged) intensity dataproduce after the diffraction imagesintegration. Merged MTZ reflection fileshavebatch_header=NULL.Names and types depend onthe type of experiment (more informationon this can be found atCCP4.)

Value

This function does not return any R object. It outputsan MTZ reflection file to some target location.

Examples

# Read the 1dei_phases data included in the packagedatadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"1dei_phases.mtz")lMTZ <- readMTZ(filename)# Change dataset nameprint(lMTZ$header$DATASET)lMTZ$header$DATASET[2,2] <- "New CRY dataset"# Add one HISTORY line (string has to be 80-letters long)addhist <- "From CRY 0.3.0 - run on Apr 2 20:12:00 2021"n <- nchar(addhist)nblanks <- 80-nfor (i in 1:nblanks) addhist <- paste0(addhist," ")lMTZ$header$HISTORY <- c(lMTZ$header$HISTORY,addhist)# Write to a new MTZ filewd <- tempdir()fname <- file.path(wd,"new.mtz")writeMTZ(lMTZ$reflections,lMTZ$header,fname)

Write data to an XDS_ASCII file.

Description

Function to write an XDS_ASCII-tye named list to a file withXDS_ASCII format (unmerged or merged).

Usage

writeXDS_ASCII(proc_info, header, reflections, filename)

Arguments

proc_info

The first component of an XDS_ASCII-typeobject. It includes up to threecomponents,MERGE,FRIEDELandPROFILE_FITTING (this lastcomponent is missing for files withmerged observations, obtained with theprogram XSCALE).

header

The second component of an XDS_ASCII-type object.This object includes several other objects (seereadXDS_ASCII).

reflections

The third component of an XDS_ASCII-typeobject. It contains the data (theexperimental observations). SeereadXDS_ASCII for more details.

filename

A character string. The path to a validXDS_ASCII file. If a file with the same nameexists, it will be deleted.

Details

The XDS_ASCII-type named list includes three components,processing_info,header andreflections(seereadXDS_ASCII).

Value

This function does not return any R object. It outputsan XDS_ASCII reflection file to some target location.

Examples

# Load one of the XDS ASCII files included with# this distribution of crydatadir <- system.file("extdata",package="cry")filename <- file.path(datadir,"xds00_ascii.hkl")lXDS <- readXDS_ASCII(filename)# Change dateprint(lXDS$header$DATE)lXDS$header$DATE <- "7-Apr-2021"# Write to a file called "new.hkl"wd <- tempdir()fname <- file.path(wd,"new.hkl")writeXDS_ASCII(lXDS$processing_info,lXDS$header,               lXDS$reflections,fname)

Matrix for cell orthogonalisation (first choice)

Description

Given the cell parameters, this function returns a matrix fortransforming fractional to orthogonal coordinates, correspondingto the first choice in Giacovazzo's book.

Usage

xtal_mat01(a, b, c, aa, bb, cc)

Arguments

a

A real number. One of the unit cell's side lengths, in angstroms.

b

A real number. One of the unit cell's side lengths, in angstroms.

c

A real number. One of the unit cell's side lengths, in angstroms.

aa

A real number. One of the unit cell's angles, in degrees.

bb

A real number. One of the unit cell's angles, in degrees.

cc

A real number. One of the unit cell's angles, in degrees.

Value

A3\times$ matrixM that transforms a3\times 1 vector of fractionalcoordinates into a3\times 1 vector of orthogonal coordinates.

Examples

# Fractional coordinatesXf = c(0.1,0.4,0.8)# Orthorombic unit cellM = xtal_mat01(10,40,20,90,90,90)# Cartesian coordinatesXc = M%*%Xf

Matrix for cell orthogonalisation (second choice)

Description

Given the cell parameters, this function returns a matrix fortransforming fractional to orthogonal coordinates, correspondingto the second choice in Giacovazzo's book.

Usage

xtal_mat02(a, b, c, aa, bb, cc)

Arguments

a

A real number. One of the unit cell's side lengths, in angstroms.

b

A real number. One of the unit cell's side lengths, in angstroms.

c

A real number. One of the unit cell's side lengths, in angstroms.

aa

A real number. One of the unit cell's angles, in degrees.

bb

A real number. One of the unit cell's angles, in degrees.

cc

A real number. One of the unit cell's angles, in degrees.

Value

A3\times$ matrixM that transforms a3\times 1 vector of fractionalcoordinates into a3\times 1 vector of orthogonal coordinates.

Examples

# Fractional coordinatesXf = c(0.1,0.4,0.8)# Orthorombic unit cellM = xtal_mat02(10,40,20,90,90,90)# Cartesian coordinatesXc = M%*%Xf

[8]ページ先頭

©2009-2025 Movatter.jp