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 14 FILE : read_mm2.c 15 AUTHOR(S) : Pat Walters 16 DATE : 10-92 17 PURPOSE : Routines to read an mm2 output file 18 19 ******/ 20 21 #include "bbltyp.h" 22 23 int read_mm2(FILE * file1,ums_type * mol)24 read_mm2(FILE *file1, ums_type *mol) 25 { 26 int i,j = 0; 27 char the_line[BUFF_SIZE]; 28 double strain; 29 char temp1[5],temp2[5]; 30 int start, end; 31 int is_odd = FALSE; 32 int column; 33 34 fgets(the_line,sizeof(the_line),file1); 35 fgets(the_line,sizeof(the_line),file1); 36 sscanf(the_line,"%lf",&strain); 37 fgets(the_line,sizeof(the_line),file1); 38 sscanf(the_line,"%d%d",&Atoms,&Bonds); 39 40 ShowProgress(Atoms,"Reading Atoms"); 41 initialize_ums(&mol); 42 Energy = strain; 43 for (i= 1; i <= Atoms; i ++) 44 Valence(i) = 0; 45 46 if (Atoms % 2 != 0) 47 { 48 is_odd = TRUE; 49 Atoms -= 1; 50 } 51 52 column = locate_input_type("MM2"); 53 for (i= 1; i <= Atoms; i+=2) 54 { 55 UpdateProgress(); 56 j = i + 1; 57 fgets(the_line,sizeof(the_line),file1); 58 sscanf(the_line,"%lf%lf%lf%s%lf%lf%lf%s", 59 &X(i),&Y(i),&Z(i),temp1,&X(j),&Y(j),&Z(j),temp2); 60 61 Atomic_number(i) = get_input_type(i,column,temp1,Type(i),dummy); 62 Atomic_number(j) = get_input_type(j,column,temp2,Type(j),dummy); 63 } 64 65 if (is_odd) 66 { 67 Atoms += 1; 68 fgets(the_line,sizeof(the_line),file1); 69 sscanf(the_line,"%lf%lf%lf%s",&X(Atoms),&Y(Atoms),&Z(Atoms),temp2); 70 Atomic_number(Atoms) = get_input_type(Atoms,column,temp2,Type(Atoms),dummy); 71 } 72 73 ShowProgress(Bonds,"Reading Bonds"); 74 j = 0; 75 for (i = 0; i < Bonds; i ++) 76 { 77 UpdateProgress(); 78 fgets(the_line,sizeof(the_line),file1); 79 sscanf(the_line,"%d%d",&start,&end); 80 Start(j) = start; 81 End(j) = end; 82 j++; 83 } 84 assign_bond_order(mol); 85 dissect_connection_table(mol); 86 Bonds = j; 87 return(TRUE); 88 } 89 90 91 92 93 94 95 96 97 98 99 100 101 102