| Bsoft 2.0.5 Bernard's software package

Classes | Macros | Enumerations | Functions
rwmolecule.h File Reference

Header file for reading reflection files. More...

`#include "UnitCell.h"`
`#include "Vector3.h"`
`#include "Bstring.h"`

Go to the source code of this file.

## Classes
struct | Batom
struct | Bresidue
struct | Bsecondary
struct | Bmolecule
struct | Bbond
struct | Bangle
struct | Bmolgroup

## Macros
#define | MAXSEQLEN 1000000
#define | _Bmolecule_

## Enumerations
enum | SecondaryType { RightHandedAlpha = 1, RightHandedOmega = 2, RightHandedPi = 3, RightHandedGamma = 4, RightHanded310 = 5, LeftHandedAlpha = 6, LeftHandedOmega = 7, LeftHandedGamma = 8, TwoSevenRibbon = 9, Polyproline = 10, Strand = 11, Turn = 12 }

## Functions
Bmolgroup * | molgroup_init ()
| Initializes and allocates a new molecule group. More...
Bmolecule * | molecule_add (Bmolecule **mol, char *name)
| Adds a molecule to a linked list. More...
Bmolecule * | molecule_add (Bmolecule **mol, Bstring &name)
Bresidue * | residue_add (Bresidue **res, const char *type)
| Adds a residue to a linked list. More...
Bresidue * | residue_add (Bresidue **res, Bstring &type)
Batom * | atom_add (Batom **atom, const char *type)
| Adds an atom to a linked list. More...
Batom * | atom_add (Batom **atom, Bstring &type)
long | residue_count (Bmolgroup *molgroup)
| Counts the number of residues in a molecule group. More...
long | atom_count (Bmolgroup *molgroup)
| Counts the number of atoms in a molecule group. More...
int | atom_clean_type (Batom *atom, const char *type)
| Cleans up the type string and assigns an element code to an atom. More...
Bbond * | bond_add (Bbond **bond, Batom *atom1, Batom *atom2, double l, double k)
| Adds a bond to a linked list. More...
Bangle * | angle_add (Bangle **angle, Batom *atom1, Batom *atom2, Batom *atom3, double a, double k)
| Adds an angle to a linked list. More...
int | molgroup_list_kill (Bmolgroup *molgroup)
| Destroys a molecule group linked list. More...
int | molgroup_kill (Bmolgroup *molgroup)
| Destroys a molecule group. More...
int | molecule_kill (Bmolecule *mol)
| Destroys a molecule. More...
int | residue_kill (Bresidue *res)
| Destroys a residue. More...
int | bond_kill (Bbond *bond)
| Dealocates a list of bonds. More...
int | angle_kill (Bangle *angle)
| Dealocates a list of angles. More...
Bmolgroup * | molgroup_list_copy (Bmolgroup *molgroup)
| Copies a molecule group list. More...
Bmolgroup * | molgroup_copy (Bmolgroup *molgroup)
| Copies a molecule group. More...
Bmolecule * | molecule_copy (Bmolecule *mol)
| Copies a molecule. More...
Bmolecule * | mol_copy_and_add_to_molgroup (Bmolgroup *molgroup, Bmolecule *mol)
| Copies a molecule and assign to a new pointer in the molgroup. More...
Bbond * | molgroup_bond_list_copy (Bmolgroup *molgroup, Bmolgroup *molgroupcopy)
| Copies a bond list. More...
int | molgroup_from_molgroup_list (Bmolgroup *molgroup)
| Converts a molecule group list to a single molecule group. More...
Bmolgroup * | read_molecule (const char *filename, const char *select, const char *paramfile)
| The generalized function for reading molecular files. More...
Bmolgroup * | read_molecule (Bstring &filename, Bstring &atom_select, Bstring &paramfile)
Bmolgroup * | read_molecule (Bstring *file_list, int set_pbc, Vector3< double > box, Bstring atom_select, Bstring paramfile)
| Reads and catenates multiple molecule files. More...
int | write_molecule (char *filename, Bmolgroup *molgroup)
| Writes a molecule group. More...
int | write_molecule (Bstring &filename, Bmolgroup *molgroup)
int | molgroup_list_write (Bstring &filename, Bmolgroup *molgroup)
| Writes a molecule group list. More...
long | molgroup_count_molecules (Bmolgroup *molgroup)
| Counts the total number of molecules in a molecule group. More...
long | molgroup_count_residues (Bmolgroup *molgroup)
| Counts the total number of residues in a molecule group. More...
long | mol_count_residues (Bmolecule *mol)
| Counts the total number of residues in a molecule. More...
long | molgroup_count_atoms (Bmolgroup *molgroup)
| Counts the total number of atoms in a molecule group. More...
long | mol_count_atoms (Bmolecule *mol)
| Counts the total number of atoms in a molecule. More...
int | molgroup_consolidate_gaps (Bmolgroup *molgroup)
| Removes redundant gaps from an alignment. More...
long | molgroup_stats (Bmolgroup *molgroup, int show)
| Calculates the statistics of a molecule group. More...
long | molgroup_stats (Bmolgroup *molgroup)
long | mol_stats (Bmolecule *mol, int show)
| Calculates the statistics of a molecule. More...
long | mol_stats (Bmolecule *mol)
int | molecule_update_comment (Bmolgroup *molgroup, int n, char **strings)
| Puts a set of strings and time in the main comment of a molecule group. More...
int | molecule_get_masses (Bmolgroup *molgroup, Bstring &paramfile)
| Gets atomic masses from a parameter file. More...
Bbond * | molgroup_bond_list_generate (Bmolgroup *molgroup, double maxlength, int wrap)
| Generates a bond list based on atom separation. More...
Bbond * | mol_bond_list_generate (Bmolgroup *molgroup, double bondlength, int wrap)
| Generates an intramolecular distance-based bond list. More...
int | molecules_to_molgroups (Bmolgroup *molgroup)
| Converts molecules in a molecule group to individual molecule groups. More...

