NCBI C Toolkit Cross Reference

C/biostruc/mmdbapi.doc


  1 MMDB-API  (draft document February 7 1996)
  2 
  3 Molecular Modeling Database Application Programming Interface.
  4 Author C. Hogue 
  5 Contributors:  S. Bryant, H. Ohkawa, J. Kans, A. Smirnov, J. Ostell
  6 
  7 
  8 Contents:
  9     INTRODUCTION
 10     MMDB-API DESIGN CONSIDERATIONS
 11     MMDB-API DATA ABSTRACTION
 12     MODELSTRUC DATA NODES
 13     MMDB-API EXAMPLE
 14     MMDB-API Routines 
 15       MMDB-API Interface Routines
 16       ASN.1 MODEL INDEX <> NODE POINTER CONVERSION:
 17       MODEL TRAVERSERS
 18       OUTPUT
 19       COMPUTATIONAL GOODIES
 20       MACROS
 21  
 22 
 23 
 24 
 25 http://www.ncbi.nlm.nih.gov/Structure for the latest updates to MMDB-API.
 26 ____________________________________________________________________
 27 INTRODUCTION:
 28 
 29 
 30 
 31 MMDB (Molecular Modelling DataBase) is NCBI's 3-dimensional structure service.
 32 The major source of MMDB data is from experimental X-ray crystallographic or 
 33 NMR data from the Brookhaven Protein Database (PDB).  
 34 
 35 NCBI's has a complete ASN.1 specification for storage and interchange of
 36 biochemical structure data. The development of the Molecular Modelling DataBase
 37 (MMDB) and the rationale for the use of ASN.1 are discussed at length 
 38 elsewhere.   The ASN.1 data specification is not a prerequisite for using
 39 MMDB-API, as it is parsed into complete and comprehensive memory data 
 40 structures by MMDB-API.  
 41 
 42 An ASN.1 Biostruc can represent a  3D structure consisting of several types of 
 43 experimental and derived data.  The Biostruc data consists of (a) bibligraphical
 44 and historical data; (b) a single, unambiguous chemical-graph (i.e. the 
 45 molecule's skeletal path of atoms and bonds); (c) one or more sets of 3D model 
 46 data consiting of locations in space ( X, Y, Z coordinates); and (d) features 
 47 associated with (b) and/or (c).  
 48 
 49 MMDB-API is written under the NCBI Software Development Toolkit (SDK), 
 50 required for implementing MMDB-API.  An Applications Programming Interface 
 51 (API) is a set of computer algorithms and programs that allow convenient 
 52 access to data.  
 53 
 54 The purpose of MMDB-API is to provide a programmer with the means 
 55 for accessing and computing on the structural data that is transmitted
 56 in the ASN.1 format.  MMDB-API's principal task is to restructure the 
 57 in-memory image of the ASN.1 data to make it computable.  The internal 
 58 representation of the ASN.1 Biostruc is, under MMDB-API converted into a
 59 hierarchical C data structure known as a "Modelstruc".
 60 
 61 MMDB-API provides all the C routines in a library in order to 
 62 service the I/O between these three layers,
 63 
 64 ASN.1                   C Object         MMDB-API
 65 Specification           Loaders          C Data Structures
 66 
 67 file                    Memory           Memory
 68 Biostruc (ASN.1)  <=>   Biostruc   <=>   Modelstruc
 69 
 70 Thus you can start computing at the highest-layer, MMDB-API
 71 immediately, without becoming an expert in parsing, file or network I/O,
 72 or the ASN.1 Biostruc file specification.
 73 
 74 MMDB-API has been created with some very complex data structures.
 75 You may not need to compute within these.  MMDB-API has some powerful methods 
 76 of obtaining sub-sets of structure data using routines called "traversers".  
 77 These can be applied to cast the data you require into more simple 
 78 data structures thay you design and operate on.  By writing, modified 
 79 data back into the MMDB-API data structures, one can save the results
 80 in the correct ASN.1 data specification automatically.
 81 
 82 MMDB-API should not be discounted on the basis of its data structure complexity,
 83 because it is probably the most robust and reproduceable means for obtaining
 84 structure data from a file format and getting it into memory in the first 
 85 place.  
 86 
 87 MMDB-API has provided for an astonishingly efficient amount of code-re-use.  
 88 Consider only that the PDB converter is less than
 89 1300 lines of code, and the Kinemage renderer makes 4 different kinds of
 90 renderings, add textual annotation, and is less than 1600 lines of code.   
 91 
 92 
 93 
 94 ____________________________________________________________________
 95 MMDB-API DESIGN CONSIDERATIONS
 96 
 97 A program called asncode, (NCBI Toolkit) provides a means for taking
 98 an ASN.1 data specification, and generating C data structures, and 
 99 functions that provide memory management and I/O.  This is called the
100 "object loader layer".  The data structures paralell the ASN.1 data
101 specification.  A Biostruc can be loaded into memory and manipulated 
102 in memory directly without any alteration to these ASN.1-derived C data 
103 structures.   
104 
105 Unfortunately, the Biostruc C in-memory image, derived from the ASN.1 
106 specification is ill-suited for computation.   MMDB-API adds an 
107 additional layer, the Modelstruc, to optimize the in-memory data structure 
108 for computational purposes. 
109 
110 Why is the ASN.1-derived C data structure not suited for computation?
111 Three types of changes are neccesary, data type conversion, 
112 data instantiation and the addition of explicit "backwards" pointers.  
113 None of these affect or add to the content of the data, merely they
114 are data reorganizations.
115 
116 The internal represenation of coordinate floating point data in the
117 ASN.1 Biostruc is as an integer value and integer scale factor.  
118 These must be converted to floating point for computation, hence 
119 data type conversion must be performed.
120 
121 Chemical graphs are really saved as indices into residue dictionaries,
122 both standard and non-standard (local dictionaries). Therefore, to reconstruct 
123 the graph, each residue (bonds and atoms) must be copied or instantiated 
124 from the dictionary.
125 
126 There are no pointer references from the  "chemical graph" to the "location" 
127 data (i.e. the X, Y, Z coordinates). Rather there are only references from the 
128 location back into the chemical graph.  These must be interpreted at load-time 
129 and resolved, hence the addition of explicit backwards pointers.
130 
131 For computational purposes, one must have a way of finding the chemical graph 
132 from the location, and the location from the chemical graph.  
133 In addition, given the location of an atom, one needs a
134 way of determining its bonded-neighbors, through-space non-bonded neighbors,
135 its parent molecule and structure.  There is a need to have some of these 
136 linkages availiable in a pre-computed and computed on-the-fly basis, and the
137 emphasis in the data structure design has been to use pointers and data
138 structures in order to reduce the coding and logic required to traverse
139 the data.  
140 
141 The Modelstruc is a hybrid data stucture, containing significant portions
142 of the original ASN.1 derived C structures.  
143 The portions that remain unchanged after the object-loader phase are, in
144 general, the descriptive parts. These include bibliographic
145 and identifier information.  These parts of the data structures are
146 preserved because there is a large set of NCBI programming that
147 can use the ASN.1 derived C types as-is.  
148 
149 Given that some compuations on the Modelstruc cannot be forseen in the
150 making of the API, the Modelstruc may be manipulated directly.  
151 Data hiding has not been strongly enforced by MMDB-API and virtually
152 all the library routines are public at the current time.
153 
154 Special attention has been paid to the free-ing of memory in MMDB-API, as 
155 a Structure is freed with a "hierarchical collapse".  This means if you
156 free something you aren't supposed to (like a string) and don't null out
157 all the pointers in the structure that point to it (its parents, its children),
158 MMDB-API free-ing will fail.  More safe free-ing routines will be added as
159 MMDB-API develops.  
160 
161 
162 
163 Variable Names and Hungarian Notation:
164 
165 Code for the MMDB-API attempts to employ Hungarian Notation, whereas the bulk
166 of the NCBI toolkit has no structured way of defining variables with the
167 exception of Vibrant objects.  You will either love or hate my notation,
168 but the reason it was implemented was to reduce bugs, which it does!  
169 
170 Data structures such as doubly-linked lists and singly-linked-lists are 
171 maintained by NCBI toolkit core routines.  A pointer to a singly-linked-list
172 node which contains a pointer to a MAD node, is a PVNMA a "Pointer to ValNode
173 to ModelAtom"  and a pointer to a doubly-linked list node which contains a 
174 pointer to a MMD is a PDNMM, a "Pointer to DValNode to ModelMolecule".
175 
176 Using Hungarian notation, a data type prefix is prepended to a variable name,
177 
178 a CharPtr is a "pc" meaning pointer to char.
179 The "p" is put first so that equivalencies of data types is spotted easier:
180 e.g.
181 
182 pcFetch = &mystring;
183 the "p" on the left indicates that the address on the right is an appropriate
184 cast, whereas
185 Fetch = &mystring;
186 tells nothing about whether the address of mystring is appropriate as
187 a value to insert into Fetch,
188 without examining the *.h file or wherever Fetch was declared.
189 
190 In MMDB-API, the abbreviations MS, MA, MM, etc form specific parts of the
191 Hungarian Notation prefixes:
192 e.g. the variable pdnmsList is a "P"ointer to "D"Val"N"ode to "M"odel"S"truc 
193 and the variable name is List.  A declaration of this variable would be:
194 PDNMS pdnmsList;
195 
196 
197 _____________________________________________________________________________
198 MMDB-API DATA ABSTRACTION:
199 
200 
201 In the conversion of the ASN.1 Biostruc to the C Modelstruc, the 
202 fundamental changes in the data are that: 
203 
204 A) Everything is instantiated. 
205 e.g: In a given Biostruc, there may be many references to the dictionary
206 graph for "Phe", but there is only one copy of the "Phe" chemical graph
207 (i.e. the dictionary one).  In the Modelstruc, the "Phe" chemical graph
208 is instantiated for each "Phe" in a protein.  Likewise there is a list of 
209 each and every bond in the complete chemical graph.  
210 
211 (B) All "indicies" and "id's" become C pointers to "nodes" containing the data.
212 e.g: An "atom" node contains information about the chemical graph part of the 
213 atom (bonds, name, etc).  It also contains a list of "locations" 
214 (X,Y,Z coordinates) that come from each structural model present in the ASN.1.  
215 An atom can have an unlimited number of "locations".  Likewise
216 an atom contains a complete list of bonds.   The number of bonds an atom
217 can have is not chemically constrained, rather it is unlimited (and can
218 include virtual bonds).  The bond list is a list of pointers to "bond"
219 nodes which link atoms (NOT LOCATIONS) together and indicate what type
220 the bond is (i.e. single, double, etc).  
221 
222 
223 There are 4 C functions one gets from each ASN.1 type "Xx" after making
224 "object loaders" with asncode:
225 (1) A memory-free-er XxFree().
226 (2) A memory-allocater XxNew(). 
227 (3) A read function XxAsnRead(). 
228 (4) A write funciton XxAsnWrite().  
229 
230 In addition, one can refer to structure Xx in memory with a pointer of type
231 XxPtr. 
232 
233 Similarly, the Modelstruc can be referred to by a
234 single pointer, and can be freed with a single function.  However, the act
235 of making a new unpopulated Modelstruc is complicated, and there will
236 be a provision for special routines to make de-novo structures.
237 The Modelstruc is currently instantiated by first reading in a
238 valid Biostruc with BiostrucAsnRead(), then it is converted into a Modelstruc
239 using MMDB-API routines.  MMDB-API if fully capable of handling a virtually 
240 unlimited number of structures in memory, providing there is room for them.
241 
242 Modelstruc Limits:
243 Atoms - only by memory 
244 Molecules - only by memory
245 Residues - only by memory
246 Structures - only by memory
247 Models - only by memory 
248 Features - only by memory
249 
250 
251 In addition to the "Modelstruc",  a further conversion of the data to and from a 
252 variety of data arrays and matricies can be easily performed.  This can be used
253 to allow the application of array- and vector-based algorithms (e.g. Fortran) 
254 without extensive reprogramming of the internal logic of these programs.  
255 This paradigm can be convenience to an established body of programmers and 
256 programs which work in this fashion.
257 
258 
259 The output or "writing" of a Modelstruc  involves a conversion back to a valid 
260 in-memory C Biostruct, at the "object loader" layer then the writing 
261 out of the ASN.1 Biostruc using BiostrucAsnWrite.  In the future we hope one
262 will be able to instantiate the chemical-graph portion of a Modelstruc
263 from an ASN.1 sequence or from other data types.
264 
265 
266 
267 ___________________________________________________________________________
268 MODELSTRUC DATA NODES
269 
270 There are 9 Main types of data nodes in a Modelstruc.
271   
272 NAMING CONVENTIONS:
273 MS "ModelStruc"  
274 MSD is "ModelStrucData"
275 PMSD is "Pointer to MSD"
276 
277 likewise for:
278 MM "ModelMolec",    MMD "ModelMolecData",    PMMD "Pointer to MMD"
279 MG "ModelGraph",    MGD "ModelGraphData",    PMGD "Pointer to MGD"
280 MA "ModelAtom",     MAD "ModelAtomData",     PMAD "Pointer to MAD"
281 MB "ModelBond",     MBD "ModelBondData",     PMBD "Pointer to MBD"
282 MD "ModelDensity",  MDD "ModelDensityData",  PMDD "Pointer to MDD"
283 MO "ModelObject",   MOD "ModelObjectData",   PMOD "Pointer to MOD"
284 AL "AtomLocation",  ALD "AtomLocationData",  PALD "Pointer to ALD"
285 ML "ModelLocation", MLD "ModelLocationData", PMLD "Pointer to MLD"
286 
287 A Modelstruc is loosely defined as:
288 A doubly-linked list containing MSD, containing:
289   A doubly-linked list containing MMD, containing:
290     A doubly-linked list containing MGD, containing:
291        MAD, MBD (interconnected by pointers):
292          MAD contains:
293            a linked-list of of locations - ALD's...
294            a linked-list of its own bonds - PMBD's
295          MBD contains:
296            bond type information
297            2 pointers - PMAD - to the atom endpoints
298     various lists of MAD, MBD (like disulfide bonds)
299   various lists of MAD, MBD (like alpha carbons)
300   various lists of MOD (objects - bricks, spheres, surfaces, etc)
301   various lists of MDD (grid density data)
302 
303 The root node MSD also contains
304   a pointer to the ASN.1 Biostruc which can be 
305    the entire Biostruc OR the non-redundant portion.
306   pointers to the Models MLD...
307   pointers to information & bibliographic data.
308   pointers to local & global chemical graph dictionaries.
309   pointers to Biostruc-features.
310   global rotation/translation matricies to be applied to all locations.
311   bounding box.
312   rendering information.
313 
314 
315 
316 The Linked-lists and doubly-linked list nodes contain
317 the above named data nodes.  Pointers to nodes have
318 naming prefixes:
319 PDN  "P"ointer to "D"val"N"ode.  A Doubly-linked list.
320 PVN  "P"ointer to "V"al"N"ode.   A Singly-linked list.
321   
322 PDNMS "ModelStruc",   Contains a PMSD "Pointer to MSD"
323 PDNMM "ModelMolec",   Contains a PMMD "Pointer to MMD"
324 PDNMG "ModelGraph",   Contains a PMGD "Pointer to MGD"
325 PVNMA "ModelAtom",    Contains a PMAD "Pointer to MAD"
326 PVNMB "ModelBond",    Contains a PMBD "Pointer to MBD"
327 PVNMD "ModelDensity", Contains a PMDD "Pointer to MDD"
328 PVNMO "ModelObject",  Contains a PMOD "Pointer to MOD"
329 PVNAL "AtomLocation", Contains a PALD "Pointer to ALD"
330 PDNML "ModelLocation",Contains a PMLD "Pointer to MLD"
331 
332 
333  
334 
335 OBJECT-ORIENTED NODE STRUCTURE:
336 
337 Each node, MSD, MMD, MGD, MAD, MBD, ALD (except MLD) can be referenced by the 
338 sub-type FB (FlagBlock) with  a PFB (pointer to FlagBlock). 
339 This allows one to abstract each data node for common routines,
340 e.g. a routine that returns a three-dimensional bounding box could use
341 whole structures (MSD), whole molecules (MMD) residues (MGD) or atoms (MAD)
342 as input data.  With a PFB pointer, all these data types can be referenced 
343 from a single routine.  While not quite OOP, it does reduce the code involved.
344 Other tricks are availiable, i.e. given a PFB pointer to some "Model Object"
345 one can determine its type (MSD,MMD, etc), its indicies and its parent objects,
346 (e.g. an atom's parent molecule).   This also makes all objects "clickable"
347 in a 3D graphics viewer.  If the viewer returns one pointer, one can traverse
348 the pointer links back to find out what it is (bond or atom) and find out
349 who its parents are (residue, molecule, structure).  
350 
351 The internal C definition of components in each node are found in mmdbapi1.h
352 
353 
354 ____________________________________________________________________________
355 MMDB-API EXAMPLE:
356 
357 
358 With the MMDB-API, the programmer does not need to parse the data file.  
359 The task are, Open MMDB-API,  Load an ASN.1 Biostruc,  Register it with
360 MakeAModelstruc and you obtain a pointer of type PDNMS to the structure,
361 which is the most commonly used argument in MMDBAPI functions.
362 
363 You can register as many structures as you wish, they
364 form a list in memory that is free-ed when CloseMMDBAPI is called.
365 
366 
367 Here's some sample code that uses MMDB-API prints all the atomic XYZ coordinates
368 for a given ASN.1 MMDB file (testapi.c).
369 
370 _______________________________________
371 #include <ncbi.h>  /* the NCBI SDK header */
372 #include <asn.h>   /* the ASN.1 header */
373 #include <mmdbapi.h>   /* the MMDB-API header */
374 
375 /********************************************************* 
376  *The NCBI argument routines are described in            *
377  *   the NCBI Software Development Toolkit               *
378  *********************************************************/
379 
380 #define NUMARGS 2
381 
382 Args myargs[NUMARGS] = {
383         {"Input String",NULL,NULL,NULL,FALSE,'s',ARG_FILE_IN,0.0,0,NULL},
384         {"Model Level \n0 = Atoms; 1=BB; 2=all PDB; 3=VECT; ","0","0","3",TRUE,'m',ARG_INT,0.0,0,NULL}
385       };
386 
387 
388 
389 /********************************************************* 
390  *The CALLBACK routine.                                  *
391  * Executed as the traverser visits each node.           *
392  *  If the node is an atom, it prints the atom's name,   *
393  *   and the first model's                               *
394  *   X, Y, and Z values for the atom                     *
395  *********************************************************/
396 
397 static void DoXYZ(PFB pfbThis, Int4 iModel, Int4 iIndex, Pointer ptr)
398 {
399   PMAD pmadAtom;
400   PALD paldLoc;
401 
402     /* pfbThis points to a generic data node */
403     /* we want only ModelAtomData or MAD nodes */
404     if (IsAtomNode(pfbThis))
405       {
406           /* cast to the correct PMAD pointer type */
407           pmadAtom = (PMAD) pfbThis;
408           
409           /* get the locations (XYZ coords node) for this atom, and model */
410           paldLoc = GetAtomLocs(pmadAtom, iModel);
411           
412           /* go through each location for this particular atom and model */ 
413           while (paldLoc) 
414             {
415              /* print the Atom name and location data */
416              printf("Atom, %s, X=%f, Y=%f,  Z=%f \n", 
417                 AtomPDBName(pmadAtom), 
418                 AtomLocX(paldLoc),  
419                 AtomLocY(paldLoc),  
420                 AtomLocZ(paldLoc));
421              paldLoc = paldLoc->next; /* get next location */
422             }
423       }
424 }
425 
426 
427 
428 /********************************************************* 
429  *The Main() function,  built according to the NCBI      *
430  *   Software Development Toolkit specifications, lends  *
431  *   portability between GUI and non-GUI platforms       *
432  *********************************************************/
433 
434 Nlm_Int2 Main ()
435 {
436   Int2 iTest;
437   PDNMS pdnmsModelstruc;
438   BiostrucPtr pbsBiostruc;
439   
440 
441         
442         if (! GetArgs("MMDB-API Example",NUMARGS,myargs))
443                 return 1;
444          
445         /* Initialize MMDB-API  */ 
446 
447         if (! OpenMMDBAPI(0, NULL, (Int2) myargs[1].intvalue)) 
448           {
449                 printf("Have not opened mmdbapi");
450                 return 2;       
451           }
452         /* load an ASN.1 Biostruc */
453         pbsBiostruc = FetchBiostrucPDB(myargs[0].strvalue, myargs[1].intvalue, 100);
454         if (pbsBiostruc == NULL)
455           {
456                 printf("Have not fetched Biostruc");
457                 return 3;
458           }
459 
460         /* convert it into a Modelstruc pointed to by pdnmsMain */
461         pdnmsModelstruc= MakeAModelstruc(pbsBiostruc);          
462         if ( pdnmsModelstruc == NULL )
463           {
464                 printf("Have not not Converted Biostruc");
465                 return 4;
466           }
467                 
468         /* Traverse all the ATOM nodes in each pdnmsMain, */
469         /* doing the function DoXYZ at each node for each model */  
470 
471         iTest = TraverseModels( pdnmsModelstruc,
472                                 TRAVERSE_ATOM, 
473                                 0,NULL,
474                                 (pNodeFunc)(DoXYZ));
475           
476 
477         /* Free the Modelstruc (and its enclosed Biostruc) */     
478         /* FreeAModelstruc(PDNMS pdnmsThis); not necessary */
479         /* This can be done individually - but all Modelstrucs */
480         /* remaining are freed in CloseMMDB-API() */
481 
482         /* Shut Down MMDB-API */        
483 
484         CloseMMDBAPI(); 
485 
486         return TRUE;
487 }
488 
489 
490 
491 
492 __________________________________________________________________________
493  ___________________________________________________________________________
494 MMDBAPI Interface routines:
495 
496 Main routines:
497 
498 Int2  OpenMMDBAPI(Byte bExtent, CharPtr pcDictName);
499 Boolean IsMMDBAPIOpen(void);
500 BiostrucPtr FetchBiostrucPDB(CharPtr pcAcession, Int4 iModelLevel, Int4 iMaxModels);
501 PDNMS MakeAModelstruc(BiostrucPtr pbsThis);
502 
503 Safe Free-ers (so far):
504 
505 Boolean FreeSingleModel(PDNMS pdnmsThis, Int2 iModel);
506 void  ClearStructures(void);
507 void FreeAModelstruc(PDNMS pdnmsThis);
508 void CloseMMDBAPI(void);  /* frees leftovers Modelstruc's */
509 
510 
511 Settings:
512 
513 PDNMS  GetPDNMSMain(void);  
514 PRGD   GetPRGDDictionary(void);
515 Byte  GetMMDBAPIbExtent(void);
516 void  ChangeMMDBAPIbExtent(Byte bExtent);
517 
518 Structure Access:
519 
520 void SetMasterModelstruc(PDNMS pdnmsThis);
521 PDNMS GetMasterModelstruc(void);
522 void SetSelectedModelstruc(PDNMS pdnmsThis);
523 PDNMS GetSelectedModelstruc(void);
524 void SetHolderModelstruc(PDNMS pdnmsThis);
525 PDNMS SwapModelstruc(void);
526 
527 Access from list of structures:
528 
529 PDNMS GetFirstModelstruc(void);
530 PDNMS GetNextModelstruc(void);
531 PDNMS GetPreviousModelstruc(void);
532 
533 
534 Keeping lists of selected nodes:
535 
536 ValNodePtr AddPFBSelect(PFB pfbThis);
537 void ClearPFBSelectList(void);
538 void UndoPFBSelectList(void);
539 
540 Miscellaneous:
541 
542 CharPtr GetStrucStrings(PDNMS pdnmsThis, Int4 iPickType);
543 Int4 MakeHashChange(PDNMS pdnmsThis);
544 Int4   CountModelstrucs(void);
545 _pmmdbAPI NewMMDBAPI(void);
546 
547 
548 ___________________________________________________________________
549 ASN.1 MODEL INDEX <> NODE POINTER CONVERSION:
550 
551  
552 The ASN.1 definition of the Biostruc refers to the chemical graph by 
553 MoleculeID, ResidueID (same as Graph here), and AtomID.
554 These routines find the appropriate node in the Modelstruc, given the
555 ID's.
556 
557 PMAD    AtomFromMMDBIndex(PDNMS pdnmsList, Int2 iStru, Int2 iMol, Int2 iGraph, Int2 iAtom);
558 PMGD    GraphFromMMDBIndex(PDNMS pdnmsList, Int2 iStru, Int2 iMol, Int2 iGraph);
559 PMMD    MolFromMMDBIndex(PDNMS pdnmsList, Int2 iStru, Int2 iMol);
560 
561 
562 PALD    GetLocation(PALD paldList,  Int2 iCoord,  Char cAlt);
563 PALD    GetAtomLocs(PMAD pmadThis,  Int2 iModel);
564 PMGD    GetParentGraph(PFB pfbThis);
565 PMMD    GetParentMol(PFB pfbThis);  
566 PMSD    ToMSDParent(PFB pfbThis);  
567 
568 
569 Generic conversions:
570 PFB     PFBFromVN(ValNodePtr pvnModel);
571 PFB     PFBFromDN(DValNodePtr pdnModel);
572 DValNodePtr DNFromPFB(PFB pfbThis);
573 Int2    IndexFromNode(PFB pfbNode);  
574 
575 
576 Lookup routines:
577 NOTE: You are not given your own copy of a string, you always get a
578 pointer to a string in memory.  Do not free CharPtrs returned 
579 by these functions!
580 
581 Int2    ParentMolNum(PFB pfbThis);
582 CharPtr ParentMolName(PFB pfbThis);
583 CharPtr ParentGraphPDBNo(PFB pfbThis);
584 CharPtr ParentGraphPDBName(PFB pfbThis);
585 CharPtr ParentGraphIUPAC1(PFB pfbThis);
586 Int2    ParentGraphNum(PFB pfbThis);
587 CharPtr LIBCALL ElementName(Int1 iAtomicNo);
588 CharPtr LIBCALL AminoAcidName(Char cThis, Int2 iRetCode);
589 
590  
591 
592 
593 _______________________________________________________________
594 MODEL TRAVERSERS:
595 
596 The following routines use pointers to functions which allow the programmer
597 to attach a "computation" to a routine that "walks" the Modelstruc. 
598 
599 
600 Int2 TraverseAll( DValNodePtr pdnModel, Int4 iModel, Int4 iIndex, 
601                           Pointer ptr, pNodeFunc pfnCallMe);
602 
603          Walks the structure children from the current pointer.  Performs
604          (*pfnCallMe)(pfbThis, iModel, iIndex, ptr) at each data node (as Flags Block).
605 
606         The argument pdnModel can be either a PDNMS, PDNMM, or PDNMG.
607         Note that PDNMS to traverse a single structure, but 
608         PDNMM and PDNMG continue traversing from the point where called
609         down the linked list.  Therefore if you want to traverse only
610         one molecule, say pmmdThis, use the pmmdThis->pdnmgHead pointer 
611         that hangs off the molecule as the argument for the traverser.
612 
613 
614 MODEL-SPECIFIC TRAVERSERS:
615 These routines allow you to traverse one specific model
616         or all the models.
617 
618 Int2 TraverseOneModel(DValNodePtr pdnModel, Int2 iTraverse, Int2 iModel, 
619                         Int4 iIndex, Pointer ptr, pNodeFunc pfnCallMe);
620 
621 Int2 TraverseModels(DValNodePtr pdnModel, Int2 iTraverse, 
622      Int4 iIndex, Pointer ptr,  pNodeFunc pfnCallMe);
623 
624         use the iTraverse flag as:
625 #define TRAVERSE_ALL 0
626 #define TRAVERSE_MOLECULE 1
627 #define TRAVERSE_GRAPH 2
628 #define TRAVERSE_ATOM 3
629 #define TRAVERSE_BOND 4
630 #define TRAVERSE_SOLID  5
631 #define TRAVERSE_IBOND 6
632 
633 
634 NODE-SPECIFIC TRAVERSERS:
635 These only visit the PFB nodes stated in their names, and ignore the others.
636 They are usually called by TraverseOneModel and TraverseModels. 
637 They are much faster than TraverseAll because they only call the function at 
638 the specified node type.
639 
640 
641 Int2 TraverseIBonds( DValNodePtr pdnModel, Int4 iModel, Int4 iIndex, 
642                           Pointer ptr, pNodeFunc pfnCallMe);
643 
644          Walks all the inter-res or inter-mole bond children from 
645          the current pointer.
646          Can start from MSD, MMD, MGD, MBD (self) 
647          Performs(*pfnCallMe)(pfbThis, iModel, iIndex, ptr) at each bond node.
648 
649 
650 Int2 TraverseBonds( DValNodePtr pdnModel, Int4 iModel, Int4 iIndex, 
651                           Pointer ptr, pNodeFunc pfnCallMe);
652 
653          Walks all the bond children from the current pointer.
654          Can start from MSD, MMD, MGD, MBD (self) 
655          Performs(*pfnCallMe)(pfbThis, iModel, iIndex, ptr) at each bond node.
656 
657 
658 
659 Int2 TraverseAtoms( DValNodePtr pdnModel, Int4 iModel, Int4 iIndex, 
660                           Pointer ptr, pNodeFunc pfnCallMe);
661         Walks all the atom children from the current pointer.
662          Can start from MSD, MMD, MGD, MAD (self).
663          Performs (*pfnCallMe)(pfbThis, iModel, iIndex, ptr) at each atom node.
664         
665 
666 
667 
668 Int2 TraverseGraphs( DValNodePtr pdnModel, Int4 iModel, Int4 iIndex, 
669                           Pointer ptr, pNodeFunc pfnCallMe);
670          Walks all the model children from MSD, MMD
671          Performs (*pfnCallMe)(pfbThis, iModel, iIndex, ptr) at each graph node.
672 
673 
674 
675 
676 Int2 TraverseMolecules( DValNodePtr pdnModel, Int4 iModel, Int4 iIndex, 
677                           Pointer ptr, pNodeFunc pfnCallMe);
678          Walks all the model children from MSD
679          Performs (*pfnCallMe)(pfbThis, iModel, iIndex, ptr) at each molecule node. 
680 
681 
682 
683 Int2 TraverseSolids( DValNodePtr pdnModel, Int4 iModel, Int4 iIndex, 
684                           Pointer ptr, pNodeFunc pfnCallMe);
685 
686 
687         
688                 
689 
690  
691  
692 
693 __________________________________________________________________________
694 OUTPUT:
695  
696 ASN.1 file generators
697 Boolean WriteAsnModelList(PDNMS pdnmsThis,   Int2 iNumModels,  Int2Ptr i2Vec,  
698                                     CharPtr pcSave,  Byte bSave );
699 Boolean WriteAsnOneModel(PDNMS pdnmsThis,  Int2 iModel,  CharPtr pcSave,  Byte bSave);
700 Boolean WriteAsnAllModel(PDNMS pdnmsThis,  CharPtr pcSave,  Byte bSave);
701 Boolean WriteAsnLocalDict(PDNMS pdnmsThis, CharPtr pcSave,  Byte bSave,  Boolean SaveId);
702 
703 
704 PDB file generators:
705 Int2    WritePDBModelList(PDNMS pdnmsThis,  FILE *pFile,  Int2 iNumModels,  Int2Ptr i2Vec );
706 Int2    WritePDBOneModel(PDNMS pdnmsThis,  FILE *pFile,  Int2 iModel);
707 Int2    WritePDBAllModel(PDNMS pdnmsThis,  FILE *pFile);
708 
709 
710 Kinemage file generators:
711 Int2    WriteKinModelList(PDNMS pdnmsThis,  FILE *pFile,  Int2 iColor, Byte bKinRender,
712                                  Int2 iNumModels,  Int2Ptr i2Vec );
713 Int2    WriteKinOneModel(PDNMS pdnmsThis,  FILE *pFile, Int2 iColor, Byte bKinRender, Int2 iModel);
714 Int2    WriteKinAllModel(PDNMS pdnmsThis, FILE *pFile, Int2 iColor, Byte bKinRender);
715 
716 iColor types:
717 
718 bKinRender types:
719 #define KIN_MULTANIM    0x20  /* forces KIN_COLOR_NUMBER */
720 #define KIN_ALTCONF     0x10  
721 #define KIN_HET         0x08   /* default */
722 #define KIN_RESIDUE     0x04 
723 #define KIN_BACKBONE    0x02   
724 #define KIN_VIRTUAL     0x01   /* default */
725 #define KIN_DEFAULT     0x00  /* forces KIN_VIRTUAL */
726 
727 #define KIN_COLOR_DEFAULT 0  /* forces KIN_COLOR_NUMBER */
728 #define KIN_COLOR_NUMBER  1  /* default */
729 #define KIN_COLOR_TYPE    2 
730 #define KIN_COLOR_TEMP    3  /* forces Temp groups only */ 
731 #define KIN_COLOR_ATOM    4  /* forces Element groups only */
732 
733 
734 
735 
736 
737 
738 __________________________________________________________________________
739 COMPUTATIONAL GOODIES:
740 
741 FloatLo LIBCALL AtomDistanceSq(PMAD pmadFrom, PMAD pmadTo, Int2 iModel, Char cAlt);
742 
743 
744  
745 
746 ___________________________________________________________________________
747 MACROS:
748 
749 The "Is" macros are used to triage PFB nodes and to query their contents
750 as booleans.  You must cast to a PFB if you use these macros with
751 known type data, e.g:
752 
753 if (IsNA((PFB)pmsdThis))
754   {
755     /* this structure contains a Nucleic Acid molecule */
756     /* it may contain other things... */
757   }
758 
759 if (IsNA((PFB)pmmdThis))
760   {
761     /* this molecule is a Nucleic Acid */
762   }
763 
764 Note that macros aren't used in mmdabpi[1-3].c code.  
765 That's because they weren't defined until after that code was written.
766 These are defined in mmdbapi.h.
767 
768 
769 
770 Use these with any PFB node, esp. when doing TraverseAll...
771   IsAtomNode(pfb)      ((int) pfb ->bMe == AM_MAD)
772   IsBondNode(pfb)      ((int) pfb ->bMe == AM_MBD)
773   IsGraphNode(pfb)     ((int) pfb ->bMe == AM_MGD)
774   IsMoleculeNode(pfb)  ((int) pfb ->bMe == AM_MMD)
775   IsObjectNode(pfb)    ((int) pfb ->bMe == AM_MOD)
776   IsDensityNode(pfb)   ((int) pfb ->bMe == AM_MDD)
777   IsStructureNode(pfb) ((int) pfb ->bMe == AM_MSD)
778   IsAtomLocNode(pfb)   ((int) pfb ->bMe == AM_ALD)
779 
780 Use these when IsStructureNode(pfb) OR IsMoleculeNode(pfb) == TRUE 
781   IsIon(pfb)            (pfb ->bWhat & (Byte) AM_ION)
782   IsRNA(pfb)            (pfb ->bWhat & (Byte) AM_RNA)
783   IsDNA(pfb)            (pfb ->bWhat & (Byte) AM_DNA)
784   IsNA(pfb)             ((pfb ->bWhat & (Byte) AM_RNA) || (pfb ->bWhat & (Byte) AM_DNA))
785   IsProtein(pfb)                (pfb ->bWhat & (Byte) AM_PROT)
786   IsNAorProtein(pfb)     ((pfb ->bWhat & (Byte) AM_RNA) || (pfb ->bWhat & (Byte) AM_DNA)\
787  || (pfb ->bWhat & (Byte) AM_PROT))
788   IsWater(pfb)          (pfb ->bWhat & (Byte) AM_WAT)  
789   IsSolvent(pfb)                ((pfb ->bWhat & (Byte) AM_SOL) || (pfb ->bWhat & (Byte) AM_WAT))
790   IsHeterogen(pfb)      (pfb ->bWhat & (Byte) AM_HET)
791   IsOtherPolymer(pfb)   (pfb ->bWhat & (Byte) AM_POLY)
792 
793 Use these when IsGraphNode(pfb) == TRUE 
794   IsGraphRNABase(pfb)   (pfb ->bWhat & (Byte) RES_RNA)
795   IsGraphDNABase(pfb)   (pfb ->bWhat & (Byte) RES_DNA)
796   IsGraphNABase(pfb)    ((pfb ->bWhat & (Byte) RES_RNA) || (pfb ->bWhat & (Byte) RES_DNA))
797   IsGraphAminoAcid(pfb) (pfb ->bWhat & (Byte) RES_AA)
798   IsGraphNAorAA(pfb)     ((pfb ->bWhat & (Byte) RES_RNA) || (pfb ->bWhat & (Byte) RES_DNA)\
799  || (pfb ->bWhat & (Byte) RES_AA))
800  
801 Use these when IsGraphNode(pfb) AND IsGraphAminoAcid(pfb) == TRUE 
802   IsAAInPDBSS(pfb)      (pfb ->bPDBSecStru)
803   IsAAInPDBHelix(pfb)   (pfb ->bPDBSecStru & (Byte) SS_HELIX)
804   IsAAInPDBSheet(pfb)   (pfb ->bPDBSecStru & (Byte) SS_SHEET)
805   IsAAInPDBStrand(pfb)  (pfb ->bPDBSecStru & (Byte) SS_STRAND)
806   IsAAInPDBTurn(pfb)    (pfb ->bPDBSecStru & (Byte) SS_TURN)
807   IsAAInNCBISS(pfb)   (pfb ->bNCBISecStru)
808   IsAAInNCBIHelix(pfb)  (pfb ->bNCBISecStru & (Byte) SS_HELIX)
809   IsAAInNCBISheet(pfb)  (pfb ->bNCBISecStru & (Byte) SS_SHEET)
810   IsAAInNCBIStrand(pfb) (pfb ->bNCBISecStru & (Byte) SS_STRAND)
811   IsAAInNCBITurn(pfb)   (pfb ->bNCBISecStru & (Byte) SS_TURN)
812 
813 
814 Use these when IsAtomNode(pfb) == TRUE 
815   IsAtomBackBone(pfb)     (pfb ->bWhat & (Byte) AM_BACKBONE)
816   IsAtomCAlpha(pfb)       (pfb ->bWhat & (Byte) AM_CALPHA)
817   IsAtomPAlpha(pfb)       (pfb ->bWhat & (Byte) AM_PALPHA)
818   IsAtomAlpha(pfb)        ((pfb ->bWhat & (Byte) AM_CALPHA)  ||  (pfb ->bWhat & (Byte) AM_PALPHA))
819   IsAtomOCarbonyl(pfb)    (pfb ->bWhat & (Byte) AM_OCARBNYL)
820   IsAtomCBeta(pfb)        (pfb ->bWhat & (Byte) AM_CBETA)
821   IsAtomNBeta(pfb)        (pfb ->bWhat & (Byte) AM_NBETA)
822   IsAtomBeta(pfb)        ((pfb ->bWhat & (Byte) AM_CBETA) || (pfb ->bWhat & (Byte) AM_NBETA))
823   IsAtomC1Ribose(pfb)     (pfb ->bWhat & (Byte) AM_C1RIBOSE)
824   IsAtomC4Ribose(pfb)     (pfb ->bWhat & (Byte) AM_C4RIBOSE)
825 
826 returns a CharPtr:
827   AtomPDBName(pfb)         pfb ->pcAName
828 returns an Int1
829   AtomicNumber(pfb)        pfb ->pvnmaLink->choice 
830 
831 
832 Use these when IsBondNode(pfb) == TRUE 
833   IsBondVirtual(pfb)      (pfb ->bWhat & (Byte) BOND_VIRTUAL)
834   IsBondPDouble(pfb)      (pfb ->bWhat & (Byte) BOND_PDOUBLE)
835   IsBondVanderWaal(pfb)   (pfb ->bWhat & (Byte) BOND_VDW)
836   IsBondIonic(pfb)        (pfb ->bWhat & (Byte) BOND_IONIC)
837   IsBondHydrogen(pfb)     (pfb ->bWhat & (Byte) BOND_H)
838   IsBondTriple(pfb)       (pfb ->bWhat & (Byte) BOND_TRIPLE)
839   IsBondDouble(pfb)       (pfb ->bWhat & (Byte) BOND_DOUBLE)
840   IsBondSingle(pfb)       (pfb ->bWhat & (Byte) BOND_SINGLE)
841   IsBondAromatic(pfb)     ((pfb ->bWhat & (Byte) BOND_PDOUBLE) && (pfb ->bWhat & (Byte) BOND_DOUBLE))
842 
843 Use these when IsObjectNode(pfb) == TRUE 
844   IsObjectSphere(pfb)     (pfb ->bWhat & (Byte) OBJ_SPHERE)
845   IsObjectCylinder(pfb)   (pfb ->bWhat & (Byte) OBJ_CYLINDER)
846   IsObjectBrick(pfb)      (pfb ->bWhat & (Byte) OBJ_BRICK)
847   IsObjectTMesh(pfb)      (pfb ->bWhat & (Byte) OBJ_TMESH)
848   IsObjectTriangles(pfb)  (pfb ->bWhat & (Byte) OBJ_TRIANGLES)
849   IsObjectCone(pfb)       (pfb ->bWhat & (Byte) OBJ_CONE)
850 
851 Use these when IsAtomLocNode(pfb) == TRUE 
852 these return FloatLo values
853   AtomLocX(pfb)  pfb ->pflvData[0]
854   AtomLocY(pfb)  pfb ->pflvData[1]
855   AtomLocZ(pfb)  pfb ->pflvData[2]
856 
857 Use when IsStructureNode(pfb) == TRUE
858 returns a CharPtr - which you should copy before use
859   PDBAccession(pfb)  pfb ->pcPDBName
860  

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.