schrodinger.application.jaguar.simple_spec module

schrodinger.application.jaguar.simple_spec.get_splitting_pattern(multiplicity: int, n_coupled: int) dict[int, float]

Return the splitting pattern resulting from coupling to n_coupled identical nuclei with the given spin-multiplicity. Pattern is encoded as a dictionary mapping the of the number of times the J constant is applied onto the relative height of that peak. e.g. 2 spin-1/2 nuclei return {-1: 0.25, 0: 0.5, 1: 0.25} for the 1:2:1 triplet splitting pattern.

Currently only spin-1/2 (multiplicity 2), spin-1 (multiplicity 3) and spin-3/2 (multiplicity 4) nuclei are supported.

Parameters
  • multiplicity – The multiplicity of the coupling nuclei.

  • n_coupled – The number of identical nuclei coupling.

Returns

A dictionary encoding the splitting pattern.

Raises

ValueError – If an unsupported multiplicity is passed.

class schrodinger.application.jaguar.simple_spec.Spin(shift: float, idx: int, name: str, isotope: str)

Bases: object

Class encapsulating information about a given spin, collecting together symmetry related spins in the set self.members and naming the spin.

__init__(shift: float, idx: int, name: str, isotope: str)
class schrodinger.application.jaguar.simple_spec.Peak(shift: float, scale: float, count: int, isotope: str, parent: Optional[Self] = None, name: str = '', members: set[int] | None = None, members_jnames: set[str] | None = None)

Bases: object

Class describing a peak in the spectrum. This has a highly recursive structure to facilitate easy calculation of splitting patterns and intensities. When a Peak is split it passes all splitting on to its children until leaf Peaks are reached. These then create new child Peaks that are shifted and scaled from the parent appropriately.

Likewise, the peak as drawn on the spectrum is recursively evaluated by summing the contributions from leaf Peaks.

spliting_bonds: int | None
__init__(shift: float, scale: float, count: int, isotope: str, parent: Optional[Self] = None, name: str = '', members: set[int] | None = None, members_jnames: set[str] | None = None)
shift: float
scale: float
count: int
children: list[Self]
splitting_label: str
parent: Optional[Self]
name: str
isotope: str
members: set[int]
members_jnames: set[str]
J: float | None
split_by: str | None
split_isotope: str | None
split_peak(j_const: float, n_coupled: int, split_by_label: str, n_bonds: int, split_isotope: str, magnet: float)

Recursively split the present Peak with the appropriate pattern and shift.

If this Peak has children then we recursively descend into each child. When a leaf Peak is found new child Peaks are created inheriting the direct parent’s shift and intensity modified as defined by the splitting pattern.

Parameters
  • j_const – The coupling strength in ppm. Directly corresponds to how far child peaks are shifted.

  • n_coupled – The number of coupled spins. Defines splitting pattern and intensity ratios, e.g. 3 coupling spins make a 1:3:3:1 splitting as defined in get_splitting_pattern

  • split_by_label – User-facing label for the spin that is coupling for annotation purposes.

  • n_bonds – Number of bonds between this spin and coupling spin, used to mark splitting 2J, 3J, 4J etc.

  • split_isotope – The isotope of the coupling spin from which the multiplicity of the splitting pattern is determined.

  • magnet – The magnetic strength of the spectrometer in Tesla.

get_signal(x: numpy.ndarray[Any, numpy.dtype[numpy.float64]], alpha: float) numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Generate the signal in the spectrum from this Peak by recursively summing child Peak signals.

Parameters
  • x – The array of x samples to evaluate in ppm.

  • alpha – Parameter controlling peak breadth.

Returns

The y values for each x resulting from this Peak.

make_my_signal(x: numpy.ndarray[Any, numpy.dtype[numpy._typing._generic_alias.ScalarType]], alpha: float) numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Generate the actual signal from this peak by evaluating a Gaussian centered on self.shift at each point x.

Parameters
  • x – The array of x samples to evaluate in ppm.

  • alpha – Parameter controlling peak breadth.

Returns

The y values for each x resulting from this Peak.

get_shifts() list[float]

Recursively collect the shift value of all leaf Peaks.

Returns

List collating the shift value of all leaf peaks.

printit(depth: int = 0) str

Recursively print this and all child peak information for debugging purposes.

Parameters

depth – The current depth in the tree.

Returns

string collating this and all child Peak data.

get_max_height(alpha: float, x: numpy.ndarray[Any, numpy.dtype[numpy.float64]] | None = None, _is_root: bool = True) float | numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Recursively evaluate peak intensity to numerically determine the maximum from this peak and its children. Note that it is not easy to analytically determine this as two children may coincide to be taller in sum than each individually. As a result this takes a set of x samples in ppm to assess over.