## Detailed Description

Header file for reading reflection files.

Author
  Bernard Heymann

Date
  Created: 19980822
  Modified: 20170509

Definition in file rwmolecule.h.

## Macro Definition Documentation

## ◆ _Bmolecule_

#define _Bmolecule_

Definition at line 193 of file rwmolecule.h.

## ◆ MAXSEQLEN

#define MAXSEQLEN 1000000

Definition at line 14 of file rwmolecule.h.

## Enumeration Type Documentation

## ◆ SecondaryType

enum SecondaryType

Enumerator
RightHandedAlpha |
RightHandedOmega |
RightHandedPi |
RightHandedGamma |
RightHanded310 |
LeftHandedAlpha |
LeftHandedOmega |
LeftHandedGamma |
TwoSevenRibbon |
Polyproline |
Strand |
Turn |

Definition at line 64 of file rwmolecule.h.

## Function Documentation

## ◆ angle_add()

Bangle* angle_add | ( | Bangle ** | angle,
|  | Batom * | atom1,
|  | Batom * | atom2,
|  | Batom * | atom3,
|  | double | a,
|  | double | k
| ) |  |

Adds an angle to a linked list.

Parameters

  **angle | pointer to any angle in the list.
  *atom1 | atom1 of angle.
  *atom2 | atom2 of angle (central atom).
  *atom3 | atom3 of angle.
  a | reference angle.
  k | angle strength.

Returns
  Bangle* new angle.

      The function allocates memory for a new angle structure.
      If the content of the pointer is null, the new structure is
      the first in the list. Otherwise, the end of the list is found
      and the new structure added to it.

Definition at line 312 of file rwmolecule.cpp.

## ◆ angle_kill()

int angle_kill | ( | Bangle * | angle | ) |

Dealocates a list of angles.

Parameters

  *angle | first angle in the list.

Returns
  int 0.

      All angles downstream are deallocated.

Definition at line 501 of file rwmolecule.cpp.

## ◆ atom_add() [1/2]

Batom* atom_add | ( | Batom ** | atom,
|  | const char * | type
| ) |  |

