API reference for core submodule#

Module holding the core functions.

buildh.core.buildHs_on_1C(atom, H_type, helper1, helper2, helper3=None)#

Build 1, 2 or 3 H on a given carbon.

This function is a wrapper which takes the coordinates of the helpers and call the function that builds 1, 2 or 3 H.

Parameters
  • atom (numpy 1D-array) – Central atom on which we want to reconstruct the hydrogen.

  • H_type (str) – The type of H to build. It could be ‘CH2’, ‘CH’, ‘CHdoublebond’ or ‘CH3’ (see init_dics.py)

  • helper1 (numpy 1D-array) – First neighbor of central atom.

  • helper2 (numpy 1D-array) – Second neighbor of central atom.

  • helper3 (numpy 1D-array) – Third neighbor of central atom.

Returns

Each element of the tuple is a numpy 1D-array containing 1, 2 or 3 reconstructed hydrogen(s). Important: This function returns a tuple even if there’s only one H that has been rebuilt.

Return type

tuple of numpy 1D-arrays

buildh.core.build_all_Hs_calc_OP(universe_woH, ts, dic_lipid, dic_Cname2Hnames, universe_wH, dic_OP, dic_corresp_numres_index_dic_OP, dic_lipid_indexes)#

Build all hydrogens and calculates order parameters for one frame.

This function loop overs all atoms of the universe_woH in order to update the atom coordinates and the new H built into the universe_wH.

The function also calculates the order parameter. The coordinates of the universe with H are updated in place. The order parameter is also added in place (within dic_OP dictionary).

Note

This function is slow, thus it shall be used when one wants to create a trajectory with H (such as .xtc or whatever format).

This function assumes all possible C-H pairs are present in the .def file (with -d option). They are needed since we want to build an xtc with the whole system. If one is interested in calculating only a subset of OPs, please use the function fast_build_all_Hs_calc_OP() instead.

Parameters
  • universe_woH (MDAnalysis universe instance) – This is the universe without hydrogen.

  • ts (Timestep instance) – the current timestep with the coordinates

  • dic_lipid (dictionary) – Contains carbon names and helper names needed for reconstructing hydrogens.

  • dic_Cname2Hnames (dictionary) – This dict gives the correspondance Cname -> Hname. (see make_dic_Cname2Hnames() in init_dics.py)

  • universe_wH (MDAnalysis universe instance (optional)) – This is the universe with* hydrogens.

  • dic_OP (ordered dictionary) – Each key of this dict is a couple carbon/H, and at the beginning it contains an empty list. (see init_dic_OP() in init_dics.py)

  • dic_corresp_numres_index_dic_OP (dictionary) – This dict should contain the correspondance between the numres and the corresponding index in dic_OP. For example {15: 14} means the residue numbered 15 in the PDB has an index of 14 in dic_OP.

buildh.core.build_system_hydrogens(universe_woH, dic_lipid, dic_Cname2Hnames, dic_lipid_indexes)#

Build a new system with hydrogens.

The function takes the MDAnalysis universe without hydrogens, reconstructs all hydrogens and returns a pandas dataframe. This latter will be used later to build a new MDAnalysis universe with H.

Note

There is no simple way to create a new MDAnalysis universe directly.

Parameters
  • universe_woH (MDAnalysis universe instance) – This is the universe without hydrogen.

  • dic_lipid (dictionary) – Contains carbon names and helper names needed for reconstructing hydrogens.

  • dic_Cname2Hnames (dictionary) – This dict gives the correspondance Cname -> Hname. (see make_dic_Cname2Hnames() in init_dics.py)

  • dic_lipids_with_indexes (dictionary) – The dictionary made in function make_dic_lipids_with_indexes().

Returns

contains the system with hydrogens.

Return type

pandas dataframe

buildh.core.fast_build_all_Hs_calc_OP(universe_woH, begin, end, dic_OP, dic_lipid, dic_Cname2Hnames)#

Build Hs and calc OP using fast indexing.

This function uses fast indexing to carbon atoms and helper atoms. It should be used when the user doesn’t want any output traj with hydrogens.

