home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Educational / RasMol / Source / molecule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-13  |  14.1 KB  |  468 lines

  1. /* molecule.h
  2.  * RasMol2 Molecular Graphics
  3.  * Roger Sayle, August 1995
  4.  * Version 2.6
  5.  */
  6. #define MAXMASK 40
  7. #define MAXELEM 256
  8. #define MINELEM 29
  9. #define MAXRES  100
  10. #define MINRES  52
  11.  
  12.  
  13. #define IsAmino(x)       ((x)<=23)
  14. #define IsAminoNucleo(x) ((x)<=42)
  15. #define IsNucleo(x)      (((x)>=24) && ((x)<=42))
  16. #define IsProtein(x)     (((x)<=23) || (((x)>=43) && ((x)<=45)))
  17. #define IsDNA(x)         (((x)>=24) && ((x)<=27))
  18. #define IsSolvent(x)     (((x)>=46) && ((x)<=49))
  19. #define IsWater(x)       (((x)==46) || ((x)==47))
  20. #define IsIon(x)         (((x)==48) || ((x)==49))
  21.  
  22. #define IsPyrimidine(x)  (IsCytosine(x) || IsThymine(x))
  23. #define IsPurine(x)      (IsAdenine(x) || IsGuanine(x))
  24. #define IsRNA(x)         (IsNucleo(x) && !IsThymine(x))
  25. #define NucleicCompl(x)  ((x)^3)
  26.  
  27.  
  28. #define IsProline(x)     ((x)==11)
  29. #define IsCysteine(x)    ((x)==17)
  30. #define IsAdenine(x)     ((x)==24)
  31. #define IsCytosine(x)    ((x)==25)
  32. #define IsGuanine(x)     ((x)==26)
  33. #define IsThymine(x)     ((x)==27)
  34. #define IsNADGroup(x)    ((x)==50)
  35. #define IsCOAGroup(x)    ((x)==51)
  36.  
  37.  
  38. #define IsAlphaCarbon(x)     ((x)==1)
  39. #define IsSugarPhosphate(x)  ((x)==7)
  40. #define IsAminoBackbone(x)   ((x)<=3)
  41. #define IsShapelyBackbone(x) ((x)<=7)
  42. #define IsNucleicBackbone(x) (((x)>=7) && ((x)<=18))
  43. #define IsShapelySpecial(x)  ((x)==19)
  44. #define IsCysteineSulphur(x) ((x)==20)
  45.  
  46.  
  47. /*=================*/
  48. /*  Database Flags */
  49. /*=================*/
  50.  
  51. #define SelectFlag      0x01
  52. #define DrawBondFlag    0x0e
  53. #define AllAtomFlag     0x1c
  54. #define HelixFlag       0x03
  55. #define DrawKnotFlag    0x3e
  56. #define WideKnotFlag    0x0e
  57.  
  58. /* Atom Flags */
  59. #define SphereFlag      0x02     /* Sphere representation */
  60. #define HeteroFlag      0x04     /* HETATM record         */
  61. #define HydrogenFlag    0x08     /* Hydrogen atom         */
  62. #define NormAtomFlag    0x10
  63. #define NonBondFlag     0x20
  64. #define BreakFlag       0x40     /* Break in backbone     */
  65.  
  66. /* Bond Flags */
  67. #define WireFlag        0x02     /* Depth-cued wireframe         */
  68. #define DashFlag        0x04     /* Dashed Depth-cued wireframe  */
  69. #define CylinderFlag    0x08     /* Line/Cylinder representation */
  70.  
  71. #define HydrBondFlag    0x00     /* Hydrogen bond [place keeper] */
  72. #define NormBondFlag    0x10
  73. #define DoubBondFlag    0x20
  74. #define TripBondFlag    0x40
  75. #define AromBondFlag    0x80
  76.  
  77.  
  78. /* Group Flags */
  79. #define CystineFlag     0x01     /* Disulphide bonded cysteine  */
  80. #define StrandFlag      0x02     /* Strands representation      */
  81. #define DashStrandFlag  0x04     /* Dash Strands representation */
  82. #define RibbonFlag      0x08     /* Solid Ribbon representation */
  83. #define TraceFlag       0x10     /* Smooth trace representation */
  84. #define CartoonFlag     0x20     /* Richardson protein cartoon  */
  85.  
  86. /* Structure Flags */
  87. #define Helix3Flag      0x01     /* 3,10-Helix structure       */
  88. #define Helix4Flag      0x02     /* Alpha Helix structure      */
  89. #define Helix5Flag      0x03     /* 5-Helix structure          */
  90. #define SheetFlag       0x04     /* Beta Sheet structure       */
  91. #define TurnFlag        0x08     /* Turn Secondary structure   */
  92.  
  93.  
  94. /*=====================*/
  95. /*  Molecule Database  */
  96. /*=====================*/
  97.  
  98. typedef struct _Atom {
  99.         struct _Atom __far *anext;        /* Linked list of atoms  */
  100.         struct _Atom __far *bucket;       /* Sphere Y-Bucket       */
  101.     struct _Atom __far *next;         /* Active Object List    */
  102.         Long   xorg, yorg, zorg;          /* World Co-ordinates    */
  103.         short  x, y, z;                   /* Image Co-ordinates    */
  104.         short  radius;                    /* World Radius          */
  105.         short  serno;                     /* Atom Serial Number    */
  106.         short  temp;                      /* Temperature Factor    */
  107.         short  col;                       /* Atom Colour           */
  108.         void   *label;                    /* Atom Label Structure  */
  109.         Byte   elemno;                    /* Atomic Number         */
  110.         Byte   refno;                     /* ElemDesc index number */
  111.         Byte   flag;                      /* Database flags        */
  112.         char   altl;                      /* Alternate Location    */
  113.         short  irad;                      /* Image Radius          */
  114.         short  mbox;                      /* Shadow Casting NOnce  */
  115.     } Atom;
  116.  
  117.  
  118. typedef struct _Bond {
  119.         struct _Bond __far *bnext;       /* Linked list of bonds  */
  120.         Atom __far *srcatom;             /* Source Atom Ptr       */
  121.         Atom __far *dstatom;             /* Destination Atom Ptr  */
  122.         short radius;                    /* World Radius          */
  123.         short irad;                      /* Image Radius          */
  124.         short col;                       /* Bond Colour           */
  125.         Byte  flag;                      /* Database flags        */
  126.     } Bond;
  127.  
  128. typedef struct _Group {
  129.         struct _Group __far *gnext;       /* Linked list of groups */
  130.         Atom __far *alist;                /* Linked list of atoms  */
  131.         short serno;                      /* Group serial number   */
  132.         short width;                      /* Ribbon Width          */
  133.         short col1;              /* Ribbon Colour #1      */
  134.         short col2;              /* Ribbon Colour #2      */
  135.         char  insert;                     /* PDB insertion code    */
  136.         Byte  refno;                      /* Residue index number  */
  137.         Byte  struc;                      /* Secondary Structure   */
  138.         Byte  flag;                       /* Database flags        */
  139.     } Group;
  140.  
  141. #ifdef APPLEMAC
  142. /* Avoid Name Clash! */
  143. #define Chain ChainSeg
  144. #endif
  145.  
  146. typedef struct _ChainSeg {
  147.         struct _ChainSeg __far *cnext;    /* Linked list of chains     */
  148.         Group __far *glist;               /* Linked list of groups     */
  149.         Bond __far *blist;                /* Linked list of back bonds */
  150.         char ident;                       /* Chain identifier          */
  151.         Byte model;                       /* NMR Model / Symmetry      */
  152.     } Chain;
  153.  
  154. typedef struct _AtomRef {
  155.         Chain __far *chn;
  156.         Group __far *grp;
  157.         Atom  __far *atm;
  158.         } AtomRef;
  159.  
  160. typedef struct _HBond {
  161.         struct _HBond __far *hnext;       /* Ordered list of hbonds   */
  162.         Atom __far *srcCA;                /* Source Alpha Carbon      */
  163.         Atom __far *dstCA;                /* Destination Alpha Carbon */
  164.         Atom __far *dst;                  /* Acceptor [=CO] Atom Ptr  */
  165.         Atom __far *src;                  /* Donor [=NH] Atom Ptr     */
  166.         short energy;                     /* Hydrogen bond energy     */
  167.         short radius;                     /* World Radius             */
  168.         short irad;                       /* Image Radius             */
  169.         Char offset;                      /* Signed Offset            */
  170.         Byte flag;                        /* Database flags           */
  171.         Byte col;                         /* Hydrogen bond colour     */
  172.         } HBond;
  173.  
  174. typedef struct _Molecule {
  175.         HBond __far *slist;               /* Linked list of SS bonds  */
  176.         HBond __far *hlist;               /* Linked list of hbonds    */
  177.         Chain __far *clist;               /* Linked list of chains    */
  178.         Bond __far *blist;                /* Linked list of bonds     */
  179.     } Molecule;
  180.  
  181.  
  182.  
  183. /*========================*/
  184. /* Other Consts & Structs */
  185. /*========================*/
  186.  
  187. #define SourceNone   0
  188. #define SourcePDB    1
  189. #define SourceCalc   2
  190.  
  191. #define SerNoFlag 0x01
  192. #define ResNoFlag 0x02
  193.  
  194. typedef struct {
  195.         short radius;
  196.         char  mask[19];
  197.         Byte  flags;
  198.         Byte  r;
  199.         Byte  g;
  200.         Byte  b;
  201.         } MaskDesc;
  202.  
  203. typedef struct _IntCoord {
  204.         struct _IntCoord __far *inext;
  205.         short na,nb,nc;
  206.         short refno;
  207.         Real dihed;
  208.         Real angle;
  209.         Real dist;
  210.     } IntCoord;
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217. #ifdef MOLECULE
  218. /* Avoid SGI Compiler Warnings! */
  219. char Residue[MAXRES][4] = {
  220.     /*===============*/
  221.     /*  Amino Acids  */
  222.     /*===============*/
  223.  
  224. /* Ordered by Cumulative Frequency in Brookhaven *
  225.  * Protein Databank, December 1991               */
  226.  
  227.           "ALA", /* 8.4% */     "GLY", /* 8.3% */
  228.           "LEU", /* 8.0% */     "SER", /* 7.5% */
  229.           "VAL", /* 7.1% */     "THR", /* 6.4% */
  230.           "LYS", /* 5.8% */     "ASP", /* 5.5% */
  231.           "ILE", /* 5.2% */     "ASN", /* 4.9% */
  232.           "GLU", /* 4.9% */     "PRO", /* 4.4% */
  233.           "ARG", /* 3.8% */     "PHE", /* 3.7% */
  234.           "GLN", /* 3.5% */     "TYR", /* 3.5% */
  235.           "HIS", /* 2.3% */     "CYS", /* 2.0% */
  236.           "MET", /* 1.8% */     "TRP", /* 1.4% */
  237.  
  238.           "ASX", "GLX", "PCA", "HYP",
  239.  
  240.     /*===================*/
  241.     /*  DNA Nucleotides  */
  242.     /*===================*/
  243.           "  A", "  C", "  G", "  T",
  244.  
  245.     /*===================*/
  246.     /*  RNA Nucleotides  */
  247.     /*===================*/
  248.           "  U", " +U", "  I", "1MA", 
  249.           "5MC", "OMC", "1MG", "2MG", 
  250.           "M2G", "7MG", "OMG", " YG", 
  251.           "H2U", "5MU", "PSU",
  252.  
  253.     /*=================*/
  254.     /*  Miscellaneous  */ 
  255.     /*=================*/
  256.           "UNK", "ACE", "FOR", "HOH",
  257.           "DOD", "SO4", "PO4", "NAD",
  258.           "COA"  };
  259.  
  260.  
  261. /* Avoid SGI Compiler Warnings! */
  262. char ElemDesc[MAXELEM][4] = {
  263.     { ' ', 'N', ' ', ' ' },  /* 0*/
  264.     { ' ', 'C', 'A', ' ' },  /* 1*/
  265.     { ' ', 'C', ' ', ' ' },  /* 2*/
  266.     { ' ', 'O', ' ', ' ' },  /* 3*/   /* 0-3   Amino Acid Backbone    */
  267.     { ' ', 'C', '\'', ' ' }, /* 4*/
  268.     { ' ', 'O', 'T', ' ' },  /* 5*/
  269.     { ' ', 'S', ' ', ' ' },  /* 6*/
  270.     { ' ', 'P', ' ', ' ' },  /* 7*/   /* 4-7   Shapely Amino Backbone */
  271.     { ' ', 'O', '1', 'P' },  /* 8*/
  272.     { ' ', 'O', '2', 'P' },  /* 9*/
  273.     { ' ', 'O', '5', '*' },  /*10*/
  274.     { ' ', 'C', '5', '*' },  /*11*/
  275.     { ' ', 'C', '4', '*' },  /*12*/
  276.     { ' ', 'O', '4', '*' },  /*13*/
  277.     { ' ', 'C', '3', '*' },  /*14*/
  278.     { ' ', 'O', '3', '*' },  /*15*/
  279.     { ' ', 'C', '2', '*' },  /*16*/
  280.     { ' ', 'O', '2', '*' },  /*17*/
  281.     { ' ', 'C', '1', '*' },  /*18*/   /* 7-18  Nucleic Acid Backbone  */
  282.     { ' ', 'C', 'A', '2' },  /*19*/   /* 19    Shapely Special        */
  283.     { ' ', 'S', 'G', ' ' },  /*20*/   /* 20    Cysteine Sulphur       */
  284.     { ' ', 'N', '1', ' ' },  /*21*/
  285.     { ' ', 'N', '2', ' ' },  /*22*/
  286.     { ' ', 'N', '3', ' ' },  /*23*/
  287.     { ' ', 'N', '4', ' ' },  /*24*/
  288.     { ' ', 'N', '6', ' ' },  /*25*/
  289.     { ' ', 'O', '2', ' ' },  /*26*/
  290.     { ' ', 'O', '4', ' ' },  /*27*/
  291.     { ' ', 'O', '6', ' ' }   /*28*/   /* 21-28 Nucleic Acid H-Bonding */
  292.     };
  293.  
  294.  
  295.  
  296. char InfoFileName[256];
  297. char InfoClassification[42];
  298. char InfoMoleculeName[80];
  299. char InfoSpaceGroup[11];
  300. char InfoIdentCode[6];
  301.  
  302. Real InfoCellAlpha, InfoCellBeta, InfoCellGamma;
  303. Real InfoCellA, InfoCellB, InfoCellC;
  304.  
  305. int InfoSSBondCount;
  306. int InfoLadderCount;
  307. int InfoChainCount;
  308. int InfoHBondCount;
  309. int InfoHelixCount;
  310. int InfoTurnCount;
  311. Long InfoBondCount;
  312. int InfoStrucSrc;
  313.  
  314. int MainGroupCount,HetaGroupCount;
  315. Long MainAtomCount; 
  316. int HetaAtomCount;
  317.  
  318. Long MinX, MinY, MinZ;
  319. Long MaxX, MaxY, MaxZ;
  320.  
  321. int HMinMaxFlag, MMinMaxFlag;
  322. int MinMainTemp, MaxMainTemp;
  323. int MinHetaTemp, MaxHetaTemp;
  324. int MinMainRes,  MaxMainRes;
  325. int MinHetaRes,  MaxHetaRes;
  326.  
  327. Molecule __far *CurMolecule;
  328. Chain __far *CurChain;
  329. Group __far *CurGroup;
  330. Atom __far *CurAtom;
  331. Atom __far *ConnectAtom;
  332.  
  333. IntCoord __far *IntList;
  334. Molecule __far *Database;
  335. MaskDesc UserMask[MAXMASK];
  336. Long MinHBondDist, MaxHBondDist;
  337. Long MinBondDist,  MaxBondDist;
  338. int AbsMaxBondDist;
  339. int ElemNo,ResNo;
  340. int HasHydrogen;
  341. int MaskCount;
  342. int NMRModel;
  343.  
  344. #else
  345. extern char InfoFileName[256];
  346. extern char Residue[MAXRES][4];
  347. extern char ElemDesc[MAXELEM][4];
  348. extern char InfoClassification[42];
  349. extern char InfoMoleculeName[80];
  350. extern char InfoSpaceGroup[11];
  351. extern char InfoIdentCode[6];
  352.  
  353. extern Real InfoCellAlpha, InfoCellBeta, InfoCellGamma;
  354. extern Real InfoCellA, InfoCellB, InfoCellC;
  355.  
  356. extern int InfoSSBondCount;
  357. extern int InfoLadderCount;
  358. extern int InfoChainCount;
  359. extern int InfoHBondCount;
  360. extern int InfoHelixCount;
  361. extern int InfoTurnCount;
  362. extern Long InfoBondCount;
  363. extern int InfoStrucSrc;
  364.  
  365. extern int MainGroupCount,HetaGroupCount;
  366. extern Long MainAtomCount;
  367. extern int HetaAtomCount;
  368.  
  369. extern Long MinX, MinY, MinZ;
  370. extern Long MaxX, MaxY, MaxZ;
  371.  
  372. extern int HMinMaxFlag, MMinMaxFlag;
  373. extern int MinMainTemp, MaxMainTemp;
  374. extern int MinHetaTemp, MaxHetaTemp;
  375. extern int MinMainRes,  MaxMainRes;
  376. extern int MinHetaRes,  MaxHetaRes;
  377.  
  378. extern Atom __far *ConnectAtom;
  379. extern Molecule __far *CurMolecule;
  380. extern Chain __far *CurChain;
  381. extern Group __far *CurGroup;
  382. extern Atom __far *CurAtom;
  383.  
  384. extern IntCoord __far *IntList;
  385. extern Molecule __far *Database;
  386. extern MaskDesc UserMask[MAXMASK];
  387. extern Long MinHBondDist, MaxHBondDist;
  388. extern Long MinBondDist,  MaxBondDist;
  389. extern int AbsMaxBondDist;
  390. extern int ElemNo,ResNo;
  391. extern int HasHydrogen;
  392. extern int MaskCount;
  393. extern int NMRModel;
  394.  
  395. #ifdef FUNCPROTO
  396. void CreateChain( int );
  397. void CreateGroup( int );
  398. void ProcessGroup( int );
  399. void CreateMolGroup();
  400. int FindResNo( char* );
  401.  
  402. Atom __far *CreateAtom();
  403. Atom __far *FindGroupAtom( Group __far*, int );
  404. void ProcessAtom( Atom __far* );
  405.  
  406. int NewAtomType( char* );
  407. int SimpleAtomType( char* );
  408. int ComplexAtomType( char* );
  409.  
  410. Bond __far *ProcessBond( Atom __far*, Atom __far*, int );
  411. void CreateBond( int, int, int );
  412. void CreateBondOrder( int, int );
  413. void CreateMoleculeBonds( int, int );
  414. void FindDisulphideBridges();
  415. void CalcHydrogenBonds();
  416.  
  417. void InitInternalCoords();
  418. IntCoord __far* AllocInternalCoord();
  419. int ConvertInternal2Cartesian();
  420. void FreeInternalCoords();
  421.  
  422. void DetermineStructure( int );
  423. void RenumberMolecule( int );
  424.  
  425. void InitialiseDatabase();
  426. void DescribeMolecule();
  427. void DestroyDatabase();
  428. void PurgeDatabase();
  429.  
  430. #else /* non-ANSI C compiler */
  431.  
  432. void CreateChain();
  433. void CreateGroup();
  434. void CreateMolGroup();
  435. int FindResNo();
  436.  
  437. Atom __far *CreateAtom();
  438. Atom __far *FindGroupAtom();
  439. void ProcessAtom();
  440.  
  441. int NewAtomType();
  442. int SimpleAtomType();
  443. int ComplexAtomType();
  444.  
  445. Bond __far *ProcessBond();
  446. void CreateBond();
  447. void CreateBondOrder();
  448. void CreateMoleculeBonds();
  449. void FindDisulphideBridges();
  450. void CalcHydrogenBonds();
  451.  
  452. void InitInternalCoords();
  453. IntCoord __far* AllocInternalCoord();
  454. int ConvertInternal2Cartesian();
  455. void FreeInternalCoords();
  456.  
  457. void DetermineStructure();
  458. void RenumberMolecule();
  459.  
  460. void InitialiseDatabase();
  461. void DescribeMolecule();
  462. void DestroyDatabase();
  463. void PurgeDatabase();
  464.  
  465. #endif
  466. #endif
  467.  
  468.