Adds an atom to a linked list.

Parameters

  **atom | pointer to any atom in the list.
  *type | atom type.

Returns
  Batom* new atom.

      The function allocates memory for a new atom structure.
      If the content of the pointer is null, the new structure is
      the first in the list. Otherwise, the end of the list is found
      and the new structure added to it.

Definition at line 152 of file rwmolecule.cpp.

## ◆ atom_add() [2/2]

Batom* atom_add | ( | Batom ** | atom,
|  | Bstring & | type
| ) |  |

Definition at line 158 of file rwmolecule.cpp.

## ◆ atom_clean_type()

int atom_clean_type | ( | Batom * | atom,
|  | const char * | type
| ) |  |

Cleans up the type string and assigns an element code to an atom.

Parameters

  *atom | atom.
  *type | atom type.

Returns
  int 0.

      The first two alphanumeric characters of the type string is used to
      determine the element.

Definition at line 229 of file rwmolecule.cpp.

## ◆ atom_count()

long atom_count | ( | Bmolgroup * | molgroup | ) |

Counts the number of atoms in a molecule group.

Parameters

  *molgroup | the molecule group.

Returns
  long number of atoms.

Definition at line 205 of file rwmolecule.cpp.

## ◆ bond_add()

Bbond* bond_add | ( | Bbond ** | bond,
|  | Batom * | atom1,
|  | Batom * | atom2,
|  | double | l,
|  | double | k
| ) |  |

Adds a bond to a linked list.

Parameters

  **bond | pointer to any bond in the list.
  *atom1 | atom1 of bond.
  *atom2 | atom2 of bond.
  l | reference bond length.
  k | bond strength.

Returns
  Bbond* new bond.

      The function allocates memory for a new bond structure.
      If the content of the pointer is null, the new structure is
      the first in the list. Otherwise, the end of the list is found
      and the new structure added to it.

Definition at line 269 of file rwmolecule.cpp.

## ◆ bond_kill()

int bond_kill | ( | Bbond * | bond | ) |

Dealocates a list of bonds.

Parameters

  *bond | first bond in the list.

Returns
  int 0.

      All bonds downstream are deallocated.

Definition at line 480 of file rwmolecule.cpp.

## ◆ mol_bond_list_generate()

Bbond* mol_bond_list_generate | ( | Bmolgroup * | molgroup,
|  | double | bondlength,
|  | int | wrap
| ) |  |

Generates an intramolecular distance-based bond list.

    This function defines bonds on distance and within molecules.
    If the molecule group already has a bond list, no new bonds are generated.

Parameters

  *molgroup | molecule group structure.
  bondlength | maximum bond length.
  wrap | wrap around periodic boundaries if !=0.

Returns
  Bbond* new bond list.

Definition at line 1675 of file rwmolecule.cpp.

## ◆ mol_copy_and_add_to_molgroup()

Bmolecule* mol_copy_and_add_to_molgroup | ( | Bmolgroup * | molgroup,
|  | Bmolecule * | mol
| ) |  |

Copies a molecule and assign to a new pointer in the molgroup.

Parameters

  *molgroup | the molecule group.
  *mol | the molecule to be copied.

Returns
  Bmolecule* the new molecule, NULL if copy failed.

      Adds a new molecule to the molecule group identical to the given
      molecule and returns a pointer to the new molecule.

Definition at line 664 of file rwmolecule.cpp.

## ◆ mol_count_atoms()

long mol_count_atoms | ( | Bmolecule * | mol | ) |

Counts the total number of atoms in a molecule.

Parameters

  *mol | the molecule.

Returns
  long number of atoms.

Definition at line 1135 of file rwmolecule.cpp.

## ◆ mol_count_residues()

long mol_count_residues | ( | Bmolecule * | mol | ) |

Counts the total number of residues in a molecule.

Parameters

  *mol | the molecule.

Returns
  long number of residues.

Definition at line 1101 of file rwmolecule.cpp.

## ◆ mol_stats() [1/2]

long mol_stats | ( | Bmolecule * | mol,
|  | int | show
| ) |  |

