/* * v 1.1 of conformation generation program * * Compile with cc -o cgofr cgofr.c -lm * (on HP, use c89 rather than cc) * * Tim Dellinger and Jennifer Gerbi 12-14-98 for * UIUC Matse 390AS group project * www.students.uiuc.edu/~gerbi/project.html * * this version optimized to use a 6-member-chain. The * array sizes can be reduced if the user wants to use * a 5-chain or a 4-chain. * * Input files needed: (all in the format of a return after * each number in the file.) * The program prompts for sequence size input from user. * * input.dat: the sequence chain. 1=H, 2=P. * * inputinst.dat: the list of possible conformations. * This is the set of permutations of 0,1,2,3 (left, up, * right, down), for one less than the chain member number * (since the first one is fixed). note the first number in the * file is the number of conformations to be tested, and the second * number is the number of instructions in each conformation (again, * this is one less than the sequence size.) * * energies.dat: the energy table giving HH, HP, PP, etc. energy * interaction integer magnitudes. * * Output files produced: * * output.dat: the list of all valid conformations and their energies. * */ /* global variables: * * buildconform: the array we read in from mathmatica that gives us * all the permutations of the possible conformation building * directions: left,up,right,and down. * * conform: the array of positions where the conformation is built. * * permlength: the number of instructions in each conformation building * information set. * sequence: the array holding the monomer sequence, as listed in * definitions just above. * */ #include #include #include #define FAIL 0 #define MAXNUMTWO 2200 /* min is twice the sequence size*/ #define MAXNUM 1100 /* min for this is the sequence size*/ #define MAXPERMS 2200 /* max numbers allowed, change if needed*/ #define LEFT 0 #define UP 1 #define RIGHT 2 #define DOWN 3 #define EMPTY 0 #define H 1 #define P 2 #define HH 3 #define M 4 /* global variables */ static int buildconform[MAXNUM][MAXPERMS]; int energy[5][5]; static int conform[MAXNUMTWO][MAXNUMTWO], sequence[MAXNUM]; int permlength; main() { int i,ii,jj,j,k,n,m,testnum; int numperms; int result,totalenergy; int posy,posx,FLAG,check; int sequencesize; /*****fcn to read in sequence array *****/ int fgetints(char *name, int max); /******fcn to read in the conformation building instructions****/ int getinstructions(char *name); /*****fcn to read in the energy table ******/ int gettable(char *name); /*******fcn to calculate the energy of each conformation*****/ int calcenergy(int irow, int sequencesize); /******fcn to write out the output file "output.txt"******/ int writeoutput(char *name,int energy,int irow,int sequencesize); printf("enter in the sequence size"); scanf("%d",&sequencesize); /***** read in sequence array: file expected is "input.dat"*/ testnum = fgetints("input.dat", sequencesize); /****** read in instructions for generating the conformation. ******* this file is called "inputinst.dat"*******/ numperms = getinstructions("inputinst.dat"); /* end of initial data input */ /* make the initial conformation: * this puts the first sequence number in the middle position of the * conformation array. the first one is always fixed this way to give * us an origin. posy and posx keep track of the current position * where we are. they are incremented appropriately depending on the * conformation building instructions, given by buildconform[][] */ for (i=0;i