NEP 4.3.0
NetCDF Expansion Pack
Loading...
Searching...
No Matches
pdbfile.c File Reference

Legacy PDB User-Defined Format (UDF) dispatch layer. More...

#include "config.h"
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nep_nc4.h"
#include "pdbinternal.h"

Macros

#define PDB_MAX_LINE   1024
#define PDB_NAME_LEN   4
#define PDB_RESNAME_LEN   3
#define PDB_CHAINID_LEN   1
#define PDB_ELEMENT_LEN   2
#define PDB_GROUP_LEN   6

Functions

int nc4_var_list_add (NC_GRP_INFO_T *grp, const char *name, int ndims, NC_VAR_INFO_T **var)
static void pdb_rtrim (char *s)
static void pdb_trim (char *s)
static void pdb_copy_field (const char *line, size_t linelen, int start, int end, char *dest, size_t destlen)
static int pdb_parse_float (const char *line, size_t linelen, int start, int end, float *value)
static int pdb_parse_int (const char *line, size_t linelen, int start, int end, int *value)
static int pdb_append_text (char **dest, const char *fragment)
static void pdb_free_file_info (NC_PDB_FILE_INFO_T *pdb_file)
static int pdb_set_var_type (nc_type xtype, int endianness, size_t type_size, char *type_name, NC_TYPE_INFO_T **typep)
static int pdb_var_list_add_full (NC_GRP_INFO_T *grp, const char *name, int ndims, nc_type xtype, int endianness, size_t type_size, char *type_name, void *fill_value, int contiguous, size_t *chunksizes, void *format_var_info, NC_VAR_INFO_T **var)
static int pdb_add_string_var (NC_GRP_INFO_T *grp, const char *name, int atom_dimid, size_t str_len, NC_VAR_INFO_T **var)
static int pdb_add_char_att (NC_GRP_INFO_T *grp, const char *name, const char *value)
static NC_PDB_FILE_INFO_T * pdb_parse_file (const char *path, int *retvalp)
static int pdb_build_metadata (NC_FILE_INFO_T *h5)
int NC_PDB_open (const char *path, int mode, int basepe, size_t *chunksizehintp, void *parameters, const NC_Dispatch *dispatch, int ncid)
int NC_PDB_close (int ncid, void *ignore)
int NC_PDB_abort (int ncid)
int NC_PDB_inq_format (int ncid, int *formatp)
int NC_PDB_inq_format_extended (int ncid, int *formatp, int *modep)
static size_t pdb_type_size (nc_type xtype)
static int pdb_read_coord_var (const float *src, size_t natoms, const size_t *start, const size_t *count, void *value, nc_type value_type)
static int pdb_read_1d_var (const void *src, size_t start, size_t count, void *value, nc_type src_type, nc_type value_type)
static int pdb_read_string_var (const char *src, size_t row_len, const size_t *start, const size_t *count, void *value)
int NC_PDB_get_vara (int ncid, int varid, const size_t *start, const size_t *count, void *value, nc_type memtype)

Detailed Description

Legacy PDB User-Defined Format (UDF) dispatch layer.

V3.3.0 Sprint 2: read-only fixed-column parser for legacy PDB (Protein Data Bank) files. Exposes atom coordinates, per-atom identity fields, HEADER/TITLE/COMPND/SOURCE attributes, and CRYST1 unit-cell attributes through the netCDF-4 data model using the UDF7 dispatch table.

Known limitations carried forward to later sprints:

  • SEQRES-derived sequence data is not yet exposed.
  • Hybrid-36 encoded serial/residue numbers are not supported.
  • Multi-model files are parsed but not yet covered by tests.
Author
Edward Hartnett
Date
2026-07-29

Macro Definition Documentation

◆ PDB_CHAINID_LEN

#define PDB_CHAINID_LEN   1

Width of the atom_site_auth_asym_id string field.

◆ PDB_ELEMENT_LEN

#define PDB_ELEMENT_LEN   2

Width of the atom_site_type_symbol string field.

◆ PDB_GROUP_LEN