Calculates the statistics of a molecule.

Parameters

  *mol | the molecule.
  show | flag to show statistics.

Returns
  long number of atoms (<0 if writing failed).

Definition at line 1357 of file rwmolecule.cpp.

## ◆ mol_stats() [2/2]

long mol_stats | ( | Bmolecule * | mol | ) |

Definition at line 1444 of file rwmolecule.cpp.

## ◆ molecule_add() [1/2]

Bmolecule* molecule_add | ( | Bmolecule ** | mol,
|  | char * | name
| ) |  |

Adds a molecule to a linked list.

Parameters

  **mol | pointer to any molecule in the list.
  *name | molecule name.

Returns
  Bmolecule* new molecule.

      The function allocates memory for a new molecule structure.
      If the content of the pointer is null, the new structure is
      the first in the list. Otherwise, the end of the list is found
      and the new structure added to it.

Definition at line 76 of file rwmolecule.cpp.

## ◆ molecule_add() [2/2]

Bmolecule* molecule_add | ( | Bmolecule ** | mol,
|  | Bstring & | name
| ) |  |

Definition at line 82 of file rwmolecule.cpp.

## ◆ molecule_copy()

Bmolecule* molecule_copy | ( | Bmolecule * | mol | ) |

Copies a molecule.

Parameters

  *mol | the molecule to be copied.

Returns
  Bmolecule* the new molecule, NULL if copy failed.

      Generates a new molecule with the same structure as the given molecule.

Definition at line 599 of file rwmolecule.cpp.

## ◆ molecule_get_masses()

int molecule_get_masses | ( | Bmolgroup * | molgroup,
|  | Bstring & | paramfile
| ) |  |

Gets atomic masses from a parameter file.

Parameters

  *molgroup | the molecule group.
  &paramfile | parameter file name.

Returns
  int 0.

Definition at line 1486 of file rwmolecule.cpp.

## ◆ molecule_kill()

int molecule_kill | ( | Bmolecule * | mol | ) |

Destroys a molecule.

Parameters

  *mol | the molecule.

Returns
  int 0.

Definition at line 417 of file rwmolecule.cpp.

## ◆ molecule_update_comment()

int molecule_update_comment | ( | Bmolgroup * | molgroup,
|  | int | n,
|  | char ** | strings
| ) |  |

Puts a set of strings and time in the main comment of a molecule group.

    This is designed to pack the command line into a string followed by
    a second string for the time.

Parameters

  *molgroup | the molecule group.
  n | the number of strings.
  **strings | an array of strings.

Returns
  int string length of the new comment.

Definition at line 1462 of file rwmolecule.cpp.

## ◆ molecules_to_molgroups()

int molecules_to_molgroups | ( | Bmolgroup * | molgroup | ) |

Converts molecules in a molecule group to individual molecule groups.

    A new linked list of molecule groups is created and the links to the
    individual molecules set.

Parameters

  *molgroup | molecule group structure (modified).

Returns
  int 0.

Definition at line 1739 of file rwmolecule.cpp.

## ◆ molgroup_bond_list_copy()

Bbond* molgroup_bond_list_copy | ( | Bmolgroup * | molgroup,
|  | Bmolgroup * | molgroupcopy
| ) |  |

Copies a bond list.

Parameters

  *molgroup | molecule group structure.
  *molgroupcopy | molecule group structure to copy bonds to.

Returns
  Bbond* new bond list.

      A copy of the molecule group bond list is generated and returned.

Definition at line 706 of file rwmolecule.cpp.

## ◆ molgroup_bond_list_generate()

Bbond* molgroup_bond_list_generate | ( | Bmolgroup * | molgroup,
|  | double | maxlength,
|  | int | wrap
| ) |  |

Generates a bond list based on atom separation.

Parameters

  *molgroup | the molecule group.
  maxlength | maximum bond length.
  wrap | wrap around periodic boundaries if !=0.

Returns
  Bbond* new bond list.

Definition at line 1555 of file rwmolecule.cpp.

## ◆ molgroup_consolidate_gaps()

