GLYLIB  0.3.0b
add_trajcrds_to_prmtop_assembly.c File Reference
#include <mylib.h>
#include <molecules.h>
#include <AMBER/amber.h>
Include dependency graph for add_trajcrds_to_prmtop_assembly.c:

Go to the source code of this file.

Functions

void add_trajcrds_to_prmtop_assembly (fileset F, assembly *A, char ftype, int offset)

Detailed Description

Function for adding the contents of an AMBER coordinate trajectory to an existing assembly.

Please read the following carefully if this is your first use.

Usage: void add_trajcrds_to_prmtop_assembly( fileset F, ///< The file containing the data *Must* be open assembly *A, ///< Assembly to which the crds should be added char ftype, ///< 'c'=coordinate; 'v'=velocity; 'r'=restart int offset ///< read in the offset-th trajectory -- zero=current )

Storage of Coordinates ***

This function only adds *one* set of coordinates at a time. If the file pointer is not altered between calls, each time this function is called it will read in the next set of coordinates.

The coordinates are stored via the assembly's atom double-pointers. The atom pointers must be set correctly because the the coordinates will be added in the order dictated by the **atom locations.

The coordinates are added into an 'xa' location in the incoming assembly. Regarding the 'xa' locations: The program will check through the "nalt" for each atom. It will reallocate them all to the same size if they differ. The new coordinates will be added starting in the lowest xa array location that is empty for all atoms.

You can figure out where they were added because the function will only add one set of coordinates, and the value stored in "nalt" tells you where. Alternately, you can set nalt=0 and free(xa) between each call.

If the file is a velocity trajectory, substitute velocity locations for alternate coordinate locations in the last two paragraphs.

If the file is specified as a restart file, and if velocities are found, velocities will be added into array locations to match the xa locations. Any unused velocity locations will be cleared to equal zero.

The input file pointer status ***

The calling function *must* open the file. In most cases, the file pointer should not be altered between calls to this function. This is because the function will begin reading coordinates from the current position pointed to by the file pointer. At the end of each read, it will be pointing to the next set of coordinates. Unless the calling program wants to change this behavior, it should not alter the file pointer.

Regarding BOX information ***

This assembly *MUST* have nBOX set correctly. If nBOX is less than or equal to zero, this function will assume there is no box information contained in the coordinate file. If nBOX is greater than or equal to one, it will assume there is box information. This distinction can have a significant impact on the sanity of structures defined by the coordinate sets.

LOCATION OF BOX INFO: It is assumed most folks will ignore the box info, so it will be put in a slightly annoying location. In the assembly's nBOX-long BOX array, the box info will be offset in the BOX array by an index of +1 from the locations of the coordinate and velocity information. The zeroth and first locations will be the box info originally contained in the TOP file.

To reiterate: BOX INFO IS CONTAINED STARTING AT INDEX +1

...but, the three coordinates are in the first coordinate slot, unlike the prmtop info, which also contains an angle... confused yet?

An example for coordinate and box information location ***

For example, if there are 5 sets of alternative coordinates saved in the incoming assembly, and this function is reading in a coordinate trajectory containing box info, the function will save new coordinates into the sixth coordinate location (.xa[5]), and box info into the seventh (.BOX[6]).

Begun on 20080811 by BLFoley. Significantly altered starting 20090803 BLF.

Definition in file add_trajcrds_to_prmtop_assembly.c.


Function Documentation

void add_trajcrds_to_prmtop_assembly ( fileset  F,
assembly A,
char  ftype,
int  offset 
)

< temporary char holders

< alternate coords or vectors allocated outgoing

< alternate coords or vectors allocated incoming

< for testing [f,s]scanf results

< atom index

< dummy coordinate index

< counter to test if there should be a newline

DO NOT RE/OPEN the file

See if we are at the start of the file or not

Don't make lots of silly checks -- just add coordinates to atom structures...

First, allocate space as needed, and clear any unused middle-space

Now scan through and add info to the structure

If this is type 'r', see if there is any more info in the file

Parameters:
FThe trajectory file containing the data *Must* be open
AAssembly ("incoming") to which the crds should be added
ftype'c' if coordinate ; 'v' if velocity ; 'r' if restart (might have both)
offsetread in the offset-th trajectory -- starts with zero=current

Definition at line 87 of file add_trajcrds_to_prmtop_assembly.c.

References assembly::a, assembly::BOX, boxinfo::C, vectormag_3D::d, coord_nD::D, fileset::F, coord_3D::i, vectormag_3D::i, coord_3D::j, vectormag_3D::j, coord_3D::k, vectormag_3D::k, mywhine(), assembly::na, atom::nalt, assembly::nBOX, boxinfo::nC, coord_nD::nD, atom::nvec, atom::v, and atom::xa.

Here is the call graph for this function:

 All Classes Files Functions Variables Typedefs Defines