CCL Home Page
Up Directory CCL read_sybyl
#include "utility.h"
#include "newgeo.h"

#define MAX_SYBYL_ATOM_TYPE 31
#define MIN_SYBYL_ATOM_TYPE 1

static char sybyl_mnemonics[MAX_SYBYL_ATOM_TYPE][6] =
   {
   "C.3",	/* 1 */
   "C.2",	/* 2 */
   "C.ar",	/* 3 */
   "C.1",	/* 4 */
   "N.3",	/* 5 */ 
   "N.2",	/* 6 */
   "N.1",	/* 7 */  
   "O.3",	/* 8 */
   "O.2",	/* 9 */
   "S.3",	/*10 */
   "N.ar",	/*11 */ 
   "P.3",	/*12 */
   "H",		/*13 */ 
   "Br",	/*14 */
   "Cl",	/*15 */ 
   "F",		/*16 */
   "I",		/*17 */ 
   "S.2",	/*18 */
   "N.pl3",	/*19 */ 
   "LP",	/*20 */
   "Na",	/*21 */ 
   "K",		/*22 */
   "Ca",	/*23 */ 
   "Li",	/*24 */
   "Al",	/*25 */
   "Du",	/*26 */
   "Si",	/*27 */
   "N.am",	/*28 */
   "S.O",	/*29 */
   "S.O2",	/*30 */
   "N.4" 	/*31 */
   };

static char sybyl_elements[MAX_SYBYL_ATOM_TYPE][3] =
   {
   "C ",	/* 1 */
   "C ",	/* 2 */
   "C ",	/* 3 */
   "C ",	/* 4 */
   "N ",	/* 5 */ 
   "N ",	/* 6 */
   "N ",	/* 7 */  
   "O ",	/* 8 */
   "O ",	/* 9 */
   "S ",	/*10 */
   "N ",	/*11 */ 
   "P ",	/*12 */
   "H ",	/*13 */ 
   "Br",	/*14 */
   "Cl",	/*15 */ 
   "F ",	/*16 */
   "I ",	/*17 */ 
   "S ",	/*18 */
   "N ",	/*19 */ 
   "LP",	/*20 */
   "Na",	/*21 */ 
   "K ",	/*22 */
   "Ca",	/*23 */ 
   "Li",	/*24 */
   "Al",	/*25 */
   "Du",	/*26 */
   "Si",	/*27 */
   "N ",	/*28 */
   "S ",	/*29 */
   "S ",	/*30 */
   "N " 	/*31 */
   };

int read_sybyl_mol(infile)
/*============================================================================*/
/* This routine reads in SYBYL MOL file from  a disk file .
/* AUTHOR:    John R. Hurst, Data Management, 051088
/* LAST MODIFICATION: 2 APRIL 1992 MVG (ADDED READ MOL2 CAPABILITY)
/*============================================================================*/
FILE *infile;
{
  int bond_cnt;
  char line[130];	/* Multipurpose character string */
  int i;		/* loop variable */
  int atom1;		/* FIRST ATOM IN BOND. */
  int atom2;		/* SECOND ATOM IN BOND. */

  /* READ IN THE HEADER. */
  if (fgets(line,sizeof line,infile) == NULL) return(FALSE);
  atom_cnt = 0;
  if (sscanf(line,"%hd",&atom_cnt)!=1) return(errmsg("Reading header",FALSE));	/* GET THE TOTAL NUMBER OF ATOMS. */
  strncpy(source_title,&line[18],20);	/* GET THE MOLECULE NAME AS TITLE. */
  source_title[20]='\0';		/* ADD NULL THAT STRNCPY LEAVES OFF. */
  notrail(source_title,' ');

  /* READ IN EACH ATOM OF THE GEOMETRY DEFINITION. */
  for (i=0; iMOLECULE")==0)
         {
         /* GRAB MOLECULE NAME, AND NUMBER OF ATOMS/BONDS. */
         if (fgets(source_title,sizeof source_title,infile)==NULL)
            return(errmsg("Reading molecule name",FALSE));
         if (fgets(line,sizeof line,infile)==NULL)
            return(errmsg("Reading number of atoms and bonds",FALSE));
         if (sscanf(line,"%hd %d",&atom_cnt,&bond_cnt)!=2)
            return(errmsg("Reading number of atoms and bonds",FALSE));

         /* SKIP MOLECULE TYPE, CHARGE TYPE, AND STATUS. */
         if (fgets(line,sizeof line,infile)==NULL)
            return(errmsg("Reading molecule type",FALSE));
         if (fgets(line,sizeof line,infile)==NULL)
            return(errmsg("Reading molecule charge type",FALSE));
         if (fgets(line,sizeof line,infile)==NULL)
            return(errmsg("Reading molecule status bits",FALSE));

         /* GET THE COMMENT LINE. */
         if (fgets(header_text[0],sizeof header_text[0],infile)==NULL)
            return(errmsg("Reading molecule comment",FALSE));
         }

      else if (strcmp(line,"@ATOM")==0)
         {
         /* GRAB THE DEFINITION OF EACH ATOM. */
         for (natom=0; natomBOND")==0)
         {
         /* GRAB THE DEFINITION OF EACH BOND. */
         for (nbond=0; nbond=MIN_SYBYL_ATOM_TYPE)
      return(sybyl_mnemonics[atom_type-1]);
   else return("Bad");
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 4847 times since Sat Apr 17 21:58:50 1999 GMT