コード例 #1
0
ファイル: parmcal.c プロジェクト: tianhe2/mAMBER
void readangleparm(char *filename)
{
	int mindex = -1;
	int bindex = 0;
	int aindex = 0;
	int num = 0;
	FILE *fp;
	char line[MAXCHAR];

	if ((fp = fopen(filename, "r")) == NULL) {
		printf("\n Cannot open the angle parameter file %s in readangleparm(), exit", filename);
		return;
	}
	for (;;) {
		if (fgets(line, MAXCHAR, fp) == NULL)
			break;
		num++;
		if (mindex == -1 && num == 1) {
			mindex = 1;
			continue;
		}
		if (mindex == 1 && spaceline(line) == 1) {
			mindex = 0;
			num = 0;
			bindex = -1;
			continue;
		}
		if (bindex == -1 && num == 1) {
			bindex = 1;
			continue;
		}
		if (bindex == 1 && spaceline(line) == 1) {
			bindex = 0;
			aindex = 1;
			continue;
		}
		if (aindex == 1 && spaceline(line) == 1) {
			aindex = 0;
			break;
		}
		if (aindex == 1) {
			angleparm[angleparmnum].name1[0] = line[0];
			angleparm[angleparmnum].name1[1] = line[1];
			angleparm[angleparmnum].name2[0] = line[3];
			angleparm[angleparmnum].name2[1] = line[4];
			angleparm[angleparmnum].name3[0] = line[6];
			angleparm[angleparmnum].name3[1] = line[7];
			sscanf(&line[8], "%lf%lf", &angleparm[angleparmnum].force,
				   &angleparm[angleparmnum].angle);
			angleparmnum++;
			if(angleparmnum >= 10 * MAXATOMTYPE * MAXATOMTYPE) {
				fprintf(stdout, "Error, the number of angle parameters (%ld) exceed 10 * MAXATOMTYPE * MAXATOMTYPE,\nincrease MAXATOMTYPE (%d) in define.h\n", angleparmnum, MAXATOMTYPE);
			}
		}
	}
	fclose(fp);
}
コード例 #2
0
ファイル: sqmout.c プロジェクト: choderalab/ambermini
void rsqmout_coord(char *filename, ATOM * atom) {
	/* int i,j; */
	int flag;
	int number = 0;
	int tmpint1, tmpint2;
	FILE *fpout;
	char tmpchar1[MAXCHAR];
	char tmpchar2[MAXCHAR];
	char tmpchar3[MAXCHAR];
	char tmpchar4[MAXCHAR];
	char tmpchar5[MAXCHAR];
	char tmpchar6[MAXCHAR];
	char tmpchar7[MAXCHAR];
	char line[MAXCHAR];
	double tmpfloat1;
	double tmpfloat2;
	double tmpfloat3;

	if ((fpout = fopen(filename, "r")) == NULL) {
		fprintf(stdout, "Cannot open sqm output file: %s in rsqmout(), exit\n", filename);
		exit(1);
	}
	flag = 0;

	for (;;) {
		if (fgets(line, MAXCHAR, fpout) == NULL)
			break;

		sscanf(line, "%s%s%s%s%s%s%s", tmpchar1, tmpchar2, tmpchar3,
			   tmpchar4, tmpchar5, tmpchar6, tmpchar7);
		if (strcmp(tmpchar1, "Final") == 0 && strcmp(tmpchar2, "Structure") == 0) {
			flag = 1;	
			continue;
		}
		if (flag == 1 && strcmp("QM_NO.", tmpchar2) == 0
			      && strcmp("MM_NO.", tmpchar3) == 0
			      && strcmp("ATOM",   tmpchar4) == 0
			      && strcmp("X",      tmpchar5) == 0
			      && strcmp("Y",      tmpchar6) == 0
			      && strcmp("Z",      tmpchar7) == 0) {
			flag = 2;
			continue;
		}
		if (flag == 2 && spaceline(line) == 1) break;
		if (flag == 2) {
			sscanf(line, "%s%d%d%s%lf%lf%lf", tmpchar1, &tmpint1, &tmpint2, tmpchar2, &tmpfloat1, &tmpfloat2, &tmpfloat3);
			atom[number].x = tmpfloat1;
			atom[number].y = tmpfloat2;
			atom[number].z = tmpfloat3;
			number++;
		}
	}
	fclose(fpout);
}
コード例 #3
0
ファイル: mopcrt.c プロジェクト: choderalab/ambermini
/* MOPAC CRT */
int rmopcrt(char *filename, int *atomnum, ATOM atom[], CONTROLINFO cinfo,
			MOLINFO minfo)
{
	FILE *fpin;
	int index;
	int numatom;
	int tmpint1, tmpint2, tmpint3;
	int overflow_flag = 0;
	char line[MAXCHAR];
	char tmpchar[20];
	double tmpfloat1, tmpfloat2, tmpfloat3;

	if ((fpin = fopen(filename, "r")) == NULL) {
		fprintf(stdout, "Cannot open file %s to read in rmopcrt(), exit\n", filename);
		exit(1);
	}
	initial(cinfo.maxatom, atom, minfo.resname);
	index = 0;
	numatom = 0;
	for (;;) {
		if (fgets(line, MAXCHAR, fpin) == NULL) {
/*       printf("\nFinished reading %s file.", cinfo.ifilename); */
			break;
		}
		index++;
		if (index < 4)
			continue;
		sscanf(line, "%s%lf%d%lf%d%lf%d", tmpchar, &tmpfloat1, &tmpint1,
			   &tmpfloat2, &tmpint2, &tmpfloat3, &tmpint3);
		if (spaceline(line) == 1)
			break;
		if (overflow_flag == 0) {
			strcpy(atom[numatom].name, tmpchar);
			atom[numatom].x = tmpfloat1;
			atom[numatom].y = tmpfloat2;
			atom[numatom].z = tmpfloat3;
		}
		numatom++;
		if (numatom >= cinfo.maxatom && overflow_flag == 0) {
			printf
				("\nInfo: the atom number exceeds the MAXATOM, reallocate memory automatically");
			overflow_flag = 1;
		}
	}
	fclose(fpin);
	*atomnum = numatom;
/* printf("\n atom number is  %5d", *atomnum); */
	return overflow_flag;
}
コード例 #4
0
ファイル: gcrt.c プロジェクト: tianhe2/mAMBER
/* GCRT */
int rgcrt(char *filename, int *atomnum, ATOM * atom, CONTROLINFO cinfo,
		  MOLINFO minfo)
{
	FILE *fpin;
	int i, index;
	int nameindex;
	int numatom;
	int read_charge = 1;
	int overflow_flag = 0;
	char tmpchar[MAXCHAR];
	char line[MAXCHAR];


	if ((fpin = fopen(filename, "r")) == NULL) {
		fprintf(stdout, "Cannot open the gcrt file %s to read, exit\n", filename);
		exit(1);
	}
	initial(cinfo.maxatom, atom, minfo.resname);
	index = 0;
	numatom = 0;
	nameindex = -1;
	for (;;) {
		if (fgets(line, MAXCHAR, fpin) == NULL) {
			break;
		}
		if (spaceline(line) == 1 || strlen(line) <= 1) {
			index++;
			continue;
		}
		if (index == 0 || index == 1) continue;
		if (read_charge ==1 && index == 2) {
			sscanf(line, "%d%d", &(minfo.icharge), &(minfo.multiplicity));
			read_charge = 0;
			continue;
		}
		if (index == 3) {
			break;
		}
		sscanf(line, "%s", tmpchar);
		if (nameindex == -1) {
			if (tmpchar[0] >= '0' && tmpchar[0] <= '9')
				nameindex = 0;
			else
				nameindex = 1;
		}
		if (overflow_flag == 0) {
			if (nameindex == 0)
				sscanf(line, "%d%lf%lf%lf", &atom[numatom].atomicnum,
					   &atom[numatom].x, &atom[numatom].y,
					   &atom[numatom].z);
			else
				sscanf(line, "%s%lf%lf%lf", atom[numatom].name,
					   &atom[numatom].x, &atom[numatom].y,
					   &atom[numatom].z);
		}
		numatom++;
		if (numatom >= cinfo.maxatom && overflow_flag == 0) {
			printf
				("\nInfo: the atom number exceeds the MAXATOM, reallocate memory automatically");
			overflow_flag = 1;
		}
	}
	*atomnum = numatom;
	if (nameindex == 0) {
		element(*atomnum, atom);
		for (i = 0; i < *atomnum; i++)
			strcpy(atom[i].name, atom[i].element);
	}
	if (nameindex == 1)
		atomicnum(*atomnum, atom);
/* printf("\n atom number is  %5d", *atomnum); */
	fclose(fpin);
	return overflow_flag;
}
コード例 #5
0
ファイル: gzmat.c プロジェクト: luolingqi/fragmap_2
/* GZMAT */
int rgzmat(char *filename, int *atomnum, ATOM * atom, CONTROLINFO cinfo,
		   MOLINFO minfo)
{
        typedef struct {
                char name[30];
        } STRNAME;

	FILE *fpin;
	int i, j, index, index0;
	int overflow_flag = 0;
	int findindex;
	int numatom;
	STRNAME *bondstr;	
	STRNAME *anglestr;	
	STRNAME *twiststr;	
	char tmpchar1[10];
	char tmpchar2[10];
	char line[MAXCHAR];


	if ((fpin = fopen(filename, "r")) == NULL) {
		fprintf(stderr, "Cannot open file %s, exit\n", filename);
		exit(1);
	}
        bondstr = (STRNAME *) malloc(sizeof(STRNAME) * (cinfo.maxatom +10));
        if (bondstr == NULL) {
                fprintf(stderr, "memory allocation error for *bondstr in rgzmat()\n");
                exit(0);
        }
        anglestr = (STRNAME *) malloc(sizeof(STRNAME) * (cinfo.maxatom +10));
        if (anglestr == NULL) {
                fprintf(stderr, "memory allocation error for *anglestr in rgzmat()\n");
                exit(0);
        }
        twiststr = (STRNAME *) malloc(sizeof(STRNAME) * (cinfo.maxatom +10));
        if (twiststr == NULL) {
                fprintf(stderr, "memory allocation error for *twiststr in rgzmat()\n");
                exit(0);
        }

	initial(cinfo.maxatom, atom, minfo.resname);
	index = 0;
	index0 = 1;
	numatom = 0;
	for (;;) {
		if (fgets(line, MAXCHAR, fpin) == NULL) {
/*       printf("\nFinished reading %s file.", cinfo.ifilename); */
			break;
		}
		if (spaceline(line) == 1) {
			index++;
			continue;
		}
		if (index >= 2)
			index++;
		if (index <= 3)
			continue;
		if (index >= 4) {
			if (spaceline(line) == 1 || strncmp(line, "Vari", 4) == 0
				|| strncmp(line, "vari", 4) == 0)
				index0 = -1;
			if (strncmp(line, "Const", 5) == 0
				|| strncmp(line, "const", 5) == 0)
				index0 = -1;
		}
		if (index == 4) {
			if (overflow_flag == 0)
				sscanf(line, "%s", atom[numatom].name);
			numatom++;
			if (numatom >= cinfo.maxatom && overflow_flag == 0) {
				printf
					("\nInfo: the atom number exceeds the MAXATOM, reallocate memory automatically");
				overflow_flag = 1;
			}
			continue;
		}
		if (index == 5) {
			if (overflow_flag == 0)
				sscanf(line, "%s%d%s", atom[numatom].name,
					   &atom[numatom].bondatom, bondstr[numatom].name);
			numatom++;
			if (numatom >= cinfo.maxatom && overflow_flag == 0) {
				printf
					("\nInfo: the atom number exceeds the MAXATOM, reallocate memory automatically");
				overflow_flag = 1;
			}
			continue;
		}
		if (index == 6) {
			if (overflow_flag == 0)
				sscanf(line, "%s%d%s%d%s", atom[numatom].name,
					   &atom[numatom].bondatom, bondstr[numatom].name,
					   &atom[numatom].angleatom, anglestr[numatom].name);
			numatom++;
			if (numatom >= cinfo.maxatom && overflow_flag == 0) {
				printf
					("\nInfo: the atom number exceeds the MAXATOM, reallocate memory automatically");
				overflow_flag = 1;
			}
			continue;
		}
		if (index0 != -1) {
			if (overflow_flag == 0)
				sscanf(line, "%s%d%s%d%s%d%s", atom[numatom].name,
					   &atom[numatom].bondatom, bondstr[numatom].name,
					   &atom[numatom].angleatom, anglestr[numatom].name,
					   &atom[numatom].twistatom, twiststr[numatom].name);
			numatom++;
			if (numatom >= cinfo.maxatom && overflow_flag == 0) {
				printf
					("\nInfo: the atom number exceeds the MAXATOM, reallocate memory automatically");
				overflow_flag = 1;
			}

			continue;
		}
		if (index0 == -1) {
			sscanf(line, "%s%s", tmpchar1, tmpchar2);
			for (i = 1; i < numatom; i++) {
				findindex = 1;
				for (j = 0; j < strlen(bondstr[i].name); j++)
					if (bondstr[i].name[j] != tmpchar1[j]) {
						findindex = 0;
						break;
					}
				if (findindex == 1) {
					strcpy(bondstr[i].name, tmpchar2);
					break;
				}

			}
			for (i = 2; i < numatom; i++) {
				findindex = 1;
				for (j = 0; j < strlen(anglestr[i].name); j++)
					if (anglestr[i].name[j] != tmpchar1[j]) {
						findindex = 0;
						break;
					}
				if (findindex == 1) {
					strcpy(anglestr[i].name, tmpchar2);
					break;
				}
			}
			for (i = 3; i < numatom; i++) {
				findindex = 1;
				for (j = 0; j < strlen(twiststr[i].name); j++)
					if (twiststr[i].name[j] != tmpchar1[j]) {
						findindex = 0;
						break;
					}
				if (findindex == 1) {
					strcpy(twiststr[i].name, tmpchar2);
					break;
				}
			}
		}
	}
	atom[1].bondatom--;
	atom[2].bondatom--;
	atom[2].angleatom--;
	for (i = 3; i < numatom; i++) {
		atom[i].bondatom--;
		atom[i].angleatom--;
		atom[i].twistatom--;
	}
	for (i = 1; i < numatom; i++)
		atom[i].bond = atof(bondstr[i].name);
	for (i = 2; i < numatom; i++)
		atom[i].angle = atof(anglestr[i].name);
	for (i = 3; i < numatom; i++)
		atom[i].twist = atof(twiststr[i].name);
	*atomnum = numatom;
/* printf("\n atom number is  %5d", *atomnum); */
	fclose(fpin);
	free(bondstr);
	free(anglestr);
	free(twiststr);
	return overflow_flag;

}
コード例 #6
0
ファイル: parmjoin.c プロジェクト: luolingqi/fragmap_2
void readfrcmod(char *filename)
{
	int mindex = 0;
	int bindex = 0;
	int aindex = 0;
	int tindex = 0;
	int iindex = 0;
	int vindex = 0;
	FILE *fp;
	char line[MAXCHAR];
	if ((fp = fopen(filename, "r")) == NULL) {
		printf("\n Cannot open file %s, exit", filename);
		return;
	}
	for (;;) {
		if (fgets(line, MAXCHAR, fp) == NULL)
			break;
		if (strncmp("MASS", &line[0], 4) == 0) {
			mindex = 1;
			continue;
		}
		if (strncmp("BOND", &line[0], 4) == 0) {
			bindex = 1;
			continue;
		}
		if (strncmp("ANGL", &line[0], 4) == 0) {
			aindex = 1;
			continue;
		}
		if (strncmp("DIHE", &line[0], 4) == 0) {
			tindex = 1;
			continue;
		}
		if (strncmp("IMPR", &line[0], 4) == 0) {
			iindex = 1;
			continue;
		}
		if (strncmp("NONB", &line[0], 4) == 0) {
			vindex = 1;
			continue;
		}
		if (mindex == 1 && spaceline(line) == 1)
			mindex = 0;
		if (bindex == 1 && spaceline(line) == 1)
			bindex = 0;
		if (aindex == 1 && spaceline(line) == 1)
			aindex = 0;
		if (tindex == 1 && spaceline(line) == 1)
			tindex = 0;
		if (iindex == 1 && spaceline(line) == 1)
			iindex = 0;
		if (vindex == 1 && spaceline(line) == 1)
			vindex = 0;
		if (mindex == 1) {
			sscanf(line, "%s", atomtype[atomtypenum].name);
			strcpy(atomtype[atomtypenum].parm, line);
			atomtypenum++;
			if (atomtypenum >= maxatomtype) {
				maxatomtype += MAX_FF_ATOMTYPE;
				atomtype =
					(ATOMTYPE *) realloc(atomtype,
										 sizeof(ATOMTYPE) * maxatomtype);
				if (atomtype == NULL) {
					fprintf(stderr,
							"memory allocation error for *atomtype\n");
					exit(0);
				}
			}

		}
		if (bindex == 1) {
			bondparm[bondparmnum].name1[0] = line[0];
			bondparm[bondparmnum].name1[1] = line[1];
			bondparm[bondparmnum].name2[0] = line[3];
			bondparm[bondparmnum].name2[1] = line[4];
			strcpy(bondparm[bondparmnum].parm, line);
			bondparmnum++;
			if (bondparmnum >= maxbondparm) {
				maxbondparm += MAX_FF_BOND;
				bondparm =
					(BOND_FF *) realloc(bondparm,
										sizeof(BOND_FF) * maxbondparm);
				if (bondparm == NULL) {
					fprintf(stderr,
							"memory allocation error for *bondparm\n");
					exit(0);
				}
			}

		}
		if (aindex == 1) {
			angleparm[angleparmnum].name1[0] = line[0];
			angleparm[angleparmnum].name1[1] = line[1];
			angleparm[angleparmnum].name2[0] = line[3];
			angleparm[angleparmnum].name2[1] = line[4];
			angleparm[angleparmnum].name3[0] = line[6];
			angleparm[angleparmnum].name3[1] = line[7];
			strcpy(angleparm[angleparmnum].parm, line);
			angleparmnum++;
			if (angleparmnum >= maxangleparm) {
				maxangleparm += MAX_FF_ANGLE;
				angleparm =
					(ANGLE *) realloc(angleparm,
									  sizeof(ANGLE) * maxangleparm);
				if (angleparm == NULL) {
					fprintf(stderr,
							"memory allocation error for *angleparm\n");
					exit(0);
				}
			}
		}
		if (tindex == 1) {
			torsionparm[torsionparmnum].name1[0] = line[0];
			torsionparm[torsionparmnum].name1[1] = line[1];
			torsionparm[torsionparmnum].name2[0] = line[3];
			torsionparm[torsionparmnum].name2[1] = line[4];
			torsionparm[torsionparmnum].name3[0] = line[6];
			torsionparm[torsionparmnum].name3[1] = line[7];
			torsionparm[torsionparmnum].name4[0] = line[9];
			torsionparm[torsionparmnum].name4[1] = line[10];
			strcpy(torsionparm[torsionparmnum].parm, line);
			torsionparmnum++;
			if (torsionparmnum >= maxtorsionparm) {
				maxtorsionparm += MAX_FF_TORSION;
				torsionparm =
					(TORSION *) realloc(torsionparm,
										sizeof(TORSION) * maxtorsionparm);
				if (torsionparm == NULL) {
					fprintf(stderr,
							"memory allocation error for *torsionparm\n");
					exit(0);
				}
			}
		}
		if (iindex == 1) {
			improperparm[improperparmnum].name1[0] = line[0];
			improperparm[improperparmnum].name1[1] = line[1];
			improperparm[improperparmnum].name2[0] = line[3];
			improperparm[improperparmnum].name2[1] = line[4];
			improperparm[improperparmnum].name3[0] = line[6];
			improperparm[improperparmnum].name3[1] = line[7];
			improperparm[improperparmnum].name4[0] = line[9];
			improperparm[improperparmnum].name4[1] = line[10];
			strcpy(improperparm[improperparmnum].parm, line);
			improperparmnum++;
			if (improperparmnum >= maximproperparm) {
				maximproperparm += MAX_FF_IMPROPER;
				improperparm =
					(IMPROPER *) realloc(improperparm,
										 sizeof(IMPROPER) *
										 maximproperparm);
				if (improperparm == NULL) {
					fprintf(stderr,
							"memory allocation error for *improperparm\n");
					exit(0);
				}
			}
		}

		if (vindex == 1) {
			sscanf(line, "%s", vdwparm[vdwparmnum].name);
			strcpy(vdwparm[vdwparmnum].parm, line);
			vdwparmnum++;
			if (vdwparmnum >= maxvdwparm) {
				maxvdwparm += MAX_FF_VDW;
				vdwparm =
					(VDW *) realloc(vdwparm, sizeof(VDW) * maxvdwparm);
				if (vdwparm == NULL) {
					fprintf(stderr,
							"memory allocation error for *vdwparm\n");
					exit(0);
				}
			}
		}
	}
	fclose(fp);
}
コード例 #7
0
ファイル: parmjoin.c プロジェクト: luolingqi/fragmap_2
void join(char *filename1, char *filename2)
{
	FILE *fp1, *fp2;
	char line[MAXCHAR];
	int mindex = 0;
	int bindex = 0;
	int aindex = 0;
	int tindex = 0;
	int iindex = 0;
	int vindex = 0;

	if ((fp1 = fopen(filename1, "r")) == NULL) {
		printf("\n Cannot open file %s, exit", filename1);
		return;
	}
	if ((fp2 = fopen(filename2, "w")) == NULL) {
		printf("\n Cannot open file %s, exit", filename2);
		return;
	}

	for (;;) {
		if (fgets(line, MAXCHAR, fp1) == NULL)
			break;
		if (vindex == 1 && strncmp(line, "MOD", 3) == 0)
			vindex = 2;
		if (spaceline(line) == 1) {
			if (mindex == 0)
				mindex = 1;
			if (mindex == 2 && bindex == 0)
				bindex = 1;
			if (bindex == 2 && aindex == 0)
				aindex = 1;
			if (aindex == 2 && tindex == 0)
				tindex = 1;
			if (tindex == 2 && iindex == 0)
				iindex = 1;
			if (iindex == 2 && vindex == 0)
				vindex = 1;
			if (vindex == 2)
				vindex = 3;
		}
		if (vindex == 2 && strncmp(line, "END", 3) == 0)
			vindex = 3;
		if (mindex == 1) {
			for (i = 0; i < atomtypenum; i++)
				if (atomtypeindex[i] == 0)
					fprintf(fp2, "%s", atomtype[i].parm);
			fprintf(fp2, "\n");
			mindex = 2;
			continue;
		}
		if (bindex == 1) {
			for (i = 0; i < bondparmnum; i++)
				if (bondparmindex[i] == 0)
					fprintf(fp2, "%s", bondparm[i].parm);
			fprintf(fp2, "\n");
			bindex = 2;
			continue;
		}

		if (aindex == 1) {
			for (i = 0; i < angleparmnum; i++)
				if (angleparmindex[i] == 0)
					fprintf(fp2, "%s", angleparm[i].parm);
			fprintf(fp2, "\n");
			aindex = 2;
			continue;
		}

		if (tindex == 1) {
			for (i = 0; i < torsionparmnum; i++)
				if (torsionparmindex[i] == 0)
					fprintf(fp2, "%s", torsionparm[i].parm);
			fprintf(fp2, "\n");
			tindex = 2;
			continue;
		}
		if (iindex == 1) {
			for (i = 0; i < improperparmnum; i++)
				if (improperparmindex[i] == 0)
					fprintf(fp2, "%s", improperparm[i].parm);
			fprintf(fp2, "\n");
			iindex = 2;
			continue;
		}
		if (vindex == 3) {
			for (i = 0; i < vdwparmnum; i++)
				if (vdwparmindex[i] == 0)
					fprintf(fp2, "%s", vdwparm[i].parm);
			fprintf(fp2, "\n");
			vindex = -1;
			continue;
		}
		fprintf(fp2, "%s", line);
	}
	fclose(fp1);
	fclose(fp2);
}
コード例 #8
0
ファイル: parmjoin.c プロジェクト: luolingqi/fragmap_2
void check(char *filename)
{
	int mindex = -1;
	int bindex = 0;
	int aindex = 0;
	int tindex = 0;
	int iindex = 0;
	int vindex = 0;
	int num = 0;
	FILE *fp;
	char line[MAXCHAR];
	char tmpchar[5];

	if ((fp = fopen(filename, "r")) == NULL) {
		printf("\n Cannot open file %s, exit", filename);
		return;
	}
	for (;;) {
		if (fgets(line, MAXCHAR, fp) == NULL)
			break;
		num++;
		if (mindex == -1 && num == 1) {
			mindex = 1;
			continue;
		}
		if (mindex == 1 && spaceline(line) == 1) {
			mindex = 0;
			num = 0;
			bindex = -1;
			continue;
		}
		if (bindex == -1 && num == 1) {
			bindex = 1;
			continue;
		}
		if (bindex == 1 && spaceline(line) == 1) {
			bindex = 0;
			aindex = 1;
			continue;
		}
		if (aindex == 1 && spaceline(line) == 1) {
			aindex = 0;
			tindex = 1;
			continue;
		}
		if (tindex == 1 && spaceline(line) == 1) {
			tindex = 0;
			iindex = 1;
			continue;
		}
		if (iindex == 1 && spaceline(line) == 1) {
			iindex = 0;
			vindex = -1;
			num = 0;
			continue;
		}
		if (vindex == -1 && num == 2) {
			vindex = 1;
			continue;
		}
		if (vindex == 2 && spaceline(line) == 1) {
			vindex = 0;
			continue;
		}
		if (vindex == 1)
			if (strncmp(line, "MOD4", 4) == 0) {
				vindex = 2;
				continue;
			} else
				vindex = 3;
		if (mindex == 1) {
			tmpchar[0] = '\0';
			sscanf(line, "%s", tmpchar);
			for (i = 0; i < atomtypenum; i++)
				if (strcmp(tmpchar, atomtype[i].name) == 0)
					atomtypeindex[i] = 1;
		}
		if (bindex == 1)
			for (i = 0; i < bondparmnum; i++)
				if ((bondparm[i].name1[0] == line[0]
					 && bondparm[i].name1[1] == line[1]
					 && bondparm[i].name2[0] == line[3]
					 && bondparm[i].name2[1] == line[4])
					|| (bondparm[i].name2[0] == line[0]
						&& bondparm[i].name2[1] == line[1]
						&& bondparm[i].name1[0] == line[3]
						&& bondparm[i].name1[1] == line[4]))
					bondparmindex[i] = 1;
		if (aindex == 1)
			for (i = 0; i < angleparmnum; i++)
				if ((angleparm[i].name1[0] == line[0]
					 && angleparm[i].name1[1] == line[1]
					 && angleparm[i].name2[0] == line[3]
					 && angleparm[i].name2[1] == line[4]
					 && angleparm[i].name3[0] == line[6]
					 && angleparm[i].name3[1] == line[7])
					|| (angleparm[i].name3[0] == line[0]
						&& angleparm[i].name3[1] == line[1]
						&& angleparm[i].name2[0] == line[3]
						&& angleparm[i].name2[1] == line[4]
						&& angleparm[i].name1[0] == line[6]
						&& angleparm[i].name1[1] == line[7]))
					angleparmindex[i] = 1;
		if (tindex == 1)
			for (i = 0; i < torsionparmnum; i++)
				if ((torsionparm[i].name1[0] == line[0]
					 && torsionparm[i].name1[1] == line[1]
					 && torsionparm[i].name2[0] == line[3]
					 && torsionparm[i].name2[1] == line[4]
					 && torsionparm[i].name3[0] == line[6]
					 && torsionparm[i].name3[1] == line[7]
					 && torsionparm[i].name4[0] == line[9]
					 && torsionparm[i].name4[1] == line[10])
					|| (torsionparm[i].name4[0] == line[0]
						&& torsionparm[i].name4[1] == line[1]
						&& torsionparm[i].name3[0] == line[3]
						&& torsionparm[i].name3[1] == line[4]
						&& torsionparm[i].name2[0] == line[6]
						&& torsionparm[i].name2[1] == line[7]
						&& torsionparm[i].name1[0] == line[9]
						&& torsionparm[i].name1[1] == line[10]))
					torsionparmindex[i] = 1;
		if (iindex == 1)
			if ((improperparm[i].name1[0] == line[0]
				 && improperparm[i].name1[1] == line[1]
				 && improperparm[i].name2[0] == line[3]
				 && improperparm[i].name2[1] == line[4]
				 && improperparm[i].name3[0] == line[6]
				 && improperparm[i].name3[1] == line[7]
				 && improperparm[i].name4[0] == line[9]
				 && improperparm[i].name4[1] == line[10])
				|| (improperparm[i].name4[0] == line[0]
					&& improperparm[i].name4[1] == line[1]
					&& improperparm[i].name3[0] == line[3]
					&& improperparm[i].name3[1] == line[4]
					&& improperparm[i].name2[0] == line[6]
					&& improperparm[i].name2[1] == line[7]
					&& improperparm[i].name1[0] == line[9]
					&& improperparm[i].name1[1] == line[10]))
				improperparmindex[i] = 1;

		if (vindex == 3) {
			printf
				("\nThis program does not support vdw equivalent describations");
			printf
				("\nPlease list the equivalented vdw parameters explicitly");
			exit(0);
		}
		if (vindex == 2) {
			tmpchar[0] = '\0';
			sscanf(line, "%s", tmpchar);
			if (strcmp(vdwparm[i].name, tmpchar) == 0)
				vdwparmindex[i] = 1;
		}
	}
	fclose(fp);
}
コード例 #9
0
ファイル: gcrt.c プロジェクト: luolingqi/fragmap_2
/* GCRT */
int rgcrt(char *filename, int *atomnum, ATOM * atom, CONTROLINFO cinfo,
		  MOLINFO minfo)
{
	FILE *fpin;
	int i, index;
	int nameindex;
	int numatom;
	int overflow_flag = 0;
	char tmpchar[10];
	char line[MAXCHAR];


	if ((fpin = fopen(filename, "r")) == NULL) {
		fprintf(stderr, "Cannot open file %s, exit\n", filename);
		exit(1);
	}
	initial(cinfo.maxatom, atom, minfo.resname);
	index = 0;
	numatom = 0;
	nameindex = -1;
	for (;;) {
		if (fgets(line, MAXCHAR, fpin) == NULL) {
/*     printf("\nFinished reading %s file.", cinfo.ifilename); */
			break;
		}
		if (spaceline(line) == 1) {
			index++;
			continue;
		}
		if (index >= 2)
			index++;
		if (index <= 3)
			continue;
		if (index > 4 && spaceline(line) == 1)
			break;
		sscanf(line, "%s", tmpchar);
		if (nameindex == -1) {
			if (tmpchar[0] >= '0' && tmpchar[0] <= '9')
				nameindex = 0;
			else
				nameindex = 1;
		}
		if (overflow_flag == 0) {
			if (nameindex == 0)
				sscanf(line, "%d%lf%lf%lf", &atom[numatom].atomicnum,
					   &atom[numatom].x, &atom[numatom].y,
					   &atom[numatom].z);
			else
				sscanf(line, "%s%lf%lf%lf", atom[numatom].name,
					   &atom[numatom].x, &atom[numatom].y,
					   &atom[numatom].z);
		}
		numatom++;
		if (numatom >= cinfo.maxatom && overflow_flag == 0) {
			printf
				("\nInfo: the atom number exceeds the MAXATOM, reallocate memory automatically");
			overflow_flag = 1;
		}
	}
	*atomnum = numatom;
	if (nameindex == 0) {
		element(*atomnum, atom);
		for (i = 0; i < *atomnum; i++)
			strcpy(atom[i].name, atom[i].element);
	}
	if (nameindex == 1)
		atomicnum(*atomnum, atom);
/* printf("\n atom number is  %5d", *atomnum); */
	fclose(fpin);
	return overflow_flag;
}
コード例 #10
0
ファイル: sqmout.c プロジェクト: choderalab/ambermini
/* MOPAC OUTPUT */
int rsqmout(char *filename, int *atomnum, ATOM * atom, CONTROLINFO *cinfo,
			MOLINFO *minfo)
{
	/* int i,j; */
	int flag;
	int number = 0;
	int tmpint1, tmpint2;
	int overflow_flag = 0;
	FILE *fpout;
	char tmpchar1[MAXCHAR];
	char tmpchar2[MAXCHAR];
	char tmpchar3[MAXCHAR];
	char tmpchar4[MAXCHAR];
	char tmpchar5[MAXCHAR];
	char tmpchar6[MAXCHAR];
	char tmpchar7[MAXCHAR];
	char line[MAXCHAR];
	double tmpfloat1;
	double tmpfloat2;
	double tmpfloat3;

	if ((fpout = fopen(filename, "r")) == NULL) {
		fprintf(stdout, "Cannot open sqm output file: %s in rsqmout(), exit\n", filename);
		exit(1);
	}
	initial((*cinfo).maxatom, atom, (*minfo).resname);
	flag = 0;

	for (;;) {
		if (fgets(line, MAXCHAR, fpout) == NULL)
			break;

		sscanf(line, "%s%s%s%s%s%s%s", tmpchar1, tmpchar2, tmpchar3,
			   tmpchar4, tmpchar5, tmpchar6, tmpchar7);
		if (strcmp(tmpchar1, "Total") == 0 
			&& strcmp(tmpchar2, "Mulliken") == 0 
			&& strcmp(tmpchar3, "Charge") == 0 
			&&  strcmp(tmpchar4, "=") == 0) {
			sscanf(line, "%s%s%s%s%lf", tmpchar1, tmpchar2, tmpchar3,
				   tmpchar4, &(*minfo).dcharge);
			(*minfo).icharge = (int) (*minfo).dcharge;
			continue;
		}
		if (strcmp(tmpchar1, "Final") == 0 && strcmp(tmpchar2, "Structure") == 0) {
			flag = 1;	
			continue;
		}
		if (flag == 1 && strcmp("QM_NO.", tmpchar2) == 0
			      && strcmp("MM_NO.", tmpchar3) == 0
			      && strcmp("ATOM",   tmpchar4) == 0
			      && strcmp("X",      tmpchar5) == 0
			      && strcmp("Y",      tmpchar6) == 0
			      && strcmp("Z",      tmpchar7) == 0) {
			flag = 2;
			continue;
		}
		if (flag == 2 && spaceline(line) == 1) {
			flag = 3;
			*atomnum = number;
			break;
		}
		if (flag == 2) {
			if (overflow_flag == 0) {
				sscanf(line, "%s%d%d%s%lf%lf%lf", tmpchar1, &tmpint1, &tmpint2, tmpchar2, &tmpfloat1,
					   &tmpfloat2, &tmpfloat3);
				strcpy(atom[number].name, tmpchar2);
				atom[number].x = tmpfloat1;
				atom[number].y = tmpfloat2;
				atom[number].z = tmpfloat3;
				strcpy(atom[number].aa, (*minfo).resname);
			}
			number++;
			if (number >= (*cinfo).maxatom && overflow_flag == 0) {
				printf
					("\nInfo: the atom number exceeds the MAXATOM, reallocate memory automatically");
				overflow_flag = 1;
			}
		}
	}
	fclose(fpout);
	return overflow_flag;
}