int molgroup_consolidate_gaps | ( | Bmolgroup * | molgroup | ) |

Removes redundant gaps from an alignment.

    All positions in an alignment with only gaps are removed.

Parameters

  *molgroup | the molecule group.

Returns
  int 0.

Definition at line 1244 of file rwmolecule.cpp.

## ◆ molgroup_copy()

Bmolgroup* molgroup_copy | ( | Bmolgroup * | molgroup | ) |

Copies a molecule group.

Parameters

  *molgroup | the molecule group.

Returns
  Bmolgroup* new molecule group.

      All parts of a molecule group are copied to a completely new structure
      hierarchy, except sequence flag array.

Definition at line 547 of file rwmolecule.cpp.

## ◆ molgroup_count_atoms()

long molgroup_count_atoms | ( | Bmolgroup * | molgroup | ) |

Counts the total number of atoms in a molecule group.

Parameters

  *molgroup | the molecule group.

Returns
  long number of atoms.

Definition at line 1119 of file rwmolecule.cpp.

## ◆ molgroup_count_molecules()

long molgroup_count_molecules | ( | Bmolgroup * | molgroup | ) |

Counts the total number of molecules in a molecule group.

Parameters

  *molgroup | the molecule group.

Returns
  long number of molecules.

Definition at line 1070 of file rwmolecule.cpp.

## ◆ molgroup_count_residues()

long molgroup_count_residues | ( | Bmolgroup * | molgroup | ) |

Counts the total number of residues in a molecule group.

Parameters

  *molgroup | the molecule group.

Returns
  long number of residues.

Definition at line 1085 of file rwmolecule.cpp.

## ◆ molgroup_from_molgroup_list()

int molgroup_from_molgroup_list | ( | Bmolgroup * | molgroup | ) |

Converts a molecule group list to a single molecule group.

Parameters

  *molgroup | molecule group list.

Returns
  int 0.

      The input molecule group list is replace by a single molecule group.

Definition at line 760 of file rwmolecule.cpp.

## ◆ molgroup_init()

Bmolgroup* molgroup_init | ( |  | ) |

Initializes and allocates a new molecule group.

Returns
  Bmolgroup* the new molecule group, NULL if initialization failed.

      The selection string is set to "all".
      The spacegroup is set to 1, the space group string to "P 1".
      The point group is set to "C1".
      The unit cell is set to 1,1,1,90,90,90.

Definition at line 45 of file rwmolecule.cpp.

## ◆ molgroup_kill()

int molgroup_kill | ( | Bmolgroup * | molgroup | ) |

Destroys a molecule group.

Parameters

  *molgroup | the molecule group.

Returns
  int 0.

Definition at line 374 of file rwmolecule.cpp.

## ◆ molgroup_list_copy()

Bmolgroup* molgroup_list_copy | ( | Bmolgroup * | molgroup | ) |

Copies a molecule group list.

Parameters

  *molgroup | the molecule group list.

Returns
  Bmolgroup* new molecule group list.

      All molecule groups are copied to a completely new list.

Definition at line 522 of file rwmolecule.cpp.

## ◆ molgroup_list_kill()

int molgroup_list_kill | ( | Bmolgroup * | molgroup | ) |

Destroys a molecule group linked list.

Parameters

  *molgroup | the molecule group linked list.

Returns
  int 0.

Definition at line 347 of file rwmolecule.cpp.

## ◆ molgroup_list_write()

int molgroup_list_write | ( | Bstring & | filename,
|  | Bmolgroup * | molgroup
| ) |  |

Writes a molecule group list.

    The output files are numbered if the list constains more than one molecule group.

Parameters

  *filename | the file name.
  *molgroup | the molecule group.

Returns
  int number of molecules written (<0 if writing failed).

Definition at line 1048 of file rwmolecule.cpp.

## ◆ molgroup_stats() [1/2]

long molgroup_stats | ( | Bmolgroup * | molgroup,
|  | int | show
| ) |  |

Calculates the statistics of a molecule group.

