Mercurial > repos > guerler > springsuite
annotate spring_package/pulchra/pulchra.c @ 18:c1eeb502f7ff draft
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
author | guerler |
---|---|
date | Wed, 28 Oct 2020 05:13:36 +0000 |
parents | c790d25086dc |
children |
rev | line source |
---|---|
17
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2 // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3 // PULCHRA |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4 // Protein Chain Restoration Algorithm |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5 // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
6 // Version 3.04 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
7 // July 2007 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
8 // Contact: Piotr Rotkiewicz, piotr -at- pirx -dot- com |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
9 // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
10 // to compile: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
11 // cc -O3 pulchra.c pulchra_data.c -lm -o pulchra |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
12 // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
13 // to use: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
14 // ./pulchra file.pdb |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
15 // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
16 // to display available options: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
17 // ./pulchra |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
18 // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
19 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
20 #define COMPILE_BB |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
21 #define COMPILE_ROT |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
22 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
23 #include <math.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
24 #include <stdio.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
25 #include <stdlib.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
26 #include <string.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
27 #include <sys/timeb.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
28 #include <time.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
29 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
30 #define uchar unsigned char |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
31 #define uint unsigned int |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
32 #define real double |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
33 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
34 #include "pulchra_common.h" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
35 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
36 #define PULCHRA_VERSION 3.04 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
37 #define MAX_BUF_SIZE 1000 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
38 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
39 #define FILE_SUCCESS 0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
40 #define FILE_NOT_FOUND -1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
41 #define FILE_WARNING -2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
42 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
43 #define FATAL_MAE -1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
44 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
45 #define FLAG_BACKBONE 1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
46 #define FLAG_CALPHA 2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
47 #define FLAG_SIDECHAIN 4 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
48 #define FLAG_SCM 8 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
49 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
50 #define FLAG_PROTEIN 1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
51 #define FLAG_DNA 2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
52 #define FLAG_RNA 4 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
53 #define FLAG_CHYDRO 8 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
54 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
55 #define RADDEG 180./M_PI |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
56 #define DEGRAD M_PI/180. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
57 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
58 int _VERBOSE = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
59 int _BB_REARRANGE = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
60 int _BB_OPTIMIZE = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
61 int _CA_OPTIMIZE = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
62 int _CA_RANDOM = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
63 int _CA_ITER = 100; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
64 int _CA_TRAJECTORY = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
65 int _CISPRO = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
66 int _CHIRAL = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
67 int _CENTER_CHAIN = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
68 int _REBUILD_BB = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
69 int _REBUILD_SC = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
70 int _REBUILD_H = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
71 int _PDB_SG = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
72 int _TIME_SEED = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
73 int _XVOLUME = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
74 int _XVOL_ITER = 3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
75 real _CA_START_DIST = 3.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
76 real _CA_XVOL_DIST = 3.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
77 real _SG_XVOL_DIST = 1.6; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
78 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
79 #define CALC_C_ALPHA |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
80 #define CALC_C_ALPHA_ANGLES |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
81 #define CALC_C_ALPHA_START |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
82 #define CALC_C_ALPHA_XVOL |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
83 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
84 real CA_K=10.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
85 real CA_ANGLE_K=20.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
86 real CA_START_K=0.01; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
87 real CA_XVOL_K=10.00; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
88 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
89 #define CA_DIST 3.8 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
90 #define CA_DIST_TOL 0.1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
91 #define CA_DIST_CISPRO 2.9 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
92 #define CA_DIST_CISPRO_TOL 0.1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
93 #define E_EPS 1e-10 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
94 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
95 // grid resolution (used for fast clash detection) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
96 #define GRID_RES 6.0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
97 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
98 int chain_length = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
99 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
100 char AA_NAMES[21][4] = |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
101 { "GLY", "ALA", "SER", "CYS", "VAL", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
102 "THR", "ILE", "PRO", "MET", "ASP", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
103 "ASN", "LEU", "LYS", "GLU", "GLN", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
104 "ARG", "HIS", "PHE", "TYR", "TRP", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
105 "UNK" }; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
106 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
107 char SHORT_AA_NAMES[22] = { "GASCVTIPMDNLKEQRHFYWX" }; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
108 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
109 int AA_NUMS[256]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
110 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
111 int nheavy[20] = { 0, 1, 2, 2, 3, 3, 4, 3, 4, 4, 4, 4, 5, 5, 5, 7, 6, 7, 8, 10}; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
112 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
113 char *backbone_atoms[4] = { "N ", "CA ", "C ", "O " }; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
114 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
115 char *heavy_atoms[200]= { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
116 /* GLY */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
117 /* ALA */ "CB ", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
118 /* SER */ "CB ", "OG ", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
119 /* CYS */ "CB ", "SG ", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
120 /* VAL */ "CB ", "CG1", "CG2", NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
121 /* THR */ "CB ", "OG1", "CG2", NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
122 /* ILE */ "CB ", "CG1", "CG2", "CD1", NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
123 /* PRO */ "CB ", "CG ", "CD ", NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
124 /* MET */ "CB ", "CG ", "SD ", "CE ", NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
125 /* ASP */ "CB ", "CG ", "OD1", "OD2", NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
126 /* ASN */ "CB ", "CG ", "OD1", "ND2", NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
127 /* LEU */ "CB ", "CG ", "CD1", "CD2", NULL, NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
128 /* LYS */ "CB ", "CG ", "CD ", "CE ", "NZ ", NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
129 /* GLU */ "CB ", "CG ", "CD ", "OE1", "OE2", NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
130 /* GLN */ "CB ", "CG ", "CD ", "OE1", "NE2", NULL, NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
131 /* ARG */ "CB ", "CG ", "CD ", "NE ", "CZ ", "NH1", "NH2", NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
132 /* HIS */ "CB ", "CG ", "ND1", "CD2", "CE1", "NE2", NULL, NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
133 /* PHE */ "CB ", "CG ", "CD1", "CD2", "CE1", "CE2", "CZ ", NULL, NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
134 /* TYR */ "CB ", "CG ", "CD1", "CD2", "CE1", "CE2", "CZ ", "OH ", NULL, NULL, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
135 /* TRP */ "CB ", "CG ", "CD1", "CD2", "NE1", "CE2", "CE3", "CZ2", "CZ3", "CH2"}; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
136 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
137 /* reads full-atom pdb file */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
138 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
139 struct _res_type; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
140 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
141 typedef struct _atom_type { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
142 struct _atom_type *next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
143 real x, y, z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
144 char *name; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
145 int num, locnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
146 int flag; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
147 char cispro; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
148 int gx, gy, gz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
149 struct _res_type *res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
150 struct _atom_type *prev; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
151 } atom_type; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
152 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
153 typedef struct _res_type { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
154 struct _res_type *next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
155 atom_type *atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
156 int num, locnum, natoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
157 int type; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
158 char pdbsg; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
159 char protein; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
160 char *name; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
161 char chain; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
162 real sgx, sgy, sgz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
163 real cmx, cmy, cmz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
164 struct _res_type *prev; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
165 } res_type; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
166 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
167 typedef struct _mol_type { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
168 struct _mol_type *next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
169 res_type *residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
170 int nres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
171 unsigned char *r14; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
172 char *name; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
173 uchar *seq; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
174 char **contacts; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
175 real **cutoffs; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
176 struct _mol_type *prev; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
177 } mol_type; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
178 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
179 #define MIN(a,b) (a<b?a:b) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
180 #define MAX(a,b) (a>b?a:b) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
181 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
182 mol_type *chain = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
183 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
184 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
185 real rnd(void) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
186 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
187 return 0.001*(real)(rand()%1000); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
188 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
189 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
190 atom_type *new_atom(void) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
191 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
192 atom_type *tmpatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
193 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
194 tmpatom = (atom_type*) calloc(sizeof(atom_type),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
195 if (tmpatom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
196 tmpatom->x=tmpatom->y=tmpatom->z=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
197 tmpatom->name=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
198 tmpatom->num=tmpatom->locnum=tmpatom->flag=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
199 tmpatom->next=tmpatom->prev=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
200 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
201 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
202 return tmpatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
203 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
204 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
205 res_type* new_res(void) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
206 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
207 res_type *tmpres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
208 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
209 tmpres = (res_type*) calloc(sizeof(res_type),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
210 if (tmpres) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
211 tmpres->num=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
212 tmpres->name=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
213 tmpres->atoms=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
214 tmpres->chain=' '; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
215 tmpres->next=tmpres->prev=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
216 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
217 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
218 return tmpres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
219 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
220 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
221 mol_type *new_mol(void) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
222 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
223 mol_type *tmpmol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
224 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
225 tmpmol = (mol_type*) calloc(sizeof(mol_type),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
226 if (tmpmol) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
227 tmpmol->name=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
228 tmpmol->residua=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
229 tmpmol->next=tmpmol->prev=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
230 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
231 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
232 return tmpmol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
233 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
234 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
235 void add_atom(atom_type* atomlist, atom_type* newatom) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
236 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
237 atom_type *tmpatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
238 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
239 if (!atomlist) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
240 atomlist=newatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
241 else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
242 tmpatom=atomlist->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
243 atomlist->next=newatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
244 newatom->prev=atomlist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
245 newatom->next=tmpatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
246 if (tmpatom) tmpatom->prev=newatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
247 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
248 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
249 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
250 void add_res(res_type* reslist, res_type* newres) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
251 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
252 res_type *tmpres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
253 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
254 if (!reslist) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
255 reslist=newres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
256 else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
257 tmpres=reslist->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
258 reslist->next=newres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
259 newres->prev=reslist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
260 newres->next=tmpres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
261 if (tmpres) tmpres->prev=newres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
262 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
263 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
264 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
265 void add_mol(mol_type* mollist, mol_type* newmol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
266 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
267 mol_type *tmpmol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
268 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
269 if (!mollist) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
270 mollist=newmol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
271 else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
272 tmpmol=mollist->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
273 mollist->next=newmol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
274 newmol->prev=mollist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
275 newmol->next=tmpmol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
276 if (tmpmol) tmpmol->prev=newmol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
277 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
278 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
279 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
280 void delete_atom(atom_type* atom) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
281 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
282 atom_type *tmpatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
283 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
284 if (atom->prev) atom->prev->next=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
285 if (atom->next) atom->next->prev=atom->prev; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
286 if (atom->name) free(atom->name); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
287 free(atom); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
288 atom=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
289 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
290 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
291 void delete_res(res_type* res) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
292 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
293 res_type *tmpres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
294 atom_type *tmpatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
295 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
296 if (res->prev) res->prev->next=res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
297 if (res->next) res->next->prev=res->prev; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
298 if (res->name) free(res->name); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
299 if (res->atoms) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
300 while (res->atoms) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
301 tmpatom = res->atoms->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
302 delete_atom(res->atoms); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
303 res->atoms=tmpatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
304 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
305 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
306 free(res); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
307 res=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
308 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
309 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
310 void delete_mol(mol_type* mol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
311 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
312 mol_type *tmpmol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
313 res_type *tmpres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
314 int i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
315 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
316 if (mol->prev) mol->prev->next=mol->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
317 if (mol->next) mol->next->prev=mol->prev; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
318 if (mol->name) free(mol->name); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
319 if (mol->residua) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
320 while (mol->residua) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
321 tmpres = mol->residua->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
322 delete_res(mol->residua); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
323 mol->residua=tmpres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
324 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
325 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
326 if (mol->contacts) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
327 for (i=0; i<mol->nres; i++) free(mol->contacts[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
328 free(mol->contacts); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
329 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
330 if (mol->cutoffs) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
331 for (i=0; i<mol->nres; i++) free(mol->cutoffs[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
332 free(mol->cutoffs); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
333 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
334 free(mol); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
335 mol=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
336 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
337 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
338 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
339 atom_type* get_last_atom(atom_type* atom) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
340 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
341 while (atom->next) atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
342 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
343 return atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
344 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
345 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
346 res_type* get_last_res(res_type* res) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
347 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
348 while (res->next) res=res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
349 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
350 return res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
351 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
352 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
353 mol_type *get_last_mol(mol_type* mol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
354 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
355 while (mol->next) mol=mol->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
356 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
357 return mol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
358 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
359 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
360 char setseq(char* aaname) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
361 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
362 int i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
363 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
364 for (i=0; i<21; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
365 if ((aaname[0]==AA_NAMES[i][0]) && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
366 (aaname[1]==AA_NAMES[i][1]) && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
367 (aaname[2]==AA_NAMES[i][2])) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
368 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
369 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
370 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
371 if (i==21) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
372 if (!strcmp(aaname, "GLX")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
373 return 'E'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
374 if (!strcmp(aaname, "ASX")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
375 return 'D'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
376 if (!strcmp(aaname, "HID")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
377 return 'H'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
378 if (!strcmp(aaname, "MSE")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
379 return 'M'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
380 if (!strcmp(aaname, "SEP")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
381 return 'S'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
382 if (!strcmp(aaname, "TPO")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
383 return 'T'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
384 if (!strcmp(aaname, "PTR")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
385 return 'Y'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
386 i--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
387 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
388 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
389 return SHORT_AA_NAMES[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
390 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
391 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
392 int orient(res_type *res1, res_type *res2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
393 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
394 real x1, y1, z1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
395 real x2, y2, z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
396 real cax, cay, caz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
397 real len, vect, angle; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
398 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
399 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
400 if (!res1 || !res2) return 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
401 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
402 atom=res1->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
403 cax=cay=caz=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
404 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
405 if (!strncmp(atom->name,"CA",2)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
406 cax=atom->x; cay=atom->y; caz=atom->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
407 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
408 atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
409 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
410 x1=res1->sgx-cax; y1=res1->sgy-cay; z1=res1->sgz-caz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
411 if (x1==0. && y1==0. && z1==0.) x1+=1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
412 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
413 atom=res2->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
414 cax=cay=caz=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
415 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
416 if (!strncmp(atom->name,"CA",2)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
417 cax=atom->x; cay=atom->y; caz=atom->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
418 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
419 atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
420 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
421 x2=res2->sgx-cax; y2=res2->sgy-cay; z2=res2->sgz-caz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
422 if (x2==0. && y2==0. && z2==0.) x2+=1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
423 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
424 vect = x1*x2+y1*y2+z1*z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
425 len = sqrt(x1*x1+y1*y1+z1*z1)*sqrt(x2*x2+y2*y2+z2*z2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
426 if (len) vect /= len; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
427 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
428 angle=RADDEG*acos(vect); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
429 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
430 if (angle>120.) return 1; /*anti*/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
431 if (angle>60.) return 2; /*mid*/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
432 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
433 return 3; /*par*/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
434 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
435 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
436 int res_contact(res_type *res1, res_type *res2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
437 atom_type *atoms1, *atoms2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
438 real dx, dy, dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
439 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
440 atoms1 = res1->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
441 while (atoms1) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
442 atoms2 = res2->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
443 while (atoms2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
444 dx=atoms1->x-atoms2->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
445 dy=atoms1->y-atoms2->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
446 dz=atoms1->z-atoms2->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
447 if ((atoms1->flag & FLAG_SIDECHAIN) && (atoms2->flag & FLAG_SIDECHAIN) && (dx*dx+dy*dy+dz*dz<20.25)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
448 return 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
449 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
450 atoms2=atoms2->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
451 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
452 atoms1=atoms1->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
453 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
454 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
455 return 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
456 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
457 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
458 int read_pdb_file(char* filename, mol_type* molecules, char *realname) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
459 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
460 FILE *inp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
461 char buffer[1000]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
462 char atmname[10]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
463 char resname[10]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
464 char version; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
465 int prevresnum, resnum, atmnum, locatmnum, num, locnum=0, i, j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
466 atom_type *prevatom1, *prevatom2, *prevatom3, *prevatom4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
467 int sgnum, cc, nres, ok, natom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
468 real sgx, sgy, sgz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
469 res_type *res, *test1, *test2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
470 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
471 real x, y, z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
472 real dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
473 unsigned char bin; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
474 int warn=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
475 real cutoff; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
476 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
477 if (_VERBOSE) printf("Reading input file %s...\n", filename); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
478 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
479 inp = fopen(filename, "r"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
480 if (!inp) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
481 if (_VERBOSE) printf("ERROR: can't open %s !!!\n", filename); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
482 return FILE_NOT_FOUND; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
483 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
484 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
485 molecules->nres=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
486 molecules->name=(char*)calloc(strlen(realname)+1,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
487 strcpy(molecules->name, realname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
488 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
489 atmname[3]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
490 resname[3]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
491 prevresnum=-666; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
492 locatmnum=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
493 sgnum=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
494 sgx=sgy=sgz=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
495 res=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
496 while (!feof(inp)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
497 if (fgets(buffer, 1000, inp)!=buffer) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
498 if (!strncmp(buffer, "END", 3) || !strncmp(buffer, "TER", 3)) break; // end of file; only single molecule read |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
499 if (!strncmp(buffer, "ATOM", 4) || !strncmp(buffer, "HETATM", 6)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
500 if (buffer[16]!=' ' && buffer[16]!='A') continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
501 sscanf(&buffer[22], "%d", &resnum); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
502 strncpy(resname, &buffer[17], 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
503 strncpy(atmname, &buffer[13], 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
504 if (resnum==prevresnum && !strncmp(atmname, "N ", 2)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
505 if (_VERBOSE) printf("WARNING: fault in numeration at residuum %s[%d]\n", resname, resnum); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
506 warn=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
507 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
508 if (atmname[0]=='H') continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
509 if (resnum!=prevresnum || !strncmp(atmname, "N ", 2)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
510 prevresnum=resnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
511 if (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
512 if (sgnum) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
513 res->sgx=sgx/(real)sgnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
514 res->sgy=sgy/(real)sgnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
515 res->sgz=sgz/(real)sgnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
516 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
517 res->sgx=res->sgy=res->sgz=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
518 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
519 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
520 locatmnum=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
521 version=' '; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
522 res = new_res(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
523 sgnum=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
524 sgx=sgy=sgz=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
525 molecules->nres++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
526 res->name = calloc(strlen(resname)+1, 1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
527 res->type = AA_NUMS[setseq(resname)]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
528 res->locnum=locnum++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
529 res->num = resnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
530 res->natoms=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
531 res->chain = buffer[21]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
532 strcpy(res->name, resname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
533 if (molecules->residua) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
534 add_res(get_last_res(molecules->residua), res); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
535 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
536 molecules->residua = res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
537 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
538 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
539 atom = new_atom(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
540 atom->res = res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
541 res->natoms++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
542 locatmnum++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
543 sscanf(&buffer[7], "%d", &atmnum); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
544 sscanf(&buffer[30], "%lf", &x); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
545 sscanf(&buffer[38], "%lf", &y); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
546 sscanf(&buffer[46], "%lf", &z); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
547 version = buffer[16]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
548 atom->name = calloc(strlen(atmname)+1,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
549 strcpy(atom->name, atmname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
550 atom->x=x; atom->y=y; atom->z=z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
551 atom->num = atmnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
552 atom->locnum = locatmnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
553 if ((atmname[0]=='S' && atmname[1]=='C')||(atmname[0]=='C' && atmname[1]=='M')) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
554 res->cmx = x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
555 res->cmy = y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
556 res->cmz = z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
557 res->pdbsg=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
558 if (res->type<20) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
559 res->protein=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
560 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
561 } else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
562 if (!( ((atmname[0]=='C' || atmname[0]=='N' || atmname[0]=='O') && atmname[1]==' ') || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
563 (atmname[0]=='H') || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
564 (atmname[0]=='C' && atmname[1]=='A') || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
565 (atmname[0]=='O' && atmname[1]=='X' && atmname[2]=='T') ) ) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
566 sgx+=x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
567 sgy+=y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
568 sgz+=z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
569 sgnum++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
570 atom->flag |= FLAG_SIDECHAIN; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
571 } else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
572 atom->flag |= FLAG_BACKBONE; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
573 if (atmname[0]=='C' && atmname[1]=='A') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
574 atom->flag |= FLAG_BACKBONE; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
575 if (res->type<20) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
576 res->protein=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
577 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
578 if (!res->pdbsg) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
579 res->cmx = x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
580 res->cmy = y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
581 res->cmz = z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
582 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
583 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
584 if (atmname[0]=='C' && atmname[1]=='M') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
585 atom->flag |= FLAG_SCM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
586 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
587 if (atmname[0]=='S' && atmname[1]=='C') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
588 atom->flag |= FLAG_SCM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
589 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
590 if (res->atoms) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
591 add_atom(get_last_atom(res->atoms), atom); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
592 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
593 res->atoms = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
594 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
595 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
596 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
597 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
598 if (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
599 if (sgnum) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
600 res->sgx=sgx/(real)sgnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
601 res->sgy=sgy/(real)sgnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
602 res->sgz=sgz/(real)sgnum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
603 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
604 res->sgx=res->sgy=res->sgz=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
605 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
606 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
607 fclose(inp); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
608 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
609 molecules->seq = (uchar*)calloc(sizeof(uchar)*molecules->nres+1,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
610 res=molecules->residua; i=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
611 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
612 molecules->seq[i++]=(uchar)AA_NUMS[(int)setseq(res->name)]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
613 res=res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
614 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
615 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
616 if (!warn) return FILE_SUCCESS; else return FILE_WARNING; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
617 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
618 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
619 #define bool int |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
620 #define true 1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
621 #define false 0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
622 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
623 real calc_ca_energy(atom_type **c_alpha, real **new_c_alpha, real **init_c_alpha, real **gradient, real alpha, real *ene, bool calc_gradient) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
624 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
625 int i, j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
626 real dx, dy, dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
627 real dist, ddist, ddist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
628 real new_e_pot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
629 real theta0, tdif, th, aa, bb, ab; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
630 real ff0, ff2, dth, m0, m2, grad, f0[3], f2[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
631 real adiff[3], bdiff[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
632 real deriv, theta, dtheta, len1, len2, cos_theta, sin_theta; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
633 real dx1, dy1, dz1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
634 real dx2, dy2, dz2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
635 real dx3, dy3, dz3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
636 real vx1, vy1, vz1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
637 real vx2, vy2, vz2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
638 real vx3, vy3, vz3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
639 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
640 real r12x, r12y, r12z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
641 real r32x, r32y, r32z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
642 real d12, d32, d12inv, d32inv, c1, c2, diff; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
643 real f1x, f1y, f1z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
644 real f2x, f2y, f2z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
645 real f3x, f3y, f3z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
646 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
647 for (i=0; i<chain_length; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
648 new_c_alpha[i][0]=c_alpha[i]->x+alpha*gradient[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
649 new_c_alpha[i][1]=c_alpha[i]->y+alpha*gradient[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
650 new_c_alpha[i][2]=c_alpha[i]->z+alpha*gradient[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
651 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
652 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
653 new_e_pot = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
654 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
655 ene[0]=ene[1]=ene[2]=ene[3]=0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
656 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
657 for (i=0; i<chain_length; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
658 #ifdef CALC_C_ALPHA_START |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
659 dx=new_c_alpha[i][0]-init_c_alpha[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
660 dy=new_c_alpha[i][1]-init_c_alpha[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
661 dz=new_c_alpha[i][2]-init_c_alpha[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
662 dist=sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
663 ddist = -dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
664 if (dist>_CA_START_DIST) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
665 ddist2=dist*dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
666 new_e_pot+=CA_START_K*ddist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
667 ene[1] += CA_START_K*ddist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
668 if (calc_gradient) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
669 grad = ddist * (-2.0*CA_START_K)/dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
670 gradient[i][0]-=grad*dx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
671 gradient[i][1]-=grad*dy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
672 gradient[i][2]-=grad*dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
673 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
674 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
675 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
676 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
677 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
678 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
679 #ifdef CALC_C_ALPHA |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
680 if (i>0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
681 dx=new_c_alpha[i][0]-new_c_alpha[i-1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
682 dy=new_c_alpha[i][1]-new_c_alpha[i-1][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
683 dz=new_c_alpha[i][2]-new_c_alpha[i-1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
684 dist=sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
685 if (c_alpha[i]->cispro) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
686 ddist=CA_DIST_CISPRO-dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
687 // if (fabs(ddist)<CA_DIST_CISPRO_TOL) ddist=0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
688 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
689 ddist=CA_DIST-dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
690 // if (fabs(ddist)<CA_DIST_TOL) ddist=0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
691 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
692 ddist2=ddist*ddist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
693 new_e_pot+=CA_K*ddist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
694 ene[0] += CA_K*ddist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
695 if (calc_gradient) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
696 grad = ddist * (-2.0*CA_K)/dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
697 gradient[i][0]-=grad*dx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
698 gradient[i][1]-=grad*dy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
699 gradient[i][2]-=grad*dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
700 gradient[i-1][0]+=grad*dx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
701 gradient[i-1][1]+=grad*dy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
702 gradient[i-1][2]+=grad*dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
703 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
704 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
705 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
706 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
707 #ifdef CALC_C_ALPHA_XVOL |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
708 for (j=0;j<i;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
709 if (abs(i-j)>2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
710 dx=new_c_alpha[i][0]-new_c_alpha[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
711 dy=new_c_alpha[i][1]-new_c_alpha[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
712 dz=new_c_alpha[i][2]-new_c_alpha[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
713 dist=sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
714 ddist = dist-_CA_XVOL_DIST; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
715 if (dist<_CA_XVOL_DIST) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
716 ddist2 = dist*dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
717 new_e_pot+=CA_XVOL_K*ddist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
718 ene[3] += CA_XVOL_K*ddist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
719 if (calc_gradient) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
720 grad = ddist*(8.0*CA_XVOL_K)/dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
721 gradient[i][0]-=grad*dx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
722 gradient[i][1]-=grad*dy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
723 gradient[i][2]-=grad*dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
724 gradient[j][0]+=grad*dx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
725 gradient[j][1]+=grad*dy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
726 gradient[j][2]+=grad*dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
727 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
728 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
729 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
730 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
731 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
732 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
733 #ifdef CALC_C_ALPHA_ANGLES |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
734 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
735 if (i>0 && i<chain_length-1) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
736 r12x=new_c_alpha[i-1][0]-new_c_alpha[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
737 r12y=new_c_alpha[i-1][1]-new_c_alpha[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
738 r12z=new_c_alpha[i-1][2]-new_c_alpha[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
739 r32x=new_c_alpha[i+1][0]-new_c_alpha[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
740 r32y=new_c_alpha[i+1][1]-new_c_alpha[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
741 r32z=new_c_alpha[i+1][2]-new_c_alpha[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
742 d12 = sqrt(r12x*r12x+r12y*r12y+r12z*r12z); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
743 d32 = sqrt(r32x*r32x+r32y*r32y+r32z*r32z); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
744 cos_theta = (r12x*r32x+r12y*r32y+r12z*r32z)/(d12*d32); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
745 if (cos_theta>1.0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
746 cos_theta = 1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
747 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
748 if (cos_theta<-1.0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
749 cos_theta = -1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
750 sin_theta = sqrt(1.0-cos_theta*cos_theta); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
751 theta = acos(cos_theta); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
752 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
753 if (RADDEG*theta<80.) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
754 diff = theta-80.*DEGRAD; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
755 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
756 if (RADDEG*theta>150.) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
757 diff = theta-150.*DEGRAD; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
758 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
759 diff = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
760 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
761 new_e_pot += CA_ANGLE_K*diff*diff; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
762 ene[2] += CA_ANGLE_K*diff*diff; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
763 if (calc_gradient) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
764 d12inv = 1.0/d12; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
765 d32inv = 1.0/d32; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
766 diff *= (-2.0*CA_ANGLE_K)/sin_theta; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
767 c1 = diff*d12inv; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
768 c2 = diff*d32inv; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
769 f1x = c1*(r12x*(d12inv*cos_theta)-r32x*d32inv); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
770 f1y = c1*(r12y*(d12inv*cos_theta)-r32y*d32inv); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
771 f1z = c1*(r12z*(d12inv*cos_theta)-r32z*d32inv); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
772 f3x = c2*(r32x*(d32inv*cos_theta)-r12x*d12inv); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
773 f3y = c2*(r32y*(d32inv*cos_theta)-r12y*d12inv); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
774 f3z = c2*(r32z*(d32inv*cos_theta)-r12z*d12inv); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
775 f2x = -f1x-f3x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
776 f2y = -f1y-f3y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
777 f2z = -f1z-f3z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
778 gradient[i-1][0]+=f1x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
779 gradient[i-1][1]+=f1y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
780 gradient[i-1][2]+=f1z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
781 gradient[i][0]+=f2x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
782 gradient[i][1]+=f2y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
783 gradient[i][2]+=f2z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
784 gradient[i+1][0]+=f3x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
785 gradient[i+1][1]+=f3y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
786 gradient[i+1][2]+=f3z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
787 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
788 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
789 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
790 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
791 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
792 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
793 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
794 //printf("ene[3] = %f\n", ene[3]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
795 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
796 return new_e_pot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
797 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
798 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
799 /* |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
800 * Steepest gradient optimization using v=k*(r0-r)^2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
801 * k = CA_K, r0 = CA_DIST |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
802 */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
803 void ca_optimize(char *tname, char *iname) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
804 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
805 char buf[1000]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
806 int i, j, hx, my_iter; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
807 real dx, dy, dz, dd, dist, dist2, dist3, ddist, ddist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
808 real e_pot, new_e_pot, grad, alpha, e_pot1, e_pot2, e_pot3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
809 real adiff[3], bdiff[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
810 real ff0, ff2, aa, ab, bb, th, tdif, dth, m0, m2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
811 real theta0, deg_th, maxgrad, sum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
812 real f0[3], f2[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
813 real x, y, z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
814 int numsteps, numsteps2, msteps; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
815 int *sec; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
816 real **new_c_alpha, **gradient, **init_c_alpha, last_alpha, tmp, last_good_alpha, d_alpha, last_e_pot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
817 atom_type *atom, **c_alpha; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
818 res_type *res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
819 FILE *inp, *out; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
820 int mnum, init, ok; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
821 real alpha1, alpha2, alpha3, a0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
822 real ene1, ene2, ene3, e0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
823 real energies[4]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
824 real w1, w2, w3, eps; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
825 real gnorm, last_gnorm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
826 int mode, fcnt; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
827 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
828 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
829 if (_CA_TRAJECTORY) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
830 out = fopen(tname,"w"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
831 if (out) fclose(out); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
832 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
833 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
834 if (_VERBOSE) printf("Alpha carbons optimization...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
835 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
836 new_c_alpha = (real**)calloc(sizeof(real*)*(chain_length+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
837 init_c_alpha = (real**)calloc(sizeof(real*)*(chain_length+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
838 for (i=0;i<=chain_length;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
839 new_c_alpha[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
840 init_c_alpha[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
841 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
842 gradient = (real**)calloc(sizeof(real*)*(chain_length+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
843 for (i=0;i<=chain_length;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
844 gradient[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
845 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
846 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
847 c_alpha = (atom_type**)calloc(sizeof(atom_type*)*(chain_length+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
848 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
849 i = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
850 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
851 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
852 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
853 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
854 if (atom->name[0]=='C' && atom->name[1]=='A') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
855 if (i<chain_length) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
856 c_alpha[i] = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
857 i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
858 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
859 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
860 if (_VERBOSE) printf("WARNING: number of C-alpha atoms exceeds the chain length!\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
861 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
862 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
863 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
864 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
865 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
866 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
867 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
868 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
869 if (i<chain_length) chain_length = i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
870 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
871 for (i=0; i<chain_length; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
872 init_c_alpha[i][0] = c_alpha[i]->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
873 init_c_alpha[i][1] = c_alpha[i]->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
874 init_c_alpha[i][2] = c_alpha[i]->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
875 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
876 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
877 if (_CISPRO) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
878 for (i=1; i<chain_length; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
879 dx = c_alpha[i]->x-c_alpha[i-1]->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
880 dy = c_alpha[i]->y-c_alpha[i-1]->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
881 dz = c_alpha[i]->z-c_alpha[i-1]->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
882 dd = sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
883 if ((setseq(c_alpha[i]->res->name)=='P') && (dd>CA_DIST_CISPRO-5*CA_DIST_CISPRO_TOL) && (dd<CA_DIST_CISPRO+5*CA_DIST_CISPRO_TOL)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
884 if (_VERBOSE) printf("Probable cis-proline found at postion %d\n", c_alpha[i]->res->num); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
885 c_alpha[i]->cispro = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
886 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
887 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
888 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
889 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
890 if (_CA_RANDOM) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
891 if (_VERBOSE) printf("Generating random C-alpha coordinates...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
892 c_alpha[0]->x = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
893 c_alpha[0]->y = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
894 c_alpha[0]->z = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
895 for (i=1;i<chain_length;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
896 dx = 0.01*(100-rand()%200); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
897 dy = 0.01*(100-rand()%200); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
898 dz = 0.01*(100-rand()%200); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
899 dd = 3.8/sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
900 dx *= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
901 dy *= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
902 dz *= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
903 c_alpha[i]->x = c_alpha[i-1]->x+dx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
904 c_alpha[i]->y = c_alpha[i-1]->y+dy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
905 c_alpha[i]->z = c_alpha[i-1]->z+dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
906 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
907 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
908 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
909 if (iname) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
910 inp = fopen(iname,"r"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
911 if (inp) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
912 if (_VERBOSE) printf("Reading initial structure %s...\n", iname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
913 i = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
914 while (!feof(inp)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
915 if (fgets(buf,1000,inp)==buf && buf[13]=='C' && buf[14]=='A') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
916 if (i<chain_length) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
917 if (sscanf(&buf[30],"%lf%lf%lf",&x,&y,&z)==3) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
918 c_alpha[i]->x = x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
919 c_alpha[i]->y = y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
920 c_alpha[i]->z = z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
921 i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
922 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
923 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
924 if (_VERBOSE) printf("WARNING: number of ini-file C-alpha atoms exceeds the chain length!\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
925 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
926 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
927 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
928 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
929 fclose(inp); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
930 } else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
931 if (_VERBOSE) printf("WARNING: can't read initial corrdinates %s\n", iname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
932 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
933 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
934 mnum = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
935 mode = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
936 init = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
937 numsteps=numsteps2=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
938 last_alpha = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
939 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
940 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
941 if (_VERBOSE) printf("Optimizing alpha carbons...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
942 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
943 eps = 0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
944 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
945 fcnt=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
946 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
947 last_gnorm = 1000.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
948 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
949 do { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
950 last_e_pot = e_pot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
951 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
952 if (_CA_TRAJECTORY) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
953 out = fopen(tname,"a"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
954 if (out) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
955 fprintf(out,"MODEL %d\n",mnum++); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
956 for (i=0; i<chain_length; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
957 fprintf(out, "ATOM %5d %-3s %3s %c%4d %8.3f%8.3f%8.3f\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
958 i+1, "CA ", c_alpha[i]->res->name, ' ', c_alpha[i]->res->num, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
959 c_alpha[i]->x, c_alpha[i]->y, c_alpha[i]->z); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
960 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
961 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
962 fprintf(out,"ENDMDL\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
963 fclose(out); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
964 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
965 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
966 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
967 // calculate gradients |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
968 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
969 e_pot=e_pot1=e_pot2=e_pot3=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
970 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
971 for (i=0; i<chain_length; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
972 gradient[i][0]=gradient[i][1]=gradient[i][2]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
973 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
974 e_pot = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, 0.0, energies, true); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
975 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
976 if (_VERBOSE && !init) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
977 printf("Initial energy: bond=%.5lf angle=%.5f restraints=%.5f xvol=%.5f total=%.5f\n", energies[0], energies[2], energies[1], energies[3], e_pot); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
978 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
979 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
980 if (!init) init=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
981 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
982 // LINE SEARCH |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
983 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
984 alpha1 = -1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
985 alpha2 = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
986 alpha3 = 1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
987 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
988 ene1 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, alpha1, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
989 ene2 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, alpha2, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
990 ene3 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, alpha3, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
991 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
992 msteps = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
993 while (ene2>MIN(ene1,ene3) && msteps<_CA_ITER) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
994 msteps++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
995 alpha1 *= 2.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
996 alpha3 *= 2.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
997 ene1 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, alpha1, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
998 ene3 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, alpha3, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
999 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1000 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1001 msteps = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1002 do { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1003 if (alpha3-alpha2>alpha2-alpha1) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1004 a0 = 0.5*(alpha2+alpha3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1005 e0 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, a0, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1006 e0 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, a0-1e-5, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1007 e0 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, a0+1e-5, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1008 e0 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, a0, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1009 if (e0<ene2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1010 alpha1 = alpha2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1011 alpha2 = a0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1012 ene1 = ene2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1013 ene2 = e0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1014 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1015 alpha3 = a0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1016 ene3 = e0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1017 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1018 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1019 a0 = 0.5*(alpha1+alpha2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1020 e0 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, a0, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1021 e0 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, a0-1e-5, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1022 e0 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, a0+1e-5, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1023 e0 = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, a0, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1024 if (e0<ene2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1025 alpha3 = alpha2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1026 alpha2 = a0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1027 ene3 = ene2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1028 ene2 = e0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1029 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1030 alpha1 = a0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1031 ene1 = e0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1032 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1033 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1034 msteps++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1035 } while (alpha3-alpha1>1e-6 && msteps<20); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1036 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1037 last_alpha = alpha2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1038 e_pot = ene2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1039 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1040 for (i=0; i<chain_length; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1041 c_alpha[i]->x=c_alpha[i]->x+(last_alpha+last_alpha*(rnd()-0.5)*eps)*gradient[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1042 c_alpha[i]->y=c_alpha[i]->y+(last_alpha+last_alpha*(rnd()-0.5)*eps)*gradient[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1043 c_alpha[i]->z=c_alpha[i]->z+(last_alpha+last_alpha*(rnd()-0.5)*eps)*gradient[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1044 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1045 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1046 e_pot = calc_ca_energy(c_alpha, new_c_alpha, init_c_alpha, gradient, 0.0, energies, false); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1047 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1048 eps *= 0.75; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1049 if (eps<1e-3) eps=0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1050 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1051 numsteps++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1052 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1053 gnorm = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1054 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1055 for (i=0; i<chain_length; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1056 gnorm += gradient[i][0]*gradient[i][0] + gradient[i][1]*gradient[i][1] + gradient[i][2]*gradient[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1057 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1058 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1059 gnorm = sqrt(gnorm/(double)chain_length); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1060 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1061 if (last_gnorm-gnorm<1e-3) fcnt++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1062 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1063 last_gnorm = gnorm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1064 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1065 } while ( (fcnt<3) && (gnorm>0.01) && (numsteps<_CA_ITER)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1066 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1067 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1068 if (_VERBOSE) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1069 for (i=0; i<chain_length; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1070 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1071 #ifdef CALC_C_ALPHA |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1072 if (i>0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1073 dx=c_alpha[i]->x-c_alpha[i-1]->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1074 dy=c_alpha[i]->y-c_alpha[i-1]->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1075 dz=c_alpha[i]->z-c_alpha[i-1]->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1076 dist=sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1077 if (c_alpha[i]->cispro) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1078 ddist=CA_DIST_CISPRO-dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1079 if (fabs(ddist)<CA_DIST_CISPRO_TOL) ddist=0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1080 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1081 ddist=CA_DIST-dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1082 if (fabs(ddist)<CA_DIST_TOL) ddist=0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1083 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1084 ddist2=ddist*ddist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1085 if (fabs(ddist)>=CA_DIST_TOL) printf("WARNING: distance %d = %.3lf A\n", i, dist); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1086 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1087 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1088 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1089 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1090 for (i=0; i<chain_length; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1091 #ifdef CALC_C_ALPHA_ANGLES |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1092 if (i>0 && i<chain_length-1) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1093 aa=ab=bb=0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1094 adiff[0]=c_alpha[i-1]->x-c_alpha[i]->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1095 bdiff[0]=c_alpha[i+1]->x-c_alpha[i]->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1096 aa+=adiff[0]*adiff[0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1097 ab+=adiff[0]*bdiff[0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1098 bb+=bdiff[0]*bdiff[0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1099 adiff[1]=c_alpha[i-1]->y-c_alpha[i]->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1100 bdiff[1]=c_alpha[i+1]->y-c_alpha[i]->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1101 aa+=adiff[1]*adiff[1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1102 ab+=adiff[1]*bdiff[1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1103 bb+=bdiff[1]*bdiff[1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1104 adiff[2]=c_alpha[i-1]->z-c_alpha[i]->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1105 bdiff[2]=c_alpha[i+1]->z-c_alpha[i]->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1106 aa+=adiff[2]*adiff[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1107 ab+=adiff[2]*bdiff[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1108 bb+=bdiff[2]*bdiff[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1109 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1110 th=ab/sqrt(aa*bb); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1111 if (th<-1.0) th=-1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1112 if (th>1.0) th=1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1113 th=acos(th); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1114 deg_th=RADDEG*th; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1115 if (deg_th>150.) theta0=DEGRAD*150.; else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1116 if (deg_th<75.) theta0=DEGRAD*75.; else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1117 theta0=th; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1118 if (fabs(deg_th-RADDEG*theta0)>1.0) printf("WARNING: angle %d = %.3lf degrees\n", i, deg_th); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1119 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1120 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1121 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1122 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1123 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1124 if (_VERBOSE) printf("Optimization done after %d step(s).\nFinal energy: bond=%.5lf angle=%.5f restraints=%.5f xvol=%.5f total=%.5f\n", numsteps, energies[0], energies[2], energies[1], energies[3], e_pot); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1125 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1126 if (_CA_TRAJECTORY) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1127 out = fopen(tname,"a"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1128 if (out) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1129 fprintf(out,"END\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1130 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1131 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1132 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1133 for (i=0;i<chain_length+1;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1134 free(init_c_alpha[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1135 free(new_c_alpha[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1136 free(gradient[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1137 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1138 free(new_c_alpha); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1139 free(gradient); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1140 free(c_alpha); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1141 free(init_c_alpha); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1142 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1143 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1144 void center_chain(mol_type *mol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1145 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1146 real cx, cy, cz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1147 int natom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1148 res_type *res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1149 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1150 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1151 cx = cy = cz = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1152 natom = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1153 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1154 res = mol->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1155 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1156 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1157 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1158 cx += atom->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1159 cy += atom->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1160 cz += atom->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1161 natom++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1162 atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1163 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1164 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1165 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1166 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1167 cx /= (real)natom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1168 cy /= (real)natom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1169 cz /= (real)natom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1170 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1171 if (_VERBOSE) printf("Molecule center: %8.3f %8.3f %8.3f -> 0.000 0.000 0.000\n", cx, cy, cz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1172 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1173 res = mol->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1174 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1175 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1176 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1177 atom->x -= cx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1178 atom->y -= cy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1179 atom->z -= cz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1180 natom++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1181 atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1182 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1183 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1184 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1185 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1186 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1187 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1188 void write_pdb(char *name, mol_type *mol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1189 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1190 FILE *out; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1191 res_type *res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1192 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1193 int anum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1194 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1195 out = fopen(name,"w"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1196 if (!out) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1197 if (_VERBOSE) printf("Can't open output file!\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1198 return; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1199 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1200 fprintf(out,"REMARK 999 REBUILT BY PULCHRA V.%.2f\n", PULCHRA_VERSION); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1201 anum=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1202 res = mol->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1203 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1204 if (res->protein) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1205 if (!_BB_REARRANGE) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1206 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1207 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1208 if (!(atom->name[0]=='D' && atom->name[1]=='U') && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1209 !(atom->name[0]=='S' && atom->name[1]=='C') && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1210 !(atom->name[0]=='C' && atom->name[1]=='M') && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1211 !(atom->name[0]=='H' && !_REBUILD_H)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1212 fprintf(out, "ATOM %5d %-3s %3s %c%4d %8.3f%8.3f%8.3f\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1213 anum++, atom->name, res->name, ' ', res->num, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1214 atom->x, atom->y, atom->z); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1215 atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1216 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1217 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1218 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1219 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1220 if (!(atom->name[0]=='D' && atom->name[1]=='U') && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1221 !(atom->name[0]=='S' && atom->name[1]=='C') && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1222 !(atom->name[0]=='C' && atom->name[1]==' ') && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1223 !(atom->name[0]=='O' && atom->name[1]==' ') && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1224 !(atom->name[0]=='C' && atom->name[1]=='M') && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1225 !(atom->name[0]=='H' && !_REBUILD_H)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1226 fprintf(out, "ATOM %5d %-3s %3s %c%4d %8.3f%8.3f%8.3f\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1227 anum++, atom->name, res->name, ' ', res->num, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1228 atom->x, atom->y, atom->z); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1229 atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1230 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1231 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1232 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1233 if (((atom->name[0]=='C' && atom->name[1]==' ') || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1234 (atom->name[0]=='O' && atom->name[1]==' ')) && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1235 !(atom->name[0]=='H' && !_REBUILD_H)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1236 fprintf(out, "ATOM %5d %-3s %3s %c%4d %8.3f%8.3f%8.3f\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1237 anum++, atom->name, res->name, ' ', res->num, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1238 atom->x, atom->y, atom->z); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1239 atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1240 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1241 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1242 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1243 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1244 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1245 fprintf(out,"TER\nEND\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1246 fclose(out); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1247 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1248 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1249 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1250 void write_pdb_sg(char *name, mol_type *mol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1251 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1252 FILE *out; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1253 res_type *res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1254 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1255 int anum; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1256 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1257 out = fopen(name,"w"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1258 if (!out) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1259 if (_VERBOSE) printf("Can't open output file!\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1260 return; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1261 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1262 fprintf(out,"REMARK 999 REBUILT BY PULCHRA V.%.2f\n", PULCHRA_VERSION); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1263 anum=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1264 res = mol->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1265 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1266 if (res->protein) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1267 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1268 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1269 if ((atom->name[0]=='C' && atom->name[1]=='A')) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1270 fprintf(out, "ATOM %5d %-3s %3s %c%4d %8.3f%8.3f%8.3f\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1271 anum++, atom->name, res->name, ' ', res->num, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1272 atom->x, atom->y, atom->z); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1273 atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1274 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1275 fprintf(out, "ATOM %5d %-3s %3s %c%4d %8.3f%8.3f%8.3f\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1276 anum++, "CM ", res->name, ' ', res->num, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1277 res->cmx, res->cmy, res->cmz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1278 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1279 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1280 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1281 fprintf(out,"TER\nEND\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1282 fclose(out); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1283 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1284 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1285 real calc_distance(real x1, real y1, real z1, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1286 real x2, real y2, real z2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1287 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1288 real dx,dy,dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1289 real dist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1290 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1291 dx = (x1) - (x2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1292 dy = (y1) - (y2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1293 dz = (z1) - (z2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1294 if (dx || dy || dz ) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1295 dist2 = dx*dx+dy*dy+dz*dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1296 return (sqrt(dist2)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1297 } else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1298 return 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1299 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1300 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1301 real calc_r14(real x1, real y1, real z1, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1302 real x2, real y2, real z2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1303 real x3, real y3, real z3, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1304 real x4, real y4, real z4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1305 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1306 real r, dx, dy, dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1307 real vx1, vy1, vz1, vx2, vy2, vz2, vx3, vy3, vz3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1308 real hand; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1309 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1310 dx = x4-x1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1311 dy = y4-y1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1312 dz = z4-z1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1313 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1314 r = sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1315 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1316 vx1=x2-x1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1317 vy1=y2-y1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1318 vz1=z2-z1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1319 vx2=x3-x2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1320 vy2=y3-y2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1321 vz2=z3-z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1322 vx3=x4-x3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1323 vy3=y4-y3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1324 vz3=z4-z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1325 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1326 hand = (vy1*vz2-vy2*vz1)*vx3+ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1327 (vz1*vx2-vz2*vx1)*vy3+ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1328 (vx1*vy2-vx2*vy1)*vz3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1329 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1330 if (hand<0) r=-r; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1331 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1332 return r; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1333 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1334 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1335 real superimpose2(real **coords1, real **coords2, int npoints, real **tpoints, int ntpoints) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1336 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1337 real mat_s[3][3], mat_a[3][3], mat_b[3][3], mat_g[3][3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1338 real mat_u[3][3], tmp_mat[3][3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1339 real val, d, alpha, beta, gamma, x, y, z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1340 real cx1, cy1, cz1, cx2, cy2, cz2, tmpx, tmpy, tmpz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1341 int i, j, k, n; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1342 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1343 cx1=cy1=cz1=cx2=cy2=cz2=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1344 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1345 for (i=0; i<npoints; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1346 cx1+=coords1[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1347 cy1+=coords1[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1348 cz1+=coords1[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1349 cx2+=coords2[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1350 cy2+=coords2[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1351 cz2+=coords2[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1352 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1353 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1354 cx1/=(real)npoints; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1355 cy1/=(real)npoints; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1356 cz1/=(real)npoints; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1357 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1358 cx2/=(real)npoints; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1359 cy2/=(real)npoints; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1360 cz2/=(real)npoints; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1361 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1362 for (i=0; i<npoints; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1363 coords1[i][0]-=cx1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1364 coords1[i][1]-=cy1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1365 coords1[i][2]-=cz1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1366 coords2[i][0]-=cx2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1367 coords2[i][1]-=cy2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1368 coords2[i][2]-=cz2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1369 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1370 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1371 for (i=0; i<ntpoints; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1372 tpoints[i][0]-=cx2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1373 tpoints[i][1]-=cy2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1374 tpoints[i][2]-=cz2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1375 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1376 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1377 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1378 for (j=0; j<3; j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1379 if (i==j) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1380 mat_s[i][j]=mat_a[i][j]=mat_b[i][j]=mat_g[i][j]=1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1381 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1382 mat_s[i][j]=mat_a[i][j]=mat_b[i][j]=mat_g[i][j]=0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1383 mat_u[i][j]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1384 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1385 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1386 for (n=0; n<npoints; n++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1387 mat_u[0][0]+=coords1[n][0]*coords2[n][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1388 mat_u[0][1]+=coords1[n][0]*coords2[n][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1389 mat_u[0][2]+=coords1[n][0]*coords2[n][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1390 mat_u[1][0]+=coords1[n][1]*coords2[n][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1391 mat_u[1][1]+=coords1[n][1]*coords2[n][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1392 mat_u[1][2]+=coords1[n][1]*coords2[n][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1393 mat_u[2][0]+=coords1[n][2]*coords2[n][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1394 mat_u[2][1]+=coords1[n][2]*coords2[n][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1395 mat_u[2][2]+=coords1[n][2]*coords2[n][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1396 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1397 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1398 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1399 for (j=0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1400 tmp_mat[i][j]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1401 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1402 do { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1403 d=mat_u[2][1]-mat_u[1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1404 if (d==0) alpha=0; else alpha=atan(d/(mat_u[1][1]+mat_u[2][2])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1405 if (cos(alpha)*(mat_u[1][1]+mat_u[2][2])+sin(alpha)*(mat_u[2][1]-mat_u[1][2])<0.0) alpha+=M_PI; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1406 mat_a[1][1]=mat_a[2][2]=cos(alpha); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1407 mat_a[2][1]=sin(alpha); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1408 mat_a[1][2]=-mat_a[2][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1409 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1410 for (j=0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1411 for (k=0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1412 tmp_mat[i][j]+=mat_u[i][k]*mat_a[j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1413 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1414 for (j=0; j<3; j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1415 mat_u[i][j]=tmp_mat[i][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1416 tmp_mat[i][j]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1417 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1418 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1419 for (j=0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1420 for (k=0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1421 tmp_mat[i][j]+=mat_a[i][k]*mat_s[k][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1422 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1423 for (j=0; j<3; j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1424 mat_s[i][j]=tmp_mat[i][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1425 tmp_mat[i][j]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1426 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1427 d=mat_u[0][2]-mat_u[2][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1428 if (d==0) beta=0; else beta=atan(d/(mat_u[0][0]+mat_u[2][2])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1429 if (cos(beta)*(mat_u[0][0]+mat_u[2][2])+sin(beta)*(mat_u[0][2]-mat_u[2][0])<0.0) beta+=M_PI; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1430 mat_b[0][0]=mat_b[2][2]=cos(beta); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1431 mat_b[0][2]=sin(beta); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1432 mat_b[2][0]=-mat_b[0][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1433 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1434 for (j=0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1435 for (k=0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1436 tmp_mat[i][j]+=mat_u[i][k]*mat_b[j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1437 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1438 for (j=0; j<3; j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1439 mat_u[i][j]=tmp_mat[i][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1440 tmp_mat[i][j]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1441 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1442 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1443 for (j=0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1444 for (k=0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1445 tmp_mat[i][j]+=mat_b[i][k]*mat_s[k][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1446 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1447 for (j=0; j<3; j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1448 mat_s[i][j]=tmp_mat[i][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1449 tmp_mat[i][j]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1450 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1451 d=mat_u[1][0]-mat_u[0][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1452 if (d==0) gamma=0; else gamma=atan(d/(mat_u[0][0]+mat_u[1][1])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1453 if (cos(gamma)*(mat_u[0][0]+mat_u[1][1])+sin(gamma)*(mat_u[1][0]-mat_u[0][1])<0.0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1454 gamma+=M_PI; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1455 mat_g[0][0]=mat_g[1][1]=cos(gamma); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1456 mat_g[1][0]=sin(gamma); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1457 mat_g[0][1]=-mat_g[1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1458 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1459 for (j=0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1460 for (k=0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1461 tmp_mat[i][j]+=mat_u[i][k]*mat_g[j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1462 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1463 for (j=0; j<3; j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1464 mat_u[i][j]=tmp_mat[i][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1465 tmp_mat[i][j]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1466 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1467 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1468 for (j=0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1469 for (k=0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1470 tmp_mat[i][j]+=mat_g[i][k]*mat_s[k][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1471 for (i=0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1472 for (j=0; j<3; j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1473 mat_s[i][j]=tmp_mat[i][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1474 tmp_mat[i][j]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1475 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1476 val=fabs(alpha)+fabs(beta)+fabs(gamma); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1477 } while (val>0.001); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1478 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1479 val=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1480 for (i=0; i<npoints; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1481 x=coords2[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1482 y=coords2[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1483 z=coords2[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1484 tmpx=x*mat_s[0][0]+y*mat_s[0][1]+z*mat_s[0][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1485 tmpy=x*mat_s[1][0]+y*mat_s[1][1]+z*mat_s[1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1486 tmpz=x*mat_s[2][0]+y*mat_s[2][1]+z*mat_s[2][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1487 x=coords1[i][0]-tmpx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1488 y=coords1[i][1]-tmpy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1489 z=coords1[i][2]-tmpz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1490 val+=x*x+y*y+z*z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1491 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1492 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1493 for (i=0; i<ntpoints; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1494 x=tpoints[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1495 y=tpoints[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1496 z=tpoints[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1497 tpoints[i][0]=x*mat_s[0][0]+y*mat_s[0][1]+z*mat_s[0][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1498 tpoints[i][1]=x*mat_s[1][0]+y*mat_s[1][1]+z*mat_s[1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1499 tpoints[i][2]=x*mat_s[2][0]+y*mat_s[2][1]+z*mat_s[2][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1500 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1501 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1502 for (i=0; i<npoints; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1503 coords1[i][0]+=cx1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1504 coords1[i][1]+=cy1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1505 coords1[i][2]+=cz1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1506 coords2[i][0]+=cx2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1507 coords2[i][1]+=cy2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1508 coords2[i][2]+=cz2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1509 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1510 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1511 for (i=0; i<ntpoints; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1512 tpoints[i][0]+=cx1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1513 tpoints[i][1]+=cy1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1514 tpoints[i][2]+=cz1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1515 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1516 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1517 return sqrt(val/(real)npoints); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1518 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1519 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1520 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1521 atom_type *find_atom(res_type *res, char *aname) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1522 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1523 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1524 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1525 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1526 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1527 if (atom->name[0]==aname[0] && atom->name[1]==aname[1] && atom->name[2]==aname[2]) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1528 return atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1529 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1530 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1531 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1532 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1533 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1534 return NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1535 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1536 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1537 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1538 void add_replace(res_type *res, char *aname, real x, real y, real z, int flags) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1539 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1540 atom_type *atom, *newatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1541 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1542 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1543 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1544 if (atom->name[0]==aname[0] && atom->name[1]==aname[1] && atom->name[2]==aname[2]) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1545 atom->x = x; atom->y = y; atom->z = z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1546 atom->flag |= flags; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1547 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1548 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1549 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1550 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1551 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1552 if (!atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1553 newatom = (atom_type*)calloc(sizeof(atom_type),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1554 newatom->x = x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1555 newatom->y = y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1556 newatom->z = z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1557 newatom->flag |= flags; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1558 newatom->res = res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1559 newatom->name = (char*)calloc(4,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1560 strcpy(newatom->name,aname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1561 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1562 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1563 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1564 if (atom->name[0]=='C' && atom->name[1]=='A') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1565 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1566 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1567 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1568 if (aname[0]=='N' && aname[1]==' ') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1569 newatom->next = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1570 res->atoms = newatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1571 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1572 while (atom->next) atom=atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1573 atom->next = newatom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1574 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1575 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1576 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1577 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1578 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1579 int **RBINS; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1580 real **X_COORDS, **C_ALPHA; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1581 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1582 #ifdef COMPILE_BB |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1583 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1584 void rebuild_backbone(void) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1585 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1586 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1587 res_type *res, *prevres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1588 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1589 real **cacoords, **tmpcoords, **tmpstat; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1590 real x1, y1, z1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1591 real x2, y2, z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1592 real x3, y3, z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1593 real x4, y4, z4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1594 real r13_1, r13_2, r14; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1595 real besthit, hit; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1596 int bestpos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1597 int i, j, k, l, m, bin13_1, bin13_2, bin14, found, pro; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1598 int b13_1, b13_2, b14; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1599 real rmsd, total, maxrms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1600 FILE *debug, *out; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1601 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1602 if (_VERBOSE) printf("Rebuilding backbone...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1603 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1604 RBINS = (int**)calloc(sizeof(int*)*(chain_length+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1605 for (i=0;i<chain_length+1;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1606 RBINS[i] = (int*)calloc(sizeof(int)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1607 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1608 X_COORDS = (real**)calloc(sizeof(real*)*(chain_length+10),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1609 for (i=0;i<chain_length+10;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1610 X_COORDS[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1611 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1612 i = 5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1613 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1614 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1615 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1616 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1617 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1618 if (atom->name[0]=='C' && atom->name[1]=='A') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1619 X_COORDS[i][0] = atom->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1620 X_COORDS[i][1] = atom->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1621 X_COORDS[i][2] = atom->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1622 i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1623 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1624 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1625 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1626 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1627 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1628 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1629 cacoords = (real**)calloc(sizeof(real*)*(8),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1630 tmpcoords = (real**)calloc(sizeof(real*)*(8),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1631 tmpstat = (real**)calloc(sizeof(real*)*(8),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1632 for (i=0;i<8;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1633 cacoords[i] = (real*)calloc(sizeof(real)*3,1);; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1634 tmpcoords[i] = (real*)calloc(sizeof(real)*3,1);; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1635 tmpstat[i] = (real*)calloc(sizeof(real)*3,1);; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1636 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1637 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1638 C_ALPHA = &X_COORDS[5]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1639 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1640 // rebuild ends... |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1641 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1642 for (i=0,j=0;i<5;i++,j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1643 for (k=0;k<3;k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1644 tmpcoords[j][k] = C_ALPHA[i][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1645 for (i=2,j=0;i<5;i++,j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1646 for (k=0;k<3;k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1647 cacoords[j][k] = C_ALPHA[i][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1648 for (i=0,j=0;i<3;i++,j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1649 for (k=0;k<3;k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1650 tmpstat[j][k] = C_ALPHA[i][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1651 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1652 superimpose2(tmpstat,cacoords,3,tmpcoords,5); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1653 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1654 for (i=-2,j=0;i<0;i++,j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1655 for (k=0;k<3;k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1656 C_ALPHA[i][k] = tmpcoords[j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1657 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1658 for (i=chain_length-5,j=0;i<chain_length;i++,j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1659 for (k=0;k<3;k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1660 tmpcoords[j][k] = C_ALPHA[i][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1661 for (i=chain_length-5,j=0;i<chain_length-2;i++,j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1662 for (k=0;k<3;k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1663 cacoords[j][k] = C_ALPHA[i][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1664 for (i=chain_length-3,j=0;i<chain_length;i++,j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1665 for (k=0;k<3;k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1666 tmpstat[j][k] = C_ALPHA[i][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1667 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1668 superimpose2(tmpstat,cacoords,3,tmpcoords,5); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1669 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1670 for (i=chain_length-3,j=0;i<chain_length;i++,j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1671 for (k=0;k<3;k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1672 C_ALPHA[i+3][k] = tmpcoords[j+3][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1673 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1674 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1675 prevres = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1676 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1677 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1678 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1679 total = maxrms = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1680 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1681 for (i=0;i<chain_length+1;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1682 x1 = C_ALPHA[i-2][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1683 y1 = C_ALPHA[i-2][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1684 z1 = C_ALPHA[i-2][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1685 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1686 x2 = C_ALPHA[i-1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1687 y2 = C_ALPHA[i-1][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1688 z2 = C_ALPHA[i-1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1689 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1690 x3 = C_ALPHA[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1691 y3 = C_ALPHA[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1692 z3 = C_ALPHA[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1693 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1694 x4 = C_ALPHA[i+1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1695 y4 = C_ALPHA[i+1][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1696 z4 = C_ALPHA[i+1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1697 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1698 r13_1 = calc_distance(x1, y1, z1, x3, y3, z3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1699 r13_2 = calc_distance(x2, y2, z2, x4, y4, z4); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1700 r14 = calc_r14(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1701 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1702 bin13_1 = (int)((r13_1-4.6)/0.3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1703 bin13_2 = (int)((r13_2-4.6)/0.3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1704 bin14 = (int)((r14+11.)/0.3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1705 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1706 if (bin13_1<0) bin13_1=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1707 if (bin13_2<0) bin13_2=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1708 if (bin14<0) bin14=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1709 if (bin13_1>9) bin13_1=9; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1710 if (bin13_2>9) bin13_2=9; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1711 if (bin14>73) bin14=73; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1712 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1713 RBINS[i][0] = bin13_1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1714 RBINS[i][1] = bin13_2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1715 RBINS[i][2] = bin14; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1716 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1717 cacoords[0][0] = x1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1718 cacoords[0][1] = y1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1719 cacoords[0][2] = z1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1720 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1721 cacoords[1][0] = x2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1722 cacoords[1][1] = y2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1723 cacoords[1][2] = z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1724 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1725 cacoords[2][0] = x3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1726 cacoords[2][1] = y3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1727 cacoords[2][2] = z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1728 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1729 cacoords[3][0] = x4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1730 cacoords[3][1] = y4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1731 cacoords[3][2] = z4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1732 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1733 pro = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1734 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1735 if (prevres && !strncmp(prevres->name,"PRO",3)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1736 j=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1737 besthit=1000.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1738 bestpos=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1739 do { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1740 hit = abs(nco_stat_pro[j].bins[0]-bin13_1)+abs(nco_stat_pro[j].bins[1]-bin13_2)+0.2*abs(nco_stat_pro[j].bins[2]-bin14); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1741 if (hit<besthit) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1742 besthit=hit; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1743 bestpos=j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1744 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1745 j++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1746 } while (nco_stat_pro[j].bins[0]>=0 && hit>1e-3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1747 for (j=0;j<4;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1748 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1749 tmpstat[j][k] = nco_stat_pro[bestpos].data[j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1750 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1751 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1752 for (j=0;j<8;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1753 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1754 tmpcoords[j][k] = nco_stat_pro[bestpos].data[j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1755 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1756 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1757 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1758 j=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1759 besthit=1000.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1760 bestpos=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1761 do { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1762 hit = abs(nco_stat[j].bins[0]-bin13_1)+abs(nco_stat[j].bins[1]-bin13_2)+0.2*abs(nco_stat[j].bins[2]-bin14); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1763 if (hit<besthit) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1764 besthit=hit; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1765 bestpos=j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1766 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1767 j++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1768 } while (nco_stat[j].bins[0]>=0 && hit>1e-3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1769 for (j=0;j<4;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1770 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1771 tmpstat[j][k] = nco_stat[bestpos].data[j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1772 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1773 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1774 for (j=0;j<8;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1775 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1776 tmpcoords[j][k] = nco_stat[bestpos].data[j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1777 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1778 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1779 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1780 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1781 rmsd=superimpose2(cacoords, tmpstat, 4, tmpcoords, 8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1782 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1783 total += rmsd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1784 if (rmsd>maxrms) maxrms=rmsd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1785 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1786 // add-or-replace |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1787 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1788 if (prevres) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1789 add_replace(prevres, "C ", tmpcoords[4][0], tmpcoords[4][1], tmpcoords[4][2], FLAG_BACKBONE); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1790 add_replace(prevres, "O ", tmpcoords[5][0], tmpcoords[5][1], tmpcoords[5][2], FLAG_BACKBONE); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1791 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1792 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1793 if (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1794 add_replace(res, "N ", tmpcoords[6][0], tmpcoords[6][1], tmpcoords[6][2], FLAG_BACKBONE); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1795 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1796 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1797 prevres = res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1798 if (res) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1799 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1800 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1801 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1802 if (_VERBOSE) printf("Backbone rebuilding deviation: average = %.3f, max = %.3f\n", total/(real)chain_length, maxrms); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1803 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1804 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1805 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1806 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1807 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1808 #ifdef COMPILE_ROT |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1809 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1810 typedef struct _rot_struct { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1811 int r13_1, r13_2, r14; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1812 int nc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1813 real ***coords; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1814 struct _rot_struct *next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1815 } rot_struct; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1816 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1817 rot_struct *rotamers[20]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1818 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1819 /* this is obsolete in a standalone version of PULCHRA */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1820 void read_rotamers(void) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1821 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1822 FILE *inp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1823 char buf[1000]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1824 char dum[100]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1825 int aa, i, j, k, l, n; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1826 rot_struct *new_rot, *last_rot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1827 real x, y, z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1828 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1829 if (_VERBOSE) printf("Reading rotamer library...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1830 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1831 inp = fopen("NEWROT","r"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1832 last_rot=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1833 while (!feof(inp)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1834 if (fgets(buf,1000,inp)==buf) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1835 if (buf[0]=='A') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1836 sscanf(buf,"%s %d", dum, &aa); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1837 if (last_rot) last_rot->next = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1838 last_rot = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1839 if (fgets(buf,1000,inp)!=buf) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1840 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1841 // printf("aa: %d\n", aa); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1842 if (aa==20) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1843 sscanf(buf,"%d %d %d %s %d", &i, &j, &k, dum, &l); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1844 new_rot = (rot_struct*)calloc(sizeof(rot_struct),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1845 // printf("%d %d %d nc: %d\n", i, j, k, l); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1846 new_rot->r13_1 = i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1847 new_rot->r13_2 = j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1848 new_rot->r14 = k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1849 new_rot->nc = l; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1850 new_rot->next = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1851 new_rot->coords = (real***)calloc(sizeof(real**)*l,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1852 for (i=0;i<l;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1853 new_rot->coords[i]=(real**)calloc(sizeof(real*)*(nheavy[aa]+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1854 for (j=0;j<(nheavy[aa]+1);j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1855 new_rot->coords[i][j]=(real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1856 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1857 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1858 for (i=0;i<l;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1859 fgets(buf,1000,inp); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1860 for (j=0;j<(nheavy[aa]+1);j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1861 fgets(buf,1000,inp); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1862 sscanf(buf,"%lf%lf%lf",&x, &y, &z); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1863 new_rot->coords[i][j][0]=x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1864 new_rot->coords[i][j][1]=y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1865 new_rot->coords[i][j][2]=z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1866 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1867 if (last_rot) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1868 last_rot->next = new_rot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1869 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1870 rotamers[aa] = new_rot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1871 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1872 last_rot = new_rot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1873 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1874 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1875 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1876 fclose(inp); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1877 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1878 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1879 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1880 void cross(real *v1, real *v2, real *v3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1881 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1882 v3[0] = v1[1]*v2[2]-v1[2]*v2[1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1883 v3[1] = v1[2]*v2[0]-v1[0]*v2[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1884 v3[2] = v1[0]*v2[1]-v1[1]*v2[0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1885 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1886 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1887 void norm(real *v) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1888 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1889 real d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1890 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1891 d = sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1892 v[0] /= d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1893 v[1] /= d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1894 v[2] /= d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1895 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1896 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1897 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1898 int check_xvol(res_type *res) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1899 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1900 res_type *res2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1901 atom_type *atom1, *atom2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1902 real dx, dy, dz, dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1903 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1904 res2 = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1905 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1906 while (res2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1907 atom2 = res2->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1908 if (res!=res2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1909 while (atom2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1910 atom1 = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1911 while (atom1) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1912 if (atom1->flag & FLAG_SIDECHAIN) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1913 dx = atom1->x-atom2->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1914 dy = atom1->y-atom2->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1915 dz = atom1->z-atom2->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1916 dd = dx*dx+dy*dy+dz*dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1917 if (dd<(1.7*1.7)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1918 return 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1919 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1920 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1921 atom1=atom1->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1922 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1923 atom2=atom2->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1924 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1925 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1926 res2=res2->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1927 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1928 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1929 return 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1930 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1931 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1932 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1933 real ***SORTED_ROTAMERS; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1934 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1935 void rebuild_sidechains(void) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1936 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1937 FILE *out; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1938 res_type *res, *prevres, *testres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1939 atom_type *atom, *atom1, *atom2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1940 real **cacoords, **tmpcoords, **tmpstat; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1941 real x1, y1, z1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1942 real x2, y2, z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1943 real x3, y3, z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1944 real x4, y4, z4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1945 real x5, y5, z5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1946 real r14, r13_1, r13_2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1947 real dx, dy, dz, dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1948 real hit, besthit; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1949 int exvol, bestpos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1950 int i, j, k, l, m, bin13_1, bin13_2, bin14; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1951 real rmsd, total; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1952 real v1[3], v2a[3], v2b[3], v2[3], v3[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1953 int nsc, nca; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1954 real cax, cay, caz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1955 real **lsys, **vv, **sc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1956 char scn[12][4]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1957 rot_struct *rot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1958 int ok, last_a, last_b, last_c, last_d, jpos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1959 int jx, jy, jz, jxi, jyi, jzi, b13_1, b13_2, b14, jm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1960 int crot, bestrot, minexvol, totexvol, rtried, pos, cpos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1961 real cmx, cmy, cmz, ddx, ddy, ddz, ddd, bestdd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1962 real sort_rot[100][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1963 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1964 if (_VERBOSE) printf("Rebuilding side chains...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1965 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1966 lsys = (real**)calloc(sizeof(real*)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1967 vv = (real**)calloc(sizeof(real*)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1968 sc = (real**)calloc(sizeof(real*)*12,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1969 for (i=0;i<12;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1970 sc[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1971 for (i=0;i<3;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1972 lsys[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1973 vv[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1974 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1975 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1976 SORTED_ROTAMERS = (real***)calloc(sizeof(real**)*(chain_length+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1977 for (i=0;i<chain_length+1;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1978 SORTED_ROTAMERS[i] = (real**)calloc(sizeof(real*)*10,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1979 for (j=0;j<10;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1980 SORTED_ROTAMERS[i][j] = (real*)calloc(sizeof(real)*2,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1981 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1982 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1983 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1984 prevres = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1985 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1986 totexvol = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1987 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1988 for (i=0;i<chain_length;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1989 if (!strncmp(res->name,"GLY",3) || !res->protein) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1990 if (res->next) res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1991 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1992 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1993 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1994 x1 = C_ALPHA[i-2][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1995 y1 = C_ALPHA[i-2][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1996 z1 = C_ALPHA[i-2][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1997 x2 = C_ALPHA[i-1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1998 y2 = C_ALPHA[i-1][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1999 z2 = C_ALPHA[i-1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2000 x3 = C_ALPHA[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2001 y3 = C_ALPHA[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2002 z3 = C_ALPHA[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2003 x4 = C_ALPHA[i+1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2004 y4 = C_ALPHA[i+1][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2005 z4 = C_ALPHA[i+1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2006 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2007 bin13_1 = RBINS[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2008 bin13_2 = RBINS[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2009 bin14 = RBINS[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2010 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2011 v1[0] = x4-x2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2012 v1[1] = y4-y2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2013 v1[2] = z4-z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2014 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2015 v2a[0] = x4-x3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2016 v2a[1] = y4-y3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2017 v2a[2] = z4-z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2018 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2019 v2b[0] = x3-x2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2020 v2b[1] = y3-y2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2021 v2b[2] = z3-z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2022 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2023 cross(v2a, v2b, v2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2024 cross(v1, v2, v3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2025 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2026 norm(v1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2027 norm(v2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2028 norm(v3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2029 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2030 // gather 10 closest rotamer conformations... |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2031 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2032 for (j=0;j<10;j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2033 SORTED_ROTAMERS[i][j][0] = 500.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2034 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2035 j = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2036 besthit = 1000.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2037 bestpos = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2038 do { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2039 if (rot_stat_idx[j][0]==res->type) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2040 hit = abs(rot_stat_idx[j][1]-bin13_1)+abs(rot_stat_idx[j][2]-bin13_2)+0.2*abs(rot_stat_idx[j][3]-bin14); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2041 if (hit<SORTED_ROTAMERS[i][9][0]) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2042 k = 9; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2043 while (k>=0 && hit<SORTED_ROTAMERS[i][k][0]) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2044 k--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2045 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2046 k++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2047 // k = hit |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2048 for (l=9;l>k;l--) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2049 SORTED_ROTAMERS[i][l][0]=SORTED_ROTAMERS[i][l-1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2050 SORTED_ROTAMERS[i][l][1]=SORTED_ROTAMERS[i][l-1][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2051 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2052 SORTED_ROTAMERS[i][k][0]=hit; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2053 SORTED_ROTAMERS[i][k][1]=j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2054 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2055 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2056 j++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2057 } while (rot_stat_idx[j][0]>=0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2058 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2059 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2060 besthit = SORTED_ROTAMERS[i][0][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2061 bestpos = SORTED_ROTAMERS[i][0][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2062 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2063 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2064 // new rebuild... |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2065 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2066 pos = rot_stat_idx[bestpos][5]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2067 nsc = nheavy[res->type]+1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2068 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2069 if (_PDB_SG) { // more than one rotamer - check SC |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2070 bestdd = 100.; crot = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2071 for (l=0;l<2;l++) { // check two closest conformations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2072 cpos = SORTED_ROTAMERS[i][l][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2073 for (m=0;m<rot_stat_idx[cpos][4];m++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2074 for (j=0;j<3;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2075 vv[0][j] = v1[j]; vv[1][j] = v2[j]; vv[2][j] = v3[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2076 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2077 if (j==k) lsys[j][k]=1.; else lsys[j][k]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2078 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2079 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2080 pos = rot_stat_idx[cpos][5]+nsc*m; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2081 for (j=0;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2082 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2083 sc[j][k] = rot_stat_coords[pos+j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2084 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2085 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2086 superimpose2(vv,lsys,3,sc,nsc); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2087 for (j=0;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2088 sc[j][0] += x3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2089 sc[j][1] += y3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2090 sc[j][2] += z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2091 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2092 cmx = 0.; cmy = 0.; cmz = 0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2093 for (j=0;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2094 cmx += sc[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2095 cmy += sc[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2096 cmz += sc[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2097 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2098 cmx /= (real) nsc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2099 cmy /= (real) nsc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2100 cmz /= (real) nsc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2101 ddx = res->cmx-cmx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2102 ddy = res->cmy-cmy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2103 ddz = res->cmz-cmz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2104 ddx *= ddx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2105 ddy *= ddy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2106 ddz *= ddz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2107 ddd = ddx+ddy+ddz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2108 if (ddd<bestdd) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2109 bestdd = ddd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2110 crot = pos; // closest rotamer position |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2111 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2112 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2113 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2114 pos = crot; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2115 } // PDB_SG |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2116 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2117 for (j=0;j<3;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2118 vv[0][j] = v1[j]; vv[1][j] = v2[j]; vv[2][j] = v3[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2119 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2120 if (j==k) lsys[j][k]=1.; else lsys[j][k]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2121 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2122 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2123 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2124 for (j=0;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2125 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2126 sc[j][k] = rot_stat_coords[pos+j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2127 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2128 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2129 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2130 superimpose2(vv,lsys,3,sc,nsc); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2131 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2132 for (j=0;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2133 sc[j][0] += x3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2134 sc[j][1] += y3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2135 sc[j][2] += z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2136 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2137 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2138 for (j=1;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2139 add_replace(res, heavy_atoms[10*res->type+j-1], sc[j][0], sc[j][1], sc[j][2], FLAG_SIDECHAIN); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2140 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2141 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2142 if (res->next) res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2143 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2144 } // i++, next res |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2145 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2146 for (i=0;i<12;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2147 free(sc[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2148 for (i=0;i<3;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2149 free(lsys[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2150 free(vv[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2151 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2152 free(sc); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2153 free(lsys); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2154 free(vv); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2155 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2156 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2157 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2158 typedef struct _atom_list { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2159 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2160 struct _atom_list *next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2161 } atom_list; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2162 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2163 int get_conflicts(res_type *res, atom_list ****grid, int xgrid, int ygrid, int zgrid) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2164 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2165 atom_list *llist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2166 atom_type *atom, *atom2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2167 int i, j, k, x, y, z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2168 int ii, jj, kk, con, iter, maxcon, merged; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2169 real dx, dy, dz, dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2170 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2171 con = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2172 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2173 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2174 i = atom->gx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2175 j = atom->gy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2176 k = atom->gz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2177 for (ii=i-2;ii<=i+2;ii++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2178 for (jj=j-2;jj<=j+2;jj++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2179 for (kk=k-2;kk<=k+2;kk++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2180 if (ii>=0 && ii<xgrid && jj>=0 && jj<ygrid && kk>=0 && kk<zgrid) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2181 llist = grid[ii][jj][kk]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2182 while (llist) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2183 atom2 = llist->atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2184 if (atom && atom2 && res && atom2->res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2185 merged=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2186 if (res==atom2->res) { // self-xvol |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2187 if (atom->flag & FLAG_SIDECHAIN && atom2->flag & FLAG_SIDECHAIN) merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2188 if (atom->flag & FLAG_BACKBONE && atom2->flag & FLAG_BACKBONE) merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2189 if (atom->name[0]=='C' && atom->name[1]=='A' && atom2->name[0]=='C' && atom2->name[1]=='B') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2190 if (atom->name[0]=='C' && atom->name[1]=='B' && atom2->name[0]=='C' && atom2->name[1]=='A') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2191 if (res->name[0]=='P') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2192 if (atom->name[0]=='C' && atom->name[1]=='D' && atom2->name[0]=='N' && atom2->name[1]==' ') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2193 if (atom->name[0]=='N' && atom->name[1]==' ' && atom2->name[0]=='C' && atom2->name[1]=='D') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2194 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2195 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2196 if (!merged) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2197 // printf("merged: %s[%d] %s-%s %d %d\n", res->name,res->num,atom->name,atom2->name,atom->flag,atom2->flag); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2198 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2199 } else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2200 if (res->next==atom2->res || res==atom2->res->next) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2201 if (atom->name[0]=='C' && atom->name[1]==' ' && atom2->name[0]=='N' && atom2->name[1]==' ') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2202 if (atom->name[0]=='N' && atom->name[1]==' ' && atom2->name[0]=='C' && atom2->name[1]==' ') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2203 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2204 if (atom->flag & FLAG_BACKBONE && atom2->flag & FLAG_BACKBONE) merged=1; // for now |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2205 if (atom->flag & FLAG_SCM || atom2->flag & FLAG_SCM) merged=1; // for now |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2206 if (!merged) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2207 dx = atom->x-atom2->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2208 dx*=dx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2209 dy = atom->y-atom2->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2210 dy*=dy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2211 dz = atom->z-atom2->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2212 dz*=dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2213 dd = dx+dy+dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2214 if (dd<_SG_XVOL_DIST*_SG_XVOL_DIST) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2215 con++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2216 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2217 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2218 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2219 llist = llist->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2220 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2221 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2222 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2223 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2224 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2225 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2226 return con; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2227 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2228 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2229 int display_conflicts(res_type *res, atom_list ****grid, int xgrid, int ygrid, int zgrid) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2230 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2231 atom_list *llist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2232 atom_type *atom, *atom2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2233 int i, j, k, x, y, z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2234 int ii, jj, kk, con, iter, maxcon, merged; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2235 real dx, dy, dz, dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2236 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2237 con = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2238 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2239 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2240 i = atom->gx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2241 j = atom->gy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2242 k = atom->gz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2243 for (ii=i-2;ii<=i+2;ii++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2244 for (jj=j-2;jj<=j+2;jj++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2245 for (kk=k-2;kk<=k+2;kk++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2246 if (ii>=0 && ii<xgrid && jj>=0 && jj<ygrid && kk>=0 && kk<zgrid) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2247 llist = grid[ii][jj][kk]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2248 while (llist) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2249 atom2 = llist->atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2250 if (atom && atom2 && res && atom2->res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2251 merged=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2252 if (res==atom2->res) { // self-xvol |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2253 if (atom->flag & FLAG_SIDECHAIN && atom2->flag & FLAG_SIDECHAIN) merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2254 if (atom->flag & FLAG_BACKBONE && atom2->flag & FLAG_BACKBONE) merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2255 if (atom->name[0]=='C' && atom->name[1]=='A' && atom2->name[0]=='C' && atom2->name[1]=='B') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2256 if (atom->name[0]=='C' && atom->name[1]=='B' && atom2->name[0]=='C' && atom2->name[1]=='A') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2257 if (res->name[0]=='P') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2258 if (atom->name[0]=='C' && atom->name[1]=='D' && atom2->name[0]=='N' && atom2->name[1]==' ') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2259 if (atom->name[0]=='N' && atom->name[1]==' ' && atom2->name[0]=='C' && atom2->name[1]=='D') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2260 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2261 if (!merged) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2262 // printf("merged: %s[%d] %s-%s %d %d\n", res->name,res->num,atom->name,atom2->name,atom->flag,atom2->flag); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2263 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2264 } else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2265 if (res->next==atom2->res || res==atom2->res->next) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2266 if (atom->name[0]=='C' && atom->name[1]==' ' && atom2->name[0]=='N' && atom2->name[1]==' ') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2267 if (atom->name[0]=='N' && atom->name[1]==' ' && atom2->name[0]=='C' && atom2->name[1]==' ') merged=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2268 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2269 if (atom->flag & FLAG_BACKBONE && atom2->flag & FLAG_BACKBONE) merged=1; // for now |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2270 if (atom->flag & FLAG_SCM || atom2->flag & FLAG_SCM) merged=1; // for now |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2271 if (!merged) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2272 dx = atom->x-atom2->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2273 dx*=dx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2274 dy = atom->y-atom2->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2275 dy*=dy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2276 dz = atom->z-atom2->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2277 dz*=dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2278 dd = dx+dy+dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2279 if (dd<1.6*1.6) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2280 printf("STERIC CONFLICT: %s[%d]%s-%s[%d]%s\n", atom->res->name,atom->res->num,atom->name,atom2->res->name,atom2->res->num,atom2->name); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2281 con++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2282 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2283 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2284 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2285 llist = llist->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2286 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2287 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2288 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2289 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2290 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2291 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2292 return con; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2293 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2294 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2295 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2296 void allocate_grid(atom_list *****grid_, int *xgrid_, int *ygrid_, int *zgrid_) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2297 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2298 static int xgrid, ygrid, zgrid; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2299 static atom_list ****grid = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2300 atom_list *llist, *alist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2301 real min[3], max[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2302 res_type *res, *worst; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2303 atom_type *atom, *atom2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2304 int i, j, x, y, z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2305 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2306 if (!grid && chain->residua && chain->residua->atoms) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2307 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2308 min[0]=max[0]=res->atoms->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2309 min[1]=max[1]=res->atoms->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2310 min[2]=max[2]=res->atoms->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2311 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2312 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2313 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2314 if (atom->x<min[0]) min[0]=atom->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2315 if (atom->y<min[1]) min[1]=atom->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2316 if (atom->z<min[2]) min[2]=atom->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2317 if (atom->x>max[0]) max[0]=atom->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2318 if (atom->y>max[1]) max[1]=atom->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2319 if (atom->z>max[2]) max[2]=atom->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2320 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2321 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2322 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2323 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2324 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2325 xgrid = (max[0]-min[0])/GRID_RES; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2326 ygrid = (max[1]-min[1])/GRID_RES; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2327 zgrid = (max[2]-min[2])/GRID_RES; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2328 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2329 if (_VERBOSE) printf("Allocating grid (%d %d %d)...\n", xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2330 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2331 grid = (atom_list****)calloc(sizeof(atom_list***)*(xgrid+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2332 for (i=0;i<xgrid+1;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2333 grid[i] = (atom_list***)calloc(sizeof(atom_list**)*(ygrid+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2334 for (j=0;j<ygrid+1;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2335 grid[i][j] = (atom_list**)calloc(sizeof(atom_list*)*(zgrid+1),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2336 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2337 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2338 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2339 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2340 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2341 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2342 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2343 x = xgrid*(atom->x-min[0])/(max[0]-min[0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2344 y = ygrid*(atom->y-min[1])/(max[1]-min[1]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2345 z = zgrid*(atom->z-min[2])/(max[2]-min[2]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2346 alist = (atom_list*)calloc(sizeof(atom_list),1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2347 alist->atom = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2348 atom->gx = x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2349 atom->gy = y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2350 atom->gz = z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2351 if (grid[x][y][z]!=NULL) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2352 llist = grid[x][y][z]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2353 while (llist->next) llist=llist->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2354 llist->next = alist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2355 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2356 grid[x][y][z]=alist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2357 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2358 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2359 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2360 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2361 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2362 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2363 if (_VERBOSE) printf("Grid already allocated (%d %d %d)\n", xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2364 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2365 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2366 *grid_ = grid; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2367 *xgrid_ = xgrid; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2368 *ygrid_ = ygrid; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2369 *zgrid_ = zgrid; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2370 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2371 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2372 void optimize_exvol(void) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2373 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2374 real min[3], max[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2375 res_type *res, *worst; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2376 atom_type *atom, *atom2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2377 int xgrid, ygrid, zgrid; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2378 atom_list ****grid, *llist, *alist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2379 int i, j, k, l, m, x, y, z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2380 int ii, jj, kk, con, iter, maxcon, totcon; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2381 int cpos, bestpos, pos, con0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2382 real v1[3], v2a[3], v2b[3], v2[3], v3[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2383 int nsc, nca; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2384 real cax, cay, caz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2385 real **lsys, **vv, **sc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2386 real x1, y1, z1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2387 real x2, y2, z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2388 real x3, y3, z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2389 real x4, y4, z4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2390 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2391 min[0]=1e5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2392 min[1]=1e5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2393 min[2]=1e5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2394 max[0]=-1e5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2395 max[1]=-1e5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2396 max[2]=-1e5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2397 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2398 lsys = (real**)calloc(sizeof(real*)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2399 vv = (real**)calloc(sizeof(real*)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2400 sc = (real**)calloc(sizeof(real*)*12,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2401 for (i=0;i<12;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2402 sc[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2403 for (i=0;i<3;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2404 lsys[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2405 vv[i] = (real*)calloc(sizeof(real)*3,1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2406 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2407 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2408 allocate_grid(&grid, &xgrid, &ygrid, &zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2409 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2410 if (_VERBOSE) printf("Finding excluded volume conflicts...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2411 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2412 iter = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2413 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2414 do { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2415 //printf("ITER: %d\n", iter); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2416 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2417 maxcon = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2418 totcon=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2419 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2420 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2421 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2422 if (res->protein) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2423 con = get_conflicts(res, grid, xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2424 if (con>0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2425 totcon+=con; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2426 if (con>maxcon) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2427 maxcon = con; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2428 worst = res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2429 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2430 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2431 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2432 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2433 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2434 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2435 if (_VERBOSE && iter==0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2436 printf("Total number of conflicts: %d\n", totcon); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2437 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2438 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2439 if (totcon==0) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2440 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2441 if (_VERBOSE && iter==0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2442 printf("Maximum number of conflicts: %s[%d] : %d\n", worst->name, worst->num, maxcon); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2443 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2444 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2445 totcon=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2446 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2447 if (maxcon>0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2448 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2449 // try to fix... |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2450 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2451 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2452 for (i=0;i<chain_length;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2453 if (!strncmp(res->name,"GLY",3) || !res->protein) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2454 if (res->next) res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2455 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2456 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2457 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2458 nsc = nheavy[res->type]+1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2459 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2460 x1 = C_ALPHA[i-2][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2461 y1 = C_ALPHA[i-2][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2462 z1 = C_ALPHA[i-2][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2463 x2 = C_ALPHA[i-1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2464 y2 = C_ALPHA[i-1][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2465 z2 = C_ALPHA[i-1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2466 x3 = C_ALPHA[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2467 y3 = C_ALPHA[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2468 z3 = C_ALPHA[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2469 x4 = C_ALPHA[i+1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2470 y4 = C_ALPHA[i+1][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2471 z4 = C_ALPHA[i+1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2472 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2473 v1[0] = x4-x2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2474 v1[1] = y4-y2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2475 v1[2] = z4-z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2476 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2477 v2a[0] = x4-x3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2478 v2a[1] = y4-y3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2479 v2a[2] = z4-z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2480 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2481 v2b[0] = x3-x2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2482 v2b[1] = y3-y2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2483 v2b[2] = z3-z2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2484 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2485 cross(v2a, v2b, v2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2486 cross(v1, v2, v3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2487 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2488 norm(v1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2489 norm(v2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2490 norm(v3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2491 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2492 con = get_conflicts(res, grid, xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2493 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2494 if (con>0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2495 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2496 bestpos=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2497 con0 = 100; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2498 for (l=0;l<10;l++) { // check two closest conformations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2499 cpos = SORTED_ROTAMERS[i][l][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2500 for (m=0;m<rot_stat_idx[cpos][4];m++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2501 for (j=0;j<3;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2502 vv[0][j] = v1[j]; vv[1][j] = v2[j]; vv[2][j] = v3[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2503 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2504 if (j==k) lsys[j][k]=1.; else lsys[j][k]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2505 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2506 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2507 pos = rot_stat_idx[cpos][5]+nsc*m; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2508 for (j=0;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2509 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2510 sc[j][k] = rot_stat_coords[pos+j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2511 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2512 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2513 superimpose2(vv,lsys,3,sc,nsc); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2514 for (j=0;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2515 sc[j][0] += x3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2516 sc[j][1] += y3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2517 sc[j][2] += z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2518 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2519 for (j=1;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2520 add_replace(res, heavy_atoms[10*res->type+j-1], sc[j][0], sc[j][1], sc[j][2], FLAG_SIDECHAIN); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2521 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2522 con = get_conflicts(res, grid, xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2523 //printf("test: %d\n", con); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2524 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2525 if (con<con0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2526 con0 = con; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2527 bestpos = pos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2528 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2529 if (con==0) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2530 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2531 if (con==0) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2532 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2533 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2534 totcon += con0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2535 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2536 for (j=0;j<3;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2537 vv[0][j] = v1[j]; vv[1][j] = v2[j]; vv[2][j] = v3[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2538 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2539 if (j==k) lsys[j][k]=1.; else lsys[j][k]=0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2540 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2541 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2542 pos = bestpos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2543 for (j=0;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2544 for (k=0;k<3;k++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2545 sc[j][k] = rot_stat_coords[pos+j][k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2546 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2547 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2548 superimpose2(vv,lsys,3,sc,nsc); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2549 for (j=0;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2550 sc[j][0] += x3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2551 sc[j][1] += y3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2552 sc[j][2] += z3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2553 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2554 for (j=1;j<nsc;j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2555 add_replace(res, heavy_atoms[10*res->type+j-1], sc[j][0], sc[j][1], sc[j][2], FLAG_SIDECHAIN); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2556 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2557 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2558 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2559 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2560 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2561 res=res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2562 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2563 } // i |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2564 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2565 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2566 iter++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2567 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2568 } while (iter<_XVOL_ITER); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2569 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2570 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2571 if (_VERBOSE) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2572 if (totcon>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2573 printf("WARNING: %d steric conflict(s) are still there.\n", totcon); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2574 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2575 printf("All steric conflicts removed.\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2576 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2577 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2578 for (i=0;i<12;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2579 free(sc[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2580 for (i=0;i<3;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2581 free(lsys[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2582 free(vv[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2583 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2584 free(sc); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2585 free(lsys); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2586 free(vv); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2587 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2588 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2589 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2590 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2591 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2592 void vcross(real ax,real ay,real az,real bx,real by,real bz,real *cx,real *cy,real *cz) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2593 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2594 *cx = ay * bz - by * az; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2595 *cy = az * bx - bz * ax; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2596 *cz = ax * by - bx * ay; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2597 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2598 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2599 real vdot(real ax,real ay,real az,real bx,real by,real bz) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2600 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2601 return ax*bx+ay*by+az*bz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2602 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2603 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2604 real calc_torsion(atom_type *a1, atom_type *a2, atom_type *a3, atom_type *a4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2605 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2606 real v12x, v12y, v12z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2607 real v43x, v43y, v43z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2608 real zx, zy, zz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2609 real px, py, pz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2610 real xx, xy, xz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2611 real yx, yy, yz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2612 real u, v, angle; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2613 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2614 v12x = a1->x-a2->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2615 v12y = a1->y-a2->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2616 v12z = a1->z-a2->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2617 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2618 v43x = a4->x-a3->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2619 v43y = a4->y-a3->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2620 v43z = a4->z-a3->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2621 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2622 zx = a2->x-a3->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2623 zy = a2->y-a3->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2624 zz = a2->z-a3->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2625 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2626 vcross(zx,zy,zz,v12x,v12y,v12z,&px,&py,&pz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2627 vcross(zx,zy,zz,v43x,v43y,v43z,&xx,&xy,&xz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2628 vcross(zx,zy,zz,xx,xy,xz,&yx,&yy,&yz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2629 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2630 u = vdot(xx,xy,xz,xx,xy,xz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2631 v = vdot(yx,yy,yz,yx,yy,yz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2632 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2633 angle = 360.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2634 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2635 if (u<0. || v<0.) return angle; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2636 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2637 u = vdot(px,py,pz,xx,xy,xz) / sqrt(u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2638 v = vdot(px,py,pz,yx,yy,yz) / sqrt(v); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2639 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2640 if (u != 0.0 || v != 0.0) angle = atan2(v, u) * RADDEG; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2641 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2642 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2643 return angle; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2644 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2645 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2646 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2647 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2648 // Ca-N-C-Cb angle should be close to 34 deg |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2649 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2650 void chirality_check(void) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2651 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2652 int i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2653 atom_type *a_ca, *a_n, *a_c, *a_cb; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2654 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2655 res_type *res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2656 real angle; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2657 real nx, ny, nz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2658 real px, py, pz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2659 real qx, qy, qz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2660 real rx, ry, rz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2661 real xx, xy, xz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2662 real yx, yy, yz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2663 real dd, costheta, sintheta; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2664 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2665 if (_VERBOSE) printf("Checking chirality...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2666 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2667 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2668 a_ca = a_n = a_c = a_cb = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2669 a_ca = find_atom(res,"CA "); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2670 a_n = find_atom(res,"N "); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2671 a_c = find_atom(res,"C "); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2672 a_cb = find_atom(res,"CB "); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2673 if (a_ca && a_n && a_c && a_cb) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2674 angle = calc_torsion(a_ca, a_n, a_c, a_cb); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2675 if (angle<0.) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2676 if (_VERBOSE) printf("WARNING: D-aa detected at %s %3d : %5.2f", res->name, res->num, angle); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2677 xx = a_ca->x-a_n->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2678 xy = a_ca->y-a_n->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2679 xz = a_ca->z-a_n->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2680 yx = a_c->x-a_ca->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2681 yy = a_c->y-a_ca->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2682 yz = a_c->z-a_ca->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2683 vcross(xx,xy,xz,yx,yy,yz,&nx,&ny,&nz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2684 dd = sqrt(nx*nx+ny*ny+nz*nz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2685 nx /= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2686 ny /= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2687 nz /= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2688 // nx, ny, nz = reflection plane normal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2689 rx = xx-yx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2690 ry = xy-yy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2691 rz = xz-yz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2692 dd = sqrt(rx*rx+ry*ry+rz*rz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2693 rx /= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2694 ry /= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2695 rz /= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2696 costheta = -1.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2697 sintheta = 0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2698 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2699 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2700 if (atom->flag & FLAG_SIDECHAIN) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2701 px = atom->x-a_ca->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2702 py = atom->y-a_ca->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2703 pz = atom->z-a_ca->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2704 qx = qy = qz = 0.; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2705 qx += (costheta + (1 - costheta) * rx * rx) * px; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2706 qx += ((1 - costheta) * rx * ry - rz * sintheta) * py; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2707 qx += ((1 - costheta) * rx * rz + ry * sintheta) * pz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2708 qy += ((1 - costheta) * rx * ry + rz * sintheta) * px; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2709 qy += (costheta + (1 - costheta) * ry * ry) * py; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2710 qy += ((1 - costheta) * ry * rz - rx * sintheta) * pz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2711 qz += ((1 - costheta) * rx * rz - ry * sintheta) * px; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2712 qz += ((1 - costheta) * ry * rz + rx * sintheta) * py; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2713 qz += (costheta + (1 - costheta) * rz * rz) * pz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2714 qx += a_ca->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2715 qy += a_ca->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2716 qz += a_ca->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2717 atom->x = qx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2718 atom->y = qy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2719 atom->z = qz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2720 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2721 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2722 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2723 angle = calc_torsion(a_ca, a_n, a_c, a_cb); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2724 if (_VERBOSE) printf(", fixed : %5.2f\n", angle); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2725 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2726 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2727 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2728 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2729 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2730 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2731 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2732 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2733 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2734 real hb_energy(res_type *res, atom_list ****grid, int xgrid, int ygrid, int zgrid) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2735 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2736 atom_type *atom, *c_atom1, *o_atom1, *n_atom1, *c_atom2, *o_atom2, *n_atom2, *tmp_atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2737 atom_type h_atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2738 int i, j, k, ii, jj, kk; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2739 atom_list *llist, *alist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2740 real dx, dy, dz, dist, min_dist1, min_dist2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2741 real hx1, hy1, hz1, dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2742 real dno, dnc, dho, dhc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2743 real ene, Q; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2744 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2745 ene = 1e3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2746 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2747 if (!res || !res->prev) return ene; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2748 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2749 Q = -27888.0; // DSSP h-bond energy constant |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2750 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2751 c_atom1 = o_atom1 = n_atom1 = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2752 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2753 atom = res->prev->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2754 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2755 if (atom->name[0]=='C' && atom->name[1]==' ') c_atom1 = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2756 if (atom->name[0]=='O' && atom->name[1]==' ') o_atom1 = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2757 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2758 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2759 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2760 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2761 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2762 if (atom->name[0]=='N' && atom->name[1]==' ') { n_atom1 = atom; break; } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2763 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2764 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2765 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2766 // first bond |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2767 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2768 min_dist2 = 1e10; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2769 o_atom2 = c_atom2 = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2770 if (n_atom1) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2771 i = n_atom1->gx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2772 j = n_atom1->gy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2773 k = n_atom1->gz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2774 for (ii=i-1;ii<=i+1;ii++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2775 for (jj=j-1;jj<=j+1;jj++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2776 for (kk=k-1;kk<=k+1;kk++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2777 if (ii>=0 && ii<xgrid && jj>=0 && jj<ygrid && kk>=0 && kk<=zgrid) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2778 llist = grid[ii][jj][kk]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2779 while (llist) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2780 if (llist->atom->name[0]=='O' && llist->atom->name[1]==' ' && abs(llist->atom->res->locnum-n_atom1->res->locnum)>2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2781 tmp_atom = llist->atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2782 dx = n_atom1->x-tmp_atom->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2783 dy = n_atom1->y-tmp_atom->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2784 dz = n_atom1->z-tmp_atom->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2785 dist = dx*dx+dy*dy+dz*dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2786 if (dist<min_dist2 && dist<25.0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2787 o_atom2=tmp_atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2788 min_dist2 = dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2789 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2790 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2791 llist = llist->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2792 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2793 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2794 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2795 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2796 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2797 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2798 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2799 if (o_atom2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2800 atom = o_atom2->res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2801 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2802 if (atom->name[0]=='C' && atom->name[1]==' ') { c_atom2 = atom; break; } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2803 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2804 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2805 if (c_atom2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2806 hx1 = o_atom1->x-c_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2807 hy1 = o_atom1->y-c_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2808 hz1 = o_atom1->z-c_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2809 dd = -1.081f/sqrt(hx1*hx1+hy1*hy1+hz1*hz1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2810 hx1 *= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2811 hy1 *= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2812 hz1 *= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2813 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2814 hx1 += n_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2815 hy1 += n_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2816 hz1 += n_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2817 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2818 add_replace(n_atom1->res, "H ", hx1, hy1, hz1, FLAG_BACKBONE); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2819 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2820 // dno |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2821 dx = n_atom1->x-o_atom2->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2822 dy = n_atom1->y-o_atom2->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2823 dz = n_atom1->z-o_atom2->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2824 dno = sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2825 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2826 // dnc |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2827 dx = n_atom1->x-c_atom2->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2828 dy = n_atom1->y-c_atom2->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2829 dz = n_atom1->z-c_atom2->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2830 dnc = sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2831 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2832 // dho |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2833 dx = hx1-o_atom2->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2834 dy = hy1-o_atom2->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2835 dz = hz1-o_atom2->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2836 dho = sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2837 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2838 // dhc |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2839 dx = hx1-c_atom2->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2840 dy = hy1-c_atom2->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2841 dz = hz1-c_atom2->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2842 dhc = sqrt(dx*dx+dy*dy+dz*dz); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2843 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2844 if (dho<0.01F || dhc<0.01F || dnc<0.01F || dno<0.01F) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2845 ene = -10.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2846 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2847 ene = 0.001*(Q/dho - Q/dhc + Q/dnc - Q/dno); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2848 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2849 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2850 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2851 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2852 /****** |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2853 // second bond |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2854 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2855 min_dist2 = 1e10; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2856 n_atom2 = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2857 if (n_atom1) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2858 i = o_atom1->gx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2859 j = o_atom1->gy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2860 k = o_atom1->gz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2861 for (ii=i-1;ii<=i+1;ii++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2862 for (jj=j-1;jj<=j+1;jj++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2863 for (kk=k-1;kk<=k+1;kk++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2864 if (ii>=0 && ii<xgrid && jj>=0 && jj<ygrid && kk>=0 && kk<=zgrid) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2865 llist = grid[ii][jj][kk]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2866 while (llist) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2867 if (llist->atom->name[0]=='N' && llist->atom->name[1]==' ' && (abs(llist->atom->res->locnum-n_atom1->res->locnum)>2)) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2868 tmp_atom = llist->atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2869 if (tmp_atom->res!=c_atom2->res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2870 dx = o_atom1->x-tmp_atom->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2871 dy = o_atom1->y-tmp_atom->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2872 dz = o_atom1->z-tmp_atom->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2873 dist = dx*dx+dy*dy+dz*dz; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2874 if (dist<min_dist2 && dist<25.0) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2875 n_atom2=tmp_atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2876 min_dist2 = dist; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2877 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2878 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2879 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2880 llist = llist->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2881 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2882 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2883 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2884 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2885 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2886 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2887 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2888 if (n_atom2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2889 c_atom2 = o_atom2 = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2890 atom = n_atom2->res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2891 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2892 if (atom->name[0]=='C' && atom->name[1]==' ') { c_atom2 = atom; } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2893 if (atom->name[0]=='O' && atom->name[1]==' ') { c_atom2 = atom; } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2894 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2895 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2896 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2897 if (c_atom2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2898 hx1 = o_atom1->x-c_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2899 hy1 = o_atom1->y-c_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2900 hz1 = o_atom1->z-c_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2901 dd = -1.081f/sqrt(hx1*hx1+hy1*hy1+hz1*hz1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2902 hx1 *= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2903 hy1 *= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2904 hz1 *= dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2905 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2906 hx1 += n_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2907 hy1 += n_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2908 hz1 += n_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2909 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2910 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2911 *******/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2912 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2913 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2914 return ene; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2915 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2916 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2917 // rotates a point around a vector |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2918 void rot_point_vector(real *x, real *y, real *z, real u, real v, real w, real angle) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2919 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2920 real ux, uy, uz, vx, vy, vz, wx, wy, wz, sa, ca; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2921 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2922 sa = sinf(10.0*M_PI*angle/180.0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2923 ca = cosf(10.0*M_PI*angle/180.0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2924 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2925 ux = u**x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2926 uy = u**y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2927 uz = u**z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2928 vx = v**x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2929 vy = v**y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2930 vz = v**z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2931 wx = w**x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2932 wy = w**y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2933 wz = w**z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2934 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2935 *x = u*(ux+vy+wz)+(*x*(v*v+w*w)-u*(vy+wz))*ca+(-wy+vz)*sa; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2936 *y = v*(ux+vy+wz)+(*y*(u*u+w*w)-v*(ux+wz))*ca+( wx-uz)*sa; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2937 *z = w*(ux+vy+wz)+(*z*(u*u+v*v)-w*(ux+vy))*ca+(-vx+uy)*sa; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2938 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2939 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2940 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2941 // rotates a peptide plate |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2942 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2943 void rot_peptide(res_type *res, real angle) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2944 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2945 atom_type *atom, *c_atom, *o_atom, *n_atom, *ca_atom1, *ca_atom2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2946 real u, v, w, x, y, z, dd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2947 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2948 if (!res || !res->prev) return; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2949 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2950 c_atom = o_atom = n_atom = ca_atom1 = ca_atom2 = NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2951 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2952 atom = res->prev->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2953 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2954 if (atom->name[0]=='C' && atom->name[1]=='A') ca_atom1 = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2955 if (atom->name[0]=='C' && atom->name[1]==' ') c_atom = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2956 if (atom->name[0]=='O' && atom->name[1]==' ') o_atom = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2957 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2958 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2959 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2960 atom = res->atoms; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2961 while (atom) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2962 if (atom->name[0]=='C' && atom->name[1]=='A') ca_atom2 = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2963 if (atom->name[0]=='N' && atom->name[1]==' ') n_atom = atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2964 atom = atom->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2965 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2966 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2967 if (c_atom && o_atom && n_atom && ca_atom1 && ca_atom2) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2968 u = ca_atom2->x-ca_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2969 v = ca_atom2->y-ca_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2970 w = ca_atom2->z-ca_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2971 dd = 1.0f/sqrt(u*u+v*v+w*w); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2972 u*=dd; v*=dd; w*=dd; // normalize ca-ca vector |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2973 x = n_atom->x-ca_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2974 y = n_atom->y-ca_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2975 z = n_atom->z-ca_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2976 rot_point_vector(&x, &y, &z, u, v, w, angle); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2977 n_atom->x = x+ca_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2978 n_atom->y = y+ca_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2979 n_atom->z = z+ca_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2980 x = c_atom->x-ca_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2981 y = c_atom->y-ca_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2982 z = c_atom->z-ca_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2983 rot_point_vector(&x, &y, &z, u, v, w, angle); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2984 c_atom->x = x+ca_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2985 c_atom->y = y+ca_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2986 c_atom->z = z+ca_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2987 x = o_atom->x-ca_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2988 y = o_atom->y-ca_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2989 z = o_atom->z-ca_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2990 rot_point_vector(&x, &y, &z, u, v, w, angle); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2991 o_atom->x = x+ca_atom1->x; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2992 o_atom->y = y+ca_atom1->y; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2993 o_atom->z = z+ca_atom1->z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2994 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2995 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2996 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2997 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2998 void optimize_backbone(mol_type *chain) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2999 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3000 int xgrid, ygrid, zgrid; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3001 atom_list ****grid; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3002 atom_type *atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3003 res_type *res; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3004 real ene, min_ene, tot1, tot2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3005 int i, k, best; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3006 FILE *out; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3007 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3008 if (_VERBOSE) printf("Optimizing backbone...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3009 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3010 allocate_grid(&grid, &xgrid, &ygrid, &zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3011 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3012 tot1 = tot2 = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3013 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3014 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3015 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3016 ene = hb_energy(res, grid, xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3017 if (ene<-0.5) tot1 += ene; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3018 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3019 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3020 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3021 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3022 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3023 if (res->type!=7) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3024 ene = hb_energy(res, grid, xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3025 if (ene<1.0) { // try to optimize |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3026 min_ene = ene; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3027 rot_peptide(res, -1.1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3028 best = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3029 for (i=-10;i<10;i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3030 rot_peptide(res, 0.1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3031 ene = hb_energy(res, grid, xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3032 if (ene<min_ene) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3033 best = i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3034 min_ene = ene; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3035 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3036 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3037 rot_peptide(res,-0.9); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3038 ene = hb_energy(res, grid, xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3039 if (min_ene<ene) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3040 rot_peptide(res,0.1*best); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3041 ene = hb_energy(res, grid, xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3042 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3043 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3044 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3045 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3046 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3047 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3048 res = chain->residua; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3049 while (res) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3050 ene = hb_energy(res, grid, xgrid, ygrid, zgrid); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3051 if (ene<-0.5) tot2 += ene; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3052 res = res->next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3053 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3054 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3055 if (_VERBOSE) printf("Backbone HB energy: before %g, after: %g, difference: %g\n", tot1, tot2, tot2-tot1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3056 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3057 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3058 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3059 int main(int argc, char **argv) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3060 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3061 int i, j, next; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3062 char buf[100]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3063 char *name=NULL, *ini_name=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3064 char *ptr, out_name[1000]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3065 real f; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3066 mol_type *mol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3067 struct timeb time0, time1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3068 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3069 for (i=1; i<argc; i++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3070 if (argv[i][0]=='-') { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3071 next=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3072 for (j=1; j<(int)strlen(argv[i]); j++) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3073 switch(argv[i][j]) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3074 case 'v': _VERBOSE=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3075 case 'c': _CA_OPTIMIZE=0; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3076 case 'e': _BB_REARRANGE=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3077 case 'r': _CA_RANDOM=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3078 case 'z': _CHIRAL=0; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3079 case 't': _CA_TRAJECTORY=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3080 case 'n': _CENTER_CHAIN=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3081 case 'b': _REBUILD_BB=0; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3082 case 's': _REBUILD_SC=0; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3083 case 'i': ini_name = argv[++i]; next=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3084 case 'g': _PDB_SG=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3085 case 'x': _TIME_SEED=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3086 case 'o': _XVOLUME=0; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3087 case 'h': _REBUILD_H=0; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3088 case 'q': _BB_OPTIMIZE=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3089 case 'p': _CISPRO=1; break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3090 case 'u': |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3091 if (sscanf(argv[++i],"%lf",&f)==1) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3092 _CA_START_DIST = f; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3093 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3094 next=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3095 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3096 default: { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3097 printf("Unknown option: %c\n", argv[i][j]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3098 return -1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3099 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3100 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3101 if (next) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3102 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3103 } else { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3104 if (!name) name=argv[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3105 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3106 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3107 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3108 if (!name) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3109 printf("PULCHRA Protein Chain Restoration Algorithm version %4.2f\n", PULCHRA_VERSION); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3110 printf("Usage: %s [options] <pdb_file>\n", argv[0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3111 printf("The program default input is a PDB file.\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3112 printf("Output file <pdb_file.rebuild.pdb> will be created as a result.\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3113 printf("Valid options are:\n\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3114 printf(" -v : verbose output (default: off)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3115 printf(" -n : center chain (default: off)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3116 printf(" -x : time-seed random number generator (default: off)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3117 printf(" -g : use PDBSG as an input format (CA=C-alpha, SC or CM=side chain c.m.)\n\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3118 printf(" -c : skip C-alpha positions optimization (default: on)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3119 printf(" -p : detect cis-prolins (default: off)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3120 printf(" -r : start from a random chain (default: off)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3121 printf(" -i pdbfile : read the initial C-alpha coordinates from a PDB file\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3122 printf(" -t : save chain optimization trajectory to file <pdb_file.pdb.trajectory>\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3123 printf(" -u value : maximum shift from the restraint coordinates (default: 0.5A)\n\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3124 printf(" -e : rearrange backbone atoms (C, O are output after side chain) (default: off)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3125 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3126 #ifdef COMPILE_BB |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3127 printf(" -b : skip backbone reconstruction (default: on)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3128 printf(" -q : optimize backbone hydrogen bonds pattern (default: off)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3129 printf(" -h : outputs hydrogen atoms (default: off)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3130 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3131 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3132 #ifdef COMPILE_ROT |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3133 printf(" -s : skip side chains reconstruction (default: on)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3134 printf(" -o : don't attempt to fix excluded volume conflicts (default: on)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3135 printf(" -z : don't check amino acid chirality (default: on)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3136 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3137 printf("\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3138 return -1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3139 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3140 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3141 for (i=0; i<255; i++) /* prepare hash table*/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3142 AA_NUMS[i] = 20; /* dummy aa code */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3143 for (i=0; i<20; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3144 AA_NUMS[(int)SHORT_AA_NAMES[i]] = i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3145 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3146 setbuf(stdout,0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3147 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3148 if (_TIME_SEED) srand(time(NULL)); else srand(1234); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3149 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3150 if (_VERBOSE) printf("PULCHRA Protein Chain Restoration Algorithm version %4.2f\n", PULCHRA_VERSION); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3151 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3152 ftime(&time0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3153 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3154 chain = new_mol(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3155 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3156 if (read_pdb_file(name,chain,"chain")==FILE_NOT_FOUND) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3157 if (_VERBOSE) printf("Can't read the input file!\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3158 return -1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3159 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3160 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3161 if (_VERBOSE) printf("%d residua read.\n", chain->nres); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3162 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3163 chain_length = chain->nres; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3164 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3165 if (_CA_OPTIMIZE) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3166 snprintf(out_name,1000,"%s.tra",name); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3167 ca_optimize(out_name, ini_name); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3168 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3169 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3170 #ifdef COMPILE_BB |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3171 if (_REBUILD_BB) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3172 rebuild_backbone(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3173 if (_BB_OPTIMIZE) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3174 optimize_backbone(chain); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3175 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3176 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3177 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3178 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3179 #ifdef COMPILE_ROT |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3180 if (_REBUILD_BB && _REBUILD_SC) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3181 rebuild_sidechains(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3182 if (_XVOLUME) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3183 optimize_exvol(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3184 if (_CHIRAL) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3185 chirality_check(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3186 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3187 #endif |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3188 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3189 if (_CENTER_CHAIN) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3190 center_chain(chain); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3191 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3192 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3193 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3194 if (_BB_REARRANGE) { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3195 if (_VERBOSE) printf("Rearranging backbone atoms...\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3196 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3197 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3198 ptr = strstr(name,".pdb"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3199 if (ptr) ptr[0]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3200 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3201 snprintf(out_name,1000,"%s.rebuilt.pdb",name); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3202 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3203 if (_VERBOSE) printf("Writing output file %s...\n", out_name); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3204 write_pdb(out_name, chain); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3205 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3206 ftime(&time1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3207 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3208 if (_VERBOSE) printf("Done. Reconstruction finished in %.3f s.\n", (real)0.001*(1000.*(time1.time-time0.time)+(time1.millitm-time0.millitm))); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3209 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3210 return 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3211 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3212 |