form_factor_table module

Form factors and scattering vs. resolution.

Usage: import form_factor_table (main program performs rudimentary test).

Module author: Michael S. Chapman <chapmanms@missouri.edu>

Module author: Andrew Trzynka <trzynkaa@ohsu.edu>

Authors:

Michael S. Chapman <chapmanms@missouri.edu>

Oregon Health & Science University & University of Missouri

Version:

1, Nov 26, 2024

Changed in version 2/11/10: Started

Changed in version 0.3.7: 11/25/12

Changed in version 0.5.0: 4/30/15 restructured text documentation.

Changed in version 1.0.0: 11/18/20 Python 2.7 –> 3.6

class form_factor_table.FormFactorTable(source)

Bases: object

Scattering factors obtained from a resolution-dependent look-up table.

Several tables supported: x-ray, neutron & electron scattering, determined empirically or through quantum calculation by others.

Loads one of several form factor tables ready to support look-up:

  • “XTNT” - X-ray scattering factors from TNT distribution.

  • “XCCP4” - X-ray scattering factors from the CCP4 distribution.

  • “NCCP4” - Neutron scattering factors from the CCP4 distribution.

  • “ERSRef” - (Few-atom) Electron scattering factors from RSRef EM (unknown attribution).

  • “ELECTRON” - Electron scattering factors, neutral atoms, Int. Tab.

Excellent introduction to electron scattering factors in Int. Tables Vol.C sect 4.3.2 (p.262).

Parameters:

source (str) – defines which of the supported tables (above) is used.

class Counter

Bases: dict

Counter for references to each entry in form-factor table.

increment(name)
at_dstar(dstar, atom_type='C', type_num=None, b=0.0)

Form factor at d*.

Parameters:
  • atom_type (str)

  • type_num (int) – number corresponding to atom_type, takes predence over atom_type unless “None”.

  • b (float) – temperature factor (including overall B / envelope function), Å2

Returns:

form factor at d*.

Return type:

float

at_dstar_array = <numpy.vectorize object>
at_dstar_sq(dstar_sq, atom_type='C', type_num=None, b=0.0)

Form factor at d*2.

Parameters:
  • atom_type (str)

  • type_num (int) – number corresponding to atom_type, takes predence over atom_type unless “None”.

  • b (float) – flaot temperature factor (including overall B / envelope function), Å2

Returns:

form factor at d*2.

Return type:

float

at_dstar_sq_array = <numpy.vectorize object>
at_s(s, atom_type='C', type_num=None, b=0.0)

Form factor at S.

Parameters:
  • atom_type (str)

  • type_num (int) – number corresponding to atom_type, takes predence over atom_type unless “None”.

  • b (float) – temperature factor (including overall B / envelope function), Å2

Returns:

form factor at S=sin(θ/λ).

Return type:

float

at_s_array = <numpy.vectorize object>
at_s_sq(s_sq, atom_type='C', type_num=None, b=0.0)

Form factor at S2.

Parameters:
  • atom_type (str)

  • type_num (int) – number corresponding to atom_type, takes predence over atom_type unless “None”.

  • b (float float) – temperature factor (including overall B / envelope function), Å2

Returns:

form factor at S2 = (sin(θ/λ))2

Return type:

float

at_s_sq_array = <numpy.vectorize object>
findtype(atom_type=None, atom_name=None, verbose=True)

Find the formfactor atom type that is the best match.

Parameters:
  • atom_type (str) – from the input coordinates.

  • atom_name (str) – optional IUPAC or other name.

  • verbose (bool) – print warning messages for ambigous names.

Returns:

new type:

  • (silently) atom_type if there is an exact match.

  • (silently) atom_type pseudonym (eg. Ca++ for Ca2+) if exists.

  • (silently) results of prior match of the same atom_type/_name.

  • (w/ warning) 1st non-ambiguous match as the common part of atom_type and atom_name is progressively shortened. (Avoiding accidental matches such as CD (delta) to Cadmium.)

  • (w/ warning) 1st non-ambigous match to a shortened atom_type if there are no characters in common with atom_name.

  • Exception if none found.

Return type:

string

name2type(atom_name='C', shorten=True, verbose=True, exception=True)

Best guess of atom type from atom name.

Parameters:
  • atom_name (str) – IUPAC or other name (or arbitrary string).

  • shorten (bool) – shorten atom_name until a match is found.

  • exception (bool) – throw an exception if no match, else return None.

  • verbose (bool) – print warning messages for ambigous names.

Returns:

atom type or None

Return type:

string

recognized(atom_name='C')

Checks if atom type in the form factor table.

Returns:

found.

Return type:

bool

type_number(atom_type='C', atom_name=None)

Returns the index of the atom type in the form factor table.