Parameters

  *molgroup | molecule group.
  show | flag to show statistics.

Returns
  long number of molecules (<0 if writing failed).

Definition at line 1291 of file rwmolecule.cpp.

## ◆ molgroup_stats() [2/2]

long molgroup_stats | ( | Bmolgroup * | molgroup | ) |

Definition at line 1344 of file rwmolecule.cpp.

## ◆ read_molecule() [1/3]

Bmolgroup* read_molecule | ( | const char * | filename,
|  | const char * | atom_select,
|  | const char * | paramfile
| ) |  |

The generalized function for reading molecular files.

Parameters

  *filename | the file name.
  *atom_select | a selection string.
  *paramfile | parameter file name.

Returns
  Bmolgroup* new molecule group, NULL if reading failed.

      All sequence and atomic coordinate information is read from a file into
      an internal hierarchy of structures in linked lists:
          Bmolgroup   molecule group or collection of molecules
          Bmolecule   linked list of molecules in the group
          Bresidue    linked list of residues in a molecule
          Batom       linked list of atoms in a residue
          Bbond       linked list of bonds in the molecule group
      The selection string is used to select for specific atom types:
          CA          C-alpha atoms only
      The parameter file is used to load atomic properties, such as mass
          and charge. The default file is bsoft/parameters/atom_prop.star.
      The input format is based on the file name extension.

Definition at line 818 of file rwmolecule.cpp.

## ◆ read_molecule() [2/3]

Bmolgroup* read_molecule | ( | Bstring & | filename,
|  | Bstring & | atom_select,
|  | Bstring & | paramfile
| ) |  |

Definition at line 826 of file rwmolecule.cpp.

## ◆ read_molecule() [3/3]

Bmolgroup* read_molecule | ( | Bstring * | file_list,
|  | int | set_pbc,
|  | Vector3< double > | box,
|  | Bstring | atom_select,
|  | Bstring | paramfile
| ) |  |

Reads and catenates multiple molecule files.

Parameters

  file_list | list of file names.
  set_pbc | flag to fit within periodic boundaries.
  box | periodic boundary box.
  atom_select | atomic selection.
  paramfile | atomic parameters.

Returns
  Bmolgroup* new molecule group.

Definition at line 916 of file rwmolecule.cpp.

## ◆ residue_add() [1/2]

Bresidue* residue_add | ( | Bresidue ** | res,
|  | const char * | type
| ) |  |

Adds a residue to a linked list.

Parameters

  **res | pointer to any residue in the list.
  *type | residue type.

Returns
  Bresidue* new residue.

      The function allocates memory for a new residue structure.
      If the content of the pointer is null, the new structure is
      the first in the list. Otherwise, the end of the list is found
      and the new structure added to it.

Definition at line 113 of file rwmolecule.cpp.

## ◆ residue_add() [2/2]

Bresidue* residue_add | ( | Bresidue ** | res,
|  | Bstring & | type
| ) |  |

Definition at line 119 of file rwmolecule.cpp.

## ◆ residue_count()

long residue_count | ( | Bmolgroup * | molgroup | ) |

Counts the number of residues in a molecule group.

Parameters

  *molgroup | the molecule group.

Returns
  long number of residues.

Definition at line 188 of file rwmolecule.cpp.

## ◆ residue_kill()

int residue_kill | ( | Bresidue * | res | ) |

Destroys a residue.

Parameters

  *res | the residue.

Returns
  int 0.

Definition at line 453 of file rwmolecule.cpp.

## ◆ write_molecule() [1/2]

int write_molecule | ( | char * | filename,
|  | Bmolgroup * | molgroup
| ) |  |

Writes a molecule group.

    The output format is based on the file name extension.

Parameters

  *filename | the file name.
  *molgroup | the molecule group.

Returns
  int number of molecules written (<0 if writing failed).

Definition at line 975 of file rwmolecule.cpp.

## ◆ write_molecule() [2/2]

int write_molecule | ( | Bstring & | filename,
|  | Bmolgroup * | molgroup
| ) |  |

Definition at line 981 of file rwmolecule.cpp.