Parameters
  • universe_woH (MDAnalysis universe instance) – This is the universe without hydrogen.

  • begin (int) – index of the first frame of trajectory

  • end (int) – index of the last frame of trajectory

  • dic_OP (ordered dictionary) – Each key of this dict is a couple carbon/H, and at the beginning it contains an empty list. (see init_dic_OP() in init_dics.py)

  • dic_lipid (dictionary) – Contains carbon names and helper names needed for reconstructing hydrogens.

  • dic_Cname2Hnames (dictionary) – This dict gives the correspondance Cname -> Hname. (see make_dic_Cname2Hnames() in init_dics.py)

Returns

This function returns nothing, dic_OP is changed in place.

Return type

None

buildh.core.gen_coordinates_calcOP(basename, universe_woH, dic_OP, dic_lipid, dic_Cname2Hnames, dic_corresp_numres_index_dic_OP, begin, end, traj_file)#

Generate coordinates files (pdb and/or xtc) with computed hydrogens and compute the order parameter.

If traj_file is set to False, only a pdb file will be written. This depends whether or not the user supplied a trajectory file in the first place.

Parameters
  • basename (str) – basename for the output coordinate file(s).

  • universe_woH (MDAnalysis universe instance) – This is the universe without hydrogen.

  • dic_OP (ordered dictionary) – Each key of this dict is a couple carbon/H, and at the beginning it contains an empty list. (see init_dic_OP() in init_dics.py)

  • dic_lipid (dictionary) – Contains carbon names and helper names needed for reconstructing hydrogens.

  • dic_Cname2Hnames (dictionary) – This dict gives the correspondance Cname -> Hname. (see make_dic_Cname2Hnames() in init_dics.py)

  • dic_corresp_numres_index_dic_OP (dictionary) – This dict should contain the correspondance between the numres and the corresponding index in dic_OP. For example {15: 14} means the residue numbered 15 in the PDB has an index of 14 in dic_OP.

  • begin (int) – index of the first frame of trajectory

  • end (int) – index of the last frame of trajectory

  • traj_file (bool) – a trajectory output file has to be generated?

buildh.core.get_indexes(atom, dic_lipid)#

Return the index of helpers for a given carbon.

Parameters
  • atom (MDAnalysis Atom instance) – This is an Atom instance of a carbon on which we want to build Hs.

  • dic_lipid (dictionary) – Contains carbon names and helper names needed for reconstructing hydrogens.

Returns

The tuple contains the index of the 2 (or 3) helpers for the atom that was passed as argument. (e.g. for atom C37 with index 99, the function returns a tuple containing 98 (index of C36 = helper 1) and 100 (index of C38=helper2).

Return type

tuple of 2 or 3 int

buildh.core.make_dic_lipids_with_indexes(universe_woH, dic_lipid, dic_OP)#

Expand dic_lipid and adds the index of each atom and helper.

IMPORTANT: the index of each atom/helper is given with respect to the first atom in that residue.

For example, if we have a POPC where C1 is the first atom, and C50 the last one, we want in the end:

{'C1': ('CH3', 'N4', 'C5', 0, 3, 4), ...,
 'C50': ('CH3', 'C49', 'C48', 49, 48, 47)}

Where the 3 last int are the index (ix) of the atom, helper1, helper2 (possibly helper3) with respect to the first atom. Thus for C1 : 0 is index of C1, N4 is 3 atoms away from C1 and C5 is 4 atoms away from C1. For C50: C50 is 49 atoms away from C1, C49 is 48 atoms away from C1, C48 is 47 atoms away from C1.

Parameters
  • universe_woH (MDAnalysis Universe instance) – The universe without hydrogens.

  • dic_lipid (dictionary) – Contains carbon names and helper names needed for reconstructing hydrogens.

  • dic_OP (ordered dictionary) – Each key of this dict is a couple carbon/H, and at the beginning it contains an empty list. (see init_dic_OP() in init_dics.py)

Returns

The returned dictionary as described above in this docstring.

Return type

dictionary