summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tng_io.h17
-rw-r--r--src/lib/tng_io.c23
2 files changed, 39 insertions, 1 deletions
diff --git a/include/tng_io.h b/include/tng_io.h
index d1ce168..caa4d63 100644
--- a/include/tng_io.h
+++ b/include/tng_io.h
@@ -924,7 +924,7 @@ tng_function_status tng_molecule_cnt_set(tng_trajectory_t tng_data,
/**
* @brief Find a chain in a molecule.
- * @param tng_data is the trajectory data container containing the molecule..
+ * @param tng_data is the trajectory data container containing the molecule.
* @param molecule is the molecule in which to search for the chain.
* @param name is a string containing the name of the chain. If name is empty
* only id will be used for finding the chain.
@@ -969,6 +969,21 @@ tng_function_status tng_chain_name_set(tng_trajectory_t tng_data,
const char *new_name);
/**
+ * @brief Find a residue in a chain.
+ * @param tng_data is the trajectory data container containing the chain.
+ * @param chain is the chain in which to search for the residue.
+ * @param name is a string containing the name of the residue.
+ * @param residue is a pointer to the residue if it was found - otherwise 0.
+ * @return TNG_SUCCESS (0) if the residue is found or TNG_FAILURE (1) if the
+ * residue is not found.
+ * @details If name is an empty string the first residue will be found.
+ */
+tng_function_status tng_chain_residue_find(tng_trajectory_t tng_data,
+ tng_chain_t chain,
+ const char *name,
+ tng_residue_t *residue);
+
+/**
* @brief Add a residue to a chain.
* @param tng_data is the trajectory data container containing the chain..
* @param chain is the chain to add a residue to.
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c
index b4a65ae..ef4d14a 100644
--- a/src/lib/tng_io.c
+++ b/src/lib/tng_io.c
@@ -5850,6 +5850,29 @@ tng_function_status tng_chain_name_set(tng_trajectory_t tng_data,
return(TNG_SUCCESS);
}
+tng_function_status tng_chain_residue_find(tng_trajectory_t tng_data,
+ tng_chain_t chain,
+ const char *name,
+ tng_residue_t *residue)
+{
+ int i, n_residues;
+
+ n_residues = chain->n_residues;
+
+ for(i = 0; i < n_residues; i++)
+ {
+ *residue = &chain->residues[i];
+ if(name[0] != 0 || strcmp(name, (*residue)->name) == 0)
+ {
+ return(TNG_SUCCESS);
+ }
+ }
+
+ *residue = 0;
+
+ return(TNG_FAILURE);
+}
+
tng_function_status tng_chain_residue_add(tng_trajectory_t tng_data,
tng_chain_t chain,
const char *name,
contact: Jan Huwald // Impressum