#define PDB_GROUP_LEN   6

Width of the atom_site_group_PDB string field.

◆ PDB_MAX_LINE

#define PDB_MAX_LINE   1024

Maximum length of a legacy PDB text line.

◆ PDB_NAME_LEN

#define PDB_NAME_LEN   4

Width of the atom_site_label_atom_id string field.

◆ PDB_RESNAME_LEN

#define PDB_RESNAME_LEN   3

Width of the atom_site_label_comp_id string field.

Function Documentation

◆ nc4_var_list_add()

int nc4_var_list_add ( NC_GRP_INFO_T * grp,
const char * name,
int ndims,
NC_VAR_INFO_T ** var )
extern

◆ NC_PDB_abort()

int NC_PDB_abort ( int ncid)

◆ NC_PDB_close()

int NC_PDB_close ( int ncid,
void * ignore )

◆ NC_PDB_get_vara()

int NC_PDB_get_vara ( int ncid,
int varid,
const size_t * start,
const size_t * count,
void * value,
nc_type memtype )

◆ NC_PDB_inq_format()

int NC_PDB_inq_format ( int ncid,
int * formatp )

◆ NC_PDB_inq_format_extended()

int NC_PDB_inq_format_extended ( int ncid,
int * formatp,
int * modep )

◆ NC_PDB_open()

int NC_PDB_open ( const char * path,
int mode,
int basepe,
size_t * chunksizehintp,
void * parameters,
const NC_Dispatch * dispatch,
int ncid )

◆ pdb_add_char_att()

int pdb_add_char_att ( NC_GRP_INFO_T * grp,
const char * name,
const char * value )
static

◆ pdb_add_string_var()

int pdb_add_string_var ( NC_GRP_INFO_T * grp,
const char * name,
int atom_dimid,
size_t str_len,
NC_VAR_INFO_T ** var )
static

◆ pdb_append_text()

int pdb_append_text ( char ** dest,
const char * fragment )
static

◆ pdb_build_metadata()

int pdb_build_metadata ( NC_FILE_INFO_T * h5)
static

◆ pdb_copy_field()

void pdb_copy_field ( const char * line,
size_t linelen,
int start,
int end,
char * dest,
size_t destlen )
static

◆ pdb_free_file_info()

void pdb_free_file_info ( NC_PDB_FILE_INFO_T * pdb_file)
static

◆ pdb_parse_file()

NC_PDB_FILE_INFO_T * pdb_parse_file ( const char * path,
int * retvalp )
static

◆ pdb_parse_float()

int pdb_parse_float ( const char * line,
size_t linelen,
int start,
int end,
float * value )
static

◆ pdb_parse_int()

int pdb_parse_int ( const char * line,
size_t linelen,
int start,
int end,
int * value )
static

◆ pdb_read_1d_var()

int pdb_read_1d_var ( const void * src,
size_t start,
size_t count,
void * value,
nc_type src_type,
nc_type value_type )
static

◆ pdb_read_coord_var()

int pdb_read_coord_var ( const float * src,
size_t natoms,
const size_t * start,
const size_t * count,
void * value,
nc_type value_type )
static

◆ pdb_read_string_var()

int pdb_read_string_var ( const char * src,
size_t row_len,
const size_t * start,
const size_t * count,
void * value )
static

◆ pdb_rtrim()

void pdb_rtrim ( char * s)
static

◆ pdb_set_var_type()

int pdb_set_var_type ( nc_type xtype,
int endianness,
size_t type_size,
char * type_name,
NC_TYPE_INFO_T ** typep )
static

◆ pdb_trim()

void pdb_trim ( char * s)
static

◆ pdb_type_size()

size_t pdb_type_size ( nc_type xtype)
static

◆ pdb_var_list_add_full()

int pdb_var_list_add_full ( NC_GRP_INFO_T * grp,
const char * name,
int ndims,
nc_type xtype,
int endianness,
size_t type_size,
char * type_name,
void * fill_value,
int contiguous,
size_t * chunksizes,
void * format_var_info,
NC_VAR_INFO_T ** var )
static