sith.utils package
Submodules
- class sith.utils.analysis.DataSetAnalysis(inner_steps: Callable, data_dir: str = './', subdir='', exclude_prolines=True, exclude=None, pdb_pattern='stretched00', struc_pattern='force*.fchk', alternative_subdir=None, **kwargs)[source]
Bases:
objectCreates the objects of to do the analysis of a set of peptides in a data set.
- Parameters:
inner_steps (function. Default=None) – function with the operations to apply to every sith object -its unique argument- after initialized. Note that it has to have the analysis you want to apply. For example,
data_dir (str. Default='./') – directory containing the directories of the molecules.
subdir (str. Default='') – subdirectory inside each molecule directory containing the files to be analyzed by sith.
exclude_prolines (bool. Default=True) – if True, neglects all the peptides with a proline in their sequence. In other words, it ignores all the directories with a ‘P’ in their name.
exclude (list. Default=None) – list of molecules to exclude from the analysis.
pdb_pattern (str. Default='stretched00') – pattern to identify the pdb file in each molecule directory.
struc_pattern (Default='forces<all>.fchk') – pattern to identify the files to be analyzed by sith in each molecule directory.
kwargs – for initializing sith
alternative_subdir (Default=None) – subdirectory inside each molecule directory containing the files to be analyzed by SITH. If None, the molecule directory will be used.
note:: (..) –
The function inner_steps has to have as unique argument a sith object and return the same sith object after applying the analysis you want. For example, if you want to remove the first and last structure and then apply the sith_analysis, you can define the function as:
def inner_steps(sith): sith.rem_first_last(from_last_minimum=True) sith.sith_analysis() return sith
- amino_freq()[source]
Extract the name of the peptides in one-letter-convention for the amino acids.
- Return type:
(numpy.array) set of names.
- dof_vs_energy(aa_names, naas=3)[source]
Extract the values of the dofs and the associated dofs energies for a set all the molecules of data set. Check sith.sith.analysis.SithAnalysis.le_dof_amino
- Parameters:
aa_names (list) – Atom names forming the DOF.
naas (list or int. Default=3) – index of the residue from which each atoms belongs to. In case of only an integer, all the atoms are assumed to belong to the same residue.
- Returns:
(tuple) list of arrays with dof values and dof energies in the
extension trajectory of each molecule in the dataset.
Note
This function returns the absolute value of the DOF, to obtain the same but computing the change in the DOF in respect to the optimized configuration of see sith.sith.analysis.DataSetAnalysis.dofs_vs_energy_rescaled
- dof_vs_energy_rescaled(aa_names, naas=3)[source]
Extract the values of the delta dofs in respect to the optimized configuration and the associated dofs energies for a set all the molecules of data set. Check sith.sith.analysis.SithAnalysis.le_dof_amino
- Parameters:
aa_names (list) – Atom names forming the DOF.
naas (list or int. Default=3) – index of the residue from which each atoms belongs to. In case of only an integer, all the atoms are assumed to belong to the same residue.
- Returns:
(tuple) list of arrays with delta dof values and dof energies in the
extension trajectory in respect to the optimized configuration of each
molecule in the dataset.
- plot_DFT_ener(ax: Axes = None, sp=None, lw=1, ms=1, **kwargs)[source]
Plots the DFT energy of the extension process
- Parameters:
ax (plt.Axes Default=None) – Axes to plot in. If Nonne, a new axis is created.
sp (StandardPlotter. Default=None) – sith.plotters.StandardPlotter
lw (float. Default=1) – line width.
ms (float. Default=1) – marker size.
StandardPlotters. (kwargs for)
- Returns:
(StandardPlotter, list, list) Standard plotter, all dofs values,
all energy values used for the plot.
- test()[source]
check that the first sith has the basic variables. It assumes that the rest also has it
- Return type:
(None)
- test_continuity(sith, analysis)[source]
Test that the changes in the Ca-C-N angle are lower than 10 degrees and the Ca-C and Ca-N distances are lower than 0.2 Angstroms between stretched configurations.
- Parameters:
sith – SITH object containing the information of the current peptide.
analysis – Analysis object containing the information of the current peptide.
- Return type:
(bool) True if the test passes, False otherwise.
- class sith.utils.analysis.SithAnalysis(sith, pepinfo)[source]
Bases:
objectSet of tools to anayze the data extracted from SITH.
- Parameters:
sith (sith.SITH) – SITH object with all the information inside.
pepinfo (dict) – Information of the peptide. Like amino acids, atoms, and so. It is an attribute of sith.utils.peptides.PepSetter.
- index_dof(target: tuple)[source]
Search the index of a specific dof.
- Parameters:
target (np.ndarray) – degree of freedom.
- Return type:
(int) index of the DOF.
- le_dof_amino(a_names, aminos)[source]
Value and the change of the energy of a DOF.
- Parameters:
a_names (list) – atom names of the atoms forminf the DOF.
aminos (list or int) – index of the residue from which each atoms belongs to. In case of only an integer, all the atoms are assumed to belong to the same residue.
- Returns:
(tuple) array of dof values and change dof energies in the extension
trajectory in respect to the optimized configuration.
- sith.utils.analysis.analysis_energy_dof(dsa, es)[source]
Create a list of distributions per each one of the positions.
- Parameters:
dsa (DataSetAnalysis) – object that contains the information of the molecules in the dataset.
es (list of arrays) – list of energies to be analyzed.
- Returns:
(duple) list of distribution of energies, mean and std per position.
Namely, the first element of the first element of the output is the list of
energies of the amino acid at the first position.
- sith.utils.analysis.closest_indices(ref, value)[source]
Find the indexes of the points after and before certain value
- Parameters:
ref (numpy.array) – list contaning the data.
value (float) – threshold value.
- Return type:
(list) indexes of the next-lower and the next-upper elements in the list.
- sith.utils.analysis.construct_neigh_dic(dsa, es)[source]
Creates a dictionary with all the combination of two amino acids and stores in each combitation, a list of energies of the peptides with the first amino acid in the middle and the second in any side of the peptide.
- Parameters:
dsa (DataSetAnalysis) – object that contains the information of the molecules in the dataset.
es (list of arrays) – list of energies to be analyzed.
- Returns:
(dict) keys (Amino combination, values: list of energies appearing in)
peptides with those combinations.
Example
# if energies per peptides are peptides = {‘ABC’: 1.5, ‘GBA’: 2.3} # neigh dictionary would be combi_neigh = {‘BC’: [1.5, 2.3]}
- sith.utils.analysis.cross_val(x, y, val)[source]
Finds the crossing of a linearly interpolated curve with certain value in the y data (horizontal line).
- Parameters:
x (numpy.array) – x-data of the curve.
y (numpy.array) – y-data of the curve.
val (float) – threshold value.
- Return type:
(float) x value where the interpolated curve crosses the specified value.
Note
If you want to interpolate to a value of x (vertical line), just change x by y when you pass the arguments.
- sith.utils.analysis.dof_classificator_all(dofs_indexes, atoms_per_aminoacids)[source]
Separates all degrees of freedom defined by atoms (all) of a residue.
- Parameters:
dofs_indexes (list of duples) – sith.structures[n].dim_indices containing definition of the degrees of freedom in term of the atomic indexes.
atoms_per_aminoacids (dict) – Atoms in each residue. The keys are the number of the residues, values should be the indexes of the atoms belonging to the residue of the key.
- Returns:
(dict) [keys (Residues (int), values: (array) [#DOFsPerResidue (int)]])
Indexes of the degrees of freedom containing all atoms of each residue.
Note
atoms_per_aminoacids can be obtained from sith.utils.peptides.PepSetter.atom_indexes
- sith.utils.analysis.dof_classificator_one(dofs_indexes, atoms_per_aminoacids)[source]
Separates all degrees of freedom defined by atoms (at least one) of a residue.
- Parameters:
dofs_indexes (list of duples) – sith.structures[n].dim_indices containing definition of the degrees of freedom in term of the atomic indexes.
atoms_per_aminoacids (dict) – Atoms in each residue. The keys are the number of the residues, values should be the indexes of the atoms belonging to the residue of the key.
- Returns:
(dict) [keys (Residues (str), values: (array) [#DOFsPerResidue (int)]])
Indexes of the degrees of freedom containing at least one atom of each
residue.
Note
atoms_per_aminoacids can be obtained from sith.utils.peptides.PepSetter.atom_indexes
- sith.utils.analysis.le_same_aminoacids(sith, peptides_info, atom_types, kind_amino)[source]
Return distances between two atom types in the same type of amino acid and the energy associated with these DOF as the molecule is stretched.
- Parameters:
sith (sith object) – sith object containing the distribution of energies. That implies to have the class variable ‘energies’ with the energies per deformed configuration and and per DOF.
peptides_info – object with the info of the peptide.
atom_types (str) – name of the atoms inside the aminoacid that will be studied, example [‘CA’, ‘CB’].
kind_amino ((list) [(str)]) – name of the amino acids.
- Returns:
(list) [#kindAmino x [2 x #Def (float)]] values of the DOF and energies
associate with those DOFs per deformed configuration in the selected amino.
Note
peptides_info can be obtained from sith.utils.peptides.PepSetter
- sith.utils.analysis.length_energy(sith, aminos_info, atom_types)[source]
Return distances between two atom types in one amino acid and the energy associated with this DOF as the molecule is stretched.
- Parameters:
sith (sith object) – sith object containing the distribution of energies. That implies to have the class variable ‘energies’ with the energies per deformed configuration and and per DOF.
aminos_info (dic) – name of the atoms of one amino acid associated with the index.
atom_types (str) – name of the atoms inside the aminoacid that will be studied, example [‘CA’, ‘CB’].
- Returns:
(list) [2 x #Def (float)] values of the DOF and energies associate with
those DOFs per deformed configuration in the selected amino.
Note
aminos_info can be obtained from sith.utils.peptides.PepSetter.amino_info[n] where n is the selected amino acid.
- sith.utils.analysis.mean_n_std(distri)[source]
Extract the mean and standard deviation of a set of values associated to an amino acid in distri.
- Parameters:
distri (dict) – keys amino acid, values list of values to obtain mean and standard deviation.
- Returns:
(tuple) dictionary of mean, dictionary of standard deviation. Both
dictionaries have the shape keys (amino acid; values: mean/std)
- sith.utils.analysis.pep_per_x(xs, ys, value, dsa)[source]
Separate the value of x in which y crosses a certain value, identifying it with an specific peptide.
- Parameters:
xs (numpy.array) – x-data of the curve.
ys (numpy.array) – y-data of the curve.
value (float) – threshold value.
dsa (DataSetAnalysis) – object containing the analysis.
- Return type:
(dict) The name of the peptide as key and the x-value as dict value.
- sith.utils.analysis.reduce_data(xs, ys)[source]
Reduces the data to the range of maximum minimum xs (highest of the lowest) and minumim maximum xs (lowest of the highest). Returns a new list of xs and ys where all the minum/maximum xs are the same and the ys of the minumum/maximum xs are found by interpolation. Also makes the transformation new_y -= new_y[:, 0]
- Parameters:
xs (list of arrays) – set of xs data.
ys (list of arrays) – set of xs data.
- Return type:
(tuple) list of new xs and new ys
Note
if defmin/defmax is higher/lower than the real minimum/maximum, this code would not recognize the proper values. Be sure that defmin/defmax is lower/higher than the lowest/highest of xs.
- sith.utils.analysis.separate_by_position(dsa, es, pos)[source]
Stores the last values of “es” that correspond to an amino acid in a specific position.
- Parameters:
dsa (DataSetAnalysis) – object that contains the information of the molecules in the dataset.
es (list of arrays) – list of energies to be analyzed.
pos (int) – position to be extracted.
- Returns:
(dict) keys (amino acid in the asked position; values: list of energies to)
be analyzed.
- sith.utils.analysis.set_hes_from_ref(geo_ref, sith_tar, structure)[source]
Set the hessian in in a target sith taken from a geometry of reference.
- Parameters:
geo_ref (sith.Utilities.Geometry) – sith object that contains the atribute you want to redefine.
sith_tar (sith.SITH) – sith object that will change its property.
structure (int) – index of the deformed structure to set the hessian.
- Returns:
(sith.SITH) returns the sith_tar with the hessian in the defined structure.
Note (All the sith.sith.structures are Geometry objects with all the)
information of the structure.
- sith.utils.analysis.statistics(ener_per_pos, pos, aminos)[source]
Compute the p-value and F-statistic between distributions of the amino acids in the dataset for a given position.
- Parameters:
ener_per_pos (list) – set of energy data per position, per amino acid.
pos (int) – position to be analyzed.
aminos (list) – list of amino acids in the data set.
- Returns:
(tuple) arrays in shape of sqared matrices containing pval and fstat
matrix.
- sith.utils.compare_siths.extract_common(sith1, sith2)[source]
Finds the DOfs that are in common in both sith objects
- Parameters:
sith1 (sith.SITH) – obtject of reference.
sith2 (sith.SITH) – object to be compared.
- Return type:
(tuple), list of indexes in sith1 that are in sith2, organized list.
- sith.utils.compare_siths.extract_diff(sith1, sith2)[source]
Finds the indexes of the DOfs that are in sith1 that are not in sith2 and the other way around.
- Parameters:
sith1 (sith.SITH) – object to compare.
sith2 (sith.SITH) – object to compare.
- Returns:
(tuple), list of indexes in sith1 that are not in sith2 and list of indexes
in sith2 that are not in sith1.
- sith.utils.compare_siths.index_dof(sith, target: tuple)[source]
Search the index of a specific dof.
- Parameters:
sith (sith.SITH) – SITH object.
target (np.ndarray) – degree of freedom.
- Return type:
(int) index
- sith.utils.compare_siths.organize_lengths(sith1, sith2)[source]
sort the distances in sith1 such that they fit with sith2. # TODO: confirm that the description is correct and it is # not the other way arround
- Parameters:
sith1 (sith.SITH) – obtject of reference.
sith2 (sith.SITH) – object to be compared.
- Returns:
(numpy.array) set of sorted indexes that makes the distance of sith2 to
coincide with the distances of sith1.
- sith.utils.miscellaneous.output_terminal(cmd, print_output=True, skip_error=False, print_cmd=False, **kwargs)[source]
Runs a command in a terminal and save the output in a list of strings
- Parameters:
cmd (str) – bash command to be executed in the terminal.
print_output (bool. Default=True) – True for printing the output besides of returning it. Default False.
skip_error (bool. Default=False) – True for continuing running although the command fails. Default False.
**kwargs – additional options for subprocess.Popen
print_cmd (Default=False) – print the command that was just executed.
- Return type:
(list) [#linesStr] output of the executed command, line by line.
- class sith.utils.molecules.Alignment(atoms)[source]
Bases:
objectSet of tools to apply the necessary transformations for aligning a the three first eigenvectors of PCA with the x, y, z axis, in that order.
- Parameters:
atoms (ase.Atoms) – molecule to be aligned.
- static align_with_components(atoms)[source]
Aligns the coordinates x, y, z axis with the main vectors (in that order).
- Parameters:
atoms (ase.Atoms) – Molecule to be aligned.
- Return type:
(ase.Atoms) rotated and shifted molecule.
- static center_geo(atoms)[source]
Moves the coordinates origin to the geometrical center atoms.
- Parameters:
atoms (ase.Atoms) – Molecule to be moved.
- Return type:
(ase.Atoms) Transformed atoms
- static pca_vectors(atoms, indexes='all')[source]
Find the eigen vectors of the Principal Component Analysis of the positis of the atoms.
- Parameters:
atoms (ase.Atoms) – molecule to be analyzed.
indexes (list. Default="all") – subset of atoms to be included in the pca analysis. 1-based numbering.
- Return type:
(array) principal components.
- class sith.utils.molecules.MoleculeSetter(atoms)[source]
Bases:
objectTool to edit or extract information from a molecule.
- Parameters:
atoms (ase.Atoms) – molecule to be analyzed.
- align_axis(vector)[source]
Apply the necessary rotations to set a vector aligned with positive x axis.
- Parameters:
vector (array) – vector to be aligned.
- Return type:
(numpy.array) [3float x 3float] Transformation matrix.
- align_plane(vector)[source]
Rotation around x axis to set a vector in the xy plane.
- Parameters:
vector (array) – vector to be rotated to be in the xy plane.
- Return type:
(numpy.array) [3float x 3float] Transformation matrix.
- apply_trans(trans, indexes=None, shift=None)[source]
Apply a transformation to all vector positions of some atoms.
- Parameters:
trans (array (3x3)) – transformation matrix to be applied to all atom positions.
indexes (list or array. Defatult=None) – indexes of the atoms to apply the transformation. Default None that means the transformation is applied to the positions of all the atoms. 1-based numbering.
shift (list. Default=None) – vector to apply a translation.
- Returns:
changes the positions of the internal atoms object.
- Return type:
(numpy.array)[#natoms x 3float] new xyz positions of the N atoms. It
- create_gaussian_input(out=None, charge=0, xc='bmk', basis='6-31+g', mem='10GB')[source]
Creates a gaussian .com file without specifing the kind of calculus to run (optimization, ab-initio md, frequencies…). You would have to add it.
- Parameters:
out (str. Defatult=None) – name of the gaussian file (.com) without extension. Default chemical formula.
charge (int. Default=0) – charge of the molecule in electron units. Default 0.
xc (str. Default='bmk') – exchange correlation functional used in gaussian. Default bmk
basis (str. Default='6-31+g') – basis set used in gaussian. Default 6-31+g
mem (Default=10GB) – memory assigned to gaussian calculation.
- Return type:
(ase.calculator.Gaussian) Calculator used to create the input.
- increase_distance(constraints, deltad)[source]
Increases the distance between two atoms by moving them and keeping the rest of the atoms in the same place.
- Parameters:
constraints – constraints with the shape (n, 2), where n is the number of constraints and the first pair is the one to increase the distance. 1-based numbering.
deltad (float) – amount to add to the distance between atoms.
- Return type:
(ase.Atoms) Internal Atoms object with the corresponding modification.
- increase_distance_with_constraints(constraints, deltad)[source]
Takes a configuration and increases the distance between two atoms by moving those atoms and all those connected by constraints (all together) containing them and keeping the rest of the atoms in the same place.
- Parameters:
constraints – constraints with the shape (n, 2), where n is the number of constraints and the first pair is the one to increase the distance. 1-based numbering.
deltad (float) – amount to add to the distance between atoms.
- Return type:
(ase.Atoms) Internal Atoms object with the corresponding modification.
- rot_x(angle)[source]
Rotation matrix around x axis.
- Parameters:
angle (float) – angle to rotate around the x axis in radians.
- Return type:
(numpy.array) [3float x 3float] Rotation matrix.
- rot_y(angle)[source]
Retuns the rotation matrix around y axis.
- Parameters:
angle (float) – angle to rotate around the y axis in radians.
- Return type:
(numpy.array) [3float x 3float] Rotation matrix.
- rot_z(angle)[source]
Retuns the rotation matrix around z axis.
- Parameters:
angle (float) – angle to rotate around the z axis in radians.
- Return type:
(numpy.array) [3float x 3float] Rotation matrix.
- scale_distance(constraints, deltad, index3=None)[source]
Increase the distance between two atoms by aligning those atoms with the x axis and scaling the x-coordinate of all intermedia atoms.
- Parameters:
constraints (list) – constraints with the shape (n, 2), where n is the number of constraints and the first pair is the one to increase the distance. 1-based numbering.
deltad (float) – amount to add to the distance between atoms.
index3 (int. Default=None) – The atom with index 3 would be in the xy plane in case to be given. 1-based numbering.
- Return type:
(ase.Atoms) Internal Atoms object with the corresponding modification.
- xy_alignment(index1, index2, index3=None, center=None)[source]
Transform the positions of the atoms such that the atoms of indexes1 and index2 are aligned in the x axis. The atom with index3 would be in the xy plane in case to be given.
- Parameters:
index2 (index1 and) – indexes of the atoms to be aligned with the x-axis. The positive direction of x would go from atom 1 to atom 2. 1-based numbering.
index3 (int. Default=None) – The atom with index 3 would be in the xy plane in case to be given. 1-based numbering.
Center (int. Default=None) – It must be index1 or index2, that means the atom with this index will be placed in the origin. In case center=None (default), the origin would be in the geometrical center between atoms with index1 and index2.
- Returns:
changes the positions of the internal atoms object.
- Return type:
(numpy.array)[#natoms x 3float] new xyz positions of the N atoms. It
- class sith.utils.molecules.PCAMatcher(reference, to_compare)[source]
Bases:
objectTools to align two molecules with their PCA main vectors.
- Parameters:
reference (ase.Atoms) – reference of the molecule to be matched.
to_compare (ase.Atoms) – molecule to be compared to the reference.
- align_molecules()[source]
Align each molecule with their own main PCA vectors.
- Return type:
(tuple) aligned reference and molecule to compare.
- matching()[source]
Finds the order of the indices of the molecule which fit with the atoms of the reference. So, if the outcome of this function is “out”, then PCAMatcher.to_compare[out[i]] == PCAMatcher.reference[i] should be true.
- Returns:
(numpy.array) indices of the molecule that match the indices of the
reference.
Note
align before using this function
- class sith.utils.peptides.PepSetter(pdb_file)[source]
Bases:
MoleculeSetterThe equivalent to but used specifically for proteins.
- Parameters:
pdb_file (str or path) – path to the pdb file containing the information of the protein.
- build_proline_state(aminoacid, state)[source]
Takes a defined peptide with prolines and changes the prolines to endo or exo states.
- Parameters:
aminoacid (int) – number of the aminoacid to modify. It has to correspond with a proline aminoacid.
state (str) – ‘endo’ or ‘exo’. States of the proline.
- Returns:
atoms – Atoms object with the modified structure.
- Return type:
ase.Atoms object
- compute_angle(atom1index, atom2index, atom3index, structure=None)[source]
Compute the angle between 3 atoms. Consider the nexts facts:
- Parameters:
atom1index (int) – index of the atom 1 in 1-based convention.
atom2index (int) – index of the atom 2 in 1-based convention.
atom3index (int) – index of the atom 3 in 1-based convention.
structure (ase.Atoms. Default=None) – Structure to obtain the dihedrals. This has to be the same peptide chemistry than the basis.
- Returns:
(float) Angle as defined in the description in radians.
- The index 2 should correspond to the atom in the vertex.
- The angle is always positive and its range is [0, pi].
- The atoms do not have to be bonded.
- compute_dihedrals(atom1index, atom2index, atom3index, atom4index, structure=None)[source]
Compute the dihedral angle between 4 atoms. Consider the nexts facts: - The dihedral is defined here as the angle between the projection of the vector 2->1 and 3->4 in the plane generated by the normal vector 3->2. - The zero of the angle is set at the projection of 2->1. - The positive direction of the angle is clock-wise (left-hand-rule respect to the normal vector) and its range is [-pi, pi]. - The atoms do not have to be bonded. - vmd also meassures dihedrals as it is explained here.
- Parameters:
atom1index (int) – index of the atom 1 in 1-based convention.
atom2index (int) – index of the atom 2 in 1-based convention.
atom3index (int) – index of the atom 3 in 1-based convention.
atom4index (int) – index of the atom 4 in 1-based convention.
structure (ase.Atoms. Default=None) – Structure to obtain the dihedrals. This has to be the same peptide chemistry than the basis.
- Returns:
dihedral – dihedral angle as defined in the description in radians.
- Return type:
float
- endo_exo_proline()[source]
Computes the dihedral angles a1=(N, Ca, Cb, Cg) and a2=(Cb, Ca, N, Cd) in proline amino acids of the peptide. This angles meassure the endo-exo states, which must be given by the combination [a1 positive, a2 approx 0] for exo, or [a1 negative, a2 approx 0] for endo. ‘a’, ‘b’, ‘g’, and ‘d’ means ‘aplha’, ‘beta’, ‘gamma’ and ‘delta’ respectively.
- Returns:
(numpy.ndarray) [#prolines x (angle1, angle2)] set of angles 1 and 2 in
each proline.
- class sith.utils.sith_plots.SithPlotter(sith: SITH, pdb_template: str)[source]
Bases:
PepSetter,SithAnalysisObject that plots the main graphs to analyze sith outcomes.
- add_color_per_amino(ax: Axes) dict[source]
Add an colored rectangle in the background for every DOF belonging to an aminoacid.
Paramenters
- ax: plt.Axes
Axes of the graphics to add the colors
- rtype:
(dict) colors patches per amino acid labeled by indices.
- plot_angles(cmap: Colormap = None, step: int = 1, sp_pref: dict = {}) Tuple[Figure, Axes][source]
Plot values of angles and changes during the deformations.
- Parameters:
cmap (Colormap) – colormap to the increasing changes.
step (int) – steps between radius ticks.
sp_pref (dict) – dictionary with kwargs for StandardPlotter.
- Return type:
(StandardPlotter) Standard plotter.
- plot_energies_in_DOFs(steps: list = None, jump_stretching: int = 1, **kwargs) Tuple[Figure, Axes][source]
Plot of distribution of energies in all degrees of freedom and in each kind. Namely, distances, angles, dihedrals. Then, it creates a 2x2 plot.
- Parameters:
steps (list. Default=[1, 1, 1, 1]) – size of steps separating the labels of the degrees of freedom.
**kwargs – SithPlotter.plot_data arguments.
- Return type:
plt.figure.Figure, plt.Axes
- plot_error(classical: list | tuple | ndarray = None, sp_pref={}) Tuple[ndarray, ndarray, list][source]
Plot the error between the expected value (DFT) and the computed using sith.
- Parameters:
classical (array-like) – set of classical energies of each deformation computed with amber99.
sp_pref
- Return type:
(np.ndarray, np.ndarray, list) energies, distances and sp.axes
- plot_hessian(ax=None, deci=2, orientation='vertical', cbar=True, ticks=15)[source]
Function that plots the a matrix using a divergent colormap to separate the negative from the positive values.
- Parameters:
hessian (NxN numpy.array) – matrix to be ploted
ax (plt.Axes) – Axis to add the plot. Default: None, in this case, the function creates a new Axis.
deci (int) – number of decimals in the colorbar.
orientation (str) – orientation of the colorbar. Default: ‘vertical’.
cbar (Bool) – True to show the colorbar. Default: True
ticks (float) – ticks size.
- Return type:
PathCollection
- plot_ramachandran(step=1, marker_size_polar=5, marker_size_rama=20, label_dots='Amino\nAcids')[source]
Shows the evolution of each phi-psi angle of each aminoacid in a polar and Ramachandran plot.
- plot_sith(dofs: list | tuple | ndarray = None, e_dofs: list | tuple | ndarray = None, xlabel: str = '', ax: Axes | int = 0, sp: StandardPlotter = None, cmap: Colormap = None, cbar: bool = True, step: int = 1, pstyle: str = '-o', ylabel: str = '$\\Delta$E$_{\\rm{\\bf i}}$[Ha]', jump_stretching: int = 1, show_amino_legends: bool = False, ax_pref: dict = {}, sp_pref={}, pad_cbar=10, **kwargs) Tuple[Figure, Axes][source]
This function plots the energies per degrees of freedom from SithPlotter.sith.energies
- Parameters:
e_dofs (array) – labels of the degrees of freedom.
dofs (array) – energies per degree of freedom. Usually a matrix where each component contains the energies for each DOF for each deformed config: dof\ deformed 0 1 2 3 … 0 [[ ]] 1 [[ ]] 2 [[ ]] . . .
xlabel (str) – label of the xlabel indicating the represented DOFS.
sp (StandardPlotter) – plotter object. if not given. It creates a new object with one graph.
cmap (plt.color.Colormap. Default: cmocean.cm.algae or 'vidris'.) – Color map for the deformations.
cbar (bool. Default=False) – True to show the color bar.
step (int. Default 1) – size of steps separating the labels of the degrees of freedom.
pstryle (str. Default='-o') – style of the lines of energies
ylabel (str. Default={'$Delta$E$_{\rm{bf i}}$' + f'Ha'}) – label in the y axis.
jump_stretching (int. Default=1) – jumps from one stretching to the other starting from the optimized one.
show_amino_legends (bool. Default=False) – True to show the name of the aminoacids painting the background.
ax_pref (dict) – axes preferences. See StandardPlotter.
- Return type:
(plt.Figure, plt.Axes) plotting objects used to create the figure.
- sith.utils.sith_plots.plot_averages_per_pos(ener_per_pos, mean_per_pos, stdr_per_pos, aminos, ylabel, ylim)[source]
Plot the mean value with error bars (std) per position (rows), per amino acids (x axis). It also shows the data points.
- Parameters:
ener_per_pos (list) – set of energy data per position, per amino acid.
mean_per_pos (list) – set of means per position, per amino acid.
stdr_per_pos (list) – set of std per position, per amino acid.
aminos (list) – list of amino acids in the data set.
ylabel (str) – label of the y axis.
ylim (list or tuple) – min and max value of the y axis.
- Return type:
(StandardPlot) sith.plotters.StandardPlot object.
Note
The three first arguments can be obtained using analysis_energy_per_dof
- sith.utils.sith_plots.plot_matrix(matrix, labels, n_per_ele, cbar_label)[source]
Plot a matrix as a heatmap and show a value per combination.
- Parameters:
matrix (numpy.array) – squared matrix as a shape of matrix of dimension 2.
labels (list) – label of the components of the matrix.
n_per_ele (numpy.array) – value to be displayed on the box of the matrix. For example, the number of samples.
cbar_label (str) – label of the color bar.
- Return type:
(StandardPlot) sith.plotters.StandardPlot object.
- sith.utils.sith_plots.plot_matrix2(matrix, labels, cbar_label, sp=None, subspace=None)[source]
Plot a matrix as a heatmap. The colormap is plt.get_cmap(‘coolwarm’) and is divergent, with 0.05 in the middle.
- Parameters:
matrix (numpy.array) – squared matrix as a shape of matrix of dimension 2.
labels (list) – label of the components of the matrix.
cbar_label (str) – label of the color bar.
- Return type:
(StandardPlot) sith.plotters.StandardPlot object.
Note
Usually applied to show p-values.
- sith.utils.sith_plots.plot_matrix3(matrix, labels, cbar_label)[source]
Plot a matrix as a heatmap and show a value per combination.
- Parameters:
matrix (numpy.array) – squared matrix as a shape of matrix of dimension 2.
labels (list) – label of the components of the matrix.
n_per_ele (numpy.array) – value to be displayed on the box of the matrix. For example, the number of samples.
cbar_label (str) – label of the color bar.
- Return type:
(StandardPlot) sith.plotters.StandardPlot object.
- sith.utils.tools.F_max_stretch(ds, pep, fd='frozen_dofs.dat')[source]
Compute the force in the end atoms of the configuration of maximum stretching.
- Parameters:
ds (str) – path to the directory containing the peptide.
pep (str) – name of the peptide on one letter amino acid code.
fd (str. Default=frozen_dofs.dat) – name of the file containing the constrained atoms in the first line.
- Returns:
(float) Force applied at the extremes of the peptide for the
maximum stretched configuration.
- sith.utils.tools.F_stretch(logfile, index)[source]
Extracts the magnitud of the force applied to an atoms of the configuration of maximum stretching.
- Parameters:
logfile – file containing the optmimization or force calculation info.
index – index of the atom that you want to extract the force. 1-based (like gaussian).
- Return type:
(float) Force applied at the selected atom.
- sith.utils.tools.all_hydrogen_atoms(mol)[source]
Finds the indexes of all the hydrogen atoms in the peptide from Atoms object.
- Parameters:
mol (string to config file or ase.Atoms object) – ASE.Atoms object to extract the hydrogen indexes.
- Returns:
(list) [#h_atoms(int)] Indexes corresponding to Hydrogen atoms in 1-based
index.
- sith.utils.tools.all_xyz2pdb(template, output_patern=None, xyzdir='')[source]
Transform all xyz files of the directory where it is executed into a pdb using a pdb file as template.
- Parameters:
pdbtemplate (str) – path to the pdb template for the output.
output_patern (str. Default=None) – the name of the output will be <this string>-<n>.pdb, where is is an increasing index, from 1 to the number of xyz files.
xyzdir (str. Default="./") – directory containing all the xyz files you want to transform.
- Return type:
(str) The name of the outputs of each pdb file.
Note
the pdb file must contain the same atoms in the same order than the xyz file, this file only would change the coordinates.
E.g. cd dir_with_xyz_files ; sith all_xyz2pdb
- sith.utils.tools.change_distance(inp, out, file_cons, deltad, charge, method, **kwargs)[source]
Takes a configuration and increase the distance between two atoms. With the new structure, it creates a gaussian file without specifing the kind of calculation to run (optimization, ab-initio md, frequencies…).
- Parameters:
inp (str) – input file containing the structure to modify.
out (str) – name of the gaussian file (.com) without extension.
file_cons (str) – file with the constraints sorted in the first two columns. The two atoms in the first row are the selected to change the distance.
deltad (float) – amount to add to the distance between atoms.
charge (int) – charge in electron charge units to create the gaussian input file. The multiplicity is assumed to be one.
method (str) – method defined in sith.ase_utils.tools. So far, the methods already implemented are: ‘scale_distance’, ‘increase_distance’, ‘increase_distance_with_constraints’.
kwargs – additional arguments to be passed to create_gaussian_input function.
- Return type:
(str) name of the output file.
- sith.utils.tools.conf2pdb(confile, pdbtemplate, pdboutput=None, write_new_pdb=True)[source]
Transform a configuration in a file (xyz, log…) into a pdb using a pdb file as template.
- Parameters:
confile (str) – path to the config file to be transformed to pdb.
pdbtemplate (str) – path to the pdb template for the output.
pdboutput (str. Default=None) – name of trasnformed config file with pdb format. The default name is the same than the confile but with pdb extension.
write_new_pdb (bool. Default=True) – If True, write a new pdb file with the properties of the template (resnames, atomtypes, residuenumbers) but the positions of the confile.
- Return type:
(str) The name of the output pdb file.
Note
the pdb file must contain the same atoms in the same order than the xyz file, this file only would change the coordinates.
E.g. sith conf2pdb optimization.log template.pdb sith conf2pdb optimization.xyz template.pdb
- sith.utils.tools.diff_bonds(conf1, conf2, frozen_dofs='frozen_dofs.dat')[source]
This function returns the bonds that are in one conf but not in the other.
- Parameters:
conf11 (str) – first configuration file to be compared.
conf2 (str) – second configuration file to be compared.
frozen_dofs (str. Default="frozen_dofs.dat") – file with the frozen DOFs. If a rupture is obtained, it will be added to this file.
- Return type:
(list) [#brocken_bonds x 2(int)] pair of brocken bonds
Note
The comparison is only in one direction, namely, this function does not find the bonds in conf2 that are not in conf1.
- sith.utils.tools.distance(file, index1, index2, frame=-1)[source]
Computes the distance between two atoms in the last configuration of a trajectory file (e.g. .log file from gaussian).
- Parameters:
file (str) – name of the file that contains the trajectory.
index1 (int) – index of the first atom to compute distances
index2 (int) – index of the second atom to compute distances
frame (Default=-1) – frame of the trajectory to compute the distance.
- Returns:
(float) Distance between atoms corresponding with atom with index1 and
index2.
E.g.
sith distance optimization.log 1 20
- sith.utils.tools.extract_bonds(readable_file)[source]
Guesses the bonds in a molecule according to ase.neighborlist.natural_cutoffs.
- Parameters:
readable_file (str) – string to the configuration file in any of the ASE readable formats.
- Returns:
(list) [#bonds x 2(int)] Bonds in the molecule.
E.g.
sith extract_bonds optimization.xyz
- sith.utils.tools.shake_except(xyz_file, file_cons, modify_input=True, stdev=0.05)[source]
Modify a xyz file by adding random noise to the position of the atoms except for those listed in the first line of a file.
- Parameters:
xyz_file (int) – original xyz file to be modified.
file_cons – file containing the atoms (1-based indices) to avoid to be modified by the shaking.
modify_input (bool. Default=True) – True to modify the input file.
scale (float. Default=0.05) – max magnitud of the noise to be added in each coordinate of each atom in Angstrom.
stdev (float. Default=0.05) – standard deviation of the normal distribution used to generate the random noise.
- Return type:
(ase.Atoms) new object atoms with the modified positions.
Module contents
basics
[script] sith/utils/basics.sh
clean_ds
[script] sith/utils/clean_ds.sh
find_blocks
[script] sith/utils/find_blocks.sh