diff options
author | Magnus Lundborg <magnus.lundborg@scilifelab.se> | 2012-12-10 14:08:31 (GMT) |
---|---|---|
committer | Magnus Lundborg <magnus.lundborg@scilifelab.se> | 2012-12-10 14:08:31 (GMT) |
commit | 651f05b1ffa8b4bfe6145b85ff72373199c0e514 (patch) | |
tree | 0f4963b96eb3add3bdf0982c47742bdc60d57945 | |
parent | ef6d069935b14956ae252dffb75844f0d265c733 (diff) |
Fix line breaks in the header.
-rw-r--r-- | src/lib/tng_io.h | 349 |
1 files changed, 193 insertions, 156 deletions
diff --git a/src/lib/tng_io.h b/src/lib/tng_io.h index 6d049ca..be8c1b8 100644 --- a/src/lib/tng_io.h +++ b/src/lib/tng_io.h @@ -65,7 +65,8 @@ typedef enum {TNG_NON_PARTICLE_BLOCK_DATA, typedef enum {FALSE, TRUE} tng_bool; -typedef enum {TNG_CONSTANT_N_ATOMS, TNG_VARIABLE_N_ATOMS} tng_variable_n_atoms_flag; +typedef enum {TNG_CONSTANT_N_ATOMS, TNG_VARIABLE_N_ATOMS} + tng_variable_n_atoms_flag; typedef enum {TNG_SUCCESS, TNG_FAILURE, TNG_CRITICAL} tng_function_status; @@ -100,41 +101,42 @@ struct tng_bond { struct tng_atom { tng_residue_t residue; /* The molecule containing this atom */ - int64_t id; /* A unique (per molecule) ID number of the atom */ - char *atom_type; /* The atom_type (depending on the forcefield) */ - char *name; /* The name of the atom */ + int64_t id; /* A unique (per molecule) ID number of the atom */ + char *atom_type; /* The atom_type (depending on the forcefield) */ + char *name; /* The name of the atom */ }; struct tng_residue { - tng_chain_t chain; /* The chain containing this residue */ - int64_t id; /* A unique (per chain) ID number of the residue */ - char *name; /* The name of the residue */ - int64_t n_atoms; /* The number of atoms in the residue */ + tng_chain_t chain; /* The chain containing this residue */ + int64_t id; /* A unique (per chain) ID number of the residue */ + char *name; /* The name of the residue */ + int64_t n_atoms; /* The number of atoms in the residue */ tng_atom_t atoms; /* A list of atoms in the residue */ }; struct tng_chain { tng_molecule_t molecule; /* The molecule containing this chain */ - int64_t id; /* A unique (per molecule) ID number of the chain */ - char *name; /* The name of the chain */ - int64_t n_residues; /* The number of residues in the chain */ + int64_t id; /* A unique (per molecule) ID number of the + chain */ + char *name; /* The name of the chain */ + int64_t n_residues; /* The number of residues in the chain */ tng_residue_t residues; /* A list of residues in the chain */ }; struct tng_molecule { - int64_t id; /* A unique ID number of the molecule */ - int64_t quaternary_str; /* Quaternary structure of the molecule. + int64_t id; /* A unique ID number of the molecule */ + int64_t quaternary_str; /* Quaternary structure of the molecule. 1 => monomeric 2 => dimeric 3 => trimeric - etc */ - int64_t n_chains; /* The number of chains in the molecule */ - int64_t n_residues; /* The number of residues in the molecule */ - int64_t n_atoms; /* The number of atoms in the molecule */ - int64_t n_bonds; /* The number of bonds in the molecule. - If the bonds are not specified this - value can be 0. */ - char *name; /* The name of the molecule */ + etc */ + int64_t n_chains; /* The number of chains in the molecule */ + int64_t n_residues; /* The number of residues in the molecule */ + int64_t n_atoms; /* The number of atoms in the molecule */ + int64_t n_bonds; /* The number of bonds in the molecule. + If the bonds are not specified this + value can be 0. */ + char *name; /* The name of the molecule */ tng_chain_t chains; /* A list of chains in the molecule */ tng_residue_t residues; /* A list of residues in the molecule */ tng_atom_t atoms; /* A list of the atoms in the molecule */ @@ -142,19 +144,21 @@ struct tng_molecule { }; struct tng_gen_block { - int64_t header_contents_size; /* The size of the block header in bytes */ - int64_t block_contents_size; /* The size of the block contents in bytes */ - int64_t id; /* The ID of the block to determine its type */ - char hash[TNG_HASH_LEN]; /* The MD5 hash of the block to verify integrity */ - char *name; /* The name of the block */ - int64_t block_version; /* The library version used to write the block */ - char *header_contents; /* The full block header contents */ - char *block_contents; /* The full block contents */ + int64_t header_contents_size; /* The size of the block header in bytes */ + int64_t block_contents_size; /* The size of the block contents in bytes */ + int64_t id; /* The ID of the block to determine its + type */ + char hash[TNG_HASH_LEN]; /* The MD5 hash of the block to verify + integrity */ + char *name; /* The name of the block */ + int64_t block_version; /* The library version used to write the block */ + char *header_contents; /* The full block header contents */ + char *block_contents; /* The full block contents */ }; struct tng_frame_set_toc { - int64_t n_blocks; /* The number of blocks listed in this - table of contents */ + int64_t n_blocks; /* The number of blocks listed in this + table of contents */ char **block_names; /* A list of block names */ }; @@ -169,25 +173,31 @@ struct tng_particle_mapping { }; struct tng_trajectory_frame_set { - struct tng_frame_set_toc contents; /* The table of contents of this frame set */ + struct tng_frame_set_toc contents; /* The table of contents of this frame + set */ int64_t n_mapping_blocks; /* The number of different particle - mapping blocks present. */ - struct tng_particle_mapping *mappings; /* The atom mappings of this frame set */ + mapping blocks present. */ + struct tng_particle_mapping *mappings; /* The atom mappings of this frame + set */ int64_t first_frame; /* The first frame of this frame set */ - int64_t n_frames; /* The number of frames in this frame set */ + int64_t n_frames; /* The number of frames in this frame + set */ int64_t *molecule_cnt_list; /* A list of the number of each molecule type - only used when using variable number of atoms */ int64_t n_particles; /* The number of particles/atoms - only used when using variable number of atoms */ - int64_t next_frame_set_file_pos; /* The file position of the next frame set */ + int64_t next_frame_set_file_pos; /* The file position of the next frame + set */ int64_t prev_frame_set_file_pos; /* The file position of the previous frame set */ - int64_t long_stride_next_frame_set_file_pos; /* The file position of the frame - set one stride step ahead */ - int64_t long_stride_prev_frame_set_file_pos; /* The file position of the frame - set one stride step behind */ + int64_t long_stride_next_frame_set_file_pos; /* The file position of the + frame set one stride step + ahead */ + int64_t long_stride_prev_frame_set_file_pos; /* The file position of the + frame set one stride step + behind */ /* The data blocks in a frame set are trajectory data blocks */ int n_particle_data_blocks; /* The number of data blocks @@ -248,85 +258,89 @@ struct tng_data { int64_t codec_id; /* ID of the CODEC used for compression 0 == no compression. */ double compression_multiplier; - union data_values **values; /* A 2-dimensional array of values, - sized n_frames x n_values_per_frame */ + union data_values **values; /* A 2-dimensional array of values, + sized n_frames x n_values_per_frame */ }; struct tng_trajectory { - char *input_file_path; /* The path of the input trajectory file */ - FILE *input_file; /* A handle to the input file */ - long int input_file_pos; /* The reading position of the file */ - long int input_file_len; /* The length of the input file */ - char *output_file_path; /* The path of the output trajectory file */ - FILE *output_file; /* A handle to the output file */ - long int output_file_pos; /* The writing position of the file */ + char *input_file_path; /* The path of the input trajectory file */ + FILE *input_file; /* A handle to the input file */ + long int input_file_pos; /* The reading position of the file */ + long int input_file_len; /* The length of the input file */ + char *output_file_path; /* The path of the output trajectory + file */ + FILE *output_file; /* A handle to the output file */ + long int output_file_pos; /* The writing position of the file */ - tng_endianness_32 endianness_32; /* The endianness of 32 bit values of - the current computer */ - tng_endianness_64 endianness_64; /* The endianness of 64 bit values of - the current computer */ + tng_endianness_32 endianness_32; /* The endianness of 32 bit values of + the current computer */ + tng_endianness_64 endianness_64; /* The endianness of 64 bit values of + the current computer */ - char *program_name; /* The name of the program producing - this trajectory */ - char *forcefield_name; /* The forcefield used in the simulations */ - char *user_name; /* The name of the user running the - simulations */ - int64_t time; /* The time (n seconds since 1970) when - the file was created */ - char *computer_name; /* The name of the computer on which the - simulations were performed */ - char *pgp_signature; /* The PGP signature of the user creating - the file. */ - char var_num_atoms_flag; /* A flag indicating if the number of atoms - can vary throughout the simulation, e.g. - using a grand canonical ensemble */ - int64_t frame_set_n_frames; /* The number of frames in a frame set. - It is allowed to have frame sets with - fewer frames, but this will help searching - for specific frames */ - int64_t stride_length; /* The number of frame sets in a long stride - step */ - - int64_t n_molecules; /* The number of different kinds of - molecules in the trajectory */ - tng_molecule_t molecules; /* A list of molecules in the trajectory */ - int64_t *molecule_cnt_list; /* A list of the count of each molecule - - if using variable number of particles - this will be specified in each frame set */ - int64_t n_particles; /* The total number of particles/atoms. If - using variable number of particles this - will be specified in each frame set */ + char *program_name; /* The name of the program producing + this trajectory */ + char *forcefield_name; /* The forcefield used in the + simulations */ + char *user_name; /* The name of the user running the + simulations */ + int64_t time; /* The time (n seconds since 1970) when + the file was created */ + char *computer_name; /* The name of the computer on which the + simulations were performed */ + char *pgp_signature; /* The PGP signature of the user creating + the file. */ + char var_num_atoms_flag; /* A flag indicating if the number of atoms + can vary throughout the simulation, e.g. + using a grand canonical ensemble */ + int64_t frame_set_n_frames; /* The number of frames in a frame set. + It is allowed to have frame sets with + fewer frames, but this will help + searching for specific frames */ + int64_t stride_length; /* The number of frame sets in a long + stride step */ + + int64_t n_molecules; /* The number of different kinds of + molecules in the trajectory */ + tng_molecule_t molecules; /* A list of molecules in the trajectory */ + int64_t *molecule_cnt_list; /* A list of the count of each molecule - + if using variable number of particles + this will be specified in each frame + set */ + int64_t n_particles; /* The total number of particles/atoms. If + using variable number of particles this + will be specified in each frame set */ - int64_t n_id_name_pairs; /* The number of ID-name - pairs */ - struct tng_block_id_name_pair *id_name_pairs; /* A list of ID-name - pairs */ - - int64_t first_trajectory_frame_set_input_file_pos; /* The pos in the src - file of the first - frame set */ - int64_t first_trajectory_frame_set_output_file_pos; /* The pos in the dest + int64_t n_id_name_pairs; /* The number of ID-name + pairs */ + struct tng_block_id_name_pair *id_name_pairs; /* A list of ID-name + pairs */ + + int64_t first_trajectory_frame_set_input_file_pos; /* The pos in the src + file of the first + frame set */ + int64_t first_trajectory_frame_set_output_file_pos; /* The pos in the dest file of the first frame set */ - int64_t last_trajectory_frame_set_input_file_pos; /* The pos in the src + int64_t last_trajectory_frame_set_input_file_pos; /* The pos in the src file of the last frame set */ - int64_t last_trajectory_frame_set_output_file_pos; /* The pos in the dest + int64_t last_trajectory_frame_set_output_file_pos; /* The pos in the dest file of the last frame set */ - struct tng_trajectory_frame_set current_trajectory_frame_set; /* The currently - active frame - set */ + struct tng_trajectory_frame_set current_trajectory_frame_set;/* The current- + ly active + frame set */ long int current_trajectory_frame_set_input_file_pos; /* The pos in the src file of the current frame set */ long int current_trajectory_frame_set_output_file_pos;/* The pos in the dest file of the current frame set */ - int64_t n_trajectory_frame_sets; /* The number of frame sets - in the trajectory */ + int64_t n_trajectory_frame_sets; /* The number of frame + sets in the + trajectory */ int64_t n_trajectory_blocks; /* The number of trajectory blocks in the file */ @@ -336,14 +350,17 @@ struct tng_trajectory { blocks */ /* These data blocks are non-trajectory data blocks */ - int n_particle_data_blocks; /* The number of non-frame dependent - particle dependent data blocks */ - struct tng_particle_data *non_tr_particle_data; /* A list of data blocks containing particle + int n_particle_data_blocks; /* The number of non-frame + dependent particle + dependent data blocks */ + struct tng_particle_data *non_tr_particle_data; /* A list of data blocks + containing particle dependent data */ - int n_data_blocks; /* The number of frame and particle independent - data blocks */ - struct tng_data *non_tr_data; /* A list of frame and particle indepdendent data blocks */ + int n_data_blocks; /* The number of frame and particle + independent data blocks */ + struct tng_data *non_tr_data; /* A list of frame and particle + indepdendent data blocks */ }; @@ -570,8 +587,9 @@ tng_function_status tng_atom_type_set(tng_trajectory_t tng_data, /* Read the header blocks from the input_file of tng_data. The trajectory blocks must be read separately and iteratively in chunks to fit in memory. - tng_data is a trajectory data container. tng_data->input_file_path specifies which - file to read from. If the file (input_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->input_file_path specifies + which file to read from. If the file (input_file) is not open it will be + opened. If hash_mode == TNG_USE_HASH the written md5 hash in the file will be compared to the md5 hash of the read contents to ensure valid data. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error @@ -582,8 +600,9 @@ tng_function_status tng_file_headers_read(tng_trajectory_t tng_data, /* Write the header blocks to the output_file of tng_data. The trajectory blocks must be written separately and iteratively in chunks to fit in memory. - tng_data is a trajectory data container. tng_data->output_file_path specifies which - file to write to. If the file (output_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->output_file_path + specifies which file to write to. If the file (output_file) is not open it + will be opened. If hash_mode == TNG_USE_HASH an md5 hash for each header block will be generated. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error has occurred or TNG_CRITICAL (2) if a major error has occured. */ @@ -592,11 +611,12 @@ tng_function_status tng_file_headers_write(tng_trajectory_t tng_data, /* Read one (the next) block (of any kind) from the input_file of tng_data. - tng_data is a trajectory data container. tng_data->input_file_path specifies which - file to read from. If the file (input_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->input_file_path specifies + which file to read from. If the file (input_file) is not open it will be + opened. *block_data is a pointer to the struct which will be populated with the - data. If block_data->input_file_pos > 0 it is the position from where the reading - starts otherwise it starts from the current position. + data. If block_data->input_file_pos > 0 it is the position from where the + reading starts otherwise it starts from the current position. If hash_mode == TNG_USE_HASH the written md5 hash in the file will be compared to the md5 hash of the read contents to ensure valid data. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor @@ -608,8 +628,9 @@ tng_function_status tng_block_read_next(tng_trajectory_t tng_data, /* Read one (the next) frame set, including toc, mapping and related data blocks from the input_file of tng_data. - tng_data is a trajectory data container. tng_data->input_file_path specifies which - file to read from. If the file (input_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->input_file_path specifies + which file to read from. If the file (input_file) is not open it will be + opened. If hash_mode == TNG_USE_HASH the written md5 hash in the file will be compared to the md5 hash of the read contents to ensure valid data. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error @@ -619,8 +640,9 @@ tng_function_status tng_frame_set_read_next(tng_trajectory_t tng_data, /* Write one frame set, including toc, mapping and related data blocks to the output_file of tng_data. - tng_data is a trajectory data container. tng_data->output_file_path specifies which - file to write to. If the file (output_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->output_file_path specifies + which file to write to. If the file (output_file) is not open it will be + opened. If hash_mode == TNG_USE_HASH an md5 hash for each block will be generated. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error has occurred or TNG_CRITICAL (2) if a major error has occured. */ @@ -645,8 +667,9 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, /* Read one trajectory block from the input_file of tng_data. - tng_data is a trajectory data container. tng_data->input_file_path specifies which - file to read from. If the file (input_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->input_file_path specifies + which file to read from. If the file (input_file) is not open it will be + opened. block_id is the ID of the block to read. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error has occurred or TNG_CRITICAL (2) if a major error has occured. */ @@ -654,8 +677,9 @@ tng_function_status tng_traj_block_read(tng_trajectory_t tng_data, int64_t block_id); /* Write one trajectory block to the output_file of tng_data. - tng_data is a trajectory data container. tng_data->output_file_path specifies which - file to write to. If the file (output_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->output_file_path specifies + which file to write to. If the file (output_file) is not open it will be + opened. block_id is the ID of the block to write. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error has occurred or TNG_CRITICAL (2) if a major error has occured. */ @@ -663,17 +687,19 @@ tng_function_status tng_traj_block_write(tng_trajectory_t tng_data, int64_t block_id); /* Read a requested frame set. - tng_data is a trajectory data container. tng_data->current_trajectory_frame_set - will be the read frame set. + tng_data is a trajectory data container. + tng_data->current_trajectory_frame_set will be the read frame set. frame_set_nr is the number of the frame set to return (starting from 0). Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error has occurred or TNG_CRITICAL (2) if a major error has occured. */ tng_function_status tng_frame_set_read_nr(tng_trajectory_t tng_data, int64_t frame_set_nr); -/* Read a number of consecutive trajectory frames from the input_file of tng_data. - tng_data is a trajectory data container. tng_data->input_file_path specifies which - file to read from. If the file (input_file) is not open it will be opened. +/* Read a number of consecutive trajectory frames from the input_file of + tng_data. + tng_data is a trajectory data container. tng_data->input_file_path specifies + which file to read from. If the file (input_file) is not open it will be + opened. start_frame_nr is the index number of the first frame to read. end_frame_nr is the index number of the last frame to read. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error @@ -682,9 +708,11 @@ tng_function_status tng_frame_read_interval(tng_trajectory_t tng_data, int64_t start_frame_nr, int64_t end_frame_nr); -/* Write a number of consecutive trajectory frames to the output_file of tng_data. - tng_data is a trajectory data container. tng_data->output_file_path specifies which - file to write to. If the file (output_file) is not open it will be opened. +/* Write a number of consecutive trajectory frames to the output_file of + tng_data. + tng_data is a trajectory data container. tng_data->output_file_path specifies + which file to write to. If the file (output_file) is not open it will be + opened. start_frame_nr is the index number of the first frame to write. end_frame_nr is the index number of the last frame to write. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error @@ -720,14 +748,15 @@ tng_function_status tng_particle_data_values_free(union data_values ***values, tng_data_type type); /* Retrieve non-particle data from the last read frame set. - tng_data is a trajectory data container. tng_data->input_file_path specifies which - file to read from. If the file (input_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->input_file_path specifies + which file to read from. If the file (input_file) is not open it will be + opened. block_id is the id number of the data block to read. - ***values is a pointer to a 2-dimensional array (memory unallocated), which will - point to the data of the requested data block. The array will be sized + ***values is a pointer to a 2-dimensional array (memory unallocated), which + will point to the data of the requested data block. The array will be sized (n_frames * n_values_per_frame). - Since ***values is allocated in this function it is the callers responsibility - to free the memory. + Since ***values is allocated in this function it is the callers + responsibility to free the memory. *n_frames is set to the number of frames in the data. This is needed to properly reach and/or free the data. *n_values_per_frame is set to the number of values per frame in the data. @@ -741,16 +770,19 @@ tng_function_status tng_data_get(tng_trajectory_t tng_data, int64_t *n_values_per_frame, tng_data_type *type); -/* Read and retrieve non-particle data, in a specific interval, from the trajectory. - tng_data is a trajectory data container. tng_data->input_file_path specifies which - file to read from. If the file (input_file) is not open it will be opened. +/* Read and retrieve non-particle data, in a specific interval, from the + trajectory. + tng_data is a trajectory data container. tng_data->input_file_path specifies + which file to read from. If the file (input_file) is not open it will be + opened. block_id is the id number of the data block to read. start_frame_nr is the index number of the first frame to read. end_frame_nr is the index number of the last frame to read. - ***values is a pointer to a 2-dimensional array (memory unallocated), which will - be filled with data. The array will be sized (n_frames * n_values_per_frame). - Since ***values is allocated in this function it is the callers responsibility - to free the memory. + ***values is a pointer to a 2-dimensional array (memory unallocated), which + will be filled with data. The array will be sized + (n_frames * n_values_per_frame). + Since ***values is allocated in this function it is the callers + responsibility to free the memory. *n_values_per_frame is set to the number of values per frame in the data. This is needed to properly reach and/or free the data. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error @@ -764,14 +796,15 @@ tng_function_status tng_data_interval_get(tng_trajectory_t tng_data, tng_data_type *type); /* Retrieve particle data, from the last read frame set. - tng_data is a trajectory data container. tng_data->input_file_path specifies which - file to read from. If the file (input_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->input_file_path specifies + which file to read from. If the file (input_file) is not open it will be + opened. block_id is the id number of the particle data block to read. - ****values is a pointer to a 3-dimensional array (memory unallocated), which will - point to the data of the requested data block. The array will be sized + ****values is a pointer to a 3-dimensional array (memory unallocated), which + will point to the data of the requested data block. The array will be sized (n_frames * n_particles * n_values_per_frame). - Since ****values is allocated in this function it is the callers responsibility - to free the memory. + Since ****values is allocated in this function it is the callers + responsibility to free the memory. *n_frames is set to the number of frames in the data. This is needed to properly reach and/or free the data. *n_particles is set to the number of particles in the returned data. This is @@ -789,17 +822,21 @@ tng_function_status tng_particle_data_get(tng_trajectory_t tng_data, tng_data_type *type); /* Read and retrieve particle data, in a specific interval, from the trajectory. - tng_data is a trajectory data container. tng_data->input_file_path specifies which - file to read from. If the file (input_file) is not open it will be opened. + tng_data is a trajectory data container. tng_data->input_file_path specifies + which file to read from. If the file (input_file) is not open it will be + opened. block_id is the id number of the particle data block to read. start_frame_nr is the index number of the first frame to read. end_frame_nr is the index number of the last frame to read. - first_particle_number is the number of the first particle, for which to retrive data. - last_particle_number is the number of the last particle, for which to retrieve data. - ****values is a pointer to a 3-dimensional array (memory unallocated), which will - be filled with data. The array will be sized (n_frames * n_particles * n_values_per_frame). - Since ****values is allocated in this function it is the callers responsibility - to free the memory. + first_particle_number is the number of the first particle, for which to + retrive data. + last_particle_number is the number of the last particle, for which to + retrieve data. + ****values is a pointer to a 3-dimensional array (memory unallocated), which + will be filled with data. The array will be sized + (n_frames * n_particles * n_values_per_frame). + Since ****values is allocated in this function it is the callers + responsibility to free the memory. *n_values_per_frame is set to the number of values per frame in the data. This is needed to properly reach and/or free the data. Returns TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error |