summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Lundborg <lundborg.magnus@gmail.com>2013-11-15 14:59:22 (GMT)
committerMagnus Lundborg <lundborg.magnus@gmail.com>2013-11-15 14:59:22 (GMT)
commitb6140664d54e948ddfada3a5dc0ec0be7a159525 (patch)
treed5028ce061ba7d8645896ef044a9558f85cb33ca
parent6ca5fc9a24327e7243707cdd3b52397ccdb80378 (diff)
Added tng_molecule_of_index_get()
-rw-r--r--include/tng_io.h16
-rw-r--r--src/lib/tng_io.c18
2 files changed, 34 insertions, 0 deletions
diff --git a/include/tng_io.h b/include/tng_io.h
index 1a584e3..6ce98d0 100644
--- a/include/tng_io.h
+++ b/include/tng_io.h
@@ -1477,6 +1477,22 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_find
tng_molecule_t *molecule);
/**
+ * @brief Retrieve the molecule with specified index in the list of molecules.
+ * @param tng_data is the trajectory data container containing the molecule.
+ * @param index is the index (in tng_data->molecules) of the molecule to return
+ * @param molecule is a pointer to the molecule if it was found - otherwise 0.
+ * @pre \code tng_data != 0 \endcode The trajectory container (tng_data)
+ * must be initialised before using it.
+ * @pre \code molecule != 0 \endcode molecule must not be a NULL pointer.
+ * @return TNG_SUCCESS (0) if the molecule is found or TNG_FAILURE (1) if the
+ * molecule is not found.
+ */
+tng_function_status DECLSPECDLLEXPORT tng_molecule_of_index_get
+ (tng_trajectory_t tng_data,
+ int64_t index,
+ tng_molecule_t *molecule);
+
+/**
* @brief Find a chain in a molecule.
* @param tng_data is the trajectory data container containing the molecule.
* @param molecule is the molecule in which to search for the chain.
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c
index 1fcc7d9..364df13 100644
--- a/src/lib/tng_io.c
+++ b/src/lib/tng_io.c
@@ -7164,6 +7164,7 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_find
TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
TNG_ASSERT(name, "TNG library: name must not be a NULL pointer.");
+ TNG_ASSERT(molecule, "TNG library: molecule must not be a NULL pointer.");
n_molecules = tng_data->n_molecules;
@@ -7184,6 +7185,23 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_find
return(TNG_FAILURE);
}
+tng_function_status DECLSPECDLLEXPORT tng_molecule_of_index_get
+ (tng_trajectory_t tng_data,
+ int64_t index,
+ tng_molecule_t *molecule)
+{
+ TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
+ TNG_ASSERT(molecule, "TNG library: molecule must not be a NULL pointer.");
+
+ if(index >= tng_data->n_molecules)
+ {
+ *molecule = 0;
+ return(TNG_FAILURE);
+ }
+ *molecule = &tng_data->molecules[index];
+ return(TNG_SUCCESS);
+}
+
tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find
(tng_trajectory_t tng_data,
tng_molecule_t molecule,
contact: Jan Huwald // Impressum