Parameters
  • alpha – Parameter controlling peak breadth.

  • x – X samples in ppm to find maximum height over. If x is None this is calculated as a padding around the maximum and minimum ppm of all child peaks.

  • _is_root – Flags that this is the root Peak being called for, set to False in all recursive calls. This is an internal argument for controlling recursion and should not be set by the calling code.

Returns

If this is the Peak that this method was originally called for then return the maximum y from the spread of x assessed. Otherwise if this is a recursive call then return the array of y samples to be summed by the parent node.

get_min_ppm() float

Recursively find the minimum shift in ppm from all leaf Peaks on this branch.

Returns

Minimum shift in ppm.

get_max_ppm() float

Recursively find the maximum shift in ppm from all leaf Peaks on this branch.

Returns

Maximum shift in ppm.

get_depth() int

Recursively find how many levels the tree has including this Peak.

Returns

Number of levels in the tree. Returns 1 for a leaf Peak.

get_splittings() list[tuple[str, float]]

Recursively collect all splittings of this peak.

Returns

List associating the proton that caused the splitting and the splitting strength for each splitting.

annotate_plot(ax: matplotlib.axes._axes.Axes, magnet: float, _parent_xy: numpy.ndarray[Any, numpy.dtype[numpy.float64]] | None = None, _step: float | None = None, _lab_point: float | None = None, alpha_width: float = 230831.20654223417, color: str = 'b', base_point: float | None = None, top_point: float | None = None)

Recursively annotate splitting tree information onto a figure. Showing each splitting and child splitting etc.

Parameters
  • ax – Matplotlib axis that should contain annotations.

  • magnet – Field strength of the spectrometer in Tesla.

  • _parent_xy – The x, y position of the parent’s annotation. Updated and passed into child Peaks to recursively update this position.

  • _step – The step size in y for each descending section of the diagram. This is omitted when calling initially.

  • _lab_point – The x position from which the splitting labels should be drawn. This is omitted when calling initially.

  • alpha_width – Parameter controlling peak breadth.

  • color – The matplotlib accepted color for the tree annotations.

  • base_point – The point to extend the trees downwards to. Determined as the highest point on the peak if omitted.

  • top_point – The point to extend the trees downwards from. Determined as the highest point on the y axis if omitted.

clear_annotations()

Clear all annotations for this peak and its children.

acs_summary_string(magnet: float) str

Build a string summarizing this peak in ACS NMR blurb format: https://pubsapp.acs.org/paragonplus/submission/acs_nmr_guidelines.pdf

Parameters

magnet – Magnetic field strength for the specrometer in Tesla for unit conversion.

Returns

The formatted string representation of this peak.

get_acs_name() str
full_summary_string(magnet: float, _is_root: bool = True) str

Recursively create a full summary blurb of the peak.

Parameters
  • magnet – Magnetic field of the spectrometer in Tesla.

  • _is_root – Flag that this call is the root call or recursive.

Returns

String summarizing the peak and all its children.

get_j_label(magnet: float) str

Coupling label for annotating plots.

Parameters

magnet – Spectrometer field in Tesla.

Returns

String describing the coupling in ACS format.

get_j_summary(magnet: float) str

Coupling summary string for building NMR blurbs.

Parameters

magnet – Spectrometer field in Tesla.

Returns

String describing the peak in ACS format.

set_member_names(jnames: list[str])
schrodinger.application.jaguar.simple_spec.format_isotope_latex(isotope: str) str

Return the isotope label formatted in LaTeX markup.

Parameters

isotope – The isotope string to be formatted, expected format like “1H”

Returns

The formatted label.

:raises ValueError if the input cannot be formatted.

schrodinger.application.jaguar.simple_spec.build_spectrum(spins: list[schrodinger.application.jaguar.simple_spec.Spin], couplings: list[tuple[int, int, float, int]], magnet: float, nmr_type: str) list[schrodinger.application.jaguar.simple_spec.Peak]

Build the textbook spectrum as a set of Peak objects created from the list of Spin objects, recursively applying the couplings provided to split the peaks.

Parameters
  • spins – List of Spin objects.

  • couplings – List of couplings as tuples indexing spins argument: (index_1, index_2, J constant (in Hz), number of separating bonds)

  • magnet – Magnetic field strength of spectrometer in Tesla.

  • nmr_type – The type of NMR spectrum experiment we are running, e.g. “1H”, “19F”, or any value with an entry in the nmr_utils.ISOTOPE_DATA dict. This is important to make sure the Hz to ppm conversions are correct for the splitting patterns. Only Peaks with an isotope value matching this will produce signals in the spectrum, but other isotopes may cause splitting patterns through coupling.

