chemistry_tools.formulae.iso_dist

Attention

This module has the following additional requirements:

cawdrey>=0.5.0
mathematical>=0.5.1
pyparsing>=2.4.6
tabulate>=0.8.9

These can be installed as follows:

python -m pip install chemistry-tools[formulae]

Isotope Distributions.

Classes:

IsoDistSort(value)

Lookup for sorting isotope distribution output.

IsotopeDistribution(formula)

An isotope distribution.

enum IsoDistSort(value)[source]

Bases: enum_tools.custom_enums.IntEnum

Lookup for sorting isotope distribution output.

Member Type

int

Valid values are as follows:

Formula = <IsoDistSort.Formula: 0>

Sort the isosope distribution by the formulae.

Mass = <IsoDistSort.Mass: 1>

Sort the isotope distribution by the masses.

Abundance = <IsoDistSort.Abundance: 2>

Sort the isotope distribution by the abundances.

Relative_Abundance = <IsoDistSort.Relative_Abundance: 3>

Sort the isotope distribution by the relative abundances.

class IsotopeDistribution(formula)[source]

Bases: DataArray

An isotope distribution.

Parameters

formula (Formula) – A Formula object to create the distribution for

Each composition can be accessed with their hill formulae like a dictionary (e.g. iso_dict['H[1]2O[16]'])

Attributes:

__class_getitem__

Methods:

__contains__(key)

Return key in self.

__eq__(other)

Return self == other.

__getitem__(key)

Return self[key].

__iter__()

Iterates over the dictionary’s keys.

__len__()

Returns the number of keys in the dictionary.

__repr__()

Return a string representation of the DataArray.

__str__()

Return str(self).

as_array([sort_by, reverse, format_percentage])

Returns the isotope distribution data as a list of lists.

as_csv(*args[, sep])

Returns the data as a CSV formatted string.

as_dataframe(*args, **kwargs)

Returns the isotope distribution data as a pandas.DataFrame.

as_table(*args, **kwargs)

Returns the isotope distribution data as a table using tabulate.

copy(*args, **kwargs)

Return a copy of the FrozenOrderedDict.

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(k[, default])

Return the value for k if k is in the dictionary, else default.

items()

Returns a set-like object providing a view on the FrozenOrderedDict's items.

keys()

Returns a set-like object providing a view on the FrozenOrderedDict's keys.

values()

Returns an object providing a view on the FrozenOrderedDict's values.

__class_getitem__ = <bound method GenericAlias of <class 'chemistry_tools.formulae.iso_dist.IsotopeDistribution'>>

Type:    MethodType

__contains__(key)

Return key in self.

Parameters

key (object)

Return type

bool

__eq__(other)

Return self == other.

Return type

bool

__getitem__(key)

Return self[key].

Parameters

key (~KT)

Return type

~VT

__iter__()

Iterates over the dictionary’s keys.

Return type

Iterator[~KT]

__len__()

Returns the number of keys in the dictionary.

Return type

int

__repr__()

Return a string representation of the DataArray.

Return type

str

__str__()[source]

Return str(self).

Return type

str

as_array(sort_by=<IsoDistSort.Formula: 0>, reverse=False, format_percentage=True)[source]

Returns the isotope distribution data as a list of lists.

Parameters
  • sort_by (Union[int, IsoDistSort]) – The column to sort by. Default <IsoDistSort.Formula: 0>.

  • reverse (bool) – Whether the isotopologues should be sorted in reverse order. Default False.

  • format_percentage (bool) – Whether the abundances should be formatted as percentages or not. Default True.

Return type

List[List[Any]]

as_csv(*args, sep=',', **kwargs)

Returns the data as a CSV formatted string.

Parameters
  • *args – Arguments passed to as_array().

  • sep (str) – The separator for the CSV data. Default ','.

  • **kwargs – Additional keyword arguments passed to as_array().

Return type

str

as_dataframe(*args, **kwargs)

Returns the isotope distribution data as a pandas.DataFrame.

Any arguments taken by as_array() can also be used here.

Return type

DataFrame

as_table(*args, **kwargs)

Returns the isotope distribution data as a table using tabulate.

Any arguments taken by as_array() can also be used here.

Additionally, any valid keyword argument for tabulate.tabulate() can be used.

Return type

str

copy(*args, **kwargs)

Return a copy of the FrozenOrderedDict.

Parameters
  • args

  • kwargs

classmethod fromkeys(iterable, value=None)

Create a new dictionary with keys from iterable and values set to value.

Return type

FrozenBase[~KT, ~VT]

get(k, default=None)

Return the value for k if k is in the dictionary, else default.

Parameters
  • k – The key to return the value for.

  • default – The value to return if key is not in the dictionary. Default None.

items()

Returns a set-like object providing a view on the FrozenOrderedDict's items.

Return type

AbstractSet[Tuple[~KT, ~VT]]

keys()

Returns a set-like object providing a view on the FrozenOrderedDict's keys.

Return type

AbstractSet[~KT]

values()

Returns an object providing a view on the FrozenOrderedDict's values.

Return type

ValuesView[~VT]