-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_sym.c
153 lines (124 loc) · 2.54 KB
/
main_sym.c
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
/*
caldep + fragment + sphere
*/
//#include <fftw3.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include <omp.h>
#include "struct.h"
#include "func.h"
#include "mrc.h"
#include "sym.h"
//#include "scoring.h"
#define PDB_STRLEN 55
void malloc_error(char *a){
fprintf(stderr,"malloc error in %s\n",a);
exit(0);
}
double gettimeofday_sec()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + (double)tv.tv_usec*1e-6;
}
int readlist(char *fname,char **list){
int num=0;
FILE *fp;
int len;
if((fp=fopen(fname,"r"))==NULL)
return FALSE;
while(fgets(list[num],LIN,fp)!=NULL){
len=strlen(list[num]);
list[num][len-1]='\0';//ignore terminal \n
num++;
}
fclose(fp);
return TRUE;
}
int line_num(char *fname){
int num=0;
FILE *fp;
char line[LIN];
if((fp=fopen(fname,"r"))==NULL)
return FALSE;
while(fgets(line,LIN,fp)!=NULL){
num++;
}
fclose(fp);
return num;
}
CMD cmd;
int main(int argc, char **argv)
{
double t1=gettimeofday_sec();
double t4;
POINTS pt;
MRC mrc;
GRAPH g;
TREE mst;
//Get Options
if(chkcmdline(argc,argv,&cmd)==FALSE)
return(0);
//Set threads
if(cmd.Nthr < omp_get_num_procs()){
omp_set_num_threads(cmd.Nthr);
}else{
omp_set_num_threads(omp_get_num_procs());
}
if(readmrc(&mrc,cmd.filename))
return(0);
if(upsampling(&mrc,cmd.map_t))
return(0);
printf("#Nact= %d\n",mrc.Nact);
//Mean Shifting
if(meanshift(&mrc,&pt))
return(0);
//Symmetry
//if(MergePointsSym(&mrc,&pt,cmd.Cn))
if(MergePoints(&mrc,&pt))
return(0);
//Find Corresponding Points by Symmetry Operation
//Circle
int *Ctabu,Ntb;
if((Ctabu=(int *)malloc(sizeof(int)*pt.Ncd*pt.Ncd*2))==NULL)
return true;
if(cmd.Cn>0)
if(FindCorrPointsCn(&pt,&mrc,cmd.Cn,Ctabu,&Ntb))
return(0);
//Dihedral
if(cmd.Dn>0)
if(FindCorrPointsDn(&pt,&mrc,cmd.Dn,Ctabu,&Ntb))
return(0);
//Set Up Graph and MST
if(SetUpGraphSym(&pt,&g,&mrc,&mst,Ctabu,Ntb))
return(0);
//return 0;
if(cmd.Mode==1){//Graph
//ShowModel(&mrc,&pt);
ShowModelChainCIF(&mrc,&pt,&g);
ShowGraph(&g);
return 0;
}
if(cmd.Mode==2){//MST
//ShowModel(&mrc,&pt);
ShowModelChainCIF(&mrc,&pt,&g);
ShowTree(&g,&mst);
return 0;
}
//Optimize Graph by Tabu seatch
TREE results[100];//Max 100 simu
if(Tabu(&g,&mst,results))
return 0;
//if(PairExhaust(&g,&mst,results))
// return 0;
//Volume and density data
ShowPath2(&mrc,&pt,&g,results,cmd.Nsim);
t4=gettimeofday_sec();
printf("#FINISHED TOTAL TIME= %f\n",t4-t1);
return 0;
}