void PointsCountMessageBox(const std::wstring s) { std::wstringstream msg; msg << L"The text has " << countpoints(s) << L" points inside it."; MessageBox(0, msg.str().c_str(), L"Points", MB_OK | MB_ICONEXCLAMATION); }
/****connecthbonds()*********************************************************/ void connecthbonds(void) { float dlimhb,angfac; int icountrewinds; int Lmore,Lscan; char a[3],resco[4],resnh[4],nhflag[4]; char flag3[4]; int numnh,numco; float nxyz[4],nhxyz[4],oxyz[4]; /*mc hbonds calculation and output */ /*find all mc hbonds that fit distance and angle criteria */ /* write triplets vector: P n L h L o */ dlimhb = 3.5; angfac = (float)2.3; Lmore = TRUE; Lscan = TRUE; icountrewinds = 0; rewindtextblock(&hbnscratch); while( Lmore ) {/*Lmore loop over all nh's*/ getonetextblockline(&hbnscratch,temps); if(temps[0]=='\0') { Lmore = 0; break; } /*sscanf for nh stuff */ sscanf(temps,"%s %s %d %s %f %f %f %f %f %f",a,resnh,&numnh,nhflag ,&nxyz[1],&nxyz[2],&nxyz[3],&nhxyz[1],&nhxyz[2],&nhxyz[3]); /* sprintf(alertstr,"first nh working= "CRLF"%s %d %f %f %f %f %f %f" ,resnh,numnh,nxyz[1],nxyz[2],nxyz[3],nhxyz[1],nhxyz[2],nhxyz[3]); DoReportDialog(); */ Lscan = TRUE; rewindtextblock(&hboscratch); /*---------------------------------------------------------------------*/ icountrewinds++; if(icountrewinds == 1 && IMAC) getmactextselect(); /*PKMCTEXT.C PKPCTEXT.C*/ /*macintosh TE variable used in pkintextreplace(temps)*/ /*PC dummies and ignores this */ sprintf(temps,"%d tries",icountrewinds); /* . for each co - hn pair processed */ if(IPC) pkintextinsert(temps); /*PKMCTEXT.C PKPCTEXT.C*/ else pkintextreplace(temps); /*PKMCTEXT.C PKPCTEXT.C*/ nLines = nLines-1; /*overwrite for PC control*/ /*---------------------------------------------------------------------*/ while(Lscan) {/*Lscan loop over all co's*/ getonetextblockline(&hboscratch,temps); if(temps[0]=='\0') { Lscan = 0; break; } /*sscanf for co stuff */ sscanf(temps,"%s %s %d %s %f %f %f" ,a,resco,&numco,flag3,&oxyz[1],&oxyz[2],&oxyz[3]); /* sprintf(alertstr,"co testing= "CRLF"%s %d %f %f %f" ,resco,numco,oxyz[1],oxyz[2],oxyz[3]); DoReportDialog(); */ /*check distance for possible h-bond from this carbonyl o to working nh */ if(numco != numnh) /*avoid nh - oc of same residue! */ {/*between different residues*/ disthb = (float)(sqrt( (nhxyz[1] - oxyz[1])*(nhxyz[1] - oxyz[1]) + (nhxyz[2] - oxyz[2])*(nhxyz[2] - oxyz[2]) + (nhxyz[3] - oxyz[3])*(nhxyz[3] - oxyz[3]) ) ); cosnho = (nhxyz[1] - nxyz[1])*(oxyz[1] - nhxyz[1])/disthb + (nhxyz[2] - nxyz[2])*(oxyz[2] - nhxyz[2])/disthb + (nhxyz[3] - nxyz[3])*(oxyz[3] - nhxyz[3])/disthb ; dimhb = dlimhb - angfac + angfac*cosnho; /* sprintf(alertstr,"disthb= %f <= dimhb= %f",disthb,dimhb); DoReportDialog(); */ if(disthb <= dimhb) {/*H-BOND*/ /*shorten ends of displayed vectors slightly for clarity */ oxyz[1] = (float)(oxyz[1] + 0.3*(nhxyz[1] - oxyz[1])); oxyz[2] = (float)(oxyz[2] + 0.3*(nhxyz[2] - oxyz[2])); oxyz[3] = (float)(oxyz[3] + 0.3*(nhxyz[3] - oxyz[3])); /*mxyz[1] = (float)(nxyz[1] + 0.3*(nhxyz[1] - nxyz[1]));*/ /*mxyz[2] = (float)(nxyz[2] + 0.3*(nhxyz[2] - nxyz[2]));*/ /*mxyz[3] = (float)(nxyz[3] + 0.3*(nhxyz[3] - nxyz[3]));*/ /*write to regular scratch file*/ typenow=typehb; /* distance as author comment */ /* U = Unpickable points */ /*--write from hn to shortened-end o */ /* note 4 char id: hb__ 920302*/ sprintf(temps,"hb {%s %d hn} <%4.3f> P U %.3f, %.3f, %.3f " "{%s %d o} L U %.3f, %.3f, %.3f"EOLO ,resnh,numnh,disthb,nhxyz[1],nhxyz[2],nhxyz[3] ,resco,numco,oxyz[1],oxyz[2],oxyz[3]); putonetextblockline(&mainscratch,temps); ++countxyz; ++pointcnt[typenow];countpoints("hb ",0); ++countxyz; ++pointcnt[typenow];countpoints("hb ",0); Listhb = TRUE; /* printf("%s\n",temps); */ }/*H-BOND*/ }/*between different residues*/ }/*Lscan loop over all co's*/ }/*Lmore loop over all nh's*/ }
int main() { remove(sr_go_1); remove(sr_go_2); remove(kl_stop_1); remove(kl_stop_2); int ready1,ready2; //new_game new_game(); countpoints(); //in file file_in(); fkl1= fopen(kl_1,"w"); fclose(fkl1); fkl2= fopen(kl_2,"w"); fclose(fkl1); if((fstop1 = fopen(kl_stop_1,"w"))==0){ printf("\nstopfile(1) error"); Sleep(3000);exit(1);} else fclose(fstop1); if((fstop2 = fopen(kl_stop_2,"w"))==0){ printf("\nstopfile(2) error"); Sleep(3000);exit(1);} else fclose(fstop2); while(1) { printf("1"); remove(sr_go_1); remove(sr_go_2); while((fstop1 = fopen(kl_stop_1,"w"))==0) printf("\nTry open kl_stop_1"); while((fstop2 = fopen(kl_stop_2,"w"))== 0) printf("\nTry open kl_stop_2") ; fclose(fstop1); fclose(fstop2); ready1= 0; ready2= 0; while(ready1*ready2 == 0) { //printf("2"); Sleep(500); if(ready1 == 0) { srgo1 = fopen(sr_go_1,"r"); if(srgo1!= 0) { check_file(1); ready1 = 1; printf("\nready 1"); fclose(srgo1); if(remove(sr_go_1) !=0) printf("\ncant del sr_go_1"); } } if(ready2 == 0) { srgo2 = fopen(sr_go_2,"r"); if(srgo2!=0) { check_file(2); ready2 = 1; printf("\nready 2"); fclose(srgo2); if(remove(sr_go_2) !=0) printf("\ncant del sr_go_2"); } } } //countwar WarCount(); countmaps(); if(countpoints()== 1); // конец игры file_in(); } }