suitename.0.3.070628/0000755000076500001200000000000010641030735014507 5ustar dcrjsradmin00000000000000suitename.0.3.070628/0.3.0705250000644000076500001200000000002510641013577015475 0ustar dcrjsradmin00000000000000suitename.0.2.070524 suitename.0.3.070628/Makefile0000644000076500001200000000205010641013577016151 0ustar dcrjsradmin00000000000000# suitename ifeq ($(MAKECMDGOALS),debug) CFLAGS = -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc else CFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc endif LIBS = -lm -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc # --------------------------------------------------------------------- PROG_FLGS = OBJS = suitename.o suitenscrt.o suiteninit.o suiteninpt.o \ suitenout.o suitenutil.o # --------------------------------------------------------------------- HEADERS = suitename.h suitenscrt.h suitenutil.h suiteninit.h suiteninpt.h \ suitenout.h suitename: $(OBJS) cc -o suitename $(CFLAGS) $(OBJS) $(LIBS) debug: $(OBJS) cc -o suitename $(CFLAGS) $(OBJS) $(LIBS) clean: rm -f *.o # ------------------------------------------------------------------------ # Dependencies (presume .o<-.c by standard cc compiler) suitename.o: $(HEADERS) suiteninit.o: $(HEADERS) suitenscrt.o: $(HEADERS) suiteninpt.o: $(HEADERS) suitenout.o: $(HEADERS) suitenutil.o: $(HEADERS) suitename.0.3.070628/Makefile.linux0000644000076500001200000000147710641013577017323 0ustar dcrjsradmin00000000000000# suitename ifeq ($(MAKECMDGOALS),debug) CFLAGS = -g else CFLAGS = endif LIBS = -lm # --------------------------------------------------------------------- OBJS = suitename.o suitenscrt.o suiteninit.o suiteninpt.o suitenout.o suitenutil.o # --------------------------------------------------------------------- HEADERS = suitename.h suitenscrt.h suitenutil.h suiteninit.h suiteninpt.h suitenout.h suitename: $(OBJS) cc -o suitename $(CFLAGS) $(OBJS) $(LIBS) debug: $(OBJS) cc -o suitename $(CFLAGS) $(OBJS) $(LIBS) clean: rm -f *.o # ------------------------------------------------------------------------ # Dependencies (presume .o<-.c by standard cc compiler) suitename.o: $(HEADERS) suiteninit.o: $(HEADERS) suitenscrt.o: $(HEADERS) suiteninpt.o: $(HEADERS) suitenout.o: $(HEADERS) suitenutil.o: $(HEADERS) suitename.0.3.070628/Makefile.macOSX0000644000076500001200000000205010641013577017302 0ustar dcrjsradmin00000000000000# suitename ifeq ($(MAKECMDGOALS),debug) CFLAGS = -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc else CFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc endif LIBS = -lm -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc # --------------------------------------------------------------------- PROG_FLGS = OBJS = suitename.o suitenscrt.o suiteninit.o suiteninpt.o \ suitenout.o suitenutil.o # --------------------------------------------------------------------- HEADERS = suitename.h suitenscrt.h suitenutil.h suiteninit.h suiteninpt.h \ suitenout.h suitename: $(OBJS) cc -o suitename $(CFLAGS) $(OBJS) $(LIBS) debug: $(OBJS) cc -o suitename $(CFLAGS) $(OBJS) $(LIBS) clean: rm -f *.o # ------------------------------------------------------------------------ # Dependencies (presume .o<-.c by standard cc compiler) suitename.o: $(HEADERS) suiteninit.o: $(HEADERS) suitenscrt.o: $(HEADERS) suiteninpt.o: $(HEADERS) suitenout.o: $(HEADERS) suitenutil.o: $(HEADERS) suitename.0.3.070628/suitename.c0000644000076500001200000007657210641030507016663 0ustar dcrjsradmin00000000000000/* suitename.c */ /*****************************************************************/ /* NOTICE: This is free software and the source code is freely */ /* available. You are free to redistribute or modify under the */ /* conditions that (1) this notice is not removed or modified */ /* in any way and (2) any modified versions of the program are */ /* also available for free. */ /* ** Absolutely no Warranty ** */ /* Copyright (C) 2007 David C. Richardson */ /*****************************************************************/ #define EXTERN /* that is, EXTERN is defined, so suitename.h will do main declarations*/ #include "suitename.h" #undef EXTERN #include "suitenscrt.h" #include "suitenutil.h" #include "suiteninit.h" #include "suiteninpt.h" #include "suitenout.h" /*0.2.070524 preserve chi-1 and chi, so could preserve eta, theta */ /*0.2.070525 general read dangle record for, e.g., eta, theta */ /*0.2.070628 triage reports zeta-1, epsilon-1, delta-1,... Ltriage codes */ /****main()*******************************************************************/ main(int argc, char** argv) { int LOK=1,ibin=0,jclst=0; char sour[32]; float suiteness=0, distance=0; char ptmaster[4]; char ptcolor[16]; int i=0,j=0,k=0,m=0; ptcolor[0] = '\0'; /*default is no point color*/ ptmaster[0] = '\0'; /*default is no point master*/ sprintf(version,"suitename.0.3.070628 "); /* VERSION */ /* default values before parsecommandline */ Ltest = 0; /*compile in... */ Ltestout = 0; /*commandline -test */ fpin = stdin; fpout = stdout; /*NOTE: for consistency, edit defaults text in usageout() */ Lreportout = 1; /* suite by suite suiteness report, & summary */ Lchart = 0; /* summary-less report for MolProbity multichart 070521*/ Ldangle = 0; /* read straight dangle records 070525*/ Lsourout = 0; /* extra info in kinemage ptIDs. optional as of 070524*/ Letatheta = 0; /* theta,eta instead of chi-1,chi kinemage angles 070524*/ Lkinemageout=0; /* kinemage of the clusters */ Lstringout = 0; /* 3 char string instead of cluster kinemage */ Lsuitesin=0; Lresiduesin=1; NptIDfields=6; /*for dangle residue input*/ Nanglefields=9; /*for 9D kinemage edited suite input*/ Lnewfile=0; Lhelpout=0; Lchangesout=0; NameStr[0] = '\0'; Lgeneralsatw = 0; /*flag for special general case satellite widths 070328*/ Lwannabe = 1;/* -wannabe input flag 070429, default 070525, else -nowannabe*/ Lsequence = 1; /*output 1 letter Base code sequence part of string 070409*/ Loverlap = 0; /*overlap string lines, e.g. 1-20, 11-30, 21-40, ... 070409*/ Loneline = 0; /*string output all as oneline 070409*/ if(argc > 1) { LOK = parsecommandline(&argc, argv); } if(LOK) {/*command OK*/ inittextblock(&mainscratch); /*__open scratch "tapes" */ /*--rewind scratch "tapes", inplicit with inittextblock() */ /*--allocation of space automatic when attempting write*/ newresidueptr = (residuestruct*)malloc(sizeof(struct residuestruct)); oldresidueptr = (residuestruct*)malloc(sizeof(struct residuestruct)); suiteptr = (suitestruct*)malloc(sizeof(struct suitestruct)); if( newresidueptr != NULL && oldresidueptr != NULL && suiteptr != NULL ) {LOK=1;} else {LOK=0;} if(LOK) {/*storage allocated*/ LOK = initializations(); /*070325*/ if(LOK) {/*LOK to work*/ clearnewresidue(); /*only at beginning so first-1 handled correctly*/ /*sudo pre-Algorithm: accummulate suites or suites from residues */ while(!LatEOF) /*allow EOF on end of last line, see Lhitend */ {/*loop over all residues in the file*/ /* if(Lresiduesin) { fprintf(stderr,"LOOP:newresidue:"); for(j=0;j<10;j++) fprintf(stderr,"%s,",newresidueptr->ptID[j]); fprintf(stderr,";%s;",newresidueptr->basechr); fprintf(stderr,"%8.3f ",newresidueptr->alpha); fprintf(stderr,"%8.3f ",newresidueptr->beta); fprintf(stderr,"%8.3f ",newresidueptr->gamma); fprintf(stderr,"%8.3f ",newresidueptr->delta); fprintf(stderr,"%8.3f ",newresidueptr->epsilon); fprintf(stderr,"%8.3f ",newresidueptr->zeta); fprintf(stderr,"\n"); } */ if(Lsuitesin) {LOK = getsuite();} else {LOK = getresidue(); Lresiduesin = 1;} if(LOK) { if(Lresiduesin) {LOK = loadsuite();} if(LOK) { LOK = confirmsuite(); if(!LOK) { ibin = 13; /*angles not fully specified*/ jclst = 0; /*cluster not assigned in dummy bin*/ sprintf(sour," tangled "); /*suite incomplete angles*/ writesuite(ibin,jclst,sour,distance,suiteness,ptmaster,ptcolor); /*binname "inc " clustername "__" 070414 */ } else /*now have to do some work*/ { /*sudo Algorithm */ /*sudo FOR all RNA suites si in S */ /*sudo program body: evaluate suite, cluster membership */ ibin = evaluatesuite(); if(ibin > 0){membership(ibin);} } }/*loaded suite*/ }/*got a residue (or a suite from a kinemage)*/ }/*loop over all residues in the file*/ writeoutput(); /*has logicals for what output possible*/ }/*LOK to work*/ }/*storage allocated*/ }/*command OK*/ else { if(Lkinemageout) /*dump of actual cluster information 070421*/ { initializations(); L33out = L32out = L23out = L22out = 1; for(i=1; i<=12; i++) { binout[i]=1; /*for(j=1; j e_max */ /*sudo THEN s_bini = e_triage AND !OK */ if(suiteptr->epsilon < epsilonmin || suiteptr->epsilon > epsilonmax) { sprintf(sour," e out "); LOK = 0; Ltriage = EPSILONM; sprintf(ptmaster,"'E'");} } if(LOK) /*------ filter on delta minus 1 -----------------------*/ { /*sudo IF OK AND si(dm) >= d3_min AND si(dm) <= d3_max */ /*sudo THEN s_dm = 3 AND OK */ /*sudo ELSE IF OK AND si(dm) >= d2_min AND si(dm) <= d2_max */ /*sudo THEN s_dm = 2 AND OK */ /*sudo ELSE s_bini = dm_triage AND !OK */ if(suiteptr->deltam >= delta3min && suiteptr->deltam <= delta3max) { puckerdm = 3; LOK = 1; } else if(suiteptr->deltam >= delta2min && suiteptr->deltam <= delta2max) { puckerdm = 2; LOK = 1; } else { puckerdm = 0; sprintf(sour," bad deltam "); LOK = 0; Ltriage = DELTAM; sprintf(ptmaster,"'D'");} } if(LOK) /*------ filter on delta -----------------------*/ { /*sudo IF OK AND si(d) >= d3_min AND si(d) <= d3_max */ /*sudo THEN s_d = 3 AND OK */ /*sudo ELSE IF OK AND si(d) >= d2_min AND si(d) <= d2_max */ /*sudo THEN s_d = 2 AND OK */ /*sudo ELSE s_bini = d_triage AND !OK */ if(suiteptr->delta >= delta3min && suiteptr->delta <= delta3max) { puckerd = 3; LOK = 1; } else if(suiteptr->delta >= delta2min && suiteptr->delta <= delta2max) { puckerd = 2; LOK = 1; } else { puckerd = 0; sprintf(sour," bad delta "); LOK = 0; Ltriage = DELTA; sprintf(ptmaster,"'D'");} if(LOK) {/*both deltas in range*/ sprintf(sour," %1d%1d delta ",puckerdm,puckerd); } } if(LOK) /*------ filter on gamma -----------------------*/ { /*sudo IF OK AND si(g) >= gp_min AND si(g) <= gp_max */ /*sudo THEN s_g = p AND OK */ /*sudo ELSE IF OK AND si(g) >= gt_min AND si(g) <= gt_max */ /*sudo THEN s_g = t AND OK */ /*sudo ELSE IF OK AND si(g) >= gm_min AND si(g) <= gm_max */ /*sudo THEN s_g = m AND OK */ /*sudo ELSE s_bini = g_triage AND !OK */ if(suiteptr->gamma >= gammapmin && suiteptr->gamma <= gammapmax) { gammaname = 'p'; LOK = 1; } else if(suiteptr->gamma >= gammatmin && suiteptr->gamma <= gammatmax) { gammaname = 't'; LOK = 1; } else if(suiteptr->gamma >= gammammin && suiteptr->gamma <= gammammax) { gammaname = 'm'; LOK = 1; } else { gammaname = 'o'; LOK = 0; sprintf(sour," g out "); Ltriage = GAMMA; sprintf(ptmaster,"'T'");} } if(LOK) /*------ filter on alpha -----------------------*/ { /*sudo IF OK AND si(a) >= a_min AND si(a) <= a_max */ /*sudo THEN OK */ /*sudo ELSE s_bini = a_triage AND !OK */ if(suiteptr->alpha >= alphamin && suiteptr->alpha <= alphamax) {LOK = 1; } else {LOK = 0; sprintf(sour," a out "); Ltriage = ALPHA; sprintf(ptmaster,"'T'");} } if(LOK) /*------ filter on beta -----------------------*/ { /*sudo IF OK AND si(b) >= b_min AND si(b) <= b_max */ /*sudo THEN OK */ /*sudo ELSE s_bini = b_triage AND !OK */ if(suiteptr->beta >= betamin && suiteptr->beta <= betamax) {LOK = 1; } else {LOK = 0; sprintf(sour," b out "); Ltriage = BETA; sprintf(ptmaster,"'T'");} } if(LOK) /*------ filter on zeta -----------------------*/ { /*sudo IF OK AND si(z) >= z_min AND si(z) <= z_max */ /*sudo THEN OK */ /*sudo ELSE s_bini = z_triage AND !OK */ if(suiteptr->zeta >= zetamin && suiteptr->zeta <= zetamax) {LOK = 1; } else {LOK = 0; sprintf(sour," z out "); Ltriage = ZETAM; sprintf(ptmaster,"'T'");} } ddg = 0; /*NO bin assigned yet...*/ /*sudo IF OK ASSIGN s_bini to one of 12 delta,delta,gamma bins */ if(LOK) /*------ categorize as one of the 12 ddg groups ------*/ {/*OK to place in one of the 12 bins*/ /* ddg */ /* 0 out */ /* 33 123 ptm */ /* 32 456 ptm */ /* 23 789 ptm */ /* 22 ABC ptm */ /*sudo IF s_dm == 3 */ if (puckerdm == 3) { /*sudo IF s_d == 3 */ if (puckerd == 3) { L33out = 1; /*sudo IF s_g == p THEN s_bini = 33p */ if (gammaname == 'p') {ddg = 1; binout[ddg] = 1;} /*sudo ELSE IF s_g == t THEN s_bini = 33t */ else if(gammaname == 't') {ddg = 2; binout[ddg] = 1;} /*sudo ELSE IF s_g == m THEN s_bini = 33m */ else if(gammaname == 'm') {ddg = 3; binout[ddg] = 1;} } /*sudo ELSE IF s_d == 2 */ else if(puckerd == 2) { L32out = 1; /*sudo IF s_g == p THEN s_bini = 32p */ if (gammaname == 'p') {ddg = 4; binout[ddg] = 1;} /*sudo ELSE IF s_g == t THEN s_bini = 32t */ else if(gammaname == 't') {ddg = 5; binout[ddg] = 1;} /*sudo ELSE IF s_g == m THEN s_bini = 32m */ else if(gammaname == 'm') {ddg = 6; binout[ddg] = 1;} } } /*sudo ELSE IF OK AND s_dm == 2 */ else if(puckerdm == 2) { /*sudo IF s_d == 3 */ if (puckerd == 3) { L23out = 1; /*sudo IF s_g == p THEN s_bini = 23p */ if (gammaname == 'p') {ddg = 7; binout[ddg] = 1;} /*sudo ELSE IF s_g == t THEN s_bini = 23t */ else if(gammaname == 't') {ddg = 8; binout[ddg] = 1;} /*sudo ELSE IF s_g == m THEN s_bini = 23m */ else if(gammaname == 'm') {ddg = 9; binout[ddg] = 1;} } /*sudo ELSE IF s_d == 2 */ else if(puckerd == 2) { L22out = 1; /*sudo IF s_g == p THEN s_bini = 22p */ if (gammaname == 'p') {ddg = 10; binout[ddg] = 1;} /*sudo ELSE IF s_g == t THEN s_bini = 22t */ else if(gammaname == 't') {ddg = 11; binout[ddg] = 1;} /*sudo ELSE IF s_g == m THEN s_bini = 22m */ else if(gammaname == 'm') {ddg = 12; binout[ddg] = 1;} } } sprintf(sour," ddg== %2d ",ddg); }/*OK to place in one of the 12 bins*/ else {/*culled by single angle triage*/ /*sudo ELSE {s_bini already set to be some kind of triage} */ Ltriageout = 1; binout[0] = 1; ibin = 0; jclst = 0; suiteness = 0; /*ibin,jclst,suiteness default to zero anyway*/ clusterout[0][0] = 1; /*triage bin, cluster number 0 */ writesuite(ibin,jclst,sour,distance,suiteness,ptmaster,ptcolor); /*binname "trig" clustername "!!" 070414 */ } return(ddg); /* ddg is the ibin number! */ } /*___evaluatesuite()_________________________________________________________*/ /****membership()*************************************************************/ void membership(int ibin) { int i=0,j=0,k=0,minj=0,matchcnt=0,domj=0,thej=0; float dsq = 0, del = 0, distance = 0, mindistance = 999; float disttodom=0, disttosat=0, thedist=0; float penmindist = 999; float pi = 3.14159; float suiteness=0; char sour[96],sourness[32]; /*070311 accum report*/ int Ldominant=0; int LOK = 0; float sattodom[8], domtosat[8],sattopt[8],domtopt[8]; char ptmaster[4]; int closestj = 0, nextclosej=0; float closestd = 999, nextclosed = 999; char ptcolor[16]; int Lassigned = 0; /*070430 status of this point...*/ ptcolor[0] = '\0'; /*default is no point color*/ sour[0] = '\0'; /*extra comment in outputed ptID*/ sourness[0] = '\0'; /*extra comment in outputed ptID*/ ptmaster[0] = '\0'; /*default is no point master*/ clearmatches(); matchcnt = 0; i = ibin; /*sudo */ /*sudo program body: cluster membership in assigned s_bini */ /*logic: find all clusters in this bin that match this conformation*********/ /*bin[].clst[].ang working-arrays count from 1 for known clusters*/ /* some bins have a major cluster with satellites */ /*--first clear the flags */ domj = 0; /*default, no dominant cluster in the bin*/ Ldominant = 0; /*conformation close to a major (dominant) cluster*/ mindistance = 999; /*especially note closest cluster*/ closestd = 999; /*sudo FOR each cluster cj in this delta,delta,gamma bin */ /*for(j=1; j<=ddgcnt[i]; j++)*/ j = 1; /*start with index 1 for first observed clst in this bin 070428*/ while(bin[i].clst[j].LOK) /*070428*/ {/*loop over all observed clusters in this ith bin*/ if( !Lwannabe && strcmp(bin[i].clst[j].status,"wannabe")==0) {j++;continue;}/*match*/ /*empty bin dummy cluster at 0,0,0,0,0,0,0 is out of angle range*/ /*but safer to explicity skip*/ /*if(i==3 || i==9){continue;} not needed 070428*/ /*sudo COMPUTE d=scaled 4D distance of si to cj (epsilon,zeta,alpha,beta)*/ resetcoordw(coordw,i,j,Lgeneralsatw); /*revert to general defaults*/ /*insert this resetcoordw() here 070414 */ distance = hyperellipsoiddist(i,j,4,coordw); /*4D scaled, normalized distance*/ if(distance < closestd) /*070311*/ { closestd = distance; closestj = j; } if(distance >= 0) /* store all distances, needed for diagnostics */ { matches[i][j] = distance; /*sudo IF 0 <= d < 1 THEN */ if(distance < 1) /* suite could be a member of this cluster */ { /*APPEND to list of clusters of which suite could be a member*/ /*sudo APPEND cj to s_list_ci */ /*sudo FLAG when possible_cluster is a dominant_cluster */ matchcnt++; /*only count possible clusters*/ /*if(j== domj) {Ldominant = 1;}*/ if(strcmp(bin[i].clst[j].domsatness,"dom")==0) /*match 070429*/ { domj = j; /*this j is a dominant cluster*/ Ldominant = 1; /*there is a close dominant cluster to consider*/ } } /*sudo END IF */ /*sudo FLAG closest_cluster */ if(distance < mindistance) { mindistance = distance; minj = j; } } j++; /*increment index for next cycle...*/ }/*loop over all clusters in this ith bin*/ /*sudo END FOR each cluster cj in this delta,delta,gamma bin */ /*now find the next closest cluster (for debugging purposes)*/ nextclosed = 999; /*next closest cluster*/ j = 1; /*start with index 1 for first observed clst in this bin 070428*/ while(bin[i].clst[j].LOK) /*070428*/ {/*loop over all clusters in this ith bin*/ if( !Lwannabe && strcmp(bin[i].clst[j].status,"wannabe")==0) {j++;continue;}/*match*/ if(matches[i][j] < nextclosed && j != closestj) { nextclosed = matches[i][j]; nextclosej = j; } j++; /*increment index for next cycle...*/ }/*loop over all clusters in this ith bin*/ /*end logic: find all clusters that match this conformation_______________*/ /*now assign suite to a particular cluster*/ Lassigned = 0; /*sudo */ /*sudo IF |s_list_ci| == 1 THEN */ if(matchcnt == 1) { /*output the only distance match*/ /*sudo ASSIGN s_cluster = cj in s_list_ci */ thej = minj; /*cluster number in this bin*/ Lassigned = 1; sprintf(sourness,"%d-only-one",matchcnt); thedist = matches[ibin][thej]; } /*sudo ELSE IF |s_list_ci| > 1 THEN */ else if(matchcnt > 1 ) {/*suite close to more than one cluster*/ /*sudo IF all cj in s_list_ci are not dominant THEN */ if(!Ldominant) /*dominant_cluster is not a member of possible_clusters */ { /*output the minimum distance match*/ /*sudo ASSIGN s_cluster = cj in s_list_ci minimizing d */ thej = minj; /*cluster number in this bin*/ Lassigned = 1; sprintf(sourness,"%d-none-dom",matchcnt); } /*sudo ELSE IF s_list_ci contains a dominant cj THEN */ else if(Ldominant) {/*match dominant cluster and highest quality other cluster*/ /*sudo ASSIGN domj = dominant cj in s_list_ci */ /*sudo ASSIGN thej = cj in s_list_ci minimizing d for all non-dominant cj in s_list_ci */ penmindist = 999; j = 1;/*start with index 1 for first observed clst in this bin 070428*/ while(bin[i].clst[j].LOK) /*070428*/ {/*loop over all clusters in this ith bin*/ if( !Lwannabe && strcmp(bin[i].clst[j].status,"wannabe")==0) {j++;continue;} if( ( strcmp(bin[i].clst[j].domsatness,"dom")!=0 )/*i.e. NOT dom*/ && (matches[i][j] < penmindist)) {/*find shortest distance to non-dominant and satellite clusters*/ penmindist = matches[i][j]; thej = j; /*j index of closest other cluster*/ } j++; /*increment index for next cycle...*/ } /*distinguish best match cluster as satellite or just another cluster*/ /*this bin has a dominant cluster and thus satellite clusters*/ /*sudo IF thej is a satellite of domj THEN */ if( strcmp(bin[i].clst[thej].domsatness,"sat")==0 )/*i.e. matches sat*/ { /*the other cluster is a satellite cluster*/ /*point close to both a satellite and the dominant cluster*/ /*NEED TO KNOW IF INBETWEEN DOMINANT AND SATELLITE CLUSTERS*/ /*if dotproducts both positive, then inbetween*/ /* p p */ /* dom/___sat and dom___\sat */ vector7ab(domtopt, bin[i].clst[domj].ang, suiteptr->ang); vector7ab(sattopt, bin[i].clst[thej].ang, suiteptr->ang); vector7ab(domtosat, bin[i].clst[domj].ang, bin[i].clst[thej].ang); vector7ab(sattodom, bin[i].clst[thej].ang, bin[i].clst[domj].ang); /*sudo IF si is located between the means of thej and domj THEN */ if( (dotproduct(domtopt,domtosat,4) > 0) &&(dotproduct(sattopt,sattodom,4) > 0) ) {/*pt between dom and sat*/ /*sudo CALCULATE rescaled distances d* of si to thej and domj */ /*sudo ASSIGN s_clusteri = thej or domj minimizing rescaled distance d* */ /*recalc distances to dominant cluster and to satellite cluster*/ /*considering different weights between special cluster pairs */ resetcoordw(dominantw, i,domj,0); /*set to dominant widths*/ resetcoordw(satellitew,i,thej,Lgeneralsatw); /*set to satellite widths, using Lgeneralsatw 070414*/ assignweights(i,thej,dominantw,satellitew); /*special widths for this satellite: weight dom--sat pair*/ /* fprintf(stderr,"satj: %d satw: ",thej); for(k=1; k<=7; k++) {fprintf(stderr,"%3.0f ",satellitew[k]);} fprintf(stderr,", domj: %d domw: ",domj); for(k=1; k<=7; k++) {fprintf(stderr,"%3.0f ",dominantw[k]);} fprintf(stderr,"\n"); */ disttodom = hyperellipsoiddist(i,domj,4,dominantw); disttosat = hyperellipsoiddist(i,thej,4,satellitew); if(disttosat <= disttodom) {thej = thej;} /*bookkeeping*/ else {thej = domj;} /*in effect, the default*/ Lassigned = 1; sprintf(sourness,"%d-BETWEEN-dom-sat(%7.3f|%7.3f)" ,matchcnt,disttodom,disttosat); }/*pt between dom and sat*/ /*sudo ELSE (not between the means of thej and domj) */ else {/*pt NOT inbetween*/ /*just assign by closest standard distance evaluation*/ /*sudo ASSIGN s_clusteri = thej or domj minimizing d */ if(matches[i][domj] < matches[i][thej]) {thej = domj;} Lassigned = 1; sprintf(sourness,"%d-OUTSIDE-dom-sat",matchcnt); }/*pt NOT inbetween*/ /*sudo END IF (between or not between satellite and dominant) */ }/*point close to both a satellite and the dominant cluster*/ /*sudo ELSE (thej is NOT a satellite of domj) */ else /* near cluster is not a satellite */ { /*point just belongs to the closest cluster*/ /*output the minimum distance match*/ /*sudo ASSIGN s_clusteri = thej or domj minimizing d */ thej = minj; /*cluster number in this bin*/ Lassigned = 1; sprintf(sourness,"%d-not-sat",matchcnt); } /*sudo END IF (satellite or not a satellite) */ }/*match dominant cluster and highest quality other cluster*/ /*sudo END IF (a cj in s_list_ci is or is not dominant) */ thedist = matches[ibin][thej]; }/*suite close to more than one cluster*/ else /*sudo ELSE IF |s_list_ci| == 0 THEN */ { /*NO match in this bin*/ /*sudo ASSIGN s_clusteri = outlier */ thej = 0; /*outlier named !!*/ Lassigned = 0; Loutlier = 1; thedist = closestd; sprintf(sourness,"outlier distance %.3f",closestd); /*070311*/ sprintf(ptmaster,"'O'"); /*outlier within a bin*/ sprintf(ptcolor," white"); /*leading space*/ /*thej = closestj; NOT viable to have outlier named by closest cluster*/ /* some are very far from any cluster, */ /* and even a singleton defines an extant cluster and makes a ring*/ } /*sudo END IF ( |s_list_ci| == ? ) */ sprintf(sour," %s:%s, %7.3f:%s, %7.3f: " ,sourness ,bin[i].clst[closestj].clustername,matches[i][closestj] ,bin[i].clst[nextclosej].clustername,matches[i][nextclosej]); clusterout[i][thej] = 1; /*this specific cluster has an entry*/ if(Lwannabe && strcmp(bin[i].clst[thej].status,"wannabe")==0) { Lwannabeout = 1; /*once set, stays set*/ Liswannabe = 1; /*set only for this cluster*/ } /*----------- final suiteness ------------------------------------------*/ /*sudo COMPUTE dist_si = scaled 7D distance of si to cluster s_clusteri */ /*sudo possible reassignment based on 7D distance */ resetcoordw(coordw,i,thej,Lgeneralsatw); /*revert to general defaults*/ /*recompute distance for all 7 dimensions, calc suiteness*/ if(Lassigned){distance = hyperellipsoiddist(i,thej,7,coordw);} else {distance = hyperellipsoiddist(i,closestj,7,coordw);} /*sudo IF s_clusteri not outlier THEN */ /*sudo IF dist_si <= 1 THEN */ if(distance <= 1) /* less than ... or equal added 070430 */ { /*sudo COMPUTE "suiteness" suiti = (cos(pi*dist_si) +1)/2 */ /*sudo limit "suiteness" suiti >= 0.01 */ /*sudo ASSIGN s_clusteri = thej */ suiteness = (cos(pi*distance) +1)/2; if(suiteness < 0.01) {suiteness = 0.01;} /*floor 070430*/ if(!Lassigned) { thej = closestj; /*assign in this case*/ if(Lreportout) { /*"7D distance forces assignment to closest cluster\n");*/ sprintf(commentstr," by 7Ddist"); /*070628*/ Lcomment=1; } } } /*sudo ELSE "suiteness" suiti = 0 */ /*sudo ASSIGN s_clusteri = outlier */ else { if(Lassigned) { if(Lreportout) { /*"7D distance forces %s assignment to be outlier\n"*/ sprintf(commentstr," 7D dist %s",bin[ibin].clst[thej].clustername); Lcomment=1; /*070628*/ } } thej = 0; /*make not assigned in any case! */ suiteness = 0; } /*Decisions are made piecemeal (ddg) or in 4D (abez) */ /* inclusion is definite to a particular cluster, based on 4D distances */ /* exclusion is general, except for knowledge of closest in 4D */ /* final suiteness is based on 7D distance */ /* but it is very difficult to understand shape in 7D */ /*Use 7D suiteness to do final choice about inclusion: */ /*case: currently assigned membership in a cluster: */ /* calc 7D dist to assigned cluster: retain as member or make an outlier*/ /*case: currently an outlier: */ /* calc 7D dist to closest cluster: assign as member or leave as outlier*/ /*----------------------------------------------------------------------*/ writesuite(ibin,thej,sour,distance,suiteness,ptmaster,ptcolor); /*binname "## c" clustername "#c" ; outlier "!!" 070414 */ if(Ltestout) { fprintf(fpout," [suite: %s %s power== %4.2f, 4Ddist== %f, 7Ddist== %f, suiteness==%f] \n",bin[ibin].clst[thej].clustername,suiteptr->ptID,power,thedist,distance,suiteness); } } /*___membership()____________________________________________________________*/ /*sudo END FOR */ /****clearmatches()***********************************************************/ void clearmatches(void) /*called from membership()*/ { int i=0,j=0; for(i=1; i<=12; i++) /*12 actual named bins, this is robust within MAXBINS*/ { /*named clusters start at index 1, no tally of actual # defined clusters*/ for(j=1; j # defined clusters*/ { matches[i][j] = 999; /*going for minimum of match distance*/ } } } /*___clearmatches()__________________________________________________________*/ suitename.0.3.070628/suitename.h0000644000076500001200000000415710641013577016666 0ustar dcrjsradmin00000000000000/* suitename.h */ #include #include #include #include #define MAXBINS 14 /*1--12 named bins, bin 0 triaged, bin 13 incomplete*/ #define MAXCLST 16 /*practical, 0) { satWarray[m] = satinfo[k].satw[m]; /*fprintf(stderr,"sat ang %d = %3.0f ",m,satWarray[m]);*/ } if(satinfo[k].domw[m] > 0) { domWarray[m] = satinfo[k].domw[m]; /*fprintf(stderr,"dom ang %d = %3.0f \n",m,domWarray[m]);*/ } } break; /*just find one*/ } } } /*no match just leaves arrays unmodified*/ } /*___assignweights()_________________________________________________________*/ /****parsecommandline()*******************************************************/ int parsecommandline(int *argc, char** argv) { int LOK=0; char *p; int i=0,j=0,k=0; char numstr[256]; for(i=1; i<*argc; i++) {/*loop over arguments*/ p = argv[i]; if(p[0] == '-') {/*flag*/ if(p[1] == '\0') {/*naked flag ignored*/ ; }/*naked flag ignored*/ else {/*interpret flag*/ if( CompArgStr(p+1,"residuein", 7) || CompArgStr(p+1,"residuesin", 7)) { Lsuitesin = 0; Lresiduesin = 1; } else if( CompArgStr(p+1,"suitein", 5) || CompArgStr(p+1,"suitesin", 5)) { Lsuitesin = 1; Lresiduesin = 0; } else if(CompArgStr(p+1,"string", 6)) { Lstringout = 1; Lreportout = 0; Lkinemageout = 0; Lchart = 0; } else if(CompArgStr(p+1,"report", 6)) { Lreportout = 1; Lstringout = 0; Lkinemageout = 0; Lchart = 0; } else if(CompArgStr(p+1,"chart", 5)) { Lreportout = 1; Lstringout = 0; Lkinemageout = 0; Lchart = 1; /*no summary of report, MolProbity multichart use*/ } else if(CompArgStr(p+1,"kinemage", 3)) { Lkinemageout = 1; Lreportout = 0; Lstringout = 0; } else if(CompArgStr(p+1,"satellites", 9)) { Lgeneralsatw = 1; } else if(CompArgStr(p+1,"wannabes", 7)) /*070429*/ { Lwannabe = 1; } else if(CompArgStr(p+1,"nowannabes", 9)) /*070525*/ { Lwannabe = 0; } else if(CompArgStr(p+1,"nosequence", 5)) { Lsequence = 0; } else if(CompArgStr(p+1,"overlaps", 7)) { Loverlap = 1; } else if(CompArgStr(p+1,"oneline", 7)) { Loneline = 1; } else if(CompArgStr(p+1,"help", 1)) { Lhelpout = 1; } else if(CompArgStr(p+1,"changes", 7)) { Lchangesout = 1; } else if(CompArgStr(p+1,"test", 4)) { Ltestout = 1; } else if(CompArgStr(p+1,"sour", 4)) /*070524*/ { Lsourout = 1; } else if(CompArgStr(p+1,"dangle", 6)) /*070525*/ { Ldangle = 1; } else if( CompArgStr(p+1,"thetaeta", 5) /*070524*/ || CompArgStr(p+1,"etatheta", 3)) /*070524*/ { Letatheta = 1; } else if( CompArgStr(p+1,"pointIDfields", 5) || CompArgStr(p+1,"ptID", 2) ) { i = i+1; /*number of pointID fields is in the next string*/ p = argv[i]; j=0; k=0; while(j<256) {/*strobe out number*/ if( isdigit(p[j]) ) { numstr[k] = p[j]; k++; j++; } else if(k==0) {/*no char yet*/ j++; } else {/*presume whole number is in*/ numstr[k]='\0'; /*end number string*/ sscanf(numstr,"%d",&NptIDfields); j=999; /*end the while loop*/ } }/*strobe out number*/ } else if( CompArgStr(p+1,"angles", 5) || CompArgStr(p+1,"anglefields", 5) || CompArgStr(p+1,"nangles", 6) ) { i = i+1; /*number of angle fields is in the next string*/ p = argv[i]; j=0; k=0; while(j<256) {/*strobe out number*/ if( isdigit(p[j]) ) { numstr[k] = p[j]; k++; j++; } else if(k==0) {/*no char yet*/ j++; } else {/*presume whole number is in*/ numstr[k]='\0'; /*end number string*/ sscanf(numstr,"%d",&Nanglefields); j=999; /*end the while loop*/ } }/*strobe out number*/ } else if( CompArgStr(p+1,"hyper", 5) || CompArgStr(p+1,"power", 5) ) { i = i+1; /*hyperellipsoid power is in the next string*/ p = argv[i]; j=0; k=0; while(j<256) {/*strobe out number*/ if( isdigit(p[j]) || p[j]=='.') { numstr[k] = p[j]; k++; j++; } else if(k==0) {/*no char yet*/ j++; } else {/*presume whole number is in*/ numstr[k]='\0'; /*end number string*/ sscanf(numstr,"%lf",&power); j=999; /*end the while loop*/ } }/*strobe out number*/ } }/*interpret flag*/ }/*flag*/ else {/*presume an input file name*/ /*THIS IS NOT IMPLEMENTED: NO CODE TO OPEN A FILE !!!! */ strcpy(NameStr,argv[i]); /*copy name into input file Name*/ Lnewfile=1; /*file is present*/ }/*presume an input file name*/ }/*loop over arguments*/ /*070222 much of this not yet implemented*/ if( Lhelpout || Ltestout || Lchangesout || Lnewfile) {LOK = 0;} else {LOK = 1;} return(LOK); } /*___parsecommandline()______________________________________________________*/ suitename.0.3.070628/suiteninit.h0000644000076500001200000004667210641013577017077 0ustar dcrjsradmin00000000000000/* suiteninit.h */ /* suitename.h MAXBINS 14 1--12 named bins, bin 0 triaged, bin 13 incomplete*/ /* suitename.h MAXCLST 16 practical, ptID[j][k] == '\0') {break;} suiteptr->ptID[n++] = newresidueptr->ptID[j][k]; } } suiteptr->ptID[n] = '\0'; /*terminate ptID string*/ suiteptr->basechr[0] = newresidueptr->basechr[0]; /*070412*/ suiteptr->basechr[1] = '\0'; suiteptr->ang[1] = suiteptr->deltam = oldresidueptr->delta; suiteptr->ang[2] = suiteptr->epsilon = oldresidueptr->epsilon; suiteptr->ang[3] = suiteptr->zeta = oldresidueptr->zeta; suiteptr->ang[4] = suiteptr->alpha = newresidueptr->alpha; suiteptr->ang[5] = suiteptr->beta = newresidueptr->beta; suiteptr->ang[6] = suiteptr->gamma = newresidueptr->gamma; suiteptr->ang[7] = suiteptr->delta = newresidueptr->delta; return(1); } /*___loadsuite()_____________________________________________________________*/ /****movenewtooldresidue()****************************************************/ int movenewtooldresidue(void) { int j=0; for(j=1; j<=9; j++) { strcpy(oldresidueptr->ptID[j],newresidueptr->ptID[j]); } oldresidueptr->basechr[0],newresidueptr->basechr[0]; /*070412*/ oldresidueptr->basechr[0] = '\0'; oldresidueptr->alpha = newresidueptr->alpha; oldresidueptr->beta = newresidueptr->beta; oldresidueptr->gamma = newresidueptr->gamma; oldresidueptr->delta = newresidueptr->delta; oldresidueptr->epsilon = newresidueptr->epsilon; oldresidueptr->zeta = newresidueptr->zeta; return(1); } /*___movenewtooldresidue()___________________________________________________*/ /****printresidue()***********************************************************/ void printresidue(char* type) { int j=0; struct residuestruct* theresidueptr; if(strcmp(type,"old")==0) {theresidueptr = oldresidueptr;} else {theresidueptr = newresidueptr;} fprintf(stderr,"%s ",type); for(j=1; j<=NptIDfields; j++) { fprintf(stderr,"%s",theresidueptr->ptID[j]); } fprintf(stderr," %7.2f, %7.2f, %7.2f, %7.2f, %7.2f, %7.2f\n" ,theresidueptr->alpha ,theresidueptr->beta ,theresidueptr->gamma ,theresidueptr->delta ,theresidueptr->epsilon ,theresidueptr->zeta); } /*___printresidue()__________________________________________________________*/ /****clearnewresidue()********************************************************/ int clearnewresidue(void) { int j=0; for(j=0; j<=9; j++) { newresidueptr->ptID[j][0] = '\0'; } newresidueptr->basechr[0] = '\0'; /*070412*/ newresidueptr->basechr[1] = '\0'; newresidueptr->alpha = 9999.99; newresidueptr->beta = 9999.99; newresidueptr->gamma = 9999.99; newresidueptr->delta = 9999.99; newresidueptr->epsilon = 9999.99; newresidueptr->zeta = 9999.99; return(1); } /*___clearnewresidue()_______________________________________________________*/ /****loadnewresidue()*********************************************************/ int loadnewresidue(void) { int j=0; for(j=1; j<=NptIDfields; j++) { strcpy(newresidueptr->ptID[j],ptID[j]); } newresidueptr->basechr[0] = basechr[0]; /*070412*/ newresidueptr->basechr[1] = '\0'; for(j=1; j<=9; j++) { /*work with angles 0 to 360, dang calc angles -180 to +180 */ if(angle[j] < 0) { angle[j] = angle[j] + 360; } } newresidueptr->alpha = angle[1]; newresidueptr->beta = angle[2]; newresidueptr->gamma = angle[3]; newresidueptr->delta = angle[4]; newresidueptr->epsilon = angle[5]; newresidueptr->zeta = angle[6]; return(1); } /*___loadnewresidue()________________________________________________________*/ /****interpretdanglerecord()**************************************************/ int interpretdanglerecord(void) { int i=0,j=0,k=0,n=0,ns=0,nan=0; char numstr[256]; /*ptID: : : : :...:alpha:beta:gamma:delta:epsilon:zeta*/ n = 1; /*count fields from 1 */ ns = 0; /*first j of current field*/ k = 0; /*counter within a field*/ for(j=0 ; j<= itext; j++) {/*loop through inputed line*/ if(texts[j] == ':' || j==itext) {/* : */ {/*close nth field*/ if(n <= NptIDfields) {/*ID fields*/ { /*k not decremented, k is index of the : character*/ for(i=0; i<=k; i++) { ptID[n][i] = texts[ns+i]; } if(n == NptIDfields) { ptID[n][k] = '\0'; /*overwrite last : character*/ /*so last char of last field is a Base name char*/ /*and this last field is the full 3char Base name*/ if(strlen(ptID[n]) == 3) { /*interpret as Base name --> 1char 070412 */ if (strstr(NAListA, ptID[n])) {basechr[0] = 'A';} else if(strstr(NAListG, ptID[n])) {basechr[0] = 'G';} else if(strstr(NAListC, ptID[n])) {basechr[0] = 'C';} else if(strstr(NAListU, ptID[n])) {basechr[0] = 'U';} else if(strstr(NAListT, ptID[n])) {basechr[0] = 'T';} else {basechr[0] = 'Y';} } else {basechr[0] = 'Z';} basechr[1] = '\0'; } else {ptID[n][k+1] = '\0';} /* not overwrite : character*/ } /*reset for another field*/ { k=0; nan=0; ns = j+1; n++; } }/*ID fields*/ else {/*angle coord fields*/ if(nan) {angle[n-NptIDfields] = 9999.99;} else {angle[n-NptIDfields] = floatfromstr(numstr);} k=0; nan=0; ns = j+1; n++; } }/*close nth field*/ }/* : */ else {/* input character , only actually use numstr for angle fields*/ numstr[k++] = texts[j]; numstr[k] = '\0'; /*keep string terminated*/ if(texts[j] == '?') {nan = 1;} /*NOT a number*/ } }/*loop through inputed line*/ return(1); } /*___interpretdanglerecord()________________________________________________*/ /****interpretresiduerecord()*************************************************/ int interpretresiduerecord(void) { int i=0,j=0,k=0,n=0,ns=0,nan=0; char numstr[256]; /*ptID: : : : :...:alpha:beta:gamma:delta:epsilon:zeta*/ n = 1; /*count fields from 1 */ ns = 0; /*first j of current field*/ k = 0; /*counter within a field*/ for(j=0 ; j<= itext; j++) {/*loop through inputed line*/ if(texts[j] == ':' || j==itext) {/* : */ {/*close nth field*/ if(n <= NptIDfields) {/*ID fields*/ { /*k not decremented, k is index of the : character*/ for(i=0; i<=k; i++) { ptID[n][i] = texts[ns+i]; } if(n == NptIDfields) { ptID[n][k] = '\0'; /*overwrite last : character*/ /*so last char of last field is a Base name char*/ /*and this last field is the full 3char Base name*/ if(strlen(ptID[n]) == 3) { /*interpret as Base name --> 1char 070412 */ if (strstr(NAListA, ptID[n])) {basechr[0] = 'A';} else if(strstr(NAListG, ptID[n])) {basechr[0] = 'G';} else if(strstr(NAListC, ptID[n])) {basechr[0] = 'C';} else if(strstr(NAListU, ptID[n])) {basechr[0] = 'U';} else if(strstr(NAListT, ptID[n])) {basechr[0] = 'T';} else {basechr[0] = 'Y';} } else {basechr[0] = 'Z';} basechr[1] = '\0'; } else {ptID[n][k+1] = '\0';} /* not overwrite : character*/ } /*reset for another field*/ { k=0; nan=0; ns = j+1; n++; } }/*ID fields*/ else {/*angle coord fields*/ if(nan) {angle[n-NptIDfields] = 9999.99;} else {angle[n-NptIDfields] = floatfromstr(numstr);} k=0; nan=0; ns = j+1; n++; } }/*close nth field*/ }/* : */ else {/* input character , only actually use numstr for angle fields*/ numstr[k++] = texts[j]; numstr[k] = '\0'; /*keep string terminated*/ if(texts[j] == '?') {nan = 1;} /*NOT a number*/ } }/*loop through inputed line*/ return(1); } /*___interpretresiduerecord()________________________________________________*/ /****interpretsuiterecord()*************************************************/ int interpretsuiterecord(void) { /*hack unprotected way to read well-formated kinemage pt records*/ int i=0,j=0,k=0,n=0,nan=0; /*nan 070525*/ char numstr[256]; int LptID = 0, iptID = 0; char ptIDstr[256]; char basechr[2]; /*070412*/ for(j=0; j<256; j++){ptIDstr[j] = '\0';} basechr[0] = 'X'; /*070412*/ basechr[1] = '\0'; /* {ptID} deltam,epsilon,zeta,alpha,beta,gamma,delta */ for(j=0 ; j<= itext; j++) {/*loop through inputed line*/ if(texts[j] == '{') /* } balance curly braces */ {/*pointID */ LptID = 1; iptID = 0; } /*{*/ else if(texts[j] == '}') /* balance curly braces */ { ptIDstr[iptID] = '\0'; /*end ptIDstr*/ LptID = 0; basechr[0] = ptIDstr[iptID -1]; /*last char of kin ptID is base char*/ } else if(LptID) { ptIDstr[iptID++] = texts[j]; } else if( (k > 0 && texts[j] == ' ') || texts[j] == ',' || j==itext) {/*white space ends a field*/ numstr[k] = '\0'; if(nan) {angle[n] = 9999.99;} /*070525*/ else {angle[n] = floatfromstr(numstr);} /*n starts at 0*/ if(angle[n] < 0) {angle[n] = 360 + angle[n];} /*scope 0 to 360 */ if(texts[j] == ' ' || texts[j] == ',') /*interior record white space*/ {/*expect another angle*/ k=0; n++; nan = 0; /*reset not-a-number flag 070525*/ } } else {/* input character */ if(texts[j] != ' ') /*ignore leading blanks*/ if(texts[j] == '_' || texts[j] == '?' ){nan = 1;} /*070525*/ {numstr[k++] = texts[j];} } }/*loop through inputed line*/ /*presume suite kinemage record was intact and good...*/ strcpy(suiteptr->ptID,ptIDstr); if(Nanglefields == 9) /*rearranged 070524 to preserve chim,chi (eta,theta)*/ { i=1; suiteptr->ang[0] = suiteptr->chim = angle[0]; suiteptr->ang[8] = suiteptr->chi = angle[7+i]; } else { i=0; suiteptr->ang[0] = suiteptr->chim = 180.0; suiteptr->ang[8] = suiteptr->chi = 180.0; } suiteptr->ang[1] = suiteptr->deltam = angle[0+i]; suiteptr->ang[2] = suiteptr->epsilon = angle[1+i]; suiteptr->ang[3] = suiteptr->zeta = angle[2+i]; suiteptr->ang[4] = suiteptr->alpha = angle[3+i]; suiteptr->ang[5] = suiteptr->beta = angle[4+i]; suiteptr->ang[6] = suiteptr->gamma = angle[5+i]; suiteptr->ang[7] = suiteptr->delta = angle[6+i]; /*now DO NOT need to loadsuite() */ } /*___interpretsuiterecord()________________________________________________*/ /****Getoneinputline()********************************************************/ int Getoneinputline(void) /*cribbed from PKININPT.c*/ { int c=0,ireturn=0; /*NOTE: normal return is from first part of while loop*/ for(itext=0; itext<256; itext++) {texts[itext] = '\0';} /*this will avoid left over garbage at ends of short records*/ itext = 0; /*itext is a global, numbers inputed characters on each line*/ texts[0] = '\0';/*initially a NULL string*/ if(!Lhitend) {/*bypass for EOF on previous line*/ while ((c = fgetc(fpin)) != EOF) { if (c == '\r' || c == '\n') { texts[itext] = '\0'; LatEOF = 0; /* not at EOF */ strcat(texts,EOLO); if(itext < 2) {ireturn = 0;} /*ignore empty or very short lines*/ else ireturn = 1; return(ireturn); /* break out of this subroutine */ } else { texts[itext] = c; if (itext > 254) { texts[itext+1] = '\0'; /*make array of characters into properly ended C string*/ itext = 0; /* Warn the reader about line too long */ fprintf(stderr,"%s\n",texts); fprintf(stderr,"above line is too long"); } else itext++; } }/* loop while file not at EOF */ /* EOF : finish out anything in text buffer */ /*if line is long enough to be coords*/ if(itext > 50) /*enough characters to have coords even on this last line*/ { ireturn = 1; /*line has content*/ LatEOF = 0; /*pretend not EOF, let next pass catch it*/ Lhitend = 1; /*but store info that EOF was hit*/ texts[itext] = '\0'; } else { ireturn = 0; /*not a valid line of any sort*/ LatEOF = 1; /* EOF */ Lhitend = 1; } }/*bypass for EOF on previous line*/ else { LatEOF = 1; /* EOF from previous call now registered*/ } return(ireturn); } /*___Getoneinputline()_______________________________________________________*/ /*****floatfromstr()*********************************************************/ float floatfromstr(char ins[256]) { int Lstart,n,m,OK; char s[256]; float freturn; /*970703 now only handles C-strings*/ freturn = 0.0; Lstart = 1; n = 0; m = 0; OK = 1; if(ins[0] != '\0') {/* not zero length C string */ while(OK) { /* start at position 0 of c str */ if(ins[n] == ' ' && Lstart) ; else if(ins[n] == '0' || ins[n] == '1' || ins[n] == '2' || ins[n] == '3' || ins[n] == '4' || ins[n] == '5' || ins[n] == '6' || ins[n] == '7' || ins[n] == '8' || ins[n] == '9' || ins[n] == '.' || ins[n] == '-' ) { s[m] = ins[n]; m++; Lstart = 0; } else { s[m] = '\0'; OK = 0; } n++; } /*c*/ sscanf(s,"%f",&freturn); } return(freturn); } /*___floatfromstr()_________________________________________________________*/ suitename.0.3.070628/suiteninpt.h0000644000076500001200000000212610641013577017070 0ustar dcrjsradmin00000000000000/* suiteninpt.h */ /*only suiteninpt.c defines SUITENINPT */ #ifndef SUITENINPT extern char *NAListA,*NAListG,*NAListC,*NAListU,*NAListT; extern float angle[10]; extern char ptID[10][32]; extern char basechr[2]; #else char *NAListA = ":ADE: A:A : Ar:ATP:ADP:AMP:T6A:1MA:RIA: I:I :"; char *NAListG = ":GUA: G:G : Gr:GTP:GDP:GMP:GSP:1MG:2MG:M2G:OMG:\ YG: 7MG:YG :"; char *NAListC = ":CYT: C:C : Cr:CTP:CDP:CMP:5MC:OMC:"; char *NAListU = ":URA:URI: U: Ur:U :UTP:UDP:UMP:5MU:H2U:PSU:4SU:"; char *NAListT = ":THY: T:T : Tr:TTP:TDP:TMP:"; float angle[10]; char ptID[10][32]; char basechr[2]; #endif int getresidue(void); int getsuite(void); /*070211 alternative to getresidue()*/ int loadsuite(void); int movenewtooldresidue(void); void printresidue(char*); int clearnewresidue(void); int loadnewresidue(void); int interpretdanglerecord(void); /*070525*/ int interpretresiduerecord(void); int interpretsuiterecord(void); /*070211*/ int Getoneinputline(void); float floatfromstr(char[256]); /*from MAGEUTIL.c*/ suitename.0.3.070628/suitenout.c0000644000076500001200000005557310641030353016725 0ustar dcrjsradmin00000000000000/* suitenout.c */ #include "suitename.h" #define SUITENOUT #include "suitenout.h" #include "suitenhead.h" /* kinemageframe[] 070414*/ #undef SUITENOUT #include "suitenscrt.h" #include "suiteninit.h" /****writesuite()*************************************************************/ void writesuite(int ibin,int jclst,char* sour, float distance, float suiteness,char* ptmaster,char* ptcolor) { int j=0,n=0; /*static int nout=1; Lstringout residue/suite counter, suitenout.h 070421*/ char resstr[32]; char basestr[2]={'\0','\0'}; char clststr[4]={'\0','\0','\0','\0'}; static char lappedstr[256]={'\0'}; char reason[16]; /*used in report: reason for triage*/ char stray[16]; /*used in report: stray wannabe*/ char sourpuss[1]; /*070524*/ char* sourptr; /*070524*/ sourpuss[0] = '\0'; /*070524*/ if(Lkinemageout) {/*kinemage showing clusters*/ if(Lsourout) {sourptr = sour;} /*070524*/ else {sourptr = sourpuss;} sprintf(temps,"{%s %s %s:D==%5.3f:S==%5.3f: %s} %s%s ,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f", bin[ibin].binname, bin[ibin].clst[jclst].clustername, sourptr, distance, suiteness, suiteptr->ptID, ptmaster, ptcolor, suiteptr->chim, suiteptr->deltam, suiteptr->epsilon, suiteptr->zeta, suiteptr->alpha, suiteptr->beta, suiteptr->gamma, suiteptr->delta, suiteptr->chi ); if(ibin > 12 || ibin < 0) { fprintf(stderr,"%s\n",temps); /*e.g. 13: angles not fully specified*/ } else { if(Ltest){fprintf(stderr,"PUT %s\n",temps);} putonetextblockline(&mainscratch,temps); } } else if(Lstringout) {/*3char string in order of input for all entries*/ if(Lsequence) { basestr[0] = suiteptr->basechr[0]; /*070412 found previously*/ } else /*colon instead of single-character Base code 070409*/ { basestr[0] = ':'; } fprintf(fpout,"%s%s",bin[ibin].clst[jclst].clustername,basestr); if(!Loneline) /*070409*/ { if(Loverlap && nout >= 11) { sprintf(clststr,"%s%s",bin[ibin].clst[jclst].clustername,basestr); j = n = 0; while(lappedstr[j] != '\0') {j++;} /*find end of lappedstr*/ while((lappedstr[j++] = clststr[n++]) != '\0') ; /*copy on end*/ } if(nout == 20) { fprintf(fpout," {%s}\n",suiteptr->ptID); if(Loverlap) { fprintf(fpout,"%s",lappedstr); lappedstr[0] = '\0'; nout = 11; } else { nout = 1; } } else {nout++;} } } else if(Lreportout) { /*report on all entries, even if suite is incomplete*/ reason[0] = '\0'; /*default to none*/ stray[0] = '\0'; /*default to none*/ if(Ltriage==EPSILONM) {sprintf(reason," epsilon-1");} /*070628*/ else if(Ltriage==DELTAM){sprintf(reason," delta-1");} /*070628*/ else if(Ltriage==DELTA) {sprintf(reason," delta");} /*070628*/ else if(Ltriage==GAMMA) {sprintf(reason," gamma");} /*070521*/ else if(Ltriage==BETA) {sprintf(reason," beta");} /*070521*/ else if(Ltriage==ALPHA) {sprintf(reason," alpha");} /*070521*/ else if(Ltriage==ZETAM) {sprintf(reason," zeta-1");} /*070628*/ else if(Lcomment){sprintf(reason,"%s",commentstr);} /*070628*/ if(Liswannabe){sprintf(stray," wannabe");} /*070525*/ fprintf(fpout,"%s %s %s %5.3f%s%s\n", suiteptr->ptID, bin[ibin].binname, bin[ibin].clst[jclst].clustername, suiteness, reason, stray /*070628*/ ); reportcountall++; /*everything that suitename brought in */ /*now accummulate sum and count for complete suites*/ if(ibin == 0) { triagecountall++; /*070328*/ } else if(ibin >= 0 && ibin < 13) /*ibin==13 when angles not all defined*/ { /*defineable suites, including triaged and outliers */ suitenesssumall = suitenesssumall + suiteness; /*adding (float)zero won't hurt this sum*/ binnedsuitecountall++; } /*distribution of suiteness values...*/ /*j==0 pseudo clusters always have a suiteness == 0, so sum not changed*/ if(jclst == 0) /*augment the k==11 outlier place for this cluster*/ { /*outliers in bins 1 to 12, triages in bin 0, not defined in bin 13*/ /*jclst membership 4D distance < 1, suiteness > 0 if 7D distance > 1*/ /*outliers in jclst 0, suiteness can be == 0 for others if 7D dist>1 */ suitenesscnt[ibin][jclst][11]++; } else { suitenesssum[ibin][jclst] = suitenesssum[ibin][jclst] + suiteness; /*3rd index for suiteness intervals: 10 at 10ths + extra at zero*/ if(suiteness == 0 ) {suitenesscnt[ibin][jclst][0]++;} if(suiteness > 0 && suiteness < .1) {suitenesscnt[ibin][jclst][1]++;} if(suiteness >= .1 && suiteness < .2) {suitenesscnt[ibin][jclst][2]++;} if(suiteness >= .2 && suiteness < .3) {suitenesscnt[ibin][jclst][3]++;} if(suiteness >= .3 && suiteness < .4) {suitenesscnt[ibin][jclst][4]++;} if(suiteness >= .4 && suiteness < .5) {suitenesscnt[ibin][jclst][5]++;} if(suiteness >= .5 && suiteness < .6) {suitenesscnt[ibin][jclst][6]++;} if(suiteness >= .6 && suiteness < .7) {suitenesscnt[ibin][jclst][7]++;} if(suiteness >= .7 && suiteness < .8) {suitenesscnt[ibin][jclst][8]++;} if(suiteness >= .8 && suiteness < .9) {suitenesscnt[ibin][jclst][9]++;} if(suiteness >= .9) {suitenesscnt[ibin][jclst][10]++;} } } } /*___writesuite()____________________________________________________________*/ /****suitenessaverage()******************************************************/ void suitenessaverage(int mode) /*mode for all, just Aform, etc. */ { int i=0,j=0,k=0; int ibin=0,nbin=0,jclst=0,nclst=0,xbin = -1,xclst = -1; double sum = 0; int num[12] = {0,0,0,0,0,0,0,0,0,0,0,0}; float average = 0; int number = 0; char comment[256]; int Ntriaged = 0; /*070328*/ if(mode == 0) /*all complete suites, all ways*/ { /*bin==13 has the incomplete pseudo-suites with incomplete angles*/ ibin = 1; nbin = 12; jclst = 0; nclst = 11; xbin = -1; xclst = -1; /*exception when >= 0*/ /*ibin 0 contains triaged clusters, never use these*/ fprintf(fpout,"Found %d complete suites derived from %d entries\n" ,binnedsuitecountall+triagecountall,reportcountall); fprintf(fpout,"%d suites were triaged, leaving %d assigned to bins\n" ,triagecountall,binnedsuitecountall); /*070328*/ sprintf(comment,"For all"); } else if(mode == 1) /* A form 1,1*/ { /*bin==13 has the incomplete, pseudo-suites with incomplete angles*/ ibin = 1; nbin = 1; jclst = 1; nclst = 1; /*no outliers (j==0)*/ xbin = -1; xclst = -1; /*exception for this clst in this bin when >= 0*/ sprintf(comment," A form (1a)"); } else if(mode == 2) /* everything except A form, i.e. except 1,1*/ { /*bin==13 has the incomplete pseudo-suites with incomplete angles*/ ibin = 1; nbin = 12; jclst = 1; nclst = 11; /*only complete suite pts*/ /*no outliers (j==0)*/ xbin = 1; xclst = 1; /*exception when >= 0*/ sprintf(comment," non-1a has"); } for(i=ibin; i<=nbin; i++) { for(j=jclst; j<=nclst; j++) /*some clusters not defined in some bins*/ { if(i != xbin || (i == xbin && j != xclst)) { sum = sum + suitenesssum[i][j]; for(k=0; k<12; k++) { num[k] = num[k] + suitenesscnt[i][j][k]; } } } } for(k=0; k<12; k++) { number = number + num[k]; } if(number > 1){average = sum/number;} else {average = 0;} fprintf(fpout,"%s %d suites: average suiteness== %5.3f (power==%4.2f)\n" ,comment,number,average,power); if(mode == 0) {fprintf(fpout,"%6d suites are outliers\n",num[11]);} fprintf(fpout,"%6d suites have suiteness == 0 \n",num[0]); fprintf(fpout,"%6d suites have suiteness > 0 <.1\n",num[1]); fprintf(fpout,"%6d suites have suiteness >=.1 <.2\n",num[2]); fprintf(fpout,"%6d suites have suiteness >=.2 <.3\n",num[3]); fprintf(fpout,"%6d suites have suiteness >=.3 <.4\n",num[4]); fprintf(fpout,"%6d suites have suiteness >=.4 <.5\n",num[5]); fprintf(fpout,"%6d suites have suiteness >=.5 <.6\n",num[6]); fprintf(fpout,"%6d suites have suiteness >=.6 <.7\n",num[7]); fprintf(fpout,"%6d suites have suiteness >=.7 <.8\n",num[8]); fprintf(fpout,"%6d suites have suiteness >=.8 <.9\n",num[9]); fprintf(fpout,"%6d suites have suiteness >=.9 \n",num[10]); } /*___suitenessaverage()______________________________________________________*/ /****writeoutput()************************************************************/ void writeoutput(void) { char commentstr[128]; if(Lgeneralsatw) { sprintf(commentstr, " special general case satellite widths, power = %4.2f",power); } else { sprintf(commentstr, " all general case widths, power = %4.2f",power); } if(Lreportout && !Lchart) { fprintf(fpout,"%s\n",commentstr); suitenessaverage(0); /* 0 mode reports on all suites */ if(clusterout[1][1] > 0) /*Aform 1a 070325*/ { suitenessaverage(1); /* 1 mode reports on A form suites */ suitenessaverage(2); /* 2 mode reports on non-A suites */ } } if(Lkinemageout &&(L33out || L32out || L23out || L22out || Ltriageout)) {/*stuff for a kinemage*/ /*Ltriageout for intact suites that fail individual angle test(s) */ /*each populated bin gets a subgroup*/ kinemageheader(commentstr); kinemagestuffer(janesviews); /*070421*/ kinemagestuffer(kinemageframe); /*070414, 070421*/ /*work through all possible bins and their suites in standard order*/ if(L33out) { fprintf(fpout,"@group {33} recessiveon dimension=9 wrap=360 select animate off\n"); binstuffout(1,3); /*bins in this group*/ } if(L32out) { fprintf(fpout,"@group {32} recessiveon dimension=9 wrap=360 select animate off\n"); binstuffout(4,6); /*bins in this group*/ } if(L23out) { fprintf(fpout,"@group {23} recessiveon dimension=9 wrap=360 select animate off\n"); binstuffout(7,9); /*bins in this group*/ } if(L22out) { fprintf(fpout,"@group {22} recessiveon dimension=9 wrap=360 select animate off\n"); binstuffout(10,12); /*bins in this group*/ } if(Ltriageout) { fprintf(fpout,"@group {triaged} dominant dimension=9 wrap=360 select off\n"); binstuffout(0,0); /*one bin (0th) in this group*/ } }/*stuff for a kinemage*/ if(Lstringout) { if(nout != 1) {fprintf(fpout," {%s}\n",suiteptr->ptID);} else {fprintf(fpout,"\n");} /*just final EOL*/ } } /*___writeoutput()___________________________________________________________*/ /****binstuffout()************************************************************/ void binstuffout(int nbin, int mbin) { int i=0,j=0,ncnt=0; char ctrl[10]; /* 7 actual characters in curly braces*/ char extras[32]; for(i=nbin; i<=mbin; i++) {/*loop over the three bins in this delta delta group*/ if(binout[i]) {/*ith bin has points*/ fprintf(fpout,"@subgroup {%s} recessiveon \n",bin[i].binname); j=1; /*zeroth cluster is for bin outliers, if any, do them later */ while(bin[i].clst[j].LOK) /*named clusters j>0 ... 070429*/ {/*loop over named clusters in this ith bin, NOT including outliers*/ if(clusterout[i][j]) { if(strcmp(bin[i].clst[j].status,"wannabe")==0) /*070429*/ { sprintf(extras," master= {wannabees}"); Lwannabeout = 1; /*redundant, already been set*/ } else {extras[0] = '\0';} fprintf(fpout, "@balllist {%s %s} color= %s radius= 1 nohilite master= {data}%s\n" ,bin[i].binname,bin[i].clst[j].clustername,bin[i].clst[j].clustercolor,extras); sprintf(ctrl,"{%s %s}" ,bin[i].binname,bin[i].clst[j].clustername); ncnt = transferout(ctrl); /*gets just pts starting with ctrl*/ if(j>0) /*obselete, but is a safety*/ {/*belong to a named cluster (av & labels initially on 070414)*/ fprintf(fpout, "@ringlist {%s %s} color= %s radius= 10 width= 1 nobutton master= {avsigma}%s\n" ,bin[i].binname,bin[i].clst[j].clustername,bin[i].clst[j].clustercolor,extras); fprintf(fpout, "{%s %s} 180 %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f 180\n" ,bin[i].binname,bin[i].clst[j].clustername ,bin[i].clst[j].ang[1] ,bin[i].clst[j].ang[2] ,bin[i].clst[j].ang[3] ,bin[i].clst[j].ang[4] ,bin[i].clst[j].ang[5] ,bin[i].clst[j].ang[6] ,bin[i].clst[j].ang[7]); fprintf(fpout, "@labellist {%s %s} color= %s nobutton master= {labels}%s\n" ,bin[i].binname,bin[i].clst[j].clustername,bin[i].clst[j].clustercolor,extras); fprintf(fpout, "{%s %s} 180 %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f 180\n" ,bin[i].binname,bin[i].clst[j].clustername ,bin[i].clst[j].ang[1] ,bin[i].clst[j].ang[2] ,bin[i].clst[j].ang[3] ,bin[i].clst[j].ang[4] ,bin[i].clst[j].ang[5] ,bin[i].clst[j].ang[6] ,bin[i].clst[j].ang[7]); }/*belong to a named cluster*/ }/*members in i,j cluster*/ j++; /*increment cluster index for the while condition 070429*/ }/*loop over named clusters in this ith bin*/ j = 0; /*look for outliers... (set j==0 to reuse code from above)*/ if(clusterout[i][j]) /*outliers in this bin*/ { extras[0] = '\0'; fprintf(fpout, "@balllist {%s %s} color= %s radius= 1 nohilite master= {data}%s\n" ,bin[i].binname,bin[i].clst[j].clustername,bin[i].clst[j].clustercolor,extras); sprintf(ctrl,"{%s %s}" ,bin[i].binname,bin[i].clst[j].clustername); ncnt = transferout(ctrl); /*gets just pts starting with ctrl*/ }/*outliers in this bin*/ }/*ith bin has points*/ }/*loop over bins*/ } /*___binstuffout()___________________________________________________________*/ /****transferout()************************************************************/ int transferout(char* ctrl) { /*cribbed from PKINCOUT/transferout() 070210 */ /* for later flexibility, include some controls not now needed 070210 */ int LatEOF=0, LOK=0; int j=0, iscrt=0, iexist=0; char scrts[256]; rewindtextblock(&mainscratch); LatEOF = 0; while(!LatEOF) {/*scan through scratch block*/ getonetextblockline(&mainscratch,temps); if(temps[0] != '\0') {/*entries still in scratch block*/ if( (temps[0]==ctrl[0]) /*check chars at beginning of ptID*/ &&(temps[1]==ctrl[1]) &&(temps[2]==ctrl[2]) &&(temps[3]==ctrl[3]) &&(temps[4]==ctrl[4]) &&(temps[5]==ctrl[5]) &&(temps[6]==ctrl[6]) &&(temps[7]==ctrl[7]) ) { LOK = 1; /*this point belongs in this list*/ iscrt = 0; if(Ltest){fprintf(stderr,"GOT %s\n",temps);} } else {/*unrecognized, can't use this point in this list*/ LOK = 0; } if(LOK) {/*this point belongs in this list*/ for( j=iscrt ; j<=255 ; j++) /*extract content from temps[] */ { scrts[j-iscrt] = temps[j]; if(temps[j] == '\0') break; } iexist++; /*increase counter*/ /*suitename writeoutput has already written list header*/ /* so do not write this here when iexist==1 */ fprintf(fpout,"%s\n",scrts); /*this point belongs in this list*/} }/*entries still in scratch block*/ else {/*reached end of scratch block*/ LatEOF = 1; } } return(iexist); } /*___transferout()___________________________________________________________*/ /****kinemageheader()*********************************************************/ void kinemageheader(char* textstr) { fprintf(fpout,"@text\n %s\n %s\n",version,textstr); fprintf(fpout,"@kinemage 1\n"); fprintf(fpout,"@onewidth\n"); if(Letatheta) /*070524*/ {fprintf(fpout,"@dimension {theta} {delta-1} {epsilon-1} {zeta-1} {alpha} {beta} {gamma} {delta} {eta}\n");} else {fprintf(fpout,"@dimension {chi-1} {delta-1} {epsilon-1} {zeta-1} {alpha} {beta} {gamma} {delta} {chi}\n");} fprintf(fpout,"@dimminmax 0.000 360.000 0.000 360.000 0.000 360.000 0.000 360.000 0.000 360.000 0.000 360.000 0.000 360.000 0.000 360.000 0.000 360.000\n"); if(LTepsilon) {fprintf(fpout,"@pointmaster 'E' {epsilon bad}\n");} else if(LTdelta || LTdeltam) {fprintf(fpout,"@pointmaster 'D' {delta bad}\n");} else if(LTzeta || LTalpha || LTbeta || LTgamma) {fprintf(fpout,"@pointmaster 'T' {various bad}\n");} if(Loutlier) {fprintf(fpout,"@pointmaster 'O' {outliers}\n");} if(Lwannabeout) {fprintf(fpout,"@master {wannabees}\n");} } /*___kinemageheader()________________________________________________________*/ /****kinemagestuffer()********************************************************/ void kinemagestuffer(char* kinemagestuff[]) { int more = 1, j=0, Nth=0; char temps[256]; while(more) {/*loop over all text for this call*/ for(j=0; j<255; j++) /*save a space for safety '\0' */ {/*load transfer string*/ temps[j] = kinemagestuff[Nth][j]; if(temps[j] == '\r') {/*ASCII Carraige Return*/ temps[j] = EOL; /*platform specific End-Of-Line character*/ } if(temps[j] == '\0'){ break;} /*separate end of text piece*/ }/*load transfer string*/ /*check for END before writing to stdout*/ if(temps[0] =='E' && temps[1] =='N' && temps[2] =='D'){more = 0;} temps[j+1] = '\0'; /*safety if runs off end of temps str*/ if(more != 0) {fprintf(fpout,"%s",temps);} Nth++; /*local, not static, so will get reset ==0 on new call*/ }/*loop over all text for this call*/ } /*___kinemagestuffer()_______________________________________________________*/ /****clearbinout()************************************************************/ void clearbinout(void) { int i=0,j=0; for(i=1; istdout\n"); fprintf(stderr,"output flags: [ -report || -string || -kinemage ]\n"); fprintf(stderr,"default: -report -residuein \n"); fprintf(stderr,"input flags: [ -residuein || -suitein ]\n"); fprintf(stderr,"flags: [ -residuein [ -pointIDfields # ] ] default#==%d\n" ,NptIDfields); fprintf(stderr," OR "); fprintf(stderr,"flags: [ -suitein [ -anglefields # ] ] default#==%d\n" ,Nanglefields); fprintf(stderr,"\n"); fprintf(stderr,"defaults: -residuein -pointIDfields %d\n",NptIDfields); fprintf(stderr," as made by dangle \n"); fprintf(stderr, "dangle \"alpha, beta, gamma, delta, epsilon, zeta\" in.pdb >out.dngl\n"); fprintf(stderr, "label:model:chain:number:ins:type:alpha:beta:gamma:delta:epsilon:zeta\n"); fprintf(stderr,"-suitein presumes point records from a kinemage\n"); fprintf(stderr,"{pointID} 7 or 9 anglefields \n"); fprintf(stderr, "{ptID} [chi] deltam epsilon zeta alpha beta gamma delta [chi] \n"); fprintf(stderr," Note that all other kinemage lines must be stripped off.\n"); fprintf(stderr,"-thetaeta kinemage labels theta,eta instead of chi-1,chi\n"); fprintf(stderr,"Note dangle trick to make theta,...,eta suites directly\n"); fprintf(stderr,"\n"); fprintf(stderr,"flag: -report [ -chart ]\n"); fprintf(stderr," suites in order of input, suiteness summary at end\n"); fprintf(stderr,"( -chart : NO summary at end, for MolProbity multichart\n"); fprintf(stderr,"\n"); fprintf(stderr,"flag: -string\n"); fprintf(stderr," 3 character per suite string in order of input\n"); fprintf(stderr," 20 per line, ptID of n*20th at end of line\n"); fprintf(stderr," flag: -nosequence\n"); fprintf(stderr," only suite names, no Base sequence character\n"); fprintf(stderr," flag: -oneline\n"); fprintf(stderr," string all one line, no point IDs\n"); fprintf(stderr," flag: -overlap\n"); fprintf(stderr," 20 per line: overlap 10 each line, 10 new per line\n"); fprintf(stderr,"\n"); fprintf(stderr,"flag: -kinemage\n"); fprintf(stderr," kinemage of clusters grouped by pucker,pucker ... \n"); fprintf(stderr," group {delta,delta},subgroup {gamma},list {cluster name}\n"); fprintf(stderr,"\n"); /*fprintf(stderr,"flag: -satellite\n"); DO NOT ADVERTISE THIS OPTION*/ /*fprintf(stderr," use special general case satellite widths\n");*/ fprintf(stderr," assigns to designated wannabe clusters, default: wannabe\n"); /*fprintf(stderr,"flag: -wannabe\n");*/ fprintf(stderr,"flag: -nowannabe to not assign them\n"); fprintf(stderr,"\n"); fprintf(stderr,"[ -power #.#] default# %4.2f multi-dimension distance calc\n" ,power); fprintf(stderr,"[ -test ] dump cluster centers, halfwidths,... to stderr\n"); fprintf(stderr,"cluster averages version: %s\n",clusteraveragesversion); fprintf(stderr,"cluster half-widths version: %s\n",clusterhalfwidthsversion); fprintf(stderr,"axes limits version: %s\n",axeslimitsversion); fprintf(stderr,"suitename is not paying attention to chains...\n"); fprintf(stderr,"%s\n",version); } /*___usageout()______________________________________________________________*/ suitename.0.3.070628/suitenout.h0000644000076500001200000000376710641024765016742 0ustar dcrjsradmin00000000000000/* suitenout.h */ #ifdef SUITENOUT #undef SUITENOUT #define SUITENOUT #else #define SUITENOUT extern #endif #define DELTAM 1 /*Ltriage reason flags 070628*/ #define EPSILONM 2 #define ZETAM 3 #define ALPHA 4 #define BETA 5 #define GAMMA 6 #define DELTA 7 /*diagnostic flags*/ SUITENOUT int Ltriage; /*reset for each suite, set to reason, e.g. DELTAM*/ SUITENOUT int Liswannabe; SUITENOUT int Lcomment; /*for 7D distance forced outlier or closest assignment*/ SUITENOUT char commentstr[16]; /*and Lcomment 070628*/ SUITENOUT int Loutlier; /*accummulates*/ SUITENOUT int LTdeltam,LTdelta,LTepsilon,LTzeta,LTalpha,LTbeta,LTgamma; /* LT...flags accummulate for pointmaster definition 070628*/ SUITENOUT int L33out,L32out,L23out,L22out,Ltriageout; /*groups*/ SUITENOUT int binout[MAXBINS]; /*incl 1--12 named bins */ /*subgroups*/ SUITENOUT int clusterout[MAXBINS][MAXCLST]; /*lists*/ SUITENOUT double suitenesssum[MAXBINS][MAXCLST], suitenesssumall; SUITENOUT int suitenesscnt[MAXBINS][MAXCLST][12]; /*3rd index for suiteness intervals: 10 at 10ths + 2 extras */ /* extra at zero counts valid suites with suiteness == 0 */ /* e.g. 4D distance < 1 but 7D distance > 1 */ /* extra at 11 counts valid suites but triaged or outlier */ SUITENOUT int binnedsuitecountall, reportcountall; SUITENOUT int triagecountall; /*070328*/ SUITENOUT int Lwannabeout; /*wannabe in output flag 070429*/ SUITENOUT char temps[256]; static int nout=1; /*Lsringout residue/suite counter*/ /*prototypes*/ void writeoutput(void); void binstuffout(int, int); int transferout(char*); void kinemageheader(char*); /*070328 char* */ void kinemagestuffer(char* kinemagestuff[]); /*070414, 070421*/ void writesuite(int, int, char*, float, float, char*, char*); void clearbinout(void); void clearclusterout(void); void usageout(void); void suitenessaverage(int); suitename.0.3.070628/suitenscrt.c0000644000076500001200000001102310641013577017060 0ustar dcrjsradmin00000000000000/* suitenscrt.c cribbed from PKINSCRT.c 070210 */ #include "suitename.h" #define SCRATCH /*that is, SCRATCH is blank, so suitenscrt.h will do initial declarations*/ #include "suitenscrt.h" #undef SCRATCH /****inittextblock()**********************************************************/ void inittextblock(textblock* tb) { tb->begin = tb->end = tb->next = tb->cursor = NULL; } /*___inittextblock()_________________________________________________________*/ /****rewindtextblock()********************************************************/ void rewindtextblock(textblock* tb) { tb->cursor = tb->begin; /*just move cursor back to beginning*/ } /*___rewindtextblock()_______________________________________________________*/ /*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/ /****disposetextblock()*******************************************************/ void disposetextblock(textblock* tb) { if (tb->begin) { free(tb->begin); /*actually releases any allocated space*/ inittextblock(tb); /*just sets member pointers==0*/ } } /*___disposetextblock()______________________________________________________*/ /*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/ /****putonetextblockline()****************************************************/ void putonetextblockline(textblock* tb, char* thestring) { static char stringtemp[256]; /*store directly in giant character array, textblock */ if( (unsigned)(tb->end - tb->next) < strlen(thestring)+8 ) /*give some slack*/ {/*build more space*/ strcpy(stringtemp,thestring);/*leaving this routine forgets contents*/ buildtextblock(tb, 10000); /*PKINSCRT.c*/ /*try for (n) more */ strcpy(thestring,stringtemp); } if( (unsigned)(tb->end - tb->next) > strlen(thestring) ) /*insurance */ { strcpy(tb->next,thestring); tb->next += strlen(tb->next) + 1; } } /*___putonetextblockline()___________________________________________________*/ /****getonetextblockline()****************************************************/ void getonetextblockline(textblock* tb, char* thestring) { /*get one character string from textblock, giant character array*/ if(tb->cursor < tb->next) /*next available open space*/ { strcpy(thestring,tb->cursor); tb->cursor += strlen(tb->cursor) + 1; } else thestring[0] = '\0'; /*NULL string signel for end of data*/ return; } /*___getonetextblockline()___________________________________________________*/ /****buildtextblock()*********************************************************/ void buildtextblock(textblock* tb, size_t more) { textblock tbtemp; /*members: char *begin, *end, *next, *cursor */ size_t length,nextoffset; int ifail, recycle, moretry; tbtemp.begin = NULL; tbtemp.end = NULL; tbtemp.next = NULL; tbtemp.cursor = NULL; moretry = more; recycle = 1; while(recycle==1) {/*recycle allocation trials*/ ifail = 0; length = tb->end - tb->begin; nextoffset = tb->next - tb->begin; if(tb->begin) {/*exists: realloc more space*/ length = tb->end - tb->begin; tbtemp.begin=(char *)realloc(tb->begin,sizeof(char)*(length+more)); if(tbtemp.begin==NULL) ifail = 1; } else {/*not previously built, malloc initial "more" space*/ length = 0; nextoffset = 0; tbtemp.begin = (char *)malloc(sizeof(char)*more); if(tbtemp.begin==NULL) ifail = 1; } if(ifail) {/*failed to do a reallocation, reduce request and try again*/ more = more/2; if(more > 3) recycle = 1; else recycle = 0; } else recycle = 0; }/*recycle allocation trials*/ if(ifail==0) { tb->begin = tbtemp.begin; /*reassign pointer*/ tb->next = tb->begin + nextoffset; /*reset*/ tb->cursor = tb->next; /*current position*/ tb->end = tb->begin + sizeof(char)*(length+more); } if(Ltest||ifail) { if(ifail) sprintf(alertstr,CRLF"+%d text block reallocation failed"CRLF ", remains: %ld" ,moretry,(tb->end - tb->begin)); else sprintf(alertstr,CRLF"text block allocation now == %ld"CRLF ,(tb->end - tb->begin)); fprintf(stderr,"%s",alertstr); } } /*___buildtextblock()________________________________________________________*/ suitename.0.3.070628/suitenscrt.h0000644000076500001200000000130310641013577017065 0ustar dcrjsradmin00000000000000/* suitenscrt.h see PKINSCRT.c */ /*suitescrt.c defines SCRATCH as nothing ("") so really does the declarations*/ /* if SCRATCH not defined, then it is defined as "extern" so only referenced*/ #ifdef SCRATCH #undef SCRATCH #define SCRATCH #else #define SCRATCH extern #endif SCRATCH char alertstr[256]; typedef struct{ char* begin; char* end; char* next; char* cursor; } textblock; SCRATCH textblock mainscratch; /*prototypes*/ void inittextblock(textblock*); void rewindtextblock(textblock*); void buildtextblock(textblock*, size_t); void disposetextblock(textblock*); void putonetextblockline(textblock*, char*); void getonetextblockline(textblock*, char*); suitename.0.3.070628/suitenutil.c0000644000076500001200000001162310641013577017070 0ustar dcrjsradmin00000000000000/* suitenutil.c */ #include "suitename.h" #define SUITENUTIL #include "suitenutil.h" #undef SUITENUTIL #include "suiteninit.h" /****vector7ab()**************************************************************/ void vector7ab(float* atob, float* a, float* b) { int j=0,ncnt=1,ndim=7; /*could pass these values ... */ if(ncnt==1) {atob[0] = 0;} /*count from 1*/ for(j=ncnt; j<=ndim; j++) { atob[j] = b[j] - a[j]; } } /*___vector7ab()_____________________________________________________________*/ /****hyperellipsoiddist()*****************************************************/ float hyperellipsoiddist(int i, int j, int nang, float* warray) { /*Piet Hein superellipse, hyperellipsoids */ /*library power function: */ /*http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_17.html*/ /*double pow (double base, double power)*/ int k=0,kmin=0,kmax=0,n=0; double del=0,delpower=0,dpower=0; /*power is global, can be specified on input: -power #.# */ if(nang == 4){kmin=2; kmax=5;} else {kmin=1; kmax=7;} dpower = 0; for(k=kmin; k<=kmax; k++) /*evaluate distance to this i,j cluster*/ { /* 1 2 3 4 5 6 7 */ /* deltam epsilon zeta alpha beta gamma delta */ /* X X X */ /* X not used in 4 angle distance calc*/ /*del = suiteptr->ang[k] - clusterav[i][j][k];*/ /*globals*/ del = suiteptr->ang[k] - bin[i].clst[j].ang[k]; /*globals*/ if(del < 0){del = -del;} del = del/warray[k]; /*normalize, del < 1 inside the ellipsoid*/ delpower = 1; /*for(n=1; n<=power; n++)*/ /*{delpower = del*delpower;}*/ /*this component*/ delpower = pow(del,power); dpower = dpower + delpower; /*accummulate components*/ } dpower = pow(dpower,1/power); /* fprintf(stderr,"suite: %s nangle==%d power== %f, distance== %f\n",suiteptr->ptID,nang,power,dpower); */ return((float)dpower); } /*___hyperellipsoiddist()____________________________________________________*/ /****dotproduct()*************************************************************/ float dotproduct(float* first, float* secnd, int nang) { int k=0,kmin=0,kmax=0; float answer=0; if(nang = 4){kmin=2; kmax=5;} else {kmin=1; kmax=7;} answer = 0; for(k=kmin; k<=kmax; k++) /*evaluate distance to this i,j cluster*/ { /* 1 2 3 4 5 6 7 */ /* deltam epsilon zeta alpha beta gamma delta */ /* X X X */ /* X not used in 4 angle calc*/ answer = answer + (first[k] * secnd[k]); } return(answer); } /*___dotproduct()____________________________________________________________*/ /****resetcoordw()************************************************************/ void resetcoordw(float* widptr, int ith, int jth, int Lspecial) { widptr[1] = deltamw ; widptr[6] = gammaw ; widptr[7] = deltaw ; if(Lspecial && satellites[ith][jth] > 0) { widptr[2] = epsilonsatw ; widptr[3] = zetasatw ; widptr[4] = alphasatw ; widptr[5] = betasatw ; } else { widptr[2] = epsilonw ; widptr[3] = zetaw ; widptr[4] = alphaw ; widptr[5] = betaw ; } } /*___resetcoordw()___________________________________________________________*/ /****confirmsuite()***********************************************************/ int confirmsuite(void) { if( suiteptr->deltam >= 0 && suiteptr->deltam <= 360 && suiteptr->epsilon >= 0 && suiteptr->epsilon <= 360 && suiteptr->zeta >= 0 && suiteptr->zeta <= 360 && suiteptr->alpha >= 0 && suiteptr->alpha <= 360 && suiteptr->beta >= 0 && suiteptr->beta <= 360 && suiteptr->gamma >= 0 && suiteptr->gamma <= 360 && suiteptr->delta >= 0 && suiteptr->delta <= 360 ) {return(1);} else {return(0);} } /*___confirmsuite()__________________________________________________________*/ /****CompArgStr()***********jmw/utility***************************************/ int CompArgStr(char *str, char *arg, int min) { /*requires exact (caseless) match up through min number of characters */ /* past that, must break or continue exactly matching to be valid*/ int i, max; char s, a; if (!str || !arg) return 0; max = strlen(arg); for(i=0; i= min && ( s == '\0' || s == ',' || s == '(' || s == '.' || s == '+' || s == '-' || isdigit(s))) { break; /* good ending point */ } else if (s != a) { i = 0; /* failed to match */ break; } } return i; } /*___CompArgStr()____________________________________________________________*/ suitename.0.3.070628/suitenutil.h0000644000076500001200000000062610641013577017076 0ustar dcrjsradmin00000000000000/* suitenutil.h */ #ifdef SUITENUTIL #undef SUITENUTIL #define SUITENUTIL #else #define SUITENUTIL extern #endif /* prototypes: */ void vector7ab(float*, float*, float*); float hyperellipsoiddist(int,int,int,float*); void resetcoordw(float*,int,int,int); float dotproduct(float*, float*,int); int confirmsuite(void); int CompArgStr(char*, char*, int);