1 /*****
2   This file is part of the Babel Program
3 Copyright (C) 1992-96 W. Patrick Walters and Matthew T. Stahl
4 All Rights Reserved
5 All Rights Reserved
6 All Rights Reserved
7 All Rights Reserved
8 
9   For more information please contact :
10 
11   babel@mercury.aichem.arizona.edu
12   ----------------------------------------------------------------------------
13   FILE : rdalch.c
14   AUTHOR(S) : Pat Walters
15   DATE : 12-92
16   PURPOSE : routines to read an Alchemy file
17   ******/
18 
19 #include "bbltyp.h"
20 
read_alchemy(FILE * file1,ums_type * mol)21 int read_alchemy(FILE *file1, ums_type *mol)
22 {
23   int i;
24   char input_line[BUFF_SIZE];
25   char temp_type[5];
26   char bo_string[10];
27   int column;
28 
29   fgets(input_line,sizeof(input_line),file1);
30   sscanf(input_line,"%d %*s %d",
31 	 &Atoms,
32 	 &Bonds);
33 
34   ShowProgress(Atoms,"Reading Atoms");
35   initialize_ums(&mol);
36 
37   column = locate_input_type("ALC");
38   for (i = 1; i <= Atoms; i ++)
39   {
40     UpdateProgress();
41     fgets(input_line,sizeof(input_line),file1);
42     sscanf(input_line,"%*d %s %lf %lf %lf",
43 	   temp_type,
44 	   &X(i),
45 	   &Y(i),
46 	   &Z(i));
47     Atomic_number(i) = get_input_type(i,column,temp_type,Type(i),dummy);
48   }
49   for (i = 0; i < Bonds; i++)
50   {
51     fgets(input_line,sizeof(input_line),file1);
52     sscanf(input_line,"%*d%d%d%s",&Start(i),&End(i),bo_string);
53     Bond_order(i) = translate_alchemy_bond_order(bo_string);
54   }
55   dissect_connection_table(mol);
56   return(TRUE);
57 }
58 
translate_alchemy_bond_order(char * bo_string)59 int translate_alchemy_bond_order(char *bo_string)
60 {
61   char err_string[50];
62 
63   if EQ(bo_string,"SINGLE")
64     return(1);
65   if EQ(bo_string,"DOUBLE")
66     return(2);
67   if EQ(bo_string,"TRIPLE")
68     return(3);
69   if EQ(bo_string,"AROMATIC")
70     return(5);
71   sprintf(err_string,"No bond type for Alchemy label %s",bo_string);
72   return(1);
73 }
74 
75 
76 
77