<commit_before>
# coord_util

coord_util is a library for reading, manipulating and writing molecule
geometries. coord_util can read and write geometries in several common
formats.  

## Dependencies

coord_util depends on my `tempfile_util` module.

coord_util also depends on `numpy` (tested with 1.6.1).  

coord_util contains a module for storing geometries in a useful
database format, `trajdb`.  In order to make use of this module, coord_util
depends on the presence of `sqlite3` and `h5py`.

Scripts for building all of the above dependencies in the user's home
directory (and thus not requring root permissions) are available in my
`build_scripts` repository.

## Installation

### Download

Clone `coord_util` into your python `site-packages` directory.

```bash
      cd your_python_site-packages
      git clone git://github.com/plediii/coord_util
```

### Configure and Build

This step is optional but recommended; all of the `coord_util`
functions are pure python.  However, some functions have been
implemented more efficiently in Fortran.  To access the more efficient
versions configure and build the moules via:


```bash
	./configure.py
	make
```


### Testing

The `coord_util` package includes several test suites with names in
the form `test_foo.py`.  To execute all of them:

```bash
		./test.bash
```

### Modules

#### coord_math

The coord_math module exposes several geometric functions which
interpret one-dimensional numpy arrays holding contiguous sequence of
atoms.  The arguments to the coord_math functions assume that the
numpy arrays are in the order:

```python
      x = np.array([x1, y1, z1, x2, y2, z2, ..., xn, yn, zn]),
```

where `x1` is the x coordinate of the first atom, `y2` is the y
coordinate of the second atom, and `zn` is the z coordinate of the nth
atom.  The atom index in the following functions is 1-based, so that
the first atom has index 1.

##### get_atom_coords
get_atom_coords returns a 1x3 array containing the coordinates of the ith atom.

```python
		get_atom_coords(np.array([1, 2, 3, 4, 5, 6]), 2) == np.array([4, 5, 6])
```

##### center_of_geometry

center_of_geometry returns a 1x3 array containing the coordinates at
the average of the atom coordinates in the system. 

For instance, the center of geometry of atoms arranged at the corners
of a square is the center of the square:

```python
    center_of_geometry(np.array([0., 0., 0., 
                                 1., 0., 0.,
	                         0., 1., 0.,
	                         0., 0., 1.,]))
	                         == np.array([0.5, 0.5, 0.5])
```

##### rmsd

`rmsd` is a slight misnomer, since rmsd is the *least* root mean
square distance between two geometries.  However, the convention is to
simply refer to this measure as rmsd. The *non* least root mean square
distance between two geometries is simply the l2-norm of the
difference vector, divided by the square root of the number of atoms:

```python
       flat_rmsd(v1, v2) == sqrt(dot(v1-v2, v1-v2)/(len(v1)/3)).
```

The *least* root mean square is the least root mean square between the<commit_msg>Fix the COG geometry to be an actual square.<commit_after>
# coord_util

coord_util is a library for reading, manipulating and writing molecule
geometries. coord_util can read and write geometries in several common
formats.  

## Dependencies

coord_util depends on my `tempfile_util` module.

coord_util also depends on `numpy` (tested with 1.6.1).  

coord_util contains a module for storing geometries in a useful
database format, `trajdb`.  In order to make use of this module, coord_util
depends on the presence of `sqlite3` and `h5py`.

Scripts for building all of the above dependencies in the user's home
directory (and thus not requring root permissions) are available in my
`build_scripts` repository.

## Installation

### Download

Clone `coord_util` into your python `site-packages` directory.

```bash
      cd your_python_site-packages
      git clone git://github.com/plediii/coord_util
```

### Configure and Build

This step is optional but recommended; all of the `coord_util`
functions are pure python.  However, some functions have been
implemented more efficiently in Fortran.  To access the more efficient
versions configure and build the moules via:


```bash
	./configure.py
	make
```


### Testing

The `coord_util` package includes several test suites with names in
the form `test_foo.py`.  To execute all of them:

```bash
		./test.bash
```

### Modules

#### coord_math

The coord_math module exposes several geometric functions which
interpret one-dimensional numpy arrays holding contiguous sequence of
atoms.  The arguments to the coord_math functions assume that the
numpy arrays are in the order:

```python
      x = np.array([x1, y1, z1, x2, y2, z2, ..., xn, yn, zn]),
```

where `x1` is the x coordinate of the first atom, `y2` is the y
coordinate of the second atom, and `zn` is the z coordinate of the nth
atom.  The atom index in the following functions is 1-based, so that
the first atom has index 1.

##### get_atom_coords
get_atom_coords returns a 1x3 array containing the coordinates of the ith atom.

```python
		get_atom_coords(np.array([1, 2, 3, 4, 5, 6]), 2) == np.array([4, 5, 6])
```

##### center_of_geometry

center_of_geometry returns a 1x3 array containing the coordinates at
the average of the atom coordinates in the system. 

For instance, the center of geometry of atoms arranged at the corners
of a square is the center of the square:

```python
    center_of_geometry(np.array([0., 0., 0., 
                                 1., 0., 0.,
	                         0., 1., 0.,
	                         1., 1., 0.,]))
	                         == np.array([0.5, 0.5, 0.0])
```

##### rmsd

`rmsd` is a slight misnomer, since rmsd is the *least* root mean
square distance between two geometries.  However, the convention is to
simply refer to this measure as rmsd. The *non* least root mean square
distance between two geometries is simply the l2-norm of the
difference vector, divided by the square root of the number of atoms:

```python
       flat_rmsd(v1, v2) == sqrt(dot(v1-v2, v1-v2)/(len(v1)/3)).
```

The *least* root mean square is the least root mean square between the
{'fraction_non_alphanumeric': 0.08988944079474444, 'fraction_numerical': 0.017945842012497996, 'mean_word_length': 3.4458689458689458, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2026337', 'n_tokens_mistral': 1974, 'n_tokens_neox': 1813, 'n_words': 843}