-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathisomif.cpp
2116 lines (1913 loc) · 78.7 KB
/
isomif.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// IsoMIF is a program to identify molecular interaction field similarities between proteins
// Copyright (C) 2015 - Matthieu Chartier (under the supervision or Rafael Najmanovich)
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "isomif.h"
/***********************************************************************/
/* 1 2 3 4 5 6 7*/
/*234567890123456789012345678901234567890123456789012345678901234567890*/
/* 1 2 3 4 5 6 7*/
/***********************************************************************/
int main(int argc, char *argv[]){
char tmp[2000];
FILE* fp;
int i,j,k,l,cg,cgs;
int count=0;
vector<node>::iterator vit1;
pNode agv=NULL;
//Read command line arguments
if(read_commandline(argc, argv)==24){ return(0); }
//Set JTT matrix for C alpha stage to determine similar atoms
//The matrix shows the similarity level for each atom pairs
setJTT(jttt);
if(pairwiseF.compare("")!=0){ //If the input file contains multiple MIF comparisons to do
getPairwise();
// open_file_ptr(&fpout,out_file,1);
}else{ //If its just a single MIF pair comparison
pwRun npw;
npw.mif1=nrg_file1;
npw.mif2=nrg_file2;
npw.rnc1=rnc1;
npw.rnc2=rnc2;
npw.getrmsd=getrmsd; //Do we need to calculate the RMSD between the superimposed ligands during this run? 1 or 0
pw.push_back(npw);
pair<map<string,mif>::iterator,bool> mit;
mif nmif1;
mit=mifs.insert(pair<string,mif>(nrg_file1,nmif1));
if(mit.second!=false){
mifs[nrg_file1].rnc=npw.rnc1;
createVrtxVec(nrg_file1,mifs[nrg_file1].mif,mifs[nrg_file1].prot,mifs[nrg_file1].ss,mifs[nrg_file1].ssm,mifs[nrg_file1].caSize,mifs[nrg_file1].pseudoL,mifs[nrg_file1].rnc,mifs[nrg_file1].lig);
}
mif nmif2;
mit=mifs.insert(pair<string,mif>(nrg_file2,nmif2));
if(mit.second!=false){
mifs[nrg_file2].rnc=npw.rnc2;
createVrtxVec(nrg_file2,mifs[nrg_file2].mif,mifs[nrg_file2].prot,mifs[nrg_file2].ss,mifs[nrg_file2].ssm,mifs[nrg_file2].caSize,mifs[nrg_file2].pseudoL,mifs[nrg_file2].rnc,mifs[nrg_file2].lig);
}
}
for(int pwr=0; pwr<pw.size(); pwr++){ //For each pairwise MIF comparisons (one or more)
//Store initial values
nrg_file1=pw[pwr].mif1;
nrg_file2=pw[pwr].mif2;
rnc1=pw[pwr].rnc1;
rnc2=pw[pwr].rnc2;
getrmsd=pw[pwr].getrmsd;
topT=-1.0; //Set the top tanimoto score
topN=-1; //Set the top nodes score
//Fetch some information form the input Mif files
if(get_info(nrg_file1,nrg_file2)==24){ return(24); }
char cmdLineJob[550]; //Cmd line is a copy of the command line
strcpy(cmdLineJob,exePath);
strcat(cmdLineJob," -p1 "); strcat(cmdLineJob,nrg_file1.c_str());
strcat(cmdLineJob," -p2 "); strcat(cmdLineJob,nrg_file2.c_str());
strcat(cmdLineJob," "); strcat(cmdLineJob,cmdArgs);
if(emptOut==1){ //If we want a short output file (to reduce file size) we only print a few information
sprintf(tmp,"REMARK command: %s\nREMARK commandJob: %s\nREMARK mif_file_1: %s\nREMARK mif_file_2: %s\nREMARK wsimfn: %d\nREMARK tag1: %s\nREMARK tag2: %s\nREMARK rnc1: %s\nREMARK rnc2: %s\n",cmdLine,cmdLineJob,nrg_file1.c_str(),nrg_file2.c_str(),wrfn,tag1.c_str(),tag2.c_str(),rnc1.c_str(),rnc2.c_str());
}else{ //Full output file
sprintf(tmp,"REMARK command: %s\nREMARK commandJob: %s\nREMARK mif_file_1: %s\nREMARK mif_file_2: %s\nREMARK nb_of_probes: %d\nREMARK C-alpha_dDist: %5.2f\nREMARK pseudocenter_dDist: %5.2f\nREMARK dDist: %5.2f\nREMARK jtt_threshold: %d\nREMARK max_nodes: %d\nREMARK commont int : %d\nREMARK wsimfn: %d\nREMARK tag1: %s\nREMARK tag2: %s\nREMARK rnc1: %s\nREMARK rnc2: %s\n",cmdLine,cmdLineJob,nrg_file1.c_str(),nrg_file2.c_str(),nb_of_probes,ca_dDist,ps_dDist,dDist,jttt,maxNodes,commonInt,wrfn,tag1.c_str(),tag2.c_str(),rnc1.c_str(),rnc2.c_str());
}
strcpy(outH,tmp);
mif1=mifs[nrg_file1].mif;
mif2=mifs[nrg_file2].mif;
prot1=mifs[nrg_file1].prot;
prot2=mifs[nrg_file2].prot;
ss1=mifs[nrg_file1].ss;
ss2=mifs[nrg_file2].ss;
ss1m=mifs[nrg_file1].ssm;
ss2m=mifs[nrg_file2].ssm;
caSize1=mifs[nrg_file1].caSize;
caSize2=mifs[nrg_file2].caSize;
pseudoL1=mifs[nrg_file1].pseudoL;
pseudoL2=mifs[nrg_file2].pseudoL;
rnc1=mifs[nrg_file1].rnc;
rnc2=mifs[nrg_file2].rnc;
lig1=mifs[nrg_file1].lig;
lig2=mifs[nrg_file2].lig;
// cout<<"mif1 size: "<<mif1.size()<<endl;
// cout<<"mif2 size: "<<mif2.size()<<endl;
// cout<<"ssm1 size: "<<ss1m[1]<<endl;
// cout<<"ssm2 size: "<<ss2m[1]<<endl;
// cout<<"ss1 "<<ss1[0]<<" "<<ss1[1]<<" "<<ss1[2]<<" "<<ss1[3]<<endl;
// cout<<"ss2 "<<ss2[0]<<" "<<ss2[1]<<" "<<ss2[2]<<" "<<ss2[3]<<endl;
// cout<<"ss1m "<<ss1m[0]<<" "<<ss1m[1]<<" "<<ss1m[2]<<" "<<ss1m[3]<<endl;
// cout<<"ss2m "<<ss2m[0]<<" "<<ss2m[1]<<" "<<ss2m[2]<<" "<<ss2m[3]<<endl;
// cout<<"lig1 "<<lig1.size()<<endl;
// for(int l=0; l<lig1.size(); l++){
// cout<<lig1[l].atomn<<endl;
// }
// cout<<"lig2 "<<lig2.size()<<endl;
// for(int l=0; l<lig2.size(); l++){
// cout<<lig2[l].atomn<<endl;
// }
//To be considered for the graph matching, nodes.cg must be set to 1
if(cg_start>-1){ //If we define a specific grid resolution in the command line
for(i=0; i<mif1.size(); ++i){
mif1.at(i).cg[cg_start]=1; //set all vertices of this resolution to 1 so we can consider them
}
for(i=0; i<mif2.size(); ++i){
mif2.at(i).cg[cg_start]=1;
}
}
cout <<endl<< "--# Starting coarsegrain steps #--\n";
//Start the coarse-grain steps (arguments -c of the command line)
//Steps vector contains the grid resolution we will do, one after the other (e.g. 0,2 means we'll do grid resolution 2.0 then 1.5)
for(int cs=0; cs<steps.size(); cs++){
//Initialize the number of cliques we explored to 0
nCliques=0;
nCliquesExplored=0;
cout<<endl<<"Coarse-Grain Step "<<steps[cs]<<endl;
//If argument -c == 2, it means the user wants to superimpose mifs using rotation matrix derived from atom list superimposition
if(steps[cs]==-2){
vector<float> la;
vector<float> lb;
if(list1.size()==0){
cout<<"You must provide two lists of corresponding atom IDs to superimpose for stage -2 using argument -q. Ex: -q 0,1,2,3 38,46,47,53"<<endl;
}
//Create a coordinate vector for atom list 1 and atom list 2 (la and lb)
for(int i=0; i<list1.size(); i++){
for(int j=0; j<prot1.size(); j++){
if(prot1[j].atomnb==list1[i]){
for(int c=0; c<3; c++){
la.push_back(prot1[j].coor[c]);
}
break;
}
}
for(int j=0; j<prot2.size(); j++){
if(prot2[j].atomnb==list2[i]){
for(int c=0; c<3; c++){
lb.push_back(prot2[j].coor[c]);
}
break;
}
}
}
if(la.size()!=lb.size()) cout<<"The -2 superimposition requires to have same number of coordinates."<<endl;
Clique nc;
nc.cg=-2;
nc.mat_r=gsl_matrix_alloc(3,3);
for(int i=0; i<3; i++) {
nc.cen_a[i]=0.0;
nc.cen_b[i]=0.0;
}
gsl_matrix_set_zero(nc.mat_r); //set the rotation matrix to 0
nc.det=calcRot(la,lb,nc.cen_a,nc.cen_b,nc.mat_r,nc.detOri); //Calculate the rotation matrix
// for(int i=0; i<3; i++) {
// cout<<"cen_a "<<i<<" "<<nc.cen_a[i]<<endl;
// cout<<"cen_b "<<i<<" "<<nc.cen_b[i]<<endl;
// }
// for(int i=0; i<3; i++) {
// for(int j=0; j<3; j++) {
// cout<<i<<" "<<j<<" "<<gsl_matrix_get(nc.mat_r,i,j)<<endl;
// }
// }
// cout<<"Rotating vertexes of Mif 1 onto Mif 2 using list of atoms..."<<endl;
//Rotate mif 1 onto mif 2
for(int v=0; v<mif1.size(); v++){
for(int i=0; i<3; i++){
mif1[v].ncoor[i]=nc.cen_b[i];
for(int j=0; j<3; j++){
mif1[v].ncoor[i]+=(mif1[v].coor[j]-nc.cen_a[j])*gsl_matrix_get(nc.mat_r,i,j);
}
}
}
// cout<<"Finding corresponding vertexes..."<<endl;
float dist=0.0;
for(int u=0; u<mif1.size(); u++){
if(mif1[u].grid[cg2]!=1) continue;
for(int v=0; v<mif2.size(); v++){
if(mif2[v].grid[cg2]!=1) continue;
dist=dist3d(mif1[u].ncoor,mif2[v].coor);
if(dist < dDist || fabs(dist-dDist)<0.001){ //If passes distance threshold
for(int i=0; i<nb_of_probes; i++){
if(mif1[u].pb[i]==1 && mif2[v].pb[i]==1){
// cout<<i<<" - "<<mif1[u].ncoor[0]<<" "<<mif1[u].ncoor[1]<<" "<<mif1[u].ncoor[2]<<" "<<mif2[v].coor[0]<<" "<<mif2[v].coor[1]<<" "<<mif2[v].coor[2]<<" - "<<mif1[u].pb[i]<<" "<<mif2[v].pb[i]<<endl;
mif1[u].m[i]=1;
mif2[v].m[i]=1;
}
}
}
}
}
for(int u=0; u<mif1.size(); u++){
for(int i=0; i<nb_of_probes; i++){
if(mif1[u].m[i]==1){
nc.va.push_back(mif1[u]);
break;
}
}
}
for(int v=0; v<mif2.size(); v++){
for(int i=0; i<nb_of_probes; i++){
if(mif2[v].m[i]==1){
nc.vb.push_back(mif2[v]);
break;
}
}
}
nc.nbNodes=nc.va.size()+nc.vb.size(); //Calculate overlap score
nc.tani=( ((float)nc.va.size()/(float)ss1[cg2]) + ((float)nc.vb.size()/(float)ss2[cg2]) ) / 2.0; //Calculate other overlap score
cliques.push_back(nc); //push this clique in the cliques vector
}else{
bool* conn=NULL;
vector<node> graph;
if(steps[cs]!=steps[cs-1]){
cout<<"Resetting top clique score"<<endl;
topT=-1.0;
topN=-1;
}
cg=steps[cs];
//If its not the first stage and its a different grid resolution than previous stage
//rotate the vertexes using the previous rotation matrix
if(cs>0 && steps[cs]!=steps[cs-1]){
// cout<<"Rotating Mif 1 onto Mif 2 using previous stage..."<<endl;
for(int v=0; v<mif1.size(); v++){
for(int i=0; i<3; i++){
mif1[v].ncoor[i]=cliques.back().cen_b[i];
for(int j=0; j<3; j++){
mif1[v].ncoor[i]+=(mif1[v].coor[j]-cliques.back().cen_a[j])*gsl_matrix_get(cliques.back().mat_r,i,j);
}
}
}
//Flag that says we need to check distance between rotated vertex and those
//found at previous stage to determine if we consider them for the graph
cgs=1;
}else{ cgs=0; }
//Create nodes
cout<<"Creating nodes..."<<endl;
createNodes(cg,graph,cgs);
numNodes=graph.size();
cout<<"NbNodes "<<numNodes<<endl;
cout << "Graph has "<<graph.size() << " nodes."<< endl;
//If there is too much nodes, sort the list by similarity and keep the max num of nodes with the best similarity
if(graph.size()>maxNodes){
//Sort nodes by similarity
//sort(graph.begin(), graph.end(), &compareSim);
int extra=0;
extra=graph.size()-maxNodes;
cout<<"Too much nodes must detele some."<<endl<< "There is "<<extra<<" extra nodes"<<endl;
for(i=0; i<extra; ++i){ graph.pop_back(); }
numNodes=maxNodes;
cout << "Graph was shrinked to "<<graph.size() << " nodes."<< endl;
}
//reset node ids from 0 to maxNodes
// for(i=0; i<graph.size(); ++i){
// graph.at(i).id=i;
// cout<<j<<" id: "<<graph.at(j).id<<endl;
// }
//Create adjacency matrix
adjMat(graph,conn,cg);
cout<<"numEdges: "<<numEdges<<endl;
//Find cliques
cout<<"Entering Bron Kerbosch"<<endl;
bk(cg,graph,conn);
//Print nodes in the output file
clearStep(cg);
//Delete graph and adjacency matrix
delete[] conn;
conn=NULL;
for(vit1=graph.begin(); vit1<graph.end(); ++vit1){ graph.erase(vit1); }
vector<node>().swap(graph);
}
}
printNodes();
for(int v=0; v<mif1.size(); v++){
mif1[v].nrg.clear();
mif1[v].ang.clear();
mif1[v].pb.clear();
mif1[v].m.clear();
}
for(int v=0; v<mif2.size(); v++){
mif2[v].nrg.clear();
mif2[v].ang.clear();
mif2[v].pb.clear();
mif2[v].m.clear();
}
mif1.clear();
// vector<vertex>().swap(mif1);
mif2.clear();
// vector<vertex>().swap(mif2);
prot1.clear();
// vector<atom>().swap(prot1);
prot2.clear();
// vector<atom>().swap(prot2);
caSize1=0;
caSize2=0;
pseudoL1.clear();
// vector<pseudoC>().swap(pseudoL1);
pseudoL2.clear();
// vector<pseudoC>().swap(pseudoL2);
lig1.clear();
// vector<atom>().swap(lig1);
lig2.clear();
// vector<atom>().swap(lig2);
cliques.clear();
vector<Clique>().swap(cliques);
for(int k=0; k<4; k++){ ss1[k]=0; ss2[k]=0; ss1m[k]=0; ss2m[k]=0; }
cout<< "Finished printing nodes and clearing"<<endl;
}
char suffix[50];
if(pairwiseF.compare("")!=0){
while(fexists(out_file)){
strcat(out_file,"_r");
}
open_file_ptr(&fpout,out_file,1);
}else{
if(wrfn==1){ //Add similarity score to filename
if(rnc1.compare("")!=0 && rnc2.compare("")!=0){ //Add ligand RMSD if rnc1 and rnc2 are provided
sprintf(suffix,"_%d_%5.4f_%5.4f",cliques[topCliques[steps.back()]].nbNodes,cliques[topCliques[steps.back()]].taniM,cliques[topCliques[steps.back()]].ligRMSD);
}else{
sprintf(suffix,"_%d_%5.4f",cliques[topCliques[steps.back()]].nbNodes,cliques[topCliques[steps.back()]].taniM);
}
strcat(out_file,suffix);
}
strcat(out_file,".isomif");
// printf("outfile: %s",out_file);
open_file_ptr(&fpout,out_file,1);
}
fprintf(fpout,"%s",matchFileOut.str().c_str());
fclose(fpout);
return(0);
}
/***********************************************************************/
/* 1 2 3 4 5 6 7*/
/*234567890123456789012345678901234567890123456789012345678901234567890*/
/* 1 2 3 4 5 6 7*/
/***********************************************************************/
void adjMat(vector<node> &graph, bool* &conn, int cg){
float dist;
int i=0;
int j=0;
long long vsize = (( ( (long long)numNodes * (long long)numNodes ) - (long long)numNodes ) / (long long)2) + (long long)numNodes;
conn=new bool[vsize];
cout<<"Size of Connected matrix: "<<vsize<<endl;
for(long long z=0; z<vsize; z++){ conn[z]=0; }
numEdges=0;
for(i=0; i<graph.size(); i++){
conn[ConnID(i,i)]=1; //Diagonal == 1
for(j=0; j<i; j++){
if(cg==-1){
if(graph.at(i).ca->id != graph.at(j).ca->id && graph.at(i).cb->id != graph.at(j).cb->id){
dist=fabs(dist3d(graph.at(i).ca->coor,graph.at(j).ca->coor)-dist3d(graph.at(i).cb->coor,graph.at(j).cb->coor));
if(dist < ca_dDist || fabs(dist-ca_dDist)<0.001){ //If passes distance threshold
// cout<<endl<<graph.at(i).a->coor[0]<<" "<<graph.at(i).a->coor[1]<<" "<<graph.at(i).a->coor[2]<<" "<<graph.at(j).a->coor[0]<<" "<<graph.at(j).a->coor[1]<<" "<<graph.at(j).a->coor[2];
// cout<<endl<<graph.at(i).b->coor[0]<<" "<<graph.at(i).b->coor[1]<<" "<<graph.at(i).b->coor[2]<<" "<<graph.at(j).b->coor[0]<<" "<<graph.at(j).b->coor[1]<<" "<<graph.at(j).b->coor[2];
// cout<<endl<<"Dist: "<<dist<<endl<<i<<" "<<j<< " ConnID: "<< ConnID(i,j)<<" Connection!"<<endl;
conn[ConnID(i,j)]=1;
numEdges++; //create the new edge
}
}
}else if(cg==-3){
if(graph.at(i).pa->id != graph.at(j).pa->id && graph.at(i).pb->id != graph.at(j).pb->id){
dist=fabs(dist3d(graph.at(i).pa->coor,graph.at(j).pa->coor)-dist3d(graph.at(i).pb->coor,graph.at(j).pb->coor));
if(dist < ps_dDist || fabs(dist-ps_dDist)<0.001){ //If passes distance threshold
// cout<<endl<<graph.at(i).a->coor[0]<<" "<<graph.at(i).a->coor[1]<<" "<<graph.at(i).a->coor[2]<<" "<<graph.at(j).a->coor[0]<<" "<<graph.at(j).a->coor[1]<<" "<<graph.at(j).a->coor[2];
// cout<<endl<<graph.at(i).b->coor[0]<<" "<<graph.at(i).b->coor[1]<<" "<<graph.at(i).b->coor[2]<<" "<<graph.at(j).b->coor[0]<<" "<<graph.at(j).b->coor[1]<<" "<<graph.at(j).b->coor[2];
// cout<<endl<<"Dist: "<<dist<<endl<<i<<" "<<j<< " ConnID: "<< ConnID(i,j)<<" Connection!"<<endl;
conn[ConnID(i,j)]=1;
numEdges++; //create the new edge
}
}
}else{
if(graph.at(i).a->id != graph.at(j).a->id && graph.at(i).b->id != graph.at(j).b->id){
dist=fabs(dist3d(graph.at(i).a->coor,graph.at(j).a->coor)-dist3d(graph.at(i).b->coor,graph.at(j).b->coor));
if(dist < dDist || fabs(dist-dDist)<0.001){ //If passes distance threshold
// cout<<endl<<graph.at(i).a->coor[0]<<" "<<graph.at(i).a->coor[1]<<" "<<graph.at(i).a->coor[2]<<" "<<graph.at(j).a->coor[0]<<" "<<graph.at(j).a->coor[1]<<" "<<graph.at(j).a->coor[2];
// cout<<endl<<graph.at(i).b->coor[0]<<" "<<graph.at(i).b->coor[1]<<" "<<graph.at(i).b->coor[2]<<" "<<graph.at(j).b->coor[0]<<" "<<graph.at(j).b->coor[1]<<" "<<graph.at(j).b->coor[2];
// cout<<endl<<"Dist: "<<dist<<endl<<i<<" "<<j<< " ConnID: "<< ConnID(i,j)<<" Connection!"<<endl;
conn[ConnID(i,j)]=1;
numEdges++; //create the new edge
}
}
}
}
}
}
/***********************************************************************/
/* 1 2 3 4 5 6 7*/
/*234567890123456789012345678901234567890123456789012345678901234567890*/
/* 1 2 3 4 5 6 7*/
/***********************************************************************/
void bk(int cg, vector<node> &graph, bool* &conn){
int c;
int* all = new int[numNodes];
compsub = new int[numNodes];
for(c=0; c<numNodes; c++){
all[c]=c;
}
// sortArray(all, numNodes, conn);
Extend(all,0,numNodes,cg,graph,conn,0);
delete[] compsub;
compsub=NULL;
return;
}
/***********************************************************************/
/* 1 2 3 4 5 6 7*/
/*234567890123456789012345678901234567890123456789012345678901234567890*/
/* 1 2 3 4 5 6 7*/
/***********************************************************************/
void sortArray(int * &in, int nn, bool* &conn){
vector<nodeI> sortn;
int i=0;
int c=0;
//Sort array
for(c=0;c<nn;c++){
nodeI newn;
newn.id=in[c];
newn.neibrs=0;
for(i=0;i<nn;i++){
if(!conn[ConnID(in[c],i)]) newn.neibrs++;
}
sortn.push_back(newn);
// cout<<endl<< newn.id<<" "<< newn.neibrs;
}
sort (sortn.begin(), sortn.end(), myfunction);
vector<nodeI>::iterator pnit;
c=0;
for(pnit=sortn.begin(); pnit!=sortn.end(); ++pnit){
in[c]=(*pnit).id;
c++;
}
}
/***********************************************************************/
/* 1 2 3 4 5 6 7*/
/*234567890123456789012345678901234567890123456789012345678901234567890*/
/* 1 2 3 4 5 6 7*/
/***********************************************************************/
bool myfunction (nodeI i,nodeI j) { return (i.neibrs<j.neibrs); }
/***********************************************************************/
/* 1 2 3 4 5 6 7*/
/*234567890123456789012345678901234567890123456789012345678901234567890*/
/* 1 2 3 4 5 6 7*/
/***********************************************************************/
void Extend(int* old,int ne,int ce, int cg, vector<node> &graph, bool* &conn, int lev){
int fixp;
int newne,newce,j,count,pos,p,s,sel,loc,l;
int* neww = new int[ce];
int minnod=ce;
int i=0;
int nod=0;
lev++;
if(lev==1){ stopBk=0; }
//Determine each count value and look for the one with least disconnections
// cout<<endl<<"Entering Extend with "<<ce<<" candidates and "<<ne<<" nots lev "<<lev<<endl;
while(i < ce && minnod != 0)
{
p = old[i]; // Id of current cand
count = 0; // Reset its disconnections counter
j = ne; // To count disconnections with candidates only
// Count disconnections with candidates only
while(j < ce) //&& count < minnod
{
if(!conn[ConnID(p,old[j])]){
count++; // Increment disconnection counter
pos=j; // Set pivot as last candidate of the list
}
j++;
}
// Remark : first "old" set is All and n_not = 0, so fixed_point and s will first be the node with the most connections.
if(count < minnod){ //If this node has less disconnections with previous one, set it as pivot
fixp=p;
minnod=count;
if(i < ne){ // If its from not, set the pivot as the last candidate
s=pos;
}else{ // Else if its a candidate take it as pivot
s=i;
nod=1;
}
}
i++;
}
// cout<<"Expanding "<<minnod+nod<<" times. bk "<<stopBk<<endl;
// Tries to expand the current clique with each candidate starting with the one with least disconnections
for(nod=minnod+nod;nod>0;nod--){
// cout<<"ce "<<ce<<" ne "<<ne<<" lev "<<lev<<endl;
// cout<<"New PIVOT "<<old[s]<<endl;
// cout<<"stopbk "<<stopBk<<endl;
if(stopBk==1) break;
// for(int z=0; z<ce; z++){
// if(z==ce) cout<<"| ";
// cout<<old[z]<<" ";
// }
// cout<<endl;
// Switch position of pivot with the first candidate
p = old[s];
old[s] = old[ne];
old[ne] = p;
sel = p;
// for(int z=0; z<ce; z++){
// if(z==ce) cout<<"| ";
// cout<<old[z]<<" ";
// }
// cout<<endl;
// Build the new "not" set based on connections between node sel and old "not" set
newne = 0;
i = 0;
while(i<ne){
// cout<<i<<" "<<old[i];
if(conn[ConnID(sel,old[i])]){
neww[newne++]=old[i];
// cout<<" conn not";
}
// cout<<endl;
i++;
}
// Build the new "candidates" set based on connections between node sel and old "candidates" set
newce=newne;
i=ne+1;
while(i < ce){
// cout<<i<<" "<<old[i];
if(conn[ConnID(sel,old[i])]){
neww[newce++]=old[i];
// cout<<" conn can";
}
// cout<<endl;
i++;
}
// Add node sel in clique
compsub[c++]=sel;
// cout<<"COMPSUB: ";
// for(int g=0; g<c; g++){
// cout<<compsub[g]<<" ";
// }
// cout<<endl;
// cout<<"newce "<<newce<<" newne "<<newne<<" c "<<c<<" lev "<<lev<<endl;
// cout<<"| ";
// for(int g=0; g<newce; g++){
// if(g==newne) cout<<"| ";
// cout<<"["<<g<<"] "<<neww[g]<<" ";
// }
// cout<<endl;
// if((newce+c)>=topN){ //Check if there is enough candidate in this extension to find a new TOP clique
if(newce == 0){ // Print clique if both "not" and "candidates" sets are empty
if(c >= Clique_threshold){
AddNewClique(c,compsub,cg,graph);
stopBk = 1;
// cout<< nCliques<<endl;
if((bkAll == 1 && (nCliques<maxCliques)) || (bkAll == 0 && nCliques == 0)){
stopBk = 0;
}
}
}else if(newne < newce){
// Continue to expand clique if there are remaining candidates or "not" nodes
Extend(neww,newne,newce,cg,graph,conn,lev);
}
// }else{
// int tmpint=newce+c;
// cout<<"exiting max size "<<tmpint<<endl;
// }
// Collapse clique (Recursion will be complete and clique will be printed at this point)
c--;
// cout<<endl<<"COMPSUB: ";
// for(int g=0; g<c; g++){
// cout<<compsub[g]<<" ";
// }
// Place node sel in "not" set (Is the last recorded point of the printed clique)
ne++;
// cout<<endl<<"neOUT | ";
// for(int g=0; g<ce; g++){
// if(g==ne) cout<<"| ceOUT | ";
// cout<<old[g]<<" ";
// }
// cout<<endl<<"Fixp "<<fixp<<" ne "<<ne<<" nod "<<nod<<endl;
// Find new starting point (new node position s) for the recursion with no connection with node fixed_point (which was part of last clique and had the most connections)
// May be able to find a new part of the clique through connections with candidates and disconnection with fixed_point
if(nod > 1){
s=ne;
while(conn[ConnID(fixp,old[s])] && s < numNodes) s++;
}
if(lev>2) break;
}
lev--;
// cout<<"exiting extend"<<endl;
delete[] neww;
return;
}
/***********************************************************************/
/* 1 2 3 4 5 6 7*/
/*234567890123456789012345678901234567890123456789012345678901234567890*/
/* 1 2 3 4 5 6 7*/
/***********************************************************************/
void AddNewClique(int n, int* list, int cg, vector<node> &graph){
vector<nodes>::iterator it;
vector<float> la;
vector<float> lb;
float overlap=0;
Clique newClique;
newClique.cg=cg;
newClique.nbNodes=n;
newClique.nbNodesM=0;
newClique.nbNodesMW=0;
newClique.normNodes=0.0;
newClique.tani=0.0;
newClique.taniM=0.0;
newClique.taniMW=0.0;
newClique.taniNorm=0.0;
newClique.normNodesRMSD=0.0;
newClique.rmsd=0.0;
newClique.nrg=0.0;
newClique.det=0.0;
newClique.detOri=0.0;
for(int i=0; i<n; i++){ newClique.nodes.push_back(graph.at(list[i])); }
cliques.push_back(newClique);
//Get list of coords to get rotation matrix
if(cg==-1){
for(it=cliques.back().nodes.begin(); it!=cliques.back().nodes.end(); ++it){
for(int i=0; i<3; i++){
la.push_back((*it).ca->coor[i]);
lb.push_back((*it).cb->coor[i]);
}
}
}else if(cg==-3){
for(it=cliques.back().nodes.begin(); it!=cliques.back().nodes.end(); ++it){
for(int i=0; i<3; i++){
la.push_back((*it).pa->coor[i]);
lb.push_back((*it).pb->coor[i]);
}
}
}else{
for(it=cliques.back().nodes.begin(); it!=cliques.back().nodes.end(); ++it){
for(int i=0; i<nb_of_probes; ++i){
if((*it).a->pb[i]==1 && (*it).b->pb[i]==1){
for(int j=0; j<3; j++){
la.push_back((*it).a->coor[j]);
lb.push_back((*it).b->coor[j]);
}
}
}
}
}
//Calculate rotation matrix
cliques.back().mat_r=gsl_matrix_alloc(3,3);
gsl_matrix_set_zero(cliques.back().mat_r);
for(int i=0; i<3; i++){
cliques.back().cen_a[i]=0.0;
cliques.back().cen_b[i]=0.0;
}
cliques.back().det=calcRot(la,lb,cliques.back().cen_a,cliques.back().cen_b,cliques.back().mat_r,cliques.back().detOri);
nCliquesExplored++;
//If determinant is not -1 (mirror image) and we skip cliques with a Det -1
if((cliques.back().detOri > 0.00 && skipDet==1) || (skipDet==0)){
nCliques++;
}else{
cliques.pop_back();
return;
}
for(int i=0; i<nb_of_probes; i++){
cliques.back().pbweight.push_back(0);
cliques.back().nrgsum.push_back(0.0);
cliques.back().angCount.push_back(0);
cliques.back().angSum.push_back(0.0);
}
//Rotate mif 1 onto mif 2
for(int u=0; u<mif1.size(); u++){
for(int i=0; i<3; i++){
mif1[u].ncoor[i]=cliques.back().cen_b[i];
for(int j=0; j<3; j++){
mif1[u].ncoor[i]+=(mif1[u].coor[j]-cliques.back().cen_a[j])*gsl_matrix_get(cliques.back().mat_r,i,j);
}
}
if(ol<0) continue;
if(mif1[u].grid[ol]==0) continue;
for(int v=0; v<mif2.size(); v++){
if(mif2[v].grid[ol]==0) continue;
float dist=dist3dnosqrt(mif1[u].ncoor,mif2[v].coor);
if(dist < olDistsq || fabs(dist-olDistsq)<0.001){
for(int pb=0; pb<nb_of_probes; pb++){
if(mif1[u].pb[pb]==1 && mif2[v].pb[pb]==1){
mif1[u].ol[pb]=1;
mif2[v].ol[pb]=1;
}
}
}
}
}
if(ol>-1){
//Calculate overlap
int ol1=0;
int ol2=0;
for(int u=0; u<mif1.size(); u++){
if(mif1[u].grid[ol]==0) continue;
for(int pb=0; pb<nb_of_probes; pb++){
if(mif1[u].ol[pb]==1) ol1++;
mif1[u].ol[pb]=0;
}
}
for(int v=0; v<mif2.size(); v++){
if(mif2[v].grid[ol]==0) continue;
for(int pb=0; pb<nb_of_probes; pb++){
if(mif2[v].ol[pb]==1) ol2++;
mif2[v].ol[pb]=0;
}
}
overlap=((float)ol1+(float)ol2)/((float)ss1m[ol]+(float)ss2m[ol]);
}
// Rotate ligand and calculate RMSD
float ligRMSD=0.0;
int ligRMSDc=0;
if(rnc1.compare("")!=0 && rnc2.compare("")!=0 && lig1.size()>0 && lig2.size()>0 && getrmsd==1){
for(int v=0; v<lig1.size(); v++){
float dist=0.0;
for(int i=0; i<3; i++){
lig1[v].ncoor[i]=cliques.back().cen_b[i];
for(int j=0; j<3; j++){ lig1[v].ncoor[i]+=(lig1[v].coor[j]-cliques.back().cen_a[j])*gsl_matrix_get(cliques.back().mat_r,i,j); }
}
for(int w=0; w<lig2.size(); w++){
if(lig2[w].atomn.compare(lig1[v].atomn)==0){
ligRMSD+=pow(dist3d(lig1[v].ncoor,lig2[w].coor),2.0);
ligRMSDc++;
break;
}
}
}
if(ligRMSDc>0 && ligRMSDc==lig1.size() && lig1.size()==lig2.size()){
ligRMSD=sqrt(ligRMSD/(float)ligRMSDc);
}else{
ligRMSD=0.0;
}
}
cliques.back().ligRMSD=ligRMSD;
//Calculate clique RMSD
float rmsd=0.0;
for(it=cliques.back().nodes.begin(); it!=cliques.back().nodes.end(); ++it){
float ncoor[3];
for(int i=0; i<3; i++){
ncoor[i]=cliques.back().cen_b[i];
for(int j=0; j<3; j++){
if(cg==-1){
ncoor[i]+=((*it).ca->coor[j]-cliques.back().cen_a[j])*gsl_matrix_get(cliques.back().mat_r,i,j);
}else if(cg==-3){
ncoor[i]+=((*it).pa->coor[j]-cliques.back().cen_a[j])*gsl_matrix_get(cliques.back().mat_r,i,j);
}else{
ncoor[i]+=((*it).a->coor[j]-cliques.back().cen_a[j])*gsl_matrix_get(cliques.back().mat_r,i,j);
}
}
}
if(cg==-1){
rmsd+=pow(dist3d(ncoor,(*it).cb->coor),2.0);
}else if(cg==-3){
rmsd+=pow(dist3d(ncoor,(*it).pb->coor),2.0);
}else{
float dist=dist3d(ncoor,(*it).b->coor);
rmsd+=pow(dist3d(ncoor,(*it).b->coor),2.0);
// cliques.back().nrg+=(*it).nrg;
cliques.back().nbNodesM+=(*it).nbi;
// cliques.back().nbNodesMW+=(*it).nbiw;
// cliques.back().normNodes+=(*it).cosim;
// for(int pb=0; pb<nb_of_probes; pb++){
// if((*it).a->pb[pb]==1 && (*it).b->pb[pb]==1){
// cliques.back().pbweight[pb]++;
// cliques.back().nrgsum[pb]+=(*it).a->nrg[pb]+(*it).b->nrg[pb];
// if(fabs((*it).a->ang[pb]-0.0)>0.01){
// cliques.back().angSum[pb]+=(*it).a->ang[pb];
// cliques.back().angCount[pb]++;
// }
// if(fabs((*it).b->ang[pb]-0.0)>0.01){
// cliques.back().angSum[pb]+=(*it).b->ang[pb];
// cliques.back().angCount[pb]++;
// }
// }
// }
}
}
// cliques.back().rmsd=sqrt(rmsd/(float)cliques.back().nbNodes);
// cliques.back().normNodesRMSD=cliques.back().normNodes/cliques.back().rmsd;
if(cg==-1){
cliques.back().tani=(float)n/((float)caSize1+(float)caSize2-(float)n);
}else if(cg==-3){
cliques.back().tani=(float)n/((float)cliques.back().rmsd);
}else{
cliques.back().tani=(float)n/((float)ss1[cg]+(float)ss2[cg]-(float)n);
if(ol>-1){ //If the tanimoto is the overlap measure
cliques.back().taniM=overlap;
}else{
cliques.back().taniM=(float)cliques.back().nbNodesM/((float)ss1m[cg]+(float)ss2m[cg]-(float)cliques.back().nbNodesM);
}
// cliques.back().taniMW=(float)cliques.back().nbNodesMW/((float)ss1m[cg]+(float)ss2m[cg]-(float)cliques.back().nbNodesMW);
// cliques.back().taniNorm=cliques.back().normNodes/((float)ss1[cg]+(float)ss2[cg]-cliques.back().normNodes);
}
if(cliques.back().taniM>topT && ((cliques.back().detOri > 0.00 && skipDet==1) || skipDet==0)){
// cout<<nCliquesExplored<<" "<<nCliques<<" NEW TOP CLIQUE CG "<<cg<<" taniM "<<cliques.back().taniM<<" detori "<<cliques.back().detOri<<endl;
topT=cliques.back().taniM;
topN=cliques.back().nbNodesM;
topCliques[cg]=cliques.size()-1;
}else{
// cout<<nCliquesExplored<<" "<<nCliques<<" Clique CG "<<cg<<" taniM "<<cliques.back().taniM<<" detori "<<cliques.back().detOri<<endl;
}
return;
}
/***********************************************************************/
/* 1 2 3 4 5 6 7*/
/*234567890123456789012345678901234567890123456789012345678901234567890*/
/* 1 2 3 4 5 6 7*/
/***********************************************************************/
void printNodes(){
vector<nodes>::iterator it;
char buffer[1000];
// fprintf(fpout,"%s",outH);
sprintf(buffer,"%s",outH);
matchFileOut << string(buffer);
// fprintf(fpout,"REMARK ncliques_scored: %d\nREMARK ncliques_explored: %d\n",nCliques,nCliquesExplored);
sprintf(buffer,"REMARK ncliques_scored: %d\nREMARK ncliques_explored: %d\n",nCliques,nCliquesExplored);
matchFileOut << string(buffer);
if(pc==1){
int istart=0;
int iend=cliques.size();
for(int i=istart; i<iend; i++){
// if(cliques[i].ligRMSD==0.0 || fabs(cliques[i].ligRMSD-0.0) < 0.0001) continue;
// fprintf(fpout,"REMARK CI %s %s ",tag1.c_str(),tag2.c_str());
sprintf(buffer,"REMARK CI %s %s ",tag1.c_str(),tag2.c_str());
matchFileOut << string(buffer);
for(int j=0; j<nb_of_probes; ++j){
// fprintf(fpout,"%4d ",cliques[i].pbweight[j]);
sprintf(buffer,"%4d ",cliques[i].pbweight[j]);
matchFileOut << string(buffer);
}
for(int j=0; j<nb_of_probes; ++j){
// fprintf(fpout,"%10.3f ",cliques[i].nrgsum[j]);
sprintf(buffer,"%10.3f ",cliques[i].nrgsum[j]);
matchFileOut << string(buffer);
}
for(int j=1; j<4; ++j){
float avg=0.0;
if(cliques[i].angCount[j]>0) avg=cliques[i].angSum[j]/(float)cliques[i].angCount[j];
// fprintf(fpout,"%10.3f %3d %10.3f ",cliques[i].angSum[j],cliques[i].angCount[j],avg);
sprintf(buffer,"%10.3f %3d %10.3f ",cliques[i].angSum[j],cliques[i].angCount[j],avg);
matchFileOut << string(buffer);
}
// fprintf(fpout,"%5d %5d %6.3f %d %6.3f\n",ss1m[cliques[i].cg],ss2m[cliques[i].cg],cliques[i].taniM,getrmsd,cliques[i].ligRMSD);
sprintf(buffer,"%5d %5d %6.3f %d %6.3f\n",ss1m[cliques[i].cg],ss2m[cliques[i].cg],cliques[i].taniM,getrmsd,cliques[i].ligRMSD);
matchFileOut << string(buffer);
}
}
for(int cs=0; cs<steps.size(); cs++){
int istart=0;
int iend=cliques.size();
if(wc==0){
istart=topCliques[steps[cs]];
iend=topCliques[steps[cs]]+1;
}
for(int i=istart; i<iend; i++){
if(steps[cs]==-2){
// fprintf(fpout,"REMARK CLIQUE CG %d NODES %d TANI %5.3f SS1 %d SS2 %d\n",cliques[i].cg,cliques[i].nbNodes,cliques[i].tani,ss1[cg2],ss2[cg2]);
sprintf(buffer,"REMARK CLIQUE CG %d NODES %d TANI %5.3f SS1 %d SS2 %d\n",cliques[i].cg,cliques[i].nbNodes,cliques[i].tani,ss1[cg2],ss2[cg2]);
matchFileOut << string(buffer);
if(emptOut!=1){
for(int j=0; j<cliques[i].va.size(); j++){
// fprintf(fpout, "A %8.3f %8.3f %8.3f %d %d %d %d %d %d\n",cliques[i].va[j].ncoor[0],cliques[i].va[j].ncoor[1],cliques[i].va[j].ncoor[2],cliques[i].va[j].m[0],cliques[i].va[j].m[1],cliques[i].va[j].m[2],cliques[i].va[j].m[3],cliques[i].va[j].m[4],cliques[i].va[j].m[5]);
sprintf(buffer, "A %8.3f %8.3f %8.3f %d %d %d %d %d %d\n",cliques[i].va[j].ncoor[0],cliques[i].va[j].ncoor[1],cliques[i].va[j].ncoor[2],cliques[i].va[j].m[0],cliques[i].va[j].m[1],cliques[i].va[j].m[2],cliques[i].va[j].m[3],cliques[i].va[j].m[4],cliques[i].va[j].m[5]);
matchFileOut << string(buffer);
}
for(int j=0; j<cliques[i].vb.size(); j++){
// fprintf(fpout, "B %8.3f %8.3f %8.3f %d %d %d %d %d %d\n",cliques[i].vb[j].coor[0],cliques[i].vb[j].coor[1],cliques[i].vb[j].coor[2],cliques[i].vb[j].m[0],cliques[i].vb[j].m[1],cliques[i].vb[j].m[2],cliques[i].vb[j].m[3],cliques[i].vb[j].m[4],cliques[i].vb[j].m[5]);
sprintf(buffer, "B %8.3f %8.3f %8.3f %d %d %d %d %d %d\n",cliques[i].vb[j].coor[0],cliques[i].vb[j].coor[1],cliques[i].vb[j].coor[2],cliques[i].vb[j].m[0],cliques[i].vb[j].m[1],cliques[i].vb[j].m[2],cliques[i].vb[j].m[3],cliques[i].vb[j].m[4],cliques[i].vb[j].m[5]);
matchFileOut << string(buffer);
}
}
}else if(steps[cs]==-1){
// fprintf(fpout,"REMARK CLIQUE CG %d NODES %d TANI %5.3f SS1 %d SS2 %d\n",cliques[i].cg,cliques[i].nbNodes,cliques[i].tani,(int)prot1.size(),(int)prot2.size());
sprintf(buffer,"REMARK CLIQUE CG %d NODES %d TANI %5.3f SS1 %d SS2 %d\n",cliques[i].cg,cliques[i].nbNodes,cliques[i].tani,(int)prot1.size(),(int)prot2.size());
matchFileOut << string(buffer);
if(emptOut!=1){
for(it=cliques[i].nodes.begin(); it!=cliques[i].nodes.end(); ++it){
// fprintf(fpout, "%3s %4d %4s %5d %s %8.3f %8.3f %8.3f %3s %4d %4s %5d %s %8.3f %8.3f %8.3f\n",(*it).ca->resn.c_str(),(*it).ca->resnb,(*it).ca->atomn.c_str(),(*it).ca->atomnb,(*it).ca->chain.c_str(),(*it).ca->coor[0],(*it).ca->coor[1],(*it).ca->coor[2],(*it).cb->resn.c_str(),(*it).cb->resnb,(*it).cb->atomn.c_str(),(*it).cb->atomnb,(*it).cb->chain.c_str(),(*it).cb->coor[0],(*it).cb->coor[1],(*it).cb->coor[2]);
sprintf(buffer, "%3s %4d %4s %5d %s %8.3f %8.3f %8.3f %3s %4d %4s %5d %s %8.3f %8.3f %8.3f\n",(*it).ca->resn.c_str(),(*it).ca->resnb,(*it).ca->atomn.c_str(),(*it).ca->atomnb,(*it).ca->chain.c_str(),(*it).ca->coor[0],(*it).ca->coor[1],(*it).ca->coor[2],(*it).cb->resn.c_str(),(*it).cb->resnb,(*it).cb->atomn.c_str(),(*it).cb->atomnb,(*it).cb->chain.c_str(),(*it).cb->coor[0],(*it).cb->coor[1],(*it).cb->coor[2]);
matchFileOut << string(buffer);
}
}