Returns

List of Peak objects that make up the textbook spectrum.

schrodinger.application.jaguar.simple_spec.get_spectrum(peaks: list[schrodinger.application.jaguar.simple_spec.Peak], nmr_type: str, line_width: float = 0.0025, x: numpy.ndarray[Any, numpy.dtype[numpy.float64]] | None = None) numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Get the textbook spectrum from a list of Peak objects. We create a scan of ppm values, then sum the corresponding intensity from each peak in the list to build an approximate spectrum.

Parameters
  • peaks – The collection of peak objects describing the spectrum.

  • nmr_type – The type of NMR spectrum experiment we are running, e.g. “1H”, “19F”, or any value with an entry in the nmr_utils.ISOTOPE_DATA dict. Only Peaks with an isotope value matching this will produce signals in the spectrum, but other isotopes may cause splitting patterns through coupling.

  • line_width – The full-width half-maximum of the peaks, in ppm.

  • x – The x samples for the spectrum in ppm for point-to-point matching a reference, if this is None then we will take the reasonable default of samples accross a sweep that covers all signals with some buffer.

schrodinger.application.jaguar.simple_spec.plot_spectra(peaks: list[schrodinger.application.jaguar.simple_spec.Peak], refx: numpy.ndarray[Any, numpy.dtype[numpy.float64]] | None, refy: numpy.ndarray[Any, numpy.dtype[numpy.float64]] | None, to_label: set[str], magnet: float, nmr_type: str, line_width: float = 0.0025, fname: pathlib.Path | None = None)

Debug helper function to plot the spectrum of a set of peaks and optionally compare it to a reference spectrum.

Parameters
  • peaks – List of Peak objects to be plotted.

  • refx – Optional x values for the reference spectrum.

  • refy – Optional y values for the reference spectrum.

  • to_label – Set of peaks for which we should construct annotations.

  • magnet – Magnetic field strength in Tesla for unit conversions.

  • nmr_type – The type of NMR spectrum experiment we are running, e.g. “1H”, “19F”, or any value with an entry in the nmr_utils.ISOTOPE_DATA dict. Only Peaks with an isotope value matching this will produce signals in the spectrum, but other isotopes may cause splitting patterns through coupling.

  • line_width – Optional FWHM of the Gaussian summed for each Peak.

  • fname – The filename the plot should be saved to. If None then it will be shown interactively instead.

schrodinger.application.jaguar.simple_spec.make_nmr_acs_summary_string(peaks: list[schrodinger.application.jaguar.simple_spec.Peak], molname: str, magnet: float) str

Create a full NMR blurb of the set of peaks in ACS format. https://pubsapp.acs.org/paragonplus/submission/acs_nmr_guidelines.pdf

Parameters
  • peaks – Collection of Peaks for which we should create the summary.

  • molname – Name of the molecule to begin the blurb.

  • magnet – Magnetic field strength in Tesla for unit conversions.

Returns

Full blurb for NMR spectrum in ACS format.

schrodinger.application.jaguar.simple_spec.read_input(infile_name: pathlib.Path, read_spectrum: bool = False) tuple[list[schrodinger.application.jaguar.simple_spec.Spin], list[Tuple[int, int, float, int]], numpy.ndarray[Any, numpy.dtype[numpy.float64]] | None, str, float]

Deserialise the JSON file into NMRData object for spectrum calculation. Also search for the associated spin-dynamics calculated spectrum and return it if present.

Parameters
  • infile_name – Filename containing JSON serialised NMRData object.

  • read_spectrum – Bool flagging if we should look for a Jaguar spectroscopy generated spectrum file for comparison.

Returns

List of Spins objects descibing the uncoupled spins.

Returns

List of Coupling data (idx_1, idx_2, J, separating_bonds).

Returns

The spin-dynamics spectrum if located, otherwise None.

Returns

The title of the structure associated with the data.

Returns

The field strength the spectrum was taken with, in Tesla.

schrodinger.application.jaguar.simple_spec.prune_couplings(spins: list[schrodinger.application.jaguar.simple_spec.Spin], couplings: list[Tuple[int, int, float, int]]) list[Tuple[int, int, float, int]]

Prune the coupling list so that intra-group coupling is removed as are duplicate couplings between groups.

Parameters
  • spins – List of spin objects describing the system.

  • couplings – List of coupling tuples possibly containing redundant couplings.

Returns

list of non-redundant couplings.

Raises

JaguarRuntimeError – If a spin index cannot be found in one of the spin objects.