diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/tng_io.c | 55 | ||||
| -rw-r--r-- | src/lib/tng_io_fortran.c | 8 | 
2 files changed, 63 insertions, 0 deletions
| diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c index b1ea313..69dbadd 100644 --- a/src/lib/tng_io.c +++ b/src/lib/tng_io.c @@ -7896,6 +7896,61 @@ tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get      return(TNG_SUCCESS);  } +tng_function_status DECLSPECDLLEXPORT tng_residue_id_of_particle_nr_get +                (const tng_trajectory_t tng_data, +                 const int64_t nr, +                 int64_t *id) +{ +    int64_t cnt = 0, i, *molecule_cnt_list; +    tng_molecule_t mol; +    tng_atom_t atom; +    tng_bool found = TNG_FALSE; +    tng_function_status stat; + +    stat = tng_check_trajectory_container(tng_data); +    if(stat != TNG_SUCCESS) +    { +        printf("Trajectory container not properly setup. %s: %d\n", +               __FILE__, __LINE__); +        return(stat); +    } + +    if(tng_data->var_num_atoms_flag) +    { +        molecule_cnt_list = tng_data->current_trajectory_frame_set. +                            molecule_cnt_list; +    } +    else +    { +        molecule_cnt_list = tng_data->molecule_cnt_list; +    } + +    for(i = 0; i < tng_data->n_molecules; i++) +    { +        mol = &tng_data->molecules[i]; +        if(cnt + mol->n_atoms * molecule_cnt_list[i] - 1 < nr) +        { +            cnt += mol->n_atoms * molecule_cnt_list[i]; +            continue; +        } +        atom = &mol->atoms[nr % mol->n_atoms]; +        found = TNG_TRUE; +        break; +    } +    if(!found) +    { +        return(TNG_FAILURE); +    } +    if(!atom->residue) +    { +        return(TNG_FAILURE); +    } + +    *id = atom->residue->id; + +    return(TNG_SUCCESS); +} +  tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get                  (const tng_trajectory_t tng_data,                   const int64_t nr, diff --git a/src/lib/tng_io_fortran.c b/src/lib/tng_io_fortran.c index 22a6d61..5c7bbb7 100644 --- a/src/lib/tng_io_fortran.c +++ b/src/lib/tng_io_fortran.c @@ -650,6 +650,14 @@ tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get_      return(tng_residue_name_of_particle_nr_get(tng_data, nr, name, max_len));  } +tng_function_status DECLSPECDLLEXPORT tng_residue_id_of_particle_nr_get_ +                (const tng_trajectory_t tng_data, +                 const int64_t nr, +                 int64_t *id) +{ +    return(tng_residue_id_of_particle_nr_get(tng_data, nr, id)); +} +  tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get_                  (const tng_trajectory_t tng_data,                   const int64_t nr, | 
