The following provides a tool for the automatic fitting of torsion motif torsion angle distributions with wrapped mirrored Gaussians as introduced in [1], section "Fitting tmTADs with Wrapped Mirrored Gaussians".
Torsion motif torsion angle distribution means that the torsion profiles originate from more than one molecule: The sets of molecules share a common chemical environment that can be expressed in a SMARTS pattern.
[1] pre-print: https://chemrxiv.org/engage/chemrxiv/article-details/68dbdcf2f2aff167703b206e
Installation of the dependencies via conda using the provided environment.yml file:
mamba env create --name fits --file=https://raw.githubusercontent.com/rinikerlab/TorsionDistributionFitting/main/environment.yml
To activate the new environment and install the package:
conda activate fits
python -m pip install git+https://github.com/rinikerlab/TorsionDistributionFitting
For verification of a sucessful installation, run the tests:
pytest
A minimal example is shown here. For a more in depth version, check the Demo.ipynb notebook.
import Fits
import numpy as np
# a dummy torsion distribution
data = np.deg2rad(np.concatenate([
np.random.normal(loc=60, scale=5, size=250),
np.random.normal(loc=300, scale=5, size=250)
]))
binSize = 2 * np.pi / (36 * 2)
bins = np.arange(0, 2*np.pi+binSize, binSize)
yHist, xHist = np.histogram(data, bins=bins, density=True)
yHistCount, _ = np.histogram(data, bins=bins, density=False)
# coeffs are the results of the fit; smoothed is the smoothed, mirrored histogram used for the fitting
coeffs, smoothed = Fits.ComputeMirroredGaussianFit(xHist[:-1] + 0.5 * binSize, yHist, yHistCount, binSize, len(data))Jessica Braun, Djahan Lamei
done
