CCP4 Coordinate Library Project

Object interface: User-defined data.

User-defined data (UDD) is the type of data, which is not found in PDB and mmCIF coordinate files, which does not have predefined meaning and which becomes known only at run-time. UDD may be saved into and retrieved from MMDB binary files.

UDD are allowed on any level of the coordinate hierarchy. This means that arbitrary number of UDDs may be added to any atom, any residue and any model.

In MMDB, UDDs are identified by three characteristics:
 
Identification Description
math type   real numbers, integers or strings
registration type    coordinate hierarchy level:
UDR_ATOM   UDD for atoms
UDR_RESIDUE   UDD for residues
UDR_CHAIN   UDD for chains
UDR_MODEL   UDD for models
name   a unique UDD name

Before a UDD may be used, its name and type must be registered. You may register any number of UDDs for any level of the coordinate hierarchy, however you are free in how to populate them. For example, if you register a integer UDD for atoms may be named "colour", and another one - "history", they may be found both in the same atom, or one without another, or none.

After registering a UDD, application gets a unique handle, which is then used in all UDD-related functions. These functions are provided as methods of atoms, residues, chains and models.

Function Purpose
CMMDBManager::RegisterUDInteger Registering a user-defined data of integer type.
CMMDBManager::RegisterUDReal Registering a user-defined data of real type.
CMMDBManager::RegisterUDString Registering a user-defined data of string type.
CMMDBManager::GetUDDHandle Obtaining a handle for already registered UDD..


int CMMDBManager::RegisterUDInteger ( 
int  udr_type, 
pstr UDDataID )
PURPOSE
Registering a user-defined data of integer type.
ARGUMENTS
int udr_type
The UDD registration type.

pstr UDDataID
The UDD name, or ID. This name has to be unique for each registration.

DESCRIPTION

The function registers an integer User-Defined Data for the level of coordinate hierarchy identified by udr_type under name UDDataID.


RETURN

The function returns a UDD handle, which provides further access to the registered UDD. The handle is non-zero and unique. Zero return means registration failure. If the function returns UDDATA_WrongUDRType it means that udr_type was given a wrong value (this will not happen if you use constants UDR_XXXX described above.


EXAMPLE

Register two UDD integers for atoms, named "color" and "history", then write and read them:

PCMMDBManager  MMDB;
PCAtom         A;
int            uddHandle1,uddHandle2, V,rc;

  . . . . . . . . . . . . . . . . . . . . . . . .

  uddHandle1 = MMDB->RegisterUDInteger ( UDR_ATOM,"color"   );
  uddHandle2 = MMDB->RegisterUDInteger ( UDR_ATOM,"history" );
  if ((!uddHandle1) || (!uddHandle2))  {
    printf ( " registration failed.\n" );
    exit ( 1 );
  }
  if ((uddHandle1==UDDATA_WrongUDRType) || 
      (uddHandle2==UDDATA_WrongUDRType))  {
    printf ( " wrong registration type used.\n" );
    exit ( 2 );
  }

  A = MMDB->GetAtom ( "/1/A/33(SER).B/CA[C].A" );
  if (A->PutUDData(uddHandle1,12)!=UDDATA_Ok)  {
    printf ( " failed to store UDD 'color'.\n" );
    exit ( 3 );
  }
  if (A->PutUDData(uddHandle2,22)!=UDDATA_Ok)  {
    printf ( " failed to store UDD 'history'.\n" );
    exit ( 4 );
  }

  rc = A->GetUDData ( uddHandle1,V );
  switch (rc)  {

    case  UDDATA_WrongUDRType :
      printf ( " wrong UDD registration type when accessing 'color'.\n" );
      exit ( 5 );

    case  UDDATA_WrongHandle  :
      printf ( " wrong UDD handle when accessing 'color'.\n" );
      exit ( 6 );

    case  UDDATA_NoData :
      printf ( " UDD 'color' not found.\n" );
      exit ( 7 );

    case  UDDATA_Ok :
      printf ( " UDD 'color' is set to %i.\n",V );
      break;

    default :
      printf ( " Unknown UDD return %i.\n",rc );
      exit ( 8 );
  }

  A->GetUDData ( uddHandle2,V );
  printf ( " UDD 'history' is set to %i.\n",V );

  . . . . . . . . . . . . . . . . . . . . . . . . . .


int CMMDBManager::RegisterUDReal ( 
int  udr_type, 
pstr UDDataID )
PURPOSE
Registering a user-defined data of real type.
ARGUMENTS
int udr_type
The UDD registration type.

pstr UDDataID
The UDD name, or ID. This name has to be unique for each registration.

DESCRIPTION

The function registers a real-type User-Defined Data for the level of coordinate hierarchy identified by udr_type under name UDDataID.

The function is conceptually identical to CMMDBManager::RegisterUDInteger.


int CMMDBManager::RegisterUDString ( 
int  udr_type, 
pstr UDDataID )
PURPOSE
Registering a user-defined data of string type.
ARGUMENTS
int udr_type
The UDD registration type.

pstr UDDataID
The UDD name, or ID. This name has to be unique for each registration.

DESCRIPTION

The function registers a string-type User-Defined Data for the level of coordinate hierarchy identified by udr_type under name UDDataID.

The function is conceptually identical to CMMDBManager::RegisterUDInteger.


int CMMDBManager::GetUDDHandle ( 
int  udr_type, 
pstr UDDataID )
PURPOSE
Obtaining a handle for already registered UDD..
ARGUMENTS
int udr_type
The UDD registration type.

pstr UDDataID
The UDD name, or ID.

DESCRIPTION

The function retrieves the UDD handle for the specified data. The UD data must be already registered with either of functions CMMDBManager::RegisterUDInteger, CMMDBManager::RegisterUDReal or CMMDBManager::RegisterUDString. The function accepts exactly the same parameters as those used at registration.


RETURN

A positive return represents the UDD handle, which may be then used for retrieving the UDD (cf. example). A zero return means that the UDD was not registered (no handle found). Return UDDATA_WrongUDRType means that udr_type was given a wrong value (this will not happen if you use constants UDR_XXXX described above.

NOTE : The UDD handles may change after reading from MMDB binary file. It is therefore advisable that you do not store UDD handles in the file, but rather obtain them from GetUDDHandle as necessary.



Back to index