Mercurial > repos > guerler > springsuite
annotate spring_package/tmalign/TMalign.cpp @ 20:8a90717c057c draft
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
author | guerler |
---|---|
date | Wed, 28 Oct 2020 05:24:28 +0000 |
parents | c790d25086dc |
children |
rev | line source |
---|---|
17
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1 /* TM-align: sequence-independent structure alignment of monomer proteins by |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2 * TM-score superposition. Please report issues to yangzhanglab@umich.edu |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3 * |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4 * References to cite: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5 * Y Zhang, J Skolnick. Nucl Acids Res 33, 2302-9 (2005) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
6 * |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
7 * DISCLAIMER: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
8 * Permission to use, copy, modify, and distribute the Software for any |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
9 * purpose, with or without fee, is hereby granted, provided that the |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
10 * notices on the head, the reference information, and this copyright |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
11 * notice appear in all copies or substantial portions of the Software. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
12 * It is provided "as is" without express or implied warranty. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
13 * |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
14 * ========================== |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
15 * How to install the program |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
16 * ========================== |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
17 * The following command compiles the program in your Linux computer: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
18 * |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
19 * g++ -static -O3 -ffast-math -lm -o TMalign TMalign.cpp |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
20 * |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
21 * The '-static' flag should be removed on Mac OS, which does not support |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
22 * building static executables. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
23 * |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
24 * ====================== |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
25 * How to use the program |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
26 * ====================== |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
27 * You can run the program without argument to obtain the document. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
28 * Briefly, you can compare two structures by: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
29 * |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
30 * ./TMalign structure1.pdb structure2.pdb |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
31 * |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
32 * ============== |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
33 * Update history |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
34 * ============== |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
35 * 2012/01/24: A C/C++ code of TM-align was constructed by Jianyi Yang |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
36 * 2016/05/21: Several updates of this program were made by Jianji Wu: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
37 * (1) fixed several compiling bugs |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
38 * (2) made I/O of C/C++ version consistent with the Fortran version |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
39 * (3) added outputs including full-atom and ligand structures |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
40 * (4) added options of '-i', '-I' and '-m' |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
41 * 2016/05/25: Fixed a bug on PDB file reading |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
42 * 2018/06/04: Several updates were made by Chengxin Zhang, including |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
43 * (1) Fixed bug in reading PDB files with negative residue index, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
44 * (2) Implemented the fTM-align algorithm (by the '-fast' option) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
45 * as described in R Dong, S Pan, Z Peng, Y Zhang, J Yang |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
46 * (2018) Nucleic acids research. gky430. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
47 * (3) Included option to perform TM-align against a whole |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
48 * folder of PDB files. A full list of options not available |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
49 * in the Fortran version can be explored by TMalign -h |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
50 * 2018/07/27: Added the -byresi option for TM-score superposition without |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
51 * re-alignment as in TMscore and TMscore -c |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
52 * 2018/08/07: Added the -dir option |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
53 * 2018/08/14: Added the -split option |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
54 * 2018/08/16: Added the -infmt1, -infmt2 options. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
55 * 2019/01/07: Added support for PDBx/mmCIF format. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
56 * 2019/02/09: Fixed asymmetric alignment bug. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
57 * 2019/03/17: Added the -cp option for circular permutation |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
58 * 2019/07/23: Supported RasMol output by '-o' option |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
59 * 2019/07/24: Fixed bug on PyMOL format output by '-o' option with mmCIF input |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
60 * 2019/08/18: Fixed bug on RasMol format output file *_atm. Removed excessive |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
61 * circular permutation alignment by -cp |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
62 * 2019/08/20: Clarified PyMOL syntax. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
63 * 2019/08/22: Added four additional PyMOL scripts. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
64 */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
65 #include <math.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
66 #include <stdio.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
67 #include <stdlib.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
68 #include <time.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
69 #include <string.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
70 #include <malloc/malloc.h> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
71 #include <sstream> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
72 #include <iostream> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
73 #include <iomanip> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
74 #include <fstream> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
75 #include <vector> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
76 #include <iterator> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
77 #include <algorithm> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
78 #include <string> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
79 #include <map> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
80 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
81 using namespace std; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
82 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
83 void print_version() |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
84 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
85 cout << |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
86 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
87 " *********************************************************************\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
88 " * TM-align (Version 20190822): protein structure alignment *\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
89 " * References: Y Zhang, J Skolnick. Nucl Acids Res 33, 2302-9 (2005) *\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
90 " * Please email comments and suggestions to yangzhanglab@umich.edu *\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
91 " *********************************************************************" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
92 << endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
93 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
94 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
95 void print_extra_help() |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
96 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
97 cout << |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
98 "Additional options:\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
99 " -dir Perform all-against-all alignment among the list of PDB\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
100 " chains listed by 'chain_list' under 'chain_folder'. Note\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
101 " that the slash is necessary.\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
102 " $ TMalign -dir chain_folder/ chain_list\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
103 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
104 " -dir1 Use chain2 to search a list of PDB chains listed by 'chain1_list'\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
105 " under 'chain1_folder'. Note that the slash is necessary.\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
106 " $ TMalign -dir1 chain1_folder/ chain1_list chain2\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
107 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
108 " -dir2 Use chain1 to search a list of PDB chains listed by 'chain2_list'\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
109 " under 'chain2_folder'\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
110 " $ TMalign chain1 -dir2 chain2_folder/ chain2_list\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
111 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
112 " -suffix (Only when -dir1 and/or -dir2 are set, default is empty)\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
113 " add file name suffix to files listed by chain1_list or chain2_list\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
114 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
115 " -atom 4-character atom name used to represent a residue.\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
116 " Default is \" CA \" for proteins\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
117 " (note the spaces before and after CA).\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
118 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
119 " -ter Strings to mark the end of a chain\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
120 " 3: (default) TER, ENDMDL, END or different chain ID\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
121 " 2: ENDMDL, END, or different chain ID\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
122 " 1: ENDMDL or END\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
123 " 0: (default in the first C++ TMalign) end of file\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
124 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
125 " -split Whether to split PDB file into multiple chains\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
126 " 0: (default) treat the whole structure as one single chain\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
127 " 1: treat each MODEL as a separate chain (-ter should be 0)\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
128 " 2: treat each chain as a seperate chain (-ter should be <=1)\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
129 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
130 " -outfmt Output format\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
131 " 0: (default) full output\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
132 " 1: fasta format compact output\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
133 " 2: tabular format very compact output\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
134 " -1: full output, but without version or citation information\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
135 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
136 " -byresi Whether to assume residue index correspondence between the\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
137 " two structures.\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
138 " 0: (default) sequence independent alignment\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
139 " 1: (same as TMscore program) sequence-dependent superposition,\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
140 " i.e. align by residue index\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
141 " 2: (same as TMscore -c, should be used with -ter <=1)\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
142 " align by residue index and chain ID\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
143 " 3: (similar to TMscore -c, should be used with -ter <=1)\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
144 " align by residue index and order of chain\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
145 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
146 " -TMcut -1: (default) do not consider TMcut\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
147 " Values in [0.5,1): Do not proceed with TM-align for this\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
148 " structure pair if TM-score is unlikely to reach TMcut.\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
149 " TMcut is normalized is set by -a option:\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
150 " -2: normalized by longer structure length\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
151 " -1: normalized by shorter structure length\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
152 " 0: (default, same as F) normalized by second structure\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
153 " 1: same as T, normalized by average structure length\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
154 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
155 " -mirror Whether to align the mirror image of input structure\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
156 " 0: (default) do not align mirrored structure\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
157 " 1: align mirror of chain1 to origin chain2\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
158 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
159 " -het Whether to align residues marked as 'HETATM' in addition to 'ATOM '\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
160 " 0: (default) only align 'ATOM ' residues\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
161 " 1: align both 'ATOM ' and 'HETATM' residues\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
162 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
163 " -infmt1 Input format for chain1\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
164 " -infmt2 Input format for chain2\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
165 " -1: (default) automatically detect PDB or PDBx/mmCIF format\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
166 " 0: PDB format\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
167 " 1: SPICKER format\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
168 " 2: xyz format\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
169 " 3: PDBx/mmCIF format\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
170 <<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
171 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
172 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
173 void print_help(bool h_opt=false) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
174 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
175 print_version(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
176 cout << |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
177 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
178 "Usage: TMalign PDB1.pdb PDB2.pdb [Options]\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
179 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
180 "Options:\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
181 " -u TM-score normalized by user assigned length (the same as -L)\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
182 " warning: it should be >= minimum length of the two structures\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
183 " otherwise, TM-score may be >1\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
184 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
185 " -a TM-score normalized by the average length of two structures\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
186 " T or F, (default F)\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
187 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
188 " -i Start with an alignment specified in fasta file 'align.txt'\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
189 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
190 " -I Stick to the alignment specified in 'align.txt'\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
191 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
192 " -m Output TM-align rotation matrix\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
193 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
194 " -d TM-score scaled by an assigned d0, e.g. 5 Angstroms\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
195 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
196 " -o Output the superposition to 'TM_sup*'\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
197 " $ TMalign PDB1.pdb PDB2.pdb -o TM_sup\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
198 " View superposed C-alpha traces of aligned regions by RasMol or PyMOL:\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
199 " $ rasmol -script TM_sup\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
200 " $ pymol -d @TM_sup.pml\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
201 " View superposed C-alpha traces of all regions:\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
202 " $ rasmol -script TM_sup_all\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
203 " $ pymol -d @TM_sup_all.pml\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
204 " View superposed full-atom structures of aligned regions:\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
205 " $ rasmol -script TM_sup_atm\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
206 " $ pymol -d @TM_sup_atm.pml\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
207 " View superposed full-atom structures of all regions:\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
208 " $ rasmol -script TM_sup_all_atm\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
209 " $ pymol -d @TM_sup_all_atm.pml\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
210 " View superposed full-atom structures and ligands of all regions\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
211 " $ rasmol -script TM_sup_all_atm_lig\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
212 " $ pymol -d @TM_sup_all_atm_lig.pml\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
213 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
214 " -fast Fast but slightly inaccurate alignment by fTM-align algorithm\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
215 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
216 " -cp Alignment with circular permutation\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
217 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
218 " -v Print the version of TM-align\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
219 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
220 " -h Print the full help message, including additional options\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
221 "\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
222 " (Options -u, -a, -d, -o will not change the final structure alignment)\n\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
223 "Example usages:\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
224 " TMalign PDB1.pdb PDB2.pdb\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
225 " TMalign PDB1.pdb PDB2.pdb -u 100 -d 5.0\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
226 " TMalign PDB1.pdb PDB2.pdb -a T -o PDB1.sup\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
227 " TMalign PDB1.pdb PDB2.pdb -i align.txt\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
228 " TMalign PDB1.pdb PDB2.pdb -m matrix.txt\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
229 " TMalign PDB1.pdb PDB2.pdb -fast\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
230 " TMalign PDB1.pdb PDB2.pdb -cp\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
231 <<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
232 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
233 if (h_opt) print_extra_help(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
234 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
235 exit(EXIT_SUCCESS); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
236 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
237 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
238 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
239 /* Functions for the core TMalign algorithm, including the entry function |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
240 * TMalign_main */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
241 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
242 void PrintErrorAndQuit(const string sErrorString) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
243 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
244 cout << sErrorString << endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
245 exit(1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
246 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
247 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
248 template <typename T> inline T getmin(const T &a, const T &b) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
249 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
250 return b<a?b:a; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
251 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
252 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
253 template <class A> void NewArray(A *** array, int Narray1, int Narray2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
254 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
255 *array=new A* [Narray1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
256 for(int i=0; i<Narray1; i++) *(*array+i)=new A [Narray2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
257 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
258 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
259 template <class A> void DeleteArray(A *** array, int Narray) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
260 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
261 for(int i=0; i<Narray; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
262 if(*(*array+i)) delete [] *(*array+i); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
263 if(Narray) delete [] (*array); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
264 (*array)=NULL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
265 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
266 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
267 string AAmap(char A) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
268 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
269 if (A=='A') return "ALA"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
270 if (A=='B') return "ASX"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
271 if (A=='C') return "CYS"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
272 if (A=='D') return "ASP"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
273 if (A=='E') return "GLU"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
274 if (A=='F') return "PHE"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
275 if (A=='G') return "GLY"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
276 if (A=='H') return "HIS"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
277 if (A=='I') return "ILE"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
278 if (A=='K') return "LYS"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
279 if (A=='L') return "LEU"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
280 if (A=='M') return "MET"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
281 if (A=='N') return "ASN"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
282 if (A=='O') return "PYL"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
283 if (A=='P') return "PRO"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
284 if (A=='Q') return "GLN"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
285 if (A=='R') return "ARG"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
286 if (A=='S') return "SER"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
287 if (A=='T') return "THR"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
288 if (A=='U') return "SEC"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
289 if (A=='V') return "VAL"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
290 if (A=='W') return "TRP"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
291 if (A=='Y') return "TYR"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
292 if (A=='Z') return "GLX"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
293 return "UNK"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
294 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
295 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
296 char AAmap(const string &AA) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
297 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
298 if (AA.compare("ALA")==0 || AA.compare("DAL")==0) return 'A'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
299 if (AA.compare("ASX")==0) return 'B'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
300 if (AA.compare("CYS")==0 || AA.compare("DCY")==0) return 'C'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
301 if (AA.compare("ASP")==0 || AA.compare("DAS")==0) return 'D'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
302 if (AA.compare("GLU")==0 || AA.compare("DGL")==0) return 'E'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
303 if (AA.compare("PHE")==0 || AA.compare("DPN")==0) return 'F'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
304 if (AA.compare("GLY")==0) return 'G'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
305 if (AA.compare("HIS")==0 || AA.compare("DHI")==0) return 'H'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
306 if (AA.compare("ILE")==0 || AA.compare("DIL")==0) return 'I'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
307 if (AA.compare("LYS")==0 || AA.compare("DLY")==0) return 'K'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
308 if (AA.compare("LEU")==0 || AA.compare("DLE")==0) return 'L'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
309 if (AA.compare("MET")==0 || AA.compare("MED")==0 || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
310 AA.compare("MSE")==0) return 'M'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
311 if (AA.compare("ASN")==0 || AA.compare("DSG")==0) return 'N'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
312 if (AA.compare("PYL")==0) return 'O'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
313 if (AA.compare("PRO")==0 || AA.compare("DPR")==0) return 'P'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
314 if (AA.compare("GLN")==0 || AA.compare("DGN")==0) return 'Q'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
315 if (AA.compare("ARG")==0 || AA.compare("DAR")==0) return 'R'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
316 if (AA.compare("SER")==0 || AA.compare("DSN")==0) return 'S'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
317 if (AA.compare("THR")==0 || AA.compare("DTH")==0) return 'T'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
318 if (AA.compare("SEC")==0) return 'U'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
319 if (AA.compare("VAL")==0 || AA.compare("DVA")==0) return 'V'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
320 if (AA.compare("TRP")==0 || AA.compare("DTR")==0) return 'W'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
321 if (AA.compare("TYR")==0 || AA.compare("DTY")==0) return 'Y'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
322 if (AA.compare("GLX")==0) return 'Z'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
323 return 'X'; |
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 /* split a long string into vectors by whitespace |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
327 * line - input string |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
328 * line_vec - output vector |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
329 * delimiter - delimiter */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
330 void split(const string &line, vector<string> &line_vec, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
331 const char delimiter=' ') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
332 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
333 bool within_word = false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
334 for (int pos=0;pos<line.size();pos++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
335 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
336 if (line[pos]==delimiter) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
337 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
338 within_word = false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
339 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
340 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
341 if (!within_word) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
342 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
343 within_word = true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
344 line_vec.push_back(""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
345 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
346 line_vec.back()+=line[pos]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
347 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
348 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
349 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
350 /* split a long string into vectors by whitespace, return both whitespaces |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
351 * and non-whitespaces |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
352 * line - input string |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
353 * line_vec - output vector |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
354 * space_vec - output vector |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
355 * delimiter - delimiter */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
356 void split_white(const string &line, vector<string> &line_vec, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
357 vector<string>&white_vec, const char delimiter=' ') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
358 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
359 bool within_word = false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
360 for (int pos=0;pos<line.size();pos++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
361 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
362 if (line[pos]==delimiter) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
363 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
364 if (within_word==true) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
365 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
366 white_vec.push_back(""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
367 within_word = false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
368 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
369 white_vec.back()+=delimiter; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
370 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
371 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
372 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
373 if (within_word==false) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
374 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
375 line_vec.push_back(""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
376 within_word = true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
377 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
378 line_vec.back()+=line[pos]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
379 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
380 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
381 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
382 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
383 size_t get_PDB_lines(const string filename, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
384 vector<vector<string> >&PDB_lines, vector<string> &chainID_list, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
385 vector<int> &mol_vec, const int ter_opt, const int infmt_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
386 const string atom_opt, const int split_opt, const int het_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
387 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
388 size_t i=0; // resi i.e. atom index |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
389 string line; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
390 char chainID=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
391 string resi=""; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
392 bool select_atom=false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
393 size_t model_idx=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
394 vector<string> tmp_str_vec; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
395 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
396 ifstream fin; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
397 fin.open(filename.c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
398 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
399 if (infmt_opt==0||infmt_opt==-1) // PDB format |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
400 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
401 while (fin.good()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
402 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
403 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
404 if (infmt_opt==-1 && line.compare(0,5,"loop_")==0) // PDBx/mmCIF |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
405 return get_PDB_lines(filename,PDB_lines,chainID_list, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
406 mol_vec, ter_opt, 3, atom_opt, split_opt,het_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
407 if (i > 0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
408 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
409 if (ter_opt>=1 && line.compare(0,3,"END")==0) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
410 else if (ter_opt>=3 && line.compare(0,3,"TER")==0) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
411 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
412 if (split_opt && line.compare(0,3,"END")==0) chainID=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
413 if ((line.compare(0, 6, "ATOM ")==0 || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
414 (line.compare(0, 6, "HETATM")==0 && het_opt)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
415 && line.size()>=54 && (line[16]==' ' || line[16]=='A')) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
416 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
417 if (atom_opt=="auto") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
418 select_atom=(line.compare(12,4," CA ")==0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
419 else select_atom=(line.compare(12,4,atom_opt)==0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
420 if (select_atom) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
421 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
422 if (!chainID) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
423 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
424 chainID=line[21]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
425 model_idx++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
426 stringstream i8_stream; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
427 i=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
428 if (split_opt==2) // split by chain |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
429 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
430 if (chainID==' ') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
431 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
432 if (ter_opt>=1) i8_stream << ":_"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
433 else i8_stream<<':'<<model_idx<<":_"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
434 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
435 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
436 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
437 if (ter_opt>=1) i8_stream << ':' << chainID; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
438 else i8_stream<<':'<<model_idx<<':'<<chainID; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
439 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
440 chainID_list.push_back(i8_stream.str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
441 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
442 else if (split_opt==1) // split by model |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
443 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
444 i8_stream << ':' << model_idx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
445 chainID_list.push_back(i8_stream.str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
446 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
447 PDB_lines.push_back(tmp_str_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
448 mol_vec.push_back(0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
449 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
450 else if (ter_opt>=2 && chainID!=line[21]) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
451 if (split_opt==2 && chainID!=line[21]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
452 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
453 chainID=line[21]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
454 i=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
455 stringstream i8_stream; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
456 if (chainID==' ') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
457 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
458 if (ter_opt>=1) i8_stream << ":_"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
459 else i8_stream<<':'<<model_idx<<":_"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
460 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
461 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
462 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
463 if (ter_opt>=1) i8_stream << ':' << chainID; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
464 else i8_stream<<':'<<model_idx<<':'<<chainID; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
465 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
466 chainID_list.push_back(i8_stream.str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
467 PDB_lines.push_back(tmp_str_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
468 mol_vec.push_back(0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
469 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
470 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
471 if (resi==line.substr(22,5)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
472 cerr<<"Warning! Duplicated residue "<<resi<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
473 resi=line.substr(22,5); // including insertion code |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
474 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
475 PDB_lines.back().push_back(line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
476 if (line[17]==' ' && (line[18]=='D'||line[18]==' ')) mol_vec.back()++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
477 else mol_vec.back()--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
478 i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
479 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
480 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
481 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
482 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
483 else if (infmt_opt==1) // SPICKER format |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
484 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
485 int L=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
486 float x,y,z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
487 stringstream i8_stream; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
488 while (fin.good()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
489 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
490 fin >>L>>x>>y>>z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
491 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
492 if (!fin.good()) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
493 model_idx++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
494 stringstream i8_stream; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
495 i8_stream << ':' << model_idx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
496 chainID_list.push_back(i8_stream.str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
497 PDB_lines.push_back(tmp_str_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
498 mol_vec.push_back(0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
499 for (i=0;i<L;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
500 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
501 fin >>x>>y>>z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
502 i8_stream<<"ATOM "<<setw(4)<<i+1<<" CA UNK "<<setw(4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
503 <<i+1<<" "<<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
504 <<setw(8)<<x<<setw(8)<<y<<setw(8)<<z; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
505 line=i8_stream.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
506 i8_stream.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
507 PDB_lines.back().push_back(line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
508 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
509 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
510 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
511 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
512 else if (infmt_opt==2) // xyz format |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
513 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
514 int L=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
515 char A; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
516 stringstream i8_stream; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
517 while (fin.good()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
518 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
519 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
520 L=atoi(line.c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
521 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
522 for (i=0;i<line.size();i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
523 if (line[i]==' '||line[i]=='\t') break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
524 if (!fin.good()) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
525 chainID_list.push_back(':'+line.substr(0,i)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
526 PDB_lines.push_back(tmp_str_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
527 mol_vec.push_back(0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
528 for (i=0;i<L;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
529 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
530 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
531 i8_stream<<"ATOM "<<setw(4)<<i+1<<" CA " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
532 <<AAmap(line[0])<<" "<<setw(4)<<i+1<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
533 <<line.substr(2,8)<<line.substr(11,8)<<line.substr(20,8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
534 line=i8_stream.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
535 i8_stream.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
536 PDB_lines.back().push_back(line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
537 if (line[0]>='a' && line[0]<='z') mol_vec.back()++; // RNA |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
538 else mol_vec.back()--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
539 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
540 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
541 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
542 else if (infmt_opt==3) // PDBx/mmCIF format |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
543 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
544 bool loop_ = false; // not reading following content |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
545 map<string,int> _atom_site; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
546 int atom_site_pos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
547 vector<string> line_vec; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
548 string alt_id="."; // alternative location indicator |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
549 string asym_id="."; // this is similar to chainID, except that |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
550 // chainID is char while asym_id is a string |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
551 // with possibly multiple char |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
552 string prev_asym_id=""; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
553 string AA=""; // residue name |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
554 string atom=""; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
555 string prev_resi=""; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
556 string model_index=""; // the same as model_idx but type is string |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
557 stringstream i8_stream; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
558 while (fin.good()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
559 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
560 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
561 if (line.size()==0) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
562 if (loop_) loop_ = line.compare(0,2,"# "); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
563 if (!loop_) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
564 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
565 if (line.compare(0,5,"loop_")) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
566 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
567 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
568 if (fin.good()) getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
569 else PrintErrorAndQuit("ERROR! Unexpected end of "+filename); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
570 if (line.size()) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
571 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
572 if (line.compare(0,11,"_atom_site.")) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
573 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
574 loop_=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
575 _atom_site.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
576 atom_site_pos=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
577 _atom_site[line.substr(11,line.size()-12)]=atom_site_pos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
578 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
579 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
580 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
581 if (fin.good()) getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
582 else PrintErrorAndQuit("ERROR! Unexpected end of "+filename); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
583 if (line.size()==0) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
584 if (line.compare(0,11,"_atom_site.")) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
585 _atom_site[line.substr(11,line.size()-12)]=++atom_site_pos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
586 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
587 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
588 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
589 if (_atom_site.count("group_PDB")* |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
590 _atom_site.count("label_atom_id")* |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
591 _atom_site.count("label_comp_id")* |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
592 (_atom_site.count("auth_asym_id")+ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
593 _atom_site.count("label_asym_id"))* |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
594 (_atom_site.count("auth_seq_id")+ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
595 _atom_site.count("label_seq_id"))* |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
596 _atom_site.count("Cartn_x")* |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
597 _atom_site.count("Cartn_y")* |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
598 _atom_site.count("Cartn_z")==0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
599 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
600 loop_ = false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
601 cerr<<"Warning! Missing one of the following _atom_site data items: group_PDB, label_atom_id, label_atom_id, auth_asym_id/label_asym_id, auth_seq_id/label_seq_id, Cartn_x, Cartn_y, Cartn_z"<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
602 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
603 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
604 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
605 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
606 line_vec.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
607 split(line,line_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
608 if (line_vec[_atom_site["group_PDB"]]!="ATOM" && (het_opt==0 || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
609 line_vec[_atom_site["group_PDB"]]!="HETATM")) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
610 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
611 alt_id="."; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
612 if (_atom_site.count("label_alt_id")) // in 39.4 % of entries |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
613 alt_id=line_vec[_atom_site["label_alt_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
614 if (alt_id!="." && alt_id!="A") continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
615 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
616 atom=line_vec[_atom_site["label_atom_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
617 if (atom[0]=='"') atom=atom.substr(1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
618 if (atom.size() && atom[atom.size()-1]=='"') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
619 atom=atom.substr(0,atom.size()-1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
620 if (atom.size()==0) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
621 if (atom.size()==1) atom=" "+atom+" "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
622 else if (atom.size()==2) atom=" "+atom+" "; // wrong for sidechain H |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
623 else if (atom.size()==3) atom=" "+atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
624 else if (atom.size()>=5) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
625 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
626 AA=line_vec[_atom_site["label_comp_id"]]; // residue name |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
627 if (AA.size()==1) AA=" "+AA; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
628 else if (AA.size()==2) AA=" " +AA; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
629 else if (AA.size()>=4) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
630 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
631 if (atom_opt=="auto") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
632 select_atom=(atom==" CA "); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
633 else select_atom=(atom==atom_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
634 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
635 if (!select_atom) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
636 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
637 if (_atom_site.count("auth_asym_id")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
638 asym_id=line_vec[_atom_site["auth_asym_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
639 else asym_id=line_vec[_atom_site["label_asym_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
640 if (asym_id==".") asym_id=" "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
641 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
642 if (_atom_site.count("pdbx_PDB_model_num") && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
643 model_index!=line_vec[_atom_site["pdbx_PDB_model_num"]]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
644 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
645 model_index=line_vec[_atom_site["pdbx_PDB_model_num"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
646 if (PDB_lines.size() && ter_opt>=1) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
647 if (PDB_lines.size()==0 || split_opt>=1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
648 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
649 PDB_lines.push_back(tmp_str_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
650 mol_vec.push_back(0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
651 prev_asym_id=asym_id; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
652 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
653 if (split_opt==1 && ter_opt==0) chainID_list.push_back( |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
654 ':'+model_index); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
655 else if (split_opt==2 && ter_opt==0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
656 chainID_list.push_back(':'+model_index+':'+asym_id); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
657 else if (split_opt==2 && ter_opt==1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
658 chainID_list.push_back(':'+asym_id); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
659 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
660 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
661 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
662 if (prev_asym_id!=asym_id) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
663 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
664 if (prev_asym_id!="" && ter_opt>=2) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
665 if (split_opt>=2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
666 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
667 PDB_lines.push_back(tmp_str_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
668 mol_vec.push_back(0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
669 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
670 if (split_opt==1 && ter_opt==0) chainID_list.push_back( |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
671 ':'+model_index); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
672 else if (split_opt==2 && ter_opt==0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
673 chainID_list.push_back(':'+model_index+':'+asym_id); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
674 else if (split_opt==2 && ter_opt==1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
675 chainID_list.push_back(':'+asym_id); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
676 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
677 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
678 if (prev_asym_id!=asym_id) prev_asym_id=asym_id; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
679 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
680 if (AA[0]==' ' && (AA[1]=='D'||AA[1]==' ')) mol_vec.back()++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
681 else mol_vec.back()--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
682 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
683 if (_atom_site.count("auth_seq_id")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
684 resi=line_vec[_atom_site["auth_seq_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
685 else resi=line_vec[_atom_site["label_seq_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
686 if (_atom_site.count("pdbx_PDB_ins_code") && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
687 line_vec[_atom_site["pdbx_PDB_ins_code"]]!="?") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
688 resi+=line_vec[_atom_site["pdbx_PDB_ins_code"]][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
689 else resi+=" "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
690 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
691 if (prev_resi==resi) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
692 cerr<<"Warning! Duplicated residue "<<resi<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
693 prev_resi=resi; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
694 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
695 i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
696 i8_stream<<"ATOM " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
697 <<setw(5)<<i<<" "<<atom<<" "<<AA<<" "<<asym_id[0] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
698 <<setw(5)<<resi.substr(0,5)<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
699 <<setw(8)<<line_vec[_atom_site["Cartn_x"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
700 <<setw(8)<<line_vec[_atom_site["Cartn_y"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
701 <<setw(8)<<line_vec[_atom_site["Cartn_z"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
702 PDB_lines.back().push_back(i8_stream.str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
703 i8_stream.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
704 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
705 _atom_site.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
706 line_vec.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
707 alt_id.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
708 asym_id.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
709 AA.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
710 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
711 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
712 fin.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
713 line.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
714 if (!split_opt) chainID_list.push_back(""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
715 return PDB_lines.size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
716 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
717 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
718 /* read fasta file from filename. sequence is stored into FASTA_lines |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
719 * while sequence name is stored into chainID_list. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
720 * if ter_opt >=1, only read the first sequence. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
721 * if ter_opt ==0, read all sequences. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
722 * if split_opt >=1 and ter_opt ==0, each sequence is a separate entry. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
723 * if split_opt ==0 and ter_opt ==0, all sequences are combined into one */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
724 size_t get_FASTA_lines(const string filename, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
725 vector<vector<string> >&FASTA_lines, vector<string> &chainID_list, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
726 vector<int> &mol_vec, const int ter_opt=3, const int split_opt=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
727 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
728 string line; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
729 vector<string> tmp_str_vec; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
730 int l; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
731 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
732 ifstream fin; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
733 fin.open(filename.c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
734 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
735 while (fin.good()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
736 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
737 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
738 if (line.size()==0 || line[0]=='#') continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
739 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
740 if (line[0]=='>') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
741 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
742 if (FASTA_lines.size()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
743 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
744 if (ter_opt) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
745 if (split_opt==0) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
746 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
747 FASTA_lines.push_back(tmp_str_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
748 FASTA_lines.back().push_back(""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
749 mol_vec.push_back(0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
750 if (ter_opt==0 && split_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
751 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
752 line[0]=':'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
753 chainID_list.push_back(line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
754 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
755 else chainID_list.push_back(""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
756 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
757 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
758 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
759 FASTA_lines.back()[0]+=line; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
760 for (l=0;l<line.size();l++) mol_vec.back()+= |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
761 ('a'<=line[l] && line[l]<='z')-('A'<=line[l] && line[l]<='Z'); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
762 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
763 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
764 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
765 line.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
766 fin.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
767 return FASTA_lines.size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
768 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
769 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
770 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
771 /* extract pairwise sequence alignment from residue index vectors, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
772 * assuming that "sequence" contains two empty strings. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
773 * return length of alignment, including gap. */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
774 int extract_aln_from_resi(vector<string> &sequence, char *seqx, char *seqy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
775 const vector<string> resi_vec1, const vector<string> resi_vec2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
776 const int byresi_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
777 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
778 sequence.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
779 sequence.push_back(""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
780 sequence.push_back(""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
781 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
782 int i1=0; // positions in resi_vec1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
783 int i2=0; // positions in resi_vec2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
784 int xlen=resi_vec1.size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
785 int ylen=resi_vec2.size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
786 map<char,int> chainID_map1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
787 map<char,int> chainID_map2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
788 if (byresi_opt==3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
789 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
790 vector<char> chainID_vec; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
791 char chainID; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
792 int i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
793 for (i=0;i<xlen;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
794 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
795 chainID=resi_vec1[i][5]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
796 if (!chainID_vec.size()|| chainID_vec.back()!=chainID) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
797 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
798 chainID_vec.push_back(chainID); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
799 chainID_map1[chainID]=chainID_vec.size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
800 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
801 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
802 chainID_vec.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
803 for (i=0;i<ylen;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
804 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
805 chainID=resi_vec2[i][5]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
806 if (!chainID_vec.size()|| chainID_vec.back()!=chainID) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
807 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
808 chainID_vec.push_back(chainID); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
809 chainID_map2[chainID]=chainID_vec.size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
810 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
811 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
812 chainID_vec.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
813 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
814 while(i1<xlen && i2<ylen) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
815 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
816 if ((byresi_opt<=2 && resi_vec1[i1]==resi_vec2[i2]) || (byresi_opt==3 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
817 && resi_vec1[i1].substr(0,5)==resi_vec2[i2].substr(0,5) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
818 && chainID_map1[resi_vec1[i1][5]]==chainID_map2[resi_vec2[i2][5]])) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
819 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
820 sequence[0]+=seqx[i1++]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
821 sequence[1]+=seqy[i2++]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
822 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
823 else if (atoi(resi_vec1[i1].substr(0,4).c_str())<= |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
824 atoi(resi_vec2[i2].substr(0,4).c_str())) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
825 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
826 sequence[0]+=seqx[i1++]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
827 sequence[1]+='-'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
828 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
829 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
830 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
831 sequence[0]+='-'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
832 sequence[1]+=seqy[i2++]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
833 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
834 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
835 chainID_map1.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
836 chainID_map2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
837 return sequence[0].size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
838 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
839 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
840 int read_PDB(const vector<string> &PDB_lines, double **a, char *seq, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
841 vector<string> &resi_vec, const int byresi_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
842 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
843 int i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
844 for (i=0;i<PDB_lines.size();i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
845 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
846 a[i][0] = atof(PDB_lines[i].substr(30, 8).c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
847 a[i][1] = atof(PDB_lines[i].substr(38, 8).c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
848 a[i][2] = atof(PDB_lines[i].substr(46, 8).c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
849 seq[i] = AAmap(PDB_lines[i].substr(17, 3)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
850 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
851 if (byresi_opt>=2) resi_vec.push_back(PDB_lines[i].substr(22,5)+ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
852 PDB_lines[i][21]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
853 if (byresi_opt==1) resi_vec.push_back(PDB_lines[i].substr(22,5)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
854 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
855 seq[i]='\0'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
856 return i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
857 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
858 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
859 double dist(double x[3], double y[3]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
860 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
861 double d1=x[0]-y[0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
862 double d2=x[1]-y[1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
863 double d3=x[2]-y[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
864 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
865 return (d1*d1 + d2*d2 + d3*d3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
866 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
867 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
868 double dot(double *a, double *b) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
869 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
870 return (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
871 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
872 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
873 void transform(double t[3], double u[3][3], double *x, double *x1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
874 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
875 x1[0]=t[0]+dot(&u[0][0], x); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
876 x1[1]=t[1]+dot(&u[1][0], x); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
877 x1[2]=t[2]+dot(&u[2][0], x); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
878 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
879 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
880 void do_rotation(double **x, double **x1, int len, double t[3], double u[3][3]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
881 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
882 for(int i=0; i<len; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
883 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
884 transform(t, u, &x[i][0], &x1[i][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
885 } |
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 /* strip white space at the begining or end of string */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
889 string Trim(const string &inputString) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
890 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
891 string result = inputString; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
892 int idxBegin = inputString.find_first_not_of(" \n\r\t"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
893 int idxEnd = inputString.find_last_not_of(" \n\r\t"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
894 if (idxBegin >= 0 && idxEnd >= 0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
895 result = inputString.substr(idxBegin, idxEnd + 1 - idxBegin); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
896 return result; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
897 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
898 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
899 /* read user specified pairwise alignment from 'fname_lign' to 'sequence'. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
900 * This function should only be called by main function, as it will |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
901 * terminate a program if wrong alignment is given */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
902 void read_user_alignment(vector<string>&sequence, const string &fname_lign, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
903 const int i_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
904 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
905 if (fname_lign == "") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
906 PrintErrorAndQuit("Please provide a file name for option -i!"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
907 // open alignment file |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
908 int n_p = 0;// number of structures in alignment file |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
909 string line; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
910 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
911 ifstream fileIn(fname_lign.c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
912 if (fileIn.is_open()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
913 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
914 while (fileIn.good()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
915 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
916 getline(fileIn, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
917 if (line.compare(0, 1, ">") == 0)// Flag for a new structure |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
918 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
919 if (n_p >= 2) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
920 sequence.push_back(""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
921 n_p++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
922 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
923 else if (n_p > 0 && line!="") sequence.back()+=line; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
924 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
925 fileIn.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
926 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
927 else PrintErrorAndQuit("ERROR! Alignment file does not exist."); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
928 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
929 if (n_p < 2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
930 PrintErrorAndQuit("ERROR: Fasta format is wrong, two proteins should be included."); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
931 if (sequence[0].size() != sequence[1].size()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
932 PrintErrorAndQuit("ERROR! FASTA file is wrong. The length in alignment should be equal for the two aligned proteins."); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
933 if (i_opt==3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
934 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
935 int aligned_resNum=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
936 for (int i=0;i<sequence[0].size();i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
937 aligned_resNum+=(sequence[0][i]!='-' && sequence[1][i]!='-'); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
938 if (aligned_resNum<3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
939 PrintErrorAndQuit("ERROR! Superposition is undefined for <3 aligned residues."); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
940 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
941 line.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
942 return; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
943 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
944 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
945 /* read list of entries from 'name' to 'chain_list'. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
946 * dir_opt is the folder name (prefix). |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
947 * suffix_opt is the file name extension (suffix_opt). |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
948 * This function should only be called by main function, as it will |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
949 * terminate a program if wrong alignment is given */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
950 void file2chainlist(vector<string>&chain_list, const string &name, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
951 const string &dir_opt, const string &suffix_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
952 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
953 ifstream fp(name.c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
954 if (! fp.is_open()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
955 PrintErrorAndQuit(("Can not open file: "+name+'\n').c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
956 string line; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
957 while (fp.good()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
958 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
959 getline(fp, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
960 if (! line.size()) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
961 chain_list.push_back(dir_opt+Trim(line)+suffix_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
962 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
963 fp.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
964 line.clear(); |
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 /************************************************************************** |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
968 Implemetation of Kabsch algoritm for finding the best rotation matrix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
969 --------------------------------------------------------------------------- |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
970 x - x(i,m) are coordinates of atom m in set x (input) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
971 y - y(i,m) are coordinates of atom m in set y (input) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
972 n - n is number of atom pairs (input) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
973 mode - 0:calculate rms only (input) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
974 1:calculate u,t only (takes medium) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
975 2:calculate rms,u,t (takes longer) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
976 rms - sum of w*(ux+t-y)**2 over all atom pairs (output) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
977 u - u(i,j) is rotation matrix for best superposition (output) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
978 t - t(i) is translation vector for best superposition (output) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
979 **************************************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
980 bool Kabsch(double **x, double **y, int n, int mode, double *rms, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
981 double t[3], double u[3][3]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
982 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
983 int i, j, m, m1, l, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
984 double e0, rms1, d, h, g; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
985 double cth, sth, sqrth, p, det, sigma; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
986 double xc[3], yc[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
987 double a[3][3], b[3][3], r[3][3], e[3], rr[6], ss[6]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
988 double sqrt3 = 1.73205080756888, tol = 0.01; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
989 int ip[] = { 0, 1, 3, 1, 2, 4, 3, 4, 5 }; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
990 int ip2312[] = { 1, 2, 0, 1 }; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
991 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
992 int a_failed = 0, b_failed = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
993 double epsilon = 0.00000001; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
994 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
995 //initializtation |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
996 *rms = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
997 rms1 = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
998 e0 = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
999 double c1[3], c2[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1000 double s1[3], s2[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1001 double sx[3], sy[3], sz[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1002 for (i = 0; i < 3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1003 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1004 s1[i] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1005 s2[i] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1006 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1007 sx[i] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1008 sy[i] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1009 sz[i] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1010 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1011 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1012 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1013 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1014 xc[i] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1015 yc[i] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1016 t[i] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1017 for (j = 0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1018 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1019 u[i][j] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1020 r[i][j] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1021 a[i][j] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1022 if (i == j) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1023 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1024 u[i][j] = 1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1025 a[i][j] = 1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1026 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1027 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1028 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1029 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1030 if (n<1) return false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1031 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1032 //compute centers for vector sets x, y |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1033 for (i = 0; i<n; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1034 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1035 for (j = 0; j < 3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1036 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1037 c1[j] = x[i][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1038 c2[j] = y[i][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1039 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1040 s1[j] += c1[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1041 s2[j] += c2[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1042 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1043 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1044 for (j = 0; j < 3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1045 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1046 sx[j] += c1[0] * c2[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1047 sy[j] += c1[1] * c2[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1048 sz[j] += c1[2] * c2[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1049 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1050 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1051 for (i = 0; i < 3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1052 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1053 xc[i] = s1[i] / n; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1054 yc[i] = s2[i] / n; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1055 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1056 if (mode == 2 || mode == 0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1057 for (int mm = 0; mm < n; mm++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1058 for (int nn = 0; nn < 3; nn++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1059 e0 += (x[mm][nn] - xc[nn]) * (x[mm][nn] - xc[nn]) + |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1060 (y[mm][nn] - yc[nn]) * (y[mm][nn] - yc[nn]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1061 for (j = 0; j < 3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1062 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1063 r[j][0] = sx[j] - s1[0] * s2[j] / n; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1064 r[j][1] = sy[j] - s1[1] * s2[j] / n; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1065 r[j][2] = sz[j] - s1[2] * s2[j] / n; |
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 //compute determinat of matrix r |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1069 det = r[0][0] * (r[1][1] * r[2][2] - r[1][2] * r[2][1])\ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1070 - r[0][1] * (r[1][0] * r[2][2] - r[1][2] * r[2][0])\ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1071 + r[0][2] * (r[1][0] * r[2][1] - r[1][1] * r[2][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1072 sigma = det; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1073 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1074 //compute tras(r)*r |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1075 m = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1076 for (j = 0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1077 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1078 for (i = 0; i <= j; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1079 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1080 rr[m] = r[0][i] * r[0][j] + r[1][i] * r[1][j] + r[2][i] * r[2][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1081 m++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1082 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1083 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1084 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1085 double spur = (rr[0] + rr[2] + rr[5]) / 3.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1086 double cof = (((((rr[2] * rr[5] - rr[4] * rr[4]) + rr[0] * rr[5])\ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1087 - rr[3] * rr[3]) + rr[0] * rr[2]) - rr[1] * rr[1]) / 3.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1088 det = det*det; |
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<3; i++) e[i] = spur; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1091 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1092 if (spur>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1093 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1094 d = spur*spur; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1095 h = d - cof; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1096 g = (spur*cof - det) / 2.0 - spur*h; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1097 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1098 if (h>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1099 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1100 sqrth = sqrt(h); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1101 d = h*h*h - g*g; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1102 if (d<0.0) d = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1103 d = atan2(sqrt(d), -g) / 3.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1104 cth = sqrth * cos(d); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1105 sth = sqrth*sqrt3*sin(d); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1106 e[0] = (spur + cth) + cth; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1107 e[1] = (spur - cth) + sth; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1108 e[2] = (spur - cth) - sth; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1109 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1110 if (mode != 0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1111 {//compute a |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1112 for (l = 0; l<3; l = l + 2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1113 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1114 d = e[l]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1115 ss[0] = (d - rr[2]) * (d - rr[5]) - rr[4] * rr[4]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1116 ss[1] = (d - rr[5]) * rr[1] + rr[3] * rr[4]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1117 ss[2] = (d - rr[0]) * (d - rr[5]) - rr[3] * rr[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1118 ss[3] = (d - rr[2]) * rr[3] + rr[1] * rr[4]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1119 ss[4] = (d - rr[0]) * rr[4] + rr[1] * rr[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1120 ss[5] = (d - rr[0]) * (d - rr[2]) - rr[1] * rr[1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1121 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1122 if (fabs(ss[0]) <= epsilon) ss[0] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1123 if (fabs(ss[1]) <= epsilon) ss[1] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1124 if (fabs(ss[2]) <= epsilon) ss[2] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1125 if (fabs(ss[3]) <= epsilon) ss[3] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1126 if (fabs(ss[4]) <= epsilon) ss[4] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1127 if (fabs(ss[5]) <= epsilon) ss[5] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1128 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1129 if (fabs(ss[0]) >= fabs(ss[2])) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1130 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1131 j = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1132 if (fabs(ss[0]) < fabs(ss[5])) j = 2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1133 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1134 else if (fabs(ss[2]) >= fabs(ss[5])) j = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1135 else j = 2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1136 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1137 d = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1138 j = 3 * j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1139 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1140 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1141 k = ip[i + j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1142 a[i][l] = ss[k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1143 d = d + ss[k] * ss[k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1144 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1145 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1146 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1147 //if( d > 0.0 ) d = 1.0 / sqrt(d); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1148 if (d > epsilon) d = 1.0 / sqrt(d); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1149 else d = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1150 for (i = 0; i<3; i++) a[i][l] = a[i][l] * d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1151 }//for l |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1152 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1153 d = a[0][0] * a[0][2] + a[1][0] * a[1][2] + a[2][0] * a[2][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1154 if ((e[0] - e[1]) >(e[1] - e[2])) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1155 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1156 m1 = 2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1157 m = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1158 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1159 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1160 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1161 m1 = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1162 m = 2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1163 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1164 p = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1165 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1166 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1167 a[i][m1] = a[i][m1] - d*a[i][m]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1168 p = p + a[i][m1] * a[i][m1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1169 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1170 if (p <= tol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1171 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1172 p = 1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1173 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1174 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1175 if (p < fabs(a[i][m])) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1176 p = fabs(a[i][m]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1177 j = i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1178 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1179 k = ip2312[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1180 l = ip2312[j + 1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1181 p = sqrt(a[k][m] * a[k][m] + a[l][m] * a[l][m]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1182 if (p > tol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1183 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1184 a[j][m1] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1185 a[k][m1] = -a[l][m] / p; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1186 a[l][m1] = a[k][m] / p; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1187 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1188 else a_failed = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1189 }//if p<=tol |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1190 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1191 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1192 p = 1.0 / sqrt(p); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1193 for (i = 0; i<3; i++) a[i][m1] = a[i][m1] * p; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1194 }//else p<=tol |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1195 if (a_failed != 1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1196 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1197 a[0][1] = a[1][2] * a[2][0] - a[1][0] * a[2][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1198 a[1][1] = a[2][2] * a[0][0] - a[2][0] * a[0][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1199 a[2][1] = a[0][2] * a[1][0] - a[0][0] * a[1][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1200 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1201 }//if(mode!=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1202 }//h>0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1203 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1204 //compute b anyway |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1205 if (mode != 0 && a_failed != 1)//a is computed correctly |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1206 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1207 //compute b |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1208 for (l = 0; l<2; l++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1209 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1210 d = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1211 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1212 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1213 b[i][l] = r[i][0] * a[0][l] + |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1214 r[i][1] * a[1][l] + r[i][2] * a[2][l]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1215 d = d + b[i][l] * b[i][l]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1216 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1217 //if( d > 0 ) d = 1.0 / sqrt(d); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1218 if (d > epsilon) d = 1.0 / sqrt(d); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1219 else d = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1220 for (i = 0; i<3; i++) b[i][l] = b[i][l] * d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1221 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1222 d = b[0][0] * b[0][1] + b[1][0] * b[1][1] + b[2][0] * b[2][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1223 p = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1224 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1225 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1226 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1227 b[i][1] = b[i][1] - d*b[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1228 p += b[i][1] * b[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1229 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1230 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1231 if (p <= tol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1232 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1233 p = 1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1234 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1235 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1236 if (p<fabs(b[i][0])) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1237 p = fabs(b[i][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1238 j = i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1239 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1240 k = ip2312[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1241 l = ip2312[j + 1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1242 p = sqrt(b[k][0] * b[k][0] + b[l][0] * b[l][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1243 if (p > tol) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1244 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1245 b[j][1] = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1246 b[k][1] = -b[l][0] / p; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1247 b[l][1] = b[k][0] / p; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1248 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1249 else b_failed = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1250 }//if( p <= tol ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1251 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1252 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1253 p = 1.0 / sqrt(p); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1254 for (i = 0; i<3; i++) b[i][1] = b[i][1] * p; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1255 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1256 if (b_failed != 1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1257 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1258 b[0][2] = b[1][0] * b[2][1] - b[1][1] * b[2][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1259 b[1][2] = b[2][0] * b[0][1] - b[2][1] * b[0][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1260 b[2][2] = b[0][0] * b[1][1] - b[0][1] * b[1][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1261 //compute u |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1262 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1263 for (j = 0; j<3; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1264 u[i][j] = b[i][0] * a[j][0] + |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1265 b[i][1] * a[j][1] + b[i][2] * a[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1266 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1267 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1268 //compute t |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1269 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1270 t[i] = ((yc[i] - u[i][0] * xc[0]) - u[i][1] * xc[1]) - |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1271 u[i][2] * xc[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1272 }//if(mode!=0 && a_failed!=1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1273 }//spur>0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1274 else //just compute t and errors |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1275 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1276 //compute t |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1277 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1278 t[i] = ((yc[i] - u[i][0] * xc[0]) - u[i][1] * xc[1]) - |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1279 u[i][2] * xc[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1280 }//else spur>0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1281 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1282 //compute rms |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1283 for (i = 0; i<3; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1284 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1285 if (e[i] < 0) e[i] = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1286 e[i] = sqrt(e[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1287 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1288 d = e[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1289 if (sigma < 0.0) d = -d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1290 d = (d + e[1]) + e[0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1291 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1292 if (mode == 2 || mode == 0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1293 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1294 rms1 = (e0 - d) - d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1295 if (rms1 < 0.0) rms1 = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1296 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1297 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1298 *rms = rms1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1299 return true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1300 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1301 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1302 /* Partial implementation of Needleman-Wunsch (NW) dymanamic programming for |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1303 * global alignment. The three NWDP_TM functions below are not complete |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1304 * implementation of NW algorithm because gap jumping in the standard Gotoh |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1305 * algorithm is not considered. Since the gap opening and gap extension is |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1306 * the same, this is not a problem. This code was exploited in TM-align |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1307 * because it is about 1.5 times faster than a complete NW implementation. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1308 * Nevertheless, if gap openning != gap extension shall be implemented in |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1309 * the future, the Gotoh algorithm must be implemented. In rare scenarios, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1310 * it is also possible to have asymmetric alignment (i.e. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1311 * TMalign A.pdb B.pdb and TMalign B.pdb A.pdb have different TM_A and TM_B |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1312 * values) caused by the NWPD_TM implement. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1313 */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1314 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1315 /* Input: score[1:len1, 1:len2], and gap_open |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1316 * Output: j2i[1:len2] \in {1:len1} U {-1} |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1317 * path[0:len1, 0:len2]=1,2,3, from diagonal, horizontal, vertical */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1318 void NWDP_TM(double **score, bool **path, double **val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1319 int len1, int len2, double gap_open, int j2i[]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1320 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1321 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1322 int i, j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1323 double h, v, d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1324 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1325 //initialization |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1326 for(i=0; i<=len1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1327 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1328 val[i][0]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1329 //val[i][0]=i*gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1330 path[i][0]=false; //not from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1331 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1332 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1333 for(j=0; j<=len2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1334 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1335 val[0][j]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1336 //val[0][j]=j*gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1337 path[0][j]=false; //not from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1338 j2i[j]=-1; //all are not aligned, only use j2i[1:len2] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1339 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1340 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1341 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1342 //decide matrix and path |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1343 for(i=1; i<=len1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1344 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1345 for(j=1; j<=len2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1346 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1347 d=val[i-1][j-1]+score[i][j]; //diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1348 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1349 //symbol insertion in horizontal (= a gap in vertical) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1350 h=val[i-1][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1351 if(path[i-1][j]) h += gap_open; //aligned in last position |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1352 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1353 //symbol insertion in vertical |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1354 v=val[i][j-1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1355 if(path[i][j-1]) v += gap_open; //aligned in last position |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1356 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1357 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1358 if(d>=h && d>=v) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1359 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1360 path[i][j]=true; //from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1361 val[i][j]=d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1362 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1363 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1364 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1365 path[i][j]=false; //from horizontal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1366 if(v>=h) val[i][j]=v; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1367 else val[i][j]=h; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1368 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1369 } //for i |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1370 } //for j |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1371 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1372 //trace back to extract the alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1373 i=len1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1374 j=len2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1375 while(i>0 && j>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1376 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1377 if(path[i][j]) //from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1378 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1379 j2i[j-1]=i-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1380 i--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1381 j--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1382 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1383 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1384 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1385 h=val[i-1][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1386 if(path[i-1][j]) h +=gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1387 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1388 v=val[i][j-1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1389 if(path[i][j-1]) v +=gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1390 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1391 if(v>=h) j--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1392 else i--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1393 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1394 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1395 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1396 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1397 /* Input: vectors x, y, rotation matrix t, u, scale factor d02, and gap_open |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1398 * Output: j2i[1:len2] \in {1:len1} U {-1} |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1399 * path[0:len1, 0:len2]=1,2,3, from diagonal, horizontal, vertical */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1400 void NWDP_TM(bool **path, double **val, double **x, double **y, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1401 int len1, int len2, double t[3], double u[3][3], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1402 double d02, double gap_open, int j2i[]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1403 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1404 int i, j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1405 double h, v, d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1406 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1407 //initialization. use old val[i][0] and val[0][j] initialization |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1408 //to minimize difference from TMalign fortran version |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1409 for(i=0; i<=len1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1410 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1411 val[i][0]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1412 //val[i][0]=i*gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1413 path[i][0]=false; //not from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1414 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1415 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1416 for(j=0; j<=len2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1417 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1418 val[0][j]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1419 //val[0][j]=j*gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1420 path[0][j]=false; //not from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1421 j2i[j]=-1; //all are not aligned, only use j2i[1:len2] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1422 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1423 double xx[3], dij; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1424 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1425 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1426 //decide matrix and path |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1427 for(i=1; i<=len1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1428 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1429 transform(t, u, &x[i-1][0], xx); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1430 for(j=1; j<=len2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1431 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1432 dij=dist(xx, &y[j-1][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1433 d=val[i-1][j-1] + 1.0/(1+dij/d02); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1434 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1435 //symbol insertion in horizontal (= a gap in vertical) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1436 h=val[i-1][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1437 if(path[i-1][j]) h += gap_open; //aligned in last position |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1438 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1439 //symbol insertion in vertical |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1440 v=val[i][j-1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1441 if(path[i][j-1]) v += gap_open; //aligned in last position |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1442 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1443 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1444 if(d>=h && d>=v) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1445 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1446 path[i][j]=true; //from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1447 val[i][j]=d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1448 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1449 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1450 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1451 path[i][j]=false; //from horizontal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1452 if(v>=h) val[i][j]=v; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1453 else val[i][j]=h; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1454 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1455 } //for i |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1456 } //for j |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1457 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1458 //trace back to extract the alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1459 i=len1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1460 j=len2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1461 while(i>0 && j>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1462 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1463 if(path[i][j]) //from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1464 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1465 j2i[j-1]=i-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1466 i--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1467 j--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1468 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1469 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1470 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1471 h=val[i-1][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1472 if(path[i-1][j]) h +=gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1473 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1474 v=val[i][j-1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1475 if(path[i][j-1]) v +=gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1476 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1477 if(v>=h) j--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1478 else i--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1479 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1480 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1481 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1482 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1483 /* This is the same as the previous NWDP_TM, except for the lack of rotation |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1484 * Input: vectors x, y, scale factor d02, and gap_open |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1485 * Output: j2i[1:len2] \in {1:len1} U {-1} |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1486 * path[0:len1, 0:len2]=1,2,3, from diagonal, horizontal, vertical */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1487 void NWDP_SE(bool **path, double **val, double **x, double **y, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1488 int len1, int len2, double d02, double gap_open, int j2i[]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1489 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1490 int i, j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1491 double h, v, d; |
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<=len1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1494 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1495 val[i][0]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1496 path[i][0]=false; //not from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1497 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1498 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1499 for(j=0; j<=len2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1500 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1501 val[0][j]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1502 path[0][j]=false; //not from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1503 j2i[j]=-1; //all are not aligned, only use j2i[1:len2] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1504 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1505 double dij; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1506 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1507 //decide matrix and path |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1508 for(i=1; i<=len1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1509 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1510 for(j=1; j<=len2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1511 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1512 dij=dist(&x[i-1][0], &y[j-1][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1513 d=val[i-1][j-1] + 1.0/(1+dij/d02); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1514 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1515 //symbol insertion in horizontal (= a gap in vertical) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1516 h=val[i-1][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1517 if(path[i-1][j]) h += gap_open; //aligned in last position |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1518 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1519 //symbol insertion in vertical |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1520 v=val[i][j-1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1521 if(path[i][j-1]) v += gap_open; //aligned in last position |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1522 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1523 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1524 if(d>=h && d>=v) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1525 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1526 path[i][j]=true; //from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1527 val[i][j]=d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1528 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1529 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1530 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1531 path[i][j]=false; //from horizontal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1532 if(v>=h) val[i][j]=v; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1533 else val[i][j]=h; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1534 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1535 } //for i |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1536 } //for j |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1537 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1538 //trace back to extract the alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1539 i=len1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1540 j=len2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1541 while(i>0 && j>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1542 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1543 if(path[i][j]) //from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1544 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1545 j2i[j-1]=i-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1546 i--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1547 j--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1548 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1549 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1550 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1551 h=val[i-1][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1552 if(path[i-1][j]) h +=gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1553 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1554 v=val[i][j-1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1555 if(path[i][j-1]) v +=gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1556 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1557 if(v>=h) j--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1558 else i--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1559 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1560 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1561 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1562 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1563 /* +ss |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1564 * Input: secondary structure secx, secy, and gap_open |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1565 * Output: j2i[1:len2] \in {1:len1} U {-1} |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1566 * path[0:len1, 0:len2]=1,2,3, from diagonal, horizontal, vertical */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1567 void NWDP_TM(bool **path, double **val, const char *secx, const char *secy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1568 const int len1, const int len2, const double gap_open, int j2i[]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1569 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1570 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1571 int i, j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1572 double h, v, d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1573 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1574 //initialization |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1575 for(i=0; i<=len1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1576 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1577 val[i][0]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1578 //val[i][0]=i*gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1579 path[i][0]=false; //not from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1580 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1581 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1582 for(j=0; j<=len2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1583 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1584 val[0][j]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1585 //val[0][j]=j*gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1586 path[0][j]=false; //not from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1587 j2i[j]=-1; //all are not aligned, only use j2i[1:len2] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1588 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1589 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1590 //decide matrix and path |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1591 for(i=1; i<=len1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1592 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1593 for(j=1; j<=len2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1594 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1595 d=val[i-1][j-1] + 1.0*(secx[i-1]==secy[j-1]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1596 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1597 //symbol insertion in horizontal (= a gap in vertical) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1598 h=val[i-1][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1599 if(path[i-1][j]) h += gap_open; //aligned in last position |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1600 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1601 //symbol insertion in vertical |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1602 v=val[i][j-1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1603 if(path[i][j-1]) v += gap_open; //aligned in last position |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1604 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1605 if(d>=h && d>=v) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1606 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1607 path[i][j]=true; //from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1608 val[i][j]=d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1609 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1610 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1611 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1612 path[i][j]=false; //from horizontal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1613 if(v>=h) val[i][j]=v; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1614 else val[i][j]=h; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1615 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1616 } //for i |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1617 } //for j |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1618 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1619 //trace back to extract the alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1620 i=len1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1621 j=len2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1622 while(i>0 && j>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1623 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1624 if(path[i][j]) //from diagonal |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1625 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1626 j2i[j-1]=i-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1627 i--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1628 j--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1629 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1630 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1631 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1632 h=val[i-1][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1633 if(path[i-1][j]) h +=gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1634 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1635 v=val[i][j-1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1636 if(path[i][j-1]) v +=gap_open; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1637 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1638 if(v>=h) j--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1639 else i--; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1640 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1641 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1642 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1643 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1644 void parameter_set4search(const int xlen, const int ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1645 double &D0_MIN, double &Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1646 double &score_d8, double &d0, double &d0_search, double &dcu0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1647 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1648 //parameter initilization for searching: D0_MIN, Lnorm, d0, d0_search, score_d8 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1649 D0_MIN=0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1650 dcu0=4.25; //update 3.85-->4.25 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1651 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1652 Lnorm=getmin(xlen, ylen); //normaliz TMscore by this in searching |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1653 if (Lnorm<=19) //update 15-->19 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1654 d0=0.168; //update 0.5-->0.168 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1655 else d0=(1.24*pow((Lnorm*1.0-15), 1.0/3)-1.8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1656 D0_MIN=d0+0.8; //this should be moved to above |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1657 d0=D0_MIN; //update: best for search |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1658 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1659 d0_search=d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1660 if (d0_search>8) d0_search=8; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1661 if (d0_search<4.5) d0_search=4.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1662 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1663 score_d8=1.5*pow(Lnorm*1.0, 0.3)+3.5; //remove pairs with dis>d8 during search & final |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1664 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1665 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1666 void parameter_set4final_C3prime(const double len, double &D0_MIN, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1667 double &Lnorm, double &d0, double &d0_search) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1668 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1669 D0_MIN=0.3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1670 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1671 Lnorm=len; //normaliz TMscore by this in searching |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1672 if(Lnorm<=11) d0=0.3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1673 else if(Lnorm>11&&Lnorm<=15) d0=0.4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1674 else if(Lnorm>15&&Lnorm<=19) d0=0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1675 else if(Lnorm>19&&Lnorm<=23) d0=0.6; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1676 else if(Lnorm>23&&Lnorm<30) d0=0.7; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1677 else d0=(0.6*pow((Lnorm*1.0-0.5), 1.0/2)-2.5); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1678 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1679 d0_search=d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1680 if (d0_search>8) d0_search=8; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1681 if (d0_search<4.5) d0_search=4.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1682 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1683 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1684 void parameter_set4final(const double len, double &D0_MIN, double &Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1685 double &d0, double &d0_search, const int mol_type) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1686 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1687 if (mol_type>0) // RNA |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1688 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1689 parameter_set4final_C3prime(len, D0_MIN, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1690 d0, d0_search); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1691 return; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1692 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1693 D0_MIN=0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1694 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1695 Lnorm=len; //normaliz TMscore by this in searching |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1696 if (Lnorm<=21) d0=0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1697 else d0=(1.24*pow((Lnorm*1.0-15), 1.0/3)-1.8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1698 if (d0<D0_MIN) d0=D0_MIN; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1699 d0_search=d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1700 if (d0_search>8) d0_search=8; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1701 if (d0_search<4.5) d0_search=4.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1702 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1703 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1704 void parameter_set4scale(const int len, const double d_s, double &Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1705 double &d0, double &d0_search) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1706 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1707 d0=d_s; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1708 Lnorm=len; //normaliz TMscore by this in searching |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1709 d0_search=d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1710 if (d0_search>8) d0_search=8; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1711 if (d0_search<4.5) d0_search=4.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1712 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1713 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1714 // 1, collect those residues with dis<d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1715 // 2, calculate TMscore |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1716 int score_fun8( double **xa, double **ya, int n_ali, double d, int i_ali[], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1717 double *score1, int score_sum_method, const double Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1718 const double score_d8, const double d0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1719 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1720 double score_sum=0, di; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1721 double d_tmp=d*d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1722 double d02=d0*d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1723 double score_d8_cut = score_d8*score_d8; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1724 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1725 int i, n_cut, inc=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1726 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1727 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1728 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1729 n_cut=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1730 score_sum=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1731 for(i=0; i<n_ali; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1732 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1733 di = dist(xa[i], ya[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1734 if(di<d_tmp) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1735 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1736 i_ali[n_cut]=i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1737 n_cut++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1738 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1739 if(score_sum_method==8) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1740 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1741 if(di<=score_d8_cut) score_sum += 1/(1+di/d02); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1742 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1743 else score_sum += 1/(1+di/d02); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1744 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1745 //there are not enough feasible pairs, reliefe the threshold |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1746 if(n_cut<3 && n_ali>3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1747 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1748 inc++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1749 double dinc=(d+inc*0.5); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1750 d_tmp = dinc * dinc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1751 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1752 else break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1753 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1754 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1755 *score1=score_sum/Lnorm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1756 return n_cut; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1757 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1758 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1759 int score_fun8_standard(double **xa, double **ya, int n_ali, double d, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1760 int i_ali[], double *score1, int score_sum_method, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1761 double score_d8, double d0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1762 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1763 double score_sum = 0, di; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1764 double d_tmp = d*d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1765 double d02 = d0*d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1766 double score_d8_cut = score_d8*score_d8; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1767 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1768 int i, n_cut, inc = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1769 while (1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1770 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1771 n_cut = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1772 score_sum = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1773 for (i = 0; i<n_ali; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1774 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1775 di = dist(xa[i], ya[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1776 if (di<d_tmp) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1777 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1778 i_ali[n_cut] = i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1779 n_cut++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1780 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1781 if (score_sum_method == 8) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1782 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1783 if (di <= score_d8_cut) score_sum += 1 / (1 + di / d02); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1784 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1785 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1786 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1787 score_sum += 1 / (1 + di / d02); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1788 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1789 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1790 //there are not enough feasible pairs, reliefe the threshold |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1791 if (n_cut<3 && n_ali>3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1792 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1793 inc++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1794 double dinc = (d + inc*0.5); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1795 d_tmp = dinc * dinc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1796 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1797 else break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1798 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1799 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1800 *score1 = score_sum / n_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1801 return n_cut; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1802 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1803 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1804 double TMscore8_search(double **r1, double **r2, double **xtm, double **ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1805 double **xt, int Lali, double t0[3], double u0[3][3], int simplify_step, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1806 int score_sum_method, double *Rcomm, double local_d0_search, double Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1807 double score_d8, double d0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1808 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1809 int i, m; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1810 double score_max, score, rmsd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1811 const int kmax=Lali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1812 int k_ali[kmax], ka, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1813 double t[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1814 double u[3][3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1815 double d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1816 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1817 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1818 //iterative parameters |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1819 int n_it=20; //maximum number of iterations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1820 int n_init_max=6; //maximum number of different fragment length |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1821 int L_ini[n_init_max]; //fragment lengths, Lali, Lali/2, Lali/4 ... 4 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1822 int L_ini_min=4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1823 if(Lali<L_ini_min) L_ini_min=Lali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1824 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1825 int n_init=0, i_init; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1826 for(i=0; i<n_init_max-1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1827 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1828 n_init++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1829 L_ini[i]=(int) (Lali/pow(2.0, (double) i)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1830 if(L_ini[i]<=L_ini_min) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1831 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1832 L_ini[i]=L_ini_min; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1833 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1834 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1835 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1836 if(i==n_init_max-1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1837 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1838 n_init++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1839 L_ini[i]=L_ini_min; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1840 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1841 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1842 score_max=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1843 //find the maximum score starting from local structures superposition |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1844 int i_ali[kmax], n_cut; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1845 int L_frag; //fragment length |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1846 int iL_max; //maximum starting postion for the fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1847 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1848 for(i_init=0; i_init<n_init; i_init++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1849 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1850 L_frag=L_ini[i_init]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1851 iL_max=Lali-L_frag; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1852 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1853 i=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1854 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1855 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1856 //extract the fragment starting from position i |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1857 ka=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1858 for(k=0; k<L_frag; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1859 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1860 int kk=k+i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1861 r1[k][0]=xtm[kk][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1862 r1[k][1]=xtm[kk][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1863 r1[k][2]=xtm[kk][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1864 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1865 r2[k][0]=ytm[kk][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1866 r2[k][1]=ytm[kk][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1867 r2[k][2]=ytm[kk][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1868 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1869 k_ali[ka]=kk; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1870 ka++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1871 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1872 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1873 //extract rotation matrix based on the fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1874 Kabsch(r1, r2, L_frag, 1, &rmsd, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1875 if (simplify_step != 1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1876 *Rcomm = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1877 do_rotation(xtm, xt, Lali, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1878 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1879 //get subsegment of this fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1880 d = local_d0_search - 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1881 n_cut=score_fun8(xt, ytm, Lali, d, i_ali, &score, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1882 score_sum_method, Lnorm, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1883 if(score>score_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1884 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1885 score_max=score; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1886 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1887 //save the rotation matrix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1888 for(k=0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1889 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1890 t0[k]=t[k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1891 u0[k][0]=u[k][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1892 u0[k][1]=u[k][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1893 u0[k][2]=u[k][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1894 } |
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 //try to extend the alignment iteratively |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1898 d = local_d0_search + 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1899 for(int it=0; it<n_it; it++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1900 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1901 ka=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1902 for(k=0; k<n_cut; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1903 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1904 m=i_ali[k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1905 r1[k][0]=xtm[m][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1906 r1[k][1]=xtm[m][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1907 r1[k][2]=xtm[m][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1908 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1909 r2[k][0]=ytm[m][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1910 r2[k][1]=ytm[m][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1911 r2[k][2]=ytm[m][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1912 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1913 k_ali[ka]=m; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1914 ka++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1915 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1916 //extract rotation matrix based on the fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1917 Kabsch(r1, r2, n_cut, 1, &rmsd, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1918 do_rotation(xtm, xt, Lali, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1919 n_cut=score_fun8(xt, ytm, Lali, d, i_ali, &score, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1920 score_sum_method, Lnorm, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1921 if(score>score_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1922 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1923 score_max=score; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1924 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1925 //save the rotation matrix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1926 for(k=0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1927 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1928 t0[k]=t[k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1929 u0[k][0]=u[k][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1930 u0[k][1]=u[k][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1931 u0[k][2]=u[k][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1932 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1933 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1934 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1935 //check if it converges |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1936 if(n_cut==ka) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1937 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1938 for(k=0; k<n_cut; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1939 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1940 if(i_ali[k]!=k_ali[k]) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1941 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1942 if(k==n_cut) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1943 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1944 } //for iteration |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1945 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1946 if(i<iL_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1947 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1948 i=i+simplify_step; //shift the fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1949 if(i>iL_max) i=iL_max; //do this to use the last missed fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1950 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1951 else if(i>=iL_max) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1952 }//while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1953 //end of one fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1954 }//for(i_init |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1955 return score_max; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1956 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1957 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1958 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1959 double TMscore8_search_standard( double **r1, double **r2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1960 double **xtm, double **ytm, double **xt, int Lali, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1961 double t0[3], double u0[3][3], int simplify_step, int score_sum_method, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1962 double *Rcomm, double local_d0_search, double score_d8, double d0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1963 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1964 int i, m; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1965 double score_max, score, rmsd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1966 const int kmax = Lali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1967 int k_ali[kmax], ka, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1968 double t[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1969 double u[3][3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1970 double d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1971 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1972 //iterative parameters |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1973 int n_it = 20; //maximum number of iterations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1974 int n_init_max = 6; //maximum number of different fragment length |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1975 int L_ini[n_init_max]; //fragment lengths, Lali, Lali/2, Lali/4 ... 4 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1976 int L_ini_min = 4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1977 if (Lali<L_ini_min) L_ini_min = Lali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1978 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1979 int n_init = 0, i_init; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1980 for (i = 0; i<n_init_max - 1; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1981 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1982 n_init++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1983 L_ini[i] = (int)(Lali / pow(2.0, (double)i)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1984 if (L_ini[i] <= L_ini_min) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1985 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1986 L_ini[i] = L_ini_min; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1987 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1988 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1989 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1990 if (i == n_init_max - 1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1991 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1992 n_init++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1993 L_ini[i] = L_ini_min; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1994 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1995 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1996 score_max = -1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1997 //find the maximum score starting from local structures superposition |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1998 int i_ali[kmax], n_cut; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
1999 int L_frag; //fragment length |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2000 int iL_max; //maximum starting postion for the fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2001 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2002 for (i_init = 0; i_init<n_init; i_init++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2003 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2004 L_frag = L_ini[i_init]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2005 iL_max = Lali - L_frag; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2006 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2007 i = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2008 while (1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2009 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2010 //extract the fragment starting from position i |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2011 ka = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2012 for (k = 0; k<L_frag; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2013 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2014 int kk = k + i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2015 r1[k][0] = xtm[kk][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2016 r1[k][1] = xtm[kk][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2017 r1[k][2] = xtm[kk][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2018 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2019 r2[k][0] = ytm[kk][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2020 r2[k][1] = ytm[kk][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2021 r2[k][2] = ytm[kk][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2022 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2023 k_ali[ka] = kk; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2024 ka++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2025 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2026 //extract rotation matrix based on the fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2027 Kabsch(r1, r2, L_frag, 1, &rmsd, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2028 if (simplify_step != 1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2029 *Rcomm = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2030 do_rotation(xtm, xt, Lali, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2031 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2032 //get subsegment of this fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2033 d = local_d0_search - 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2034 n_cut = score_fun8_standard(xt, ytm, Lali, d, i_ali, &score, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2035 score_sum_method, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2036 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2037 if (score>score_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2038 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2039 score_max = score; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2040 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2041 //save the rotation matrix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2042 for (k = 0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2043 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2044 t0[k] = t[k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2045 u0[k][0] = u[k][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2046 u0[k][1] = u[k][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2047 u0[k][2] = u[k][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2048 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2049 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2050 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2051 //try to extend the alignment iteratively |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2052 d = local_d0_search + 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2053 for (int it = 0; it<n_it; it++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2054 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2055 ka = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2056 for (k = 0; k<n_cut; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2057 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2058 m = i_ali[k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2059 r1[k][0] = xtm[m][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2060 r1[k][1] = xtm[m][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2061 r1[k][2] = xtm[m][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2062 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2063 r2[k][0] = ytm[m][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2064 r2[k][1] = ytm[m][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2065 r2[k][2] = ytm[m][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2066 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2067 k_ali[ka] = m; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2068 ka++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2069 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2070 //extract rotation matrix based on the fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2071 Kabsch(r1, r2, n_cut, 1, &rmsd, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2072 do_rotation(xtm, xt, Lali, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2073 n_cut = score_fun8_standard(xt, ytm, Lali, d, i_ali, &score, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2074 score_sum_method, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2075 if (score>score_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2076 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2077 score_max = score; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2078 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2079 //save the rotation matrix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2080 for (k = 0; k<3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2081 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2082 t0[k] = t[k]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2083 u0[k][0] = u[k][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2084 u0[k][1] = u[k][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2085 u0[k][2] = u[k][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2086 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2087 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2088 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2089 //check if it converges |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2090 if (n_cut == ka) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2091 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2092 for (k = 0; k<n_cut; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2093 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2094 if (i_ali[k] != k_ali[k]) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2095 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2096 if (k == n_cut) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2097 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2098 } //for iteration |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2099 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2100 if (i<iL_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2101 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2102 i = i + simplify_step; //shift the fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2103 if (i>iL_max) i = iL_max; //do this to use the last missed fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2104 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2105 else if (i >= iL_max) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2106 }//while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2107 //end of one fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2108 }//for(i_init |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2109 return score_max; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2110 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2111 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2112 //Comprehensive TMscore search engine |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2113 // input: two vector sets: x, y |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2114 // an alignment invmap0[] between x and y |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2115 // simplify_step: 1 or 40 or other integers |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2116 // score_sum_method: 0 for score over all pairs |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2117 // 8 for socre over the pairs with dist<score_d8 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2118 // output: the best rotaion matrix t, u that results in highest TMscore |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2119 double detailed_search(double **r1, double **r2, double **xtm, double **ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2120 double **xt, double **x, double **y, int xlen, int ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2121 int invmap0[], double t[3], double u[3][3], int simplify_step, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2122 int score_sum_method, double local_d0_search, double Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2123 double score_d8, double d0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2124 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2125 //x is model, y is template, try to superpose onto y |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2126 int i, j, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2127 double tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2128 double rmsd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2129 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2130 k=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2131 for(i=0; i<ylen; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2132 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2133 j=invmap0[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2134 if(j>=0) //aligned |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2135 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2136 xtm[k][0]=x[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2137 xtm[k][1]=x[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2138 xtm[k][2]=x[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2139 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2140 ytm[k][0]=y[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2141 ytm[k][1]=y[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2142 ytm[k][2]=y[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2143 k++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2144 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2145 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2146 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2147 //detailed search 40-->1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2148 tmscore = TMscore8_search(r1, r2, xtm, ytm, xt, k, t, u, simplify_step, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2149 score_sum_method, &rmsd, local_d0_search, Lnorm, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2150 return tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2151 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2152 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2153 double detailed_search_standard( double **r1, double **r2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2154 double **xtm, double **ytm, double **xt, double **x, double **y, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2155 int xlen, int ylen, int invmap0[], double t[3], double u[3][3], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2156 int simplify_step, int score_sum_method, double local_d0_search, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2157 const bool& bNormalize, double Lnorm, double score_d8, double d0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2158 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2159 //x is model, y is template, try to superpose onto y |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2160 int i, j, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2161 double tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2162 double rmsd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2163 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2164 k=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2165 for(i=0; i<ylen; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2166 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2167 j=invmap0[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2168 if(j>=0) //aligned |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2169 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2170 xtm[k][0]=x[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2171 xtm[k][1]=x[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2172 xtm[k][2]=x[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2173 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2174 ytm[k][0]=y[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2175 ytm[k][1]=y[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2176 ytm[k][2]=y[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2177 k++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2178 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2179 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2180 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2181 //detailed search 40-->1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2182 tmscore = TMscore8_search_standard( r1, r2, xtm, ytm, xt, k, t, u, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2183 simplify_step, score_sum_method, &rmsd, local_d0_search, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2184 if (bNormalize)// "-i", to use standard_TMscore, then bNormalize=true, else bNormalize=false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2185 tmscore = tmscore * k / Lnorm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2186 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2187 return tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2188 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2189 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2190 //compute the score quickly in three iterations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2191 double get_score_fast( double **r1, double **r2, double **xtm, double **ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2192 double **x, double **y, int xlen, int ylen, int invmap[], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2193 double d0, double d0_search, double t[3], double u[3][3]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2194 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2195 double rms, tmscore, tmscore1, tmscore2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2196 int i, j, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2197 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2198 k=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2199 for(j=0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2200 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2201 i=invmap[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2202 if(i>=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2203 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2204 r1[k][0]=x[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2205 r1[k][1]=x[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2206 r1[k][2]=x[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2207 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2208 r2[k][0]=y[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2209 r2[k][1]=y[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2210 r2[k][2]=y[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2211 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2212 xtm[k][0]=x[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2213 xtm[k][1]=x[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2214 xtm[k][2]=x[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2215 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2216 ytm[k][0]=y[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2217 ytm[k][1]=y[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2218 ytm[k][2]=y[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2219 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2220 k++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2221 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2222 else if(i!=-1) PrintErrorAndQuit("Wrong map!\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2223 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2224 Kabsch(r1, r2, k, 1, &rms, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2225 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2226 //evaluate score |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2227 double di; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2228 const int len=k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2229 double dis[len]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2230 double d00=d0_search; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2231 double d002=d00*d00; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2232 double d02=d0*d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2233 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2234 int n_ali=k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2235 double xrot[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2236 tmscore=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2237 for(k=0; k<n_ali; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2238 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2239 transform(t, u, &xtm[k][0], xrot); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2240 di=dist(xrot, &ytm[k][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2241 dis[k]=di; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2242 tmscore += 1/(1+di/d02); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2243 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2244 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2245 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2246 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2247 //second iteration |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2248 double d002t=d002; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2249 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2250 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2251 j=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2252 for(k=0; k<n_ali; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2253 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2254 if(dis[k]<=d002t) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2255 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2256 r1[j][0]=xtm[k][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2257 r1[j][1]=xtm[k][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2258 r1[j][2]=xtm[k][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2259 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2260 r2[j][0]=ytm[k][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2261 r2[j][1]=ytm[k][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2262 r2[j][2]=ytm[k][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2263 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2264 j++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2265 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2266 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2267 //there are not enough feasible pairs, relieve the threshold |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2268 if(j<3 && n_ali>3) d002t += 0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2269 else break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2270 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2271 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2272 if(n_ali!=j) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2273 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2274 Kabsch(r1, r2, j, 1, &rms, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2275 tmscore1=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2276 for(k=0; k<n_ali; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2277 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2278 transform(t, u, &xtm[k][0], xrot); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2279 di=dist(xrot, &ytm[k][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2280 dis[k]=di; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2281 tmscore1 += 1/(1+di/d02); |
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 //third iteration |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2285 d002t=d002+1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2286 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2287 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2288 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2289 j=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2290 for(k=0; k<n_ali; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2291 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2292 if(dis[k]<=d002t) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2293 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2294 r1[j][0]=xtm[k][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2295 r1[j][1]=xtm[k][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2296 r1[j][2]=xtm[k][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2297 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2298 r2[j][0]=ytm[k][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2299 r2[j][1]=ytm[k][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2300 r2[j][2]=ytm[k][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2301 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2302 j++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2303 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2304 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2305 //there are not enough feasible pairs, relieve the threshold |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2306 if(j<3 && n_ali>3) d002t += 0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2307 else break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2308 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2309 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2310 //evaluate the score |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2311 Kabsch(r1, r2, j, 1, &rms, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2312 tmscore2=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2313 for(k=0; k<n_ali; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2314 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2315 transform(t, u, &xtm[k][0], xrot); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2316 di=dist(xrot, &ytm[k][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2317 tmscore2 += 1/(1+di/d02); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2318 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2319 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2320 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2321 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2322 tmscore1=tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2323 tmscore2=tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2324 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2325 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2326 if(tmscore1>=tmscore) tmscore=tmscore1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2327 if(tmscore2>=tmscore) tmscore=tmscore2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2328 return tmscore; // no need to normalize this score because it will not be used for latter scoring |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2329 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2330 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2331 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2332 //perform gapless threading to find the best initial alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2333 //input: x, y, xlen, ylen |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2334 //output: y2x0 stores the best alignment: e.g., |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2335 //y2x0[j]=i means: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2336 //the jth element in y is aligned to the ith element in x if i>=0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2337 //the jth element in y is aligned to a gap in x if i==-1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2338 double get_initial(double **r1, double **r2, double **xtm, double **ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2339 double **x, double **y, int xlen, int ylen, int *y2x, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2340 double d0, double d0_search, const bool fast_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2341 double t[3], double u[3][3]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2342 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2343 int min_len=getmin(xlen, ylen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2344 if(min_len<3) PrintErrorAndQuit("Sequence is too short <3!\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2345 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2346 int min_ali= min_len/2; //minimum size of considered fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2347 if(min_ali<=5) min_ali=5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2348 int n1, n2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2349 n1 = -ylen+min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2350 n2 = xlen-min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2351 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2352 int i, j, k, k_best; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2353 double tmscore, tmscore_max=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2354 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2355 k_best=n1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2356 for(k=n1; k<=n2; k+=(fast_opt)?5:1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2357 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2358 //get the map |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2359 for(j=0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2360 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2361 i=j+k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2362 if(i>=0 && i<xlen) y2x[j]=i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2363 else y2x[j]=-1; |
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 //evaluate the map quickly in three iterations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2367 //this is not real tmscore, it is used to evaluate the goodness of the initial alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2368 tmscore=get_score_fast(r1, r2, xtm, ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2369 x, y, xlen, ylen, y2x, d0,d0_search, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2370 if(tmscore>=tmscore_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2371 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2372 tmscore_max=tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2373 k_best=k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2374 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2375 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2376 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2377 //extract the best map |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2378 k=k_best; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2379 for(j=0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2380 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2381 i=j+k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2382 if(i>=0 && i<xlen) y2x[j]=i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2383 else y2x[j]=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2384 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2385 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2386 return tmscore_max; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2387 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2388 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2389 void smooth(int *sec, int len) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2390 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2391 int i, j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2392 //smooth single --x-- => ----- |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2393 for (i=2; i<len-2; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2394 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2395 if(sec[i]==2 || sec[i]==4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2396 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2397 j=sec[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2398 if (sec[i-2]!=j && sec[i-1]!=j && sec[i+1]!=j && sec[i+2]!=j) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2399 sec[i]=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2400 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2401 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2402 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2403 // smooth double |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2404 // --xx-- => ------ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2405 for (i=0; i<len-5; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2406 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2407 //helix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2408 if (sec[i]!=2 && sec[i+1]!=2 && sec[i+2]==2 && sec[i+3]==2 && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2409 sec[i+4]!=2 && sec[i+5]!= 2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2410 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2411 sec[i+2]=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2412 sec[i+3]=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2413 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2414 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2415 //beta |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2416 if (sec[i]!=4 && sec[i+1]!=4 && sec[i+2]==4 && sec[i+3]==4 && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2417 sec[i+4]!=4 && sec[i+5]!= 4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2418 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2419 sec[i+2]=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2420 sec[i+3]=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2421 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2422 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2423 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2424 //smooth connect |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2425 for (i=0; i<len-2; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2426 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2427 if (sec[i]==2 && sec[i+1]!=2 && sec[i+2]==2) sec[i+1]=2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2428 else if(sec[i]==4 && sec[i+1]!=4 && sec[i+2]==4) sec[i+1]=4; |
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 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2433 char sec_str(double dis13, double dis14, double dis15, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2434 double dis24, double dis25, double dis35) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2435 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2436 char s='C'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2437 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2438 double delta=2.1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2439 if (fabs(dis15-6.37)<delta && fabs(dis14-5.18)<delta && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2440 fabs(dis25-5.18)<delta && fabs(dis13-5.45)<delta && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2441 fabs(dis24-5.45)<delta && fabs(dis35-5.45)<delta) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2442 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2443 s='H'; //helix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2444 return s; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2445 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2446 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2447 delta=1.42; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2448 if (fabs(dis15-13 )<delta && fabs(dis14-10.4)<delta && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2449 fabs(dis25-10.4)<delta && fabs(dis13-6.1 )<delta && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2450 fabs(dis24-6.1 )<delta && fabs(dis35-6.1 )<delta) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2451 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2452 s='E'; //strand |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2453 return s; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2454 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2455 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2456 if (dis15 < 8) s='T'; //turn |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2457 return s; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2458 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2459 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2460 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2461 /* secondary stucture assignment for protein: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2462 * 1->coil, 2->helix, 3->turn, 4->strand */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2463 void make_sec(double **x, int len, char *sec) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2464 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2465 int j1, j2, j3, j4, j5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2466 double d13, d14, d15, d24, d25, d35; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2467 for(int i=0; i<len; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2468 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2469 sec[i]='C'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2470 j1=i-2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2471 j2=i-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2472 j3=i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2473 j4=i+1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2474 j5=i+2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2475 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2476 if(j1>=0 && j5<len) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2477 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2478 d13=sqrt(dist(x[j1], x[j3])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2479 d14=sqrt(dist(x[j1], x[j4])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2480 d15=sqrt(dist(x[j1], x[j5])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2481 d24=sqrt(dist(x[j2], x[j4])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2482 d25=sqrt(dist(x[j2], x[j5])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2483 d35=sqrt(dist(x[j3], x[j5])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2484 sec[i]=sec_str(d13, d14, d15, d24, d25, d35); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2485 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2486 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2487 sec[len]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2488 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2489 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2490 //get initial alignment from secondary structure alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2491 //input: x, y, xlen, ylen |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2492 //output: y2x stores the best alignment: e.g., |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2493 //y2x[j]=i means: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2494 //the jth element in y is aligned to the ith element in x if i>=0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2495 //the jth element in y is aligned to a gap in x if i==-1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2496 void get_initial_ss(bool **path, double **val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2497 const char *secx, const char *secy, int xlen, int ylen, int *y2x) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2498 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2499 double gap_open=-1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2500 NWDP_TM(path, val, secx, secy, xlen, ylen, gap_open, y2x); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2501 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2502 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2503 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2504 // get_initial5 in TMalign fortran, get_initial_local in TMalign c by yangji |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2505 //get initial alignment of local structure superposition |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2506 //input: x, y, xlen, ylen |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2507 //output: y2x stores the best alignment: e.g., |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2508 //y2x[j]=i means: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2509 //the jth element in y is aligned to the ith element in x if i>=0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2510 //the jth element in y is aligned to a gap in x if i==-1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2511 bool get_initial5( double **r1, double **r2, double **xtm, double **ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2512 bool **path, double **val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2513 double **x, double **y, int xlen, int ylen, int *y2x, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2514 double d0, double d0_search, const bool fast_opt, const double D0_MIN) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2515 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2516 double GL, rmsd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2517 double t[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2518 double u[3][3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2519 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2520 double d01 = d0 + 1.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2521 if (d01 < D0_MIN) d01 = D0_MIN; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2522 double d02 = d01*d01; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2523 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2524 double GLmax = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2525 int aL = getmin(xlen, ylen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2526 int *invmap = new int[ylen + 1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2527 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2528 // jump on sequence1--------------> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2529 int n_jump1 = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2530 if (xlen > 250) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2531 n_jump1 = 45; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2532 else if (xlen > 200) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2533 n_jump1 = 35; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2534 else if (xlen > 150) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2535 n_jump1 = 25; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2536 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2537 n_jump1 = 15; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2538 if (n_jump1 > (xlen / 3)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2539 n_jump1 = xlen / 3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2540 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2541 // jump on sequence2--------------> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2542 int n_jump2 = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2543 if (ylen > 250) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2544 n_jump2 = 45; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2545 else if (ylen > 200) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2546 n_jump2 = 35; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2547 else if (ylen > 150) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2548 n_jump2 = 25; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2549 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2550 n_jump2 = 15; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2551 if (n_jump2 > (ylen / 3)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2552 n_jump2 = ylen / 3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2553 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2554 // fragment to superimpose--------------> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2555 int n_frag[2] = { 20, 100 }; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2556 if (n_frag[0] > (aL / 3)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2557 n_frag[0] = aL / 3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2558 if (n_frag[1] > (aL / 2)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2559 n_frag[1] = aL / 2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2560 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2561 // start superimpose search--------------> |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2562 if (fast_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2563 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2564 n_jump1*=5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2565 n_jump2*=5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2566 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2567 bool flag = false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2568 for (int i_frag = 0; i_frag < 2; i_frag++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2569 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2570 int m1 = xlen - n_frag[i_frag] + 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2571 int m2 = ylen - n_frag[i_frag] + 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2572 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2573 for (int i = 0; i<m1; i = i + n_jump1) //index starts from 0, different from FORTRAN |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2574 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2575 for (int j = 0; j<m2; j = j + n_jump2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2576 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2577 for (int k = 0; k<n_frag[i_frag]; k++) //fragment in y |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2578 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2579 r1[k][0] = x[k + i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2580 r1[k][1] = x[k + i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2581 r1[k][2] = x[k + i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2582 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2583 r2[k][0] = y[k + j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2584 r2[k][1] = y[k + j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2585 r2[k][2] = y[k + j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2586 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2587 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2588 // superpose the two structures and rotate it |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2589 Kabsch(r1, r2, n_frag[i_frag], 1, &rmsd, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2590 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2591 double gap_open = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2592 NWDP_TM(path, val, x, y, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2593 t, u, d02, gap_open, invmap); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2594 GL = get_score_fast(r1, r2, xtm, ytm, x, y, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2595 invmap, d0, d0_search, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2596 if (GL>GLmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2597 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2598 GLmax = GL; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2599 for (int ii = 0; ii<ylen; ii++) y2x[ii] = invmap[ii]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2600 flag = true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2601 } |
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 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2605 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2606 delete[] invmap; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2607 return flag; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2608 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2609 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2610 void score_matrix_rmsd_sec( double **r1, double **r2, double **score, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2611 const char *secx, const char *secy, double **x, double **y, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2612 int xlen, int ylen, int *y2x, const double D0_MIN, double d0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2613 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2614 double t[3], u[3][3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2615 double rmsd, dij; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2616 double d01=d0+1.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2617 if(d01 < D0_MIN) d01=D0_MIN; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2618 double d02=d01*d01; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2619 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2620 double xx[3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2621 int i, k=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2622 for(int j=0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2623 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2624 i=y2x[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2625 if(i>=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2626 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2627 r1[k][0]=x[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2628 r1[k][1]=x[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2629 r1[k][2]=x[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2630 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2631 r2[k][0]=y[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2632 r2[k][1]=y[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2633 r2[k][2]=y[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2634 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2635 k++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2636 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2637 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2638 Kabsch(r1, r2, k, 1, &rmsd, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2639 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2640 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2641 for(int ii=0; ii<xlen; ii++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2642 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2643 transform(t, u, &x[ii][0], xx); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2644 for(int jj=0; jj<ylen; jj++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2645 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2646 dij=dist(xx, &y[jj][0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2647 if (secx[ii]==secy[jj]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2648 score[ii+1][jj+1] = 1.0/(1+dij/d02) + 0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2649 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2650 score[ii+1][jj+1] = 1.0/(1+dij/d02); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2651 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2652 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2653 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2654 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2655 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2656 //get initial alignment from secondary structure and previous alignments |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2657 //input: x, y, xlen, ylen |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2658 //output: y2x stores the best alignment: e.g., |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2659 //y2x[j]=i means: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2660 //the jth element in y is aligned to the ith element in x if i>=0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2661 //the jth element in y is aligned to a gap in x if i==-1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2662 void get_initial_ssplus(double **r1, double **r2, double **score, bool **path, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2663 double **val, const char *secx, const char *secy, double **x, double **y, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2664 int xlen, int ylen, int *y2x0, int *y2x, const double D0_MIN, double d0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2665 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2666 //create score matrix for DP |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2667 score_matrix_rmsd_sec(r1, r2, score, secx, secy, x, y, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2668 y2x0, D0_MIN,d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2669 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2670 double gap_open=-1.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2671 NWDP_TM(score, path, val, xlen, ylen, gap_open, y2x); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2672 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2673 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2674 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2675 void find_max_frag(double **x, int len, int *start_max, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2676 int *end_max, double dcu0, const bool fast_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2677 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2678 int r_min, fra_min=4; //minimum fragment for search |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2679 if (fast_opt) fra_min=8; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2680 int start; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2681 int Lfr_max=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2682 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2683 r_min= (int) (len*1.0/3.0); //minimum fragment, in case too small protein |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2684 if(r_min > fra_min) r_min=fra_min; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2685 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2686 int inc=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2687 double dcu0_cut=dcu0*dcu0;; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2688 double dcu_cut=dcu0_cut; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2689 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2690 while(Lfr_max < r_min) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2691 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2692 Lfr_max=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2693 int j=1; //number of residues at nf-fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2694 start=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2695 for(int i=1; i<len; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2696 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2697 if(dist(x[i-1], x[i]) < dcu_cut) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2698 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2699 j++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2700 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2701 if(i==(len-1)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2702 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2703 if(j > Lfr_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2704 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2705 Lfr_max=j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2706 *start_max=start; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2707 *end_max=i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2708 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2709 j=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2710 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2711 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2712 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2713 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2714 if(j>Lfr_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2715 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2716 Lfr_max=j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2717 *start_max=start; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2718 *end_max=i-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2719 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2720 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2721 j=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2722 start=i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2723 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2724 }// for i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2725 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2726 if(Lfr_max < r_min) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2727 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2728 inc++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2729 double dinc=pow(1.1, (double) inc) * dcu0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2730 dcu_cut= dinc*dinc; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2731 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2732 }//while <; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2733 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2734 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2735 //perform fragment gapless threading to find the best initial alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2736 //input: x, y, xlen, ylen |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2737 //output: y2x0 stores the best alignment: e.g., |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2738 //y2x0[j]=i means: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2739 //the jth element in y is aligned to the ith element in x if i>=0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2740 //the jth element in y is aligned to a gap in x if i==-1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2741 double get_initial_fgt(double **r1, double **r2, double **xtm, double **ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2742 double **x, double **y, int xlen, int ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2743 int *y2x, double d0, double d0_search, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2744 double dcu0, const bool fast_opt, double t[3], double u[3][3]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2745 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2746 int fra_min=4; //minimum fragment for search |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2747 if (fast_opt) fra_min=8; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2748 int fra_min1=fra_min-1; //cutoff for shift, save time |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2749 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2750 int xstart=0, ystart=0, xend=0, yend=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2751 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2752 find_max_frag(x, xlen, &xstart, &xend, dcu0, fast_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2753 find_max_frag(y, ylen, &ystart, ¥d, dcu0, fast_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2754 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2755 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2756 int Lx = xend-xstart+1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2757 int Ly = yend-ystart+1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2758 int *ifr, *y2x_; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2759 int L_fr=getmin(Lx, Ly); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2760 ifr= new int[L_fr]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2761 y2x_= new int[ylen+1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2762 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2763 //select what piece will be used. The original implement may cause |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2764 //asymetry, but only when xlen==ylen and Lx==Ly |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2765 //if L1=Lfr1 and L2=Lfr2 (normal proteins), it will be the same as initial1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2766 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2767 if(Lx<Ly || (Lx==Ly && xlen<ylen)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2768 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2769 for(int i=0; i<L_fr; i++) ifr[i]=xstart+i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2770 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2771 else if(Lx>Ly || (Lx==Ly && xlen>ylen)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2772 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2773 for(int i=0; i<L_fr; i++) ifr[i]=ystart+i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2774 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2775 else // solve asymetric for 1x5gA vs 2q7nA5 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2776 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2777 /* In this case, L0==xlen==ylen; L_fr==Lx==Ly */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2778 int L0=xlen; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2779 double tmscore, tmscore_max=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2780 int i, j, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2781 int n1, n2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2782 int min_len; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2783 int min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2784 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2785 /* part 1, normalized by xlen */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2786 for(i=0; i<L_fr; i++) ifr[i]=xstart+i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2787 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2788 if(L_fr==L0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2789 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2790 n1= (int)(L0*0.1); //my index starts from 0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2791 n2= (int)(L0*0.89); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2792 j=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2793 for(i=n1; i<= n2; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2794 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2795 ifr[j]=ifr[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2796 j++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2797 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2798 L_fr=j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2799 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2800 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2801 int L1=L_fr; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2802 min_len=getmin(L1, ylen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2803 min_ali= (int) (min_len/2.5); //minimum size of considered fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2804 if(min_ali<=fra_min1) min_ali=fra_min1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2805 n1 = -ylen+min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2806 n2 = L1-min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2807 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2808 for(k=n1; k<=n2; k+=(fast_opt)?3:1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2809 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2810 //get the map |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2811 for(j=0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2812 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2813 i=j+k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2814 if(i>=0 && i<L1) y2x_[j]=ifr[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2815 else y2x_[j]=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2816 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2817 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2818 //evaluate the map quickly in three iterations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2819 tmscore=get_score_fast(r1, r2, xtm, ytm, x, y, xlen, ylen, y2x_, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2820 d0, d0_search, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2821 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2822 if(tmscore>=tmscore_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2823 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2824 tmscore_max=tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2825 for(j=0; j<ylen; j++) y2x[j]=y2x_[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2826 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2827 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2828 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2829 /* part 2, normalized by ylen */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2830 L_fr=Ly; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2831 for(i=0; i<L_fr; i++) ifr[i]=ystart+i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2832 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2833 if (L_fr==L0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2834 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2835 n1= (int)(L0*0.1); //my index starts from 0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2836 n2= (int)(L0*0.89); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2837 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2838 j=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2839 for(i=n1; i<= n2; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2840 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2841 ifr[j]=ifr[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2842 j++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2843 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2844 L_fr=j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2845 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2846 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2847 int L2=L_fr; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2848 min_len=getmin(xlen, L2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2849 min_ali= (int) (min_len/2.5); //minimum size of considered fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2850 if(min_ali<=fra_min1) min_ali=fra_min1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2851 n1 = -L2+min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2852 n2 = xlen-min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2853 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2854 for(k=n1; k<=n2; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2855 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2856 //get the map |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2857 for(j=0; j<ylen; j++) y2x_[j]=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2858 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2859 for(j=0; j<L2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2860 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2861 i=j+k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2862 if(i>=0 && i<xlen) y2x_[ifr[j]]=i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2863 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2864 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2865 //evaluate the map quickly in three iterations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2866 tmscore=get_score_fast(r1, r2, xtm, ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2867 x, y, xlen, ylen, y2x_, d0,d0_search, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2868 if(tmscore>=tmscore_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2869 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2870 tmscore_max=tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2871 for(j=0; j<ylen; j++) y2x[j]=y2x_[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2872 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2873 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2874 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2875 delete [] ifr; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2876 delete [] y2x_; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2877 return tmscore_max; |
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 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2881 int L0=getmin(xlen, ylen); //non-redundant to get_initial1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2882 if(L_fr==L0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2883 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2884 int n1= (int)(L0*0.1); //my index starts from 0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2885 int n2= (int)(L0*0.89); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2886 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2887 int j=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2888 for(int i=n1; i<= n2; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2889 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2890 ifr[j]=ifr[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2891 j++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2892 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2893 L_fr=j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2894 } |
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 //gapless threading for the extracted fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2898 double tmscore, tmscore_max=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2899 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2900 if(Lx<Ly || (Lx==Ly && xlen<=ylen)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2901 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2902 int L1=L_fr; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2903 int min_len=getmin(L1, ylen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2904 int min_ali= (int) (min_len/2.5); //minimum size of considered fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2905 if(min_ali<=fra_min1) min_ali=fra_min1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2906 int n1, n2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2907 n1 = -ylen+min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2908 n2 = L1-min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2909 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2910 int i, j, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2911 for(k=n1; k<=n2; k+=(fast_opt)?3:1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2912 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2913 //get the map |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2914 for(j=0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2915 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2916 i=j+k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2917 if(i>=0 && i<L1) y2x_[j]=ifr[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2918 else y2x_[j]=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2919 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2920 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2921 //evaluate the map quickly in three iterations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2922 tmscore=get_score_fast(r1, r2, xtm, ytm, x, y, xlen, ylen, y2x_, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2923 d0, d0_search, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2924 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2925 if(tmscore>=tmscore_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2926 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2927 tmscore_max=tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2928 for(j=0; j<ylen; j++) y2x[j]=y2x_[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2929 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2930 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2931 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2932 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2933 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2934 int L2=L_fr; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2935 int min_len=getmin(xlen, L2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2936 int min_ali= (int) (min_len/2.5); //minimum size of considered fragment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2937 if(min_ali<=fra_min1) min_ali=fra_min1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2938 int n1, n2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2939 n1 = -L2+min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2940 n2 = xlen-min_ali; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2941 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2942 int i, j, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2943 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2944 for(k=n1; k<=n2; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2945 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2946 //get the map |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2947 for(j=0; j<ylen; j++) y2x_[j]=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2948 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2949 for(j=0; j<L2; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2950 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2951 i=j+k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2952 if(i>=0 && i<xlen) y2x_[ifr[j]]=i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2953 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2954 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2955 //evaluate the map quickly in three iterations |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2956 tmscore=get_score_fast(r1, r2, xtm, ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2957 x, y, xlen, ylen, y2x_, d0,d0_search, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2958 if(tmscore>=tmscore_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2959 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2960 tmscore_max=tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2961 for(j=0; j<ylen; j++) y2x[j]=y2x_[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2962 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2963 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2964 } |
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 delete [] ifr; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2968 delete [] y2x_; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2969 return tmscore_max; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2970 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2971 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2972 //heuristic run of dynamic programing iteratively to find the best alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2973 //input: initial rotation matrix t, u |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2974 // vectors x and y, d0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2975 //output: best alignment that maximizes the TMscore, will be stored in invmap |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2976 double DP_iter(double **r1, double **r2, double **xtm, double **ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2977 double **xt, bool **path, double **val, double **x, double **y, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2978 int xlen, int ylen, double t[3], double u[3][3], int invmap0[], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2979 int g1, int g2, int iteration_max, double local_d0_search, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2980 double D0_MIN, double Lnorm, double d0, double score_d8) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2981 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2982 double gap_open[2]={-0.6, 0}; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2983 double rmsd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2984 int *invmap=new int[ylen+1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2985 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2986 int iteration, i, j, k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2987 double tmscore, tmscore_max, tmscore_old=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2988 int score_sum_method=8, simplify_step=40; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2989 tmscore_max=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2990 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2991 //double d01=d0+1.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2992 double d02=d0*d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2993 for(int g=g1; g<g2; g++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2994 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2995 for(iteration=0; iteration<iteration_max; iteration++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2996 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2997 NWDP_TM(path, val, x, y, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2998 t, u, d02, gap_open[g], invmap); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
2999 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3000 k=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3001 for(j=0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3002 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3003 i=invmap[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3004 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3005 if(i>=0) //aligned |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3006 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3007 xtm[k][0]=x[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3008 xtm[k][1]=x[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3009 xtm[k][2]=x[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3010 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3011 ytm[k][0]=y[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3012 ytm[k][1]=y[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3013 ytm[k][2]=y[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3014 k++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3015 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3016 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3017 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3018 tmscore = TMscore8_search(r1, r2, xtm, ytm, xt, k, t, u, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3019 simplify_step, score_sum_method, &rmsd, local_d0_search, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3020 Lnorm, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3021 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3022 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3023 if(tmscore>tmscore_max) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3024 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3025 tmscore_max=tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3026 for(i=0; i<ylen; i++) invmap0[i]=invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3027 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3028 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3029 if(iteration>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3030 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3031 if(fabs(tmscore_old-tmscore)<0.000001) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3032 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3033 tmscore_old=tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3034 }// for iteration |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3035 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3036 }//for gapopen |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3037 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3038 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3039 delete []invmap; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3040 return tmscore_max; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3041 } |
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 void output_superpose(const string xname, const string yname, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3045 const string fname_super, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3046 double t[3], double u[3][3], const int ter_opt, const int mirror_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3047 const char *seqM, const char *seqxA, const char *seqyA, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3048 const vector<string>&resi_vec1, const vector<string>&resi_vec2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3049 const char *chainID1, const char *chainID2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3050 const int xlen, const int ylen, const double d0A, const int n_ali8, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3051 const double rmsd, const double TM1, const double Liden) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3052 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3053 stringstream buf; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3054 stringstream buf_all; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3055 stringstream buf_atm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3056 stringstream buf_all_atm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3057 stringstream buf_all_atm_lig; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3058 stringstream buf_pdb; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3059 stringstream buf_pymol; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3060 stringstream buf_tm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3061 string line; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3062 double x[3]; // before transform |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3063 double x1[3]; // after transform |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3064 bool after_ter; // true if passed the "TER" line in PDB |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3065 string asym_id; // chain ID |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3066 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3067 buf_tm<<"REMARK TM-align" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3068 <<"\nREMARK Chain 1:"<<setw(11)<<left<<xname+chainID1<<" Size= "<<xlen |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3069 <<"\nREMARK Chain 2:"<<setw(11)<<yname+chainID2<<right<<" Size= "<<ylen |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3070 <<" (TM-score is normalized by "<<setw(4)<<ylen<<", d0=" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3071 <<setiosflags(ios::fixed)<<setprecision(2)<<setw(6)<<d0A<<")" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3072 <<"\nREMARK Aligned length="<<setw(4)<<n_ali8<<", RMSD=" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3073 <<setw(6)<<setiosflags(ios::fixed)<<setprecision(2)<<rmsd |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3074 <<", TM-score="<<setw(7)<<setiosflags(ios::fixed)<<setprecision(5)<<TM1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3075 <<", ID="<<setw(5)<<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3076 <<((n_ali8>0)?Liden/n_ali8:0)<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3077 string rasmol_CA_header="load inline\nselect *A\nwireframe .45\nselect *B\nwireframe .20\nselect all\ncolor white\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3078 string rasmol_cartoon_header="load inline\nselect all\ncartoon\nselect *A\ncolor blue\nselect *B\ncolor red\nselect ligand\nwireframe 0.25\nselect solvent\nspacefill 0.25\nselect all\nexit\n"+buf_tm.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3079 buf<<rasmol_CA_header; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3080 buf_all<<rasmol_CA_header; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3081 buf_atm<<rasmol_cartoon_header; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3082 buf_all_atm<<rasmol_cartoon_header; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3083 buf_all_atm_lig<<rasmol_cartoon_header; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3084 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3085 /* for PDBx/mmCIF only */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3086 map<string,int> _atom_site; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3087 int atom_site_pos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3088 vector<string> line_vec; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3089 string atom; // 4-character atom name |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3090 string AA; // 3-character residue name |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3091 string resi; // 4-character residue sequence number |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3092 string inscode; // 1-character insertion code |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3093 string model_index; // model index |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3094 bool is_mmcif=false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3095 int chain_num=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3096 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3097 /* used for CONECT record of chain1 */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3098 int ca_idx1=0; // all CA atoms |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3099 int lig_idx1=0; // all atoms |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3100 vector <int> idx_vec; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3101 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3102 /* used for CONECT record of chain2 */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3103 int ca_idx2=0; // all CA atoms |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3104 int lig_idx2=0; // all atoms |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3105 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3106 /* extract aligned region */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3107 vector<string> resi_aln1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3108 vector<string> resi_aln2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3109 int i1=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3110 int i2=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3111 int i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3112 for (i=0;i<strlen(seqM);i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3113 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3114 i1+=(seqxA[i]!='-'); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3115 i2+=(seqyA[i]!='-'); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3116 if (seqM[i]==' ') continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3117 resi_aln1.push_back(resi_vec1[i1].substr(0,4)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3118 resi_aln2.push_back(resi_vec2[i2].substr(0,4)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3119 if (seqM[i]!=':') continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3120 buf <<"select "<<resi_aln1.back()<<":A," |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3121 <<resi_aln2.back()<<":B\ncolor red\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3122 buf_all<<"select "<<resi_aln1.back()<<":A," |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3123 <<resi_aln2.back()<<":B\ncolor red\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3124 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3125 buf<<"select all\nexit\n"<<buf_tm.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3126 buf_all<<"select all\nexit\n"<<buf_tm.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3127 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3128 ifstream fin; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3129 /* read first file */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3130 after_ter=false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3131 asym_id=""; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3132 fin.open(xname.c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3133 while (fin.good()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3134 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3135 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3136 if (ter_opt>=3 && line.compare(0,3,"TER")==0) after_ter=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3137 if (is_mmcif==false && line.size()>=54 && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3138 (line.compare(0, 6, "ATOM ")==0 || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3139 line.compare(0, 6, "HETATM")==0)) // PDB format |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3140 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3141 x[0]=atof(line.substr(30,8).c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3142 x[1]=atof(line.substr(38,8).c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3143 x[2]=atof(line.substr(46,8).c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3144 if (mirror_opt) x[2]=-x[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3145 transform(t, u, x, x1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3146 buf_pdb<<line.substr(0,30)<<setiosflags(ios::fixed) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3147 <<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3148 <<setw(8)<<x1[0] <<setw(8)<<x1[1] <<setw(8)<<x1[2] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3149 <<line.substr(54)<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3150 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3151 if (line[16]!='A' && line[16]!=' ') continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3152 if (after_ter && line.compare(0,6,"ATOM ")==0) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3153 lig_idx1++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3154 buf_all_atm_lig<<line.substr(0,6)<<setw(5)<<lig_idx1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3155 <<line.substr(11,9)<<" A"<<line.substr(22,8) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3156 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3157 <<setw(8)<<x1[0]<<setw(8)<<x1[1] <<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3158 if (after_ter || line.compare(0,6,"ATOM ")) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3159 if (ter_opt>=2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3160 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3161 if (ca_idx1 && asym_id.size() && asym_id!=line.substr(21,1)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3162 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3163 after_ter=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3164 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3165 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3166 asym_id=line[21]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3167 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3168 buf_all_atm<<"ATOM "<<setw(5)<<lig_idx1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3169 <<line.substr(11,9)<<" A"<<line.substr(22,8) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3170 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3171 <<setw(8)<<x1[0]<<setw(8)<<x1[1] <<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3172 if (find(resi_aln1.begin(),resi_aln1.end(),line.substr(22,4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3173 )!=resi_aln1.end()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3174 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3175 buf_atm<<"ATOM "<<setw(5)<<lig_idx1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3176 <<line.substr(11,9)<<" A"<<line.substr(22,8) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3177 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3178 <<setw(8)<<x1[0]<<setw(8)<<x1[1] <<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3179 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3180 if (line.substr(12,4)!=" CA ") continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3181 ca_idx1++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3182 buf_all<<"ATOM "<<setw(5)<<ca_idx1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3183 <<" CA "<<line.substr(17,3)<<" A"<<line.substr(22,8) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3184 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3185 <<setw(8)<<x1[0]<<setw(8)<<x1[1]<<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3186 if (find(resi_aln1.begin(),resi_aln1.end(),line.substr(22,4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3187 )==resi_aln1.end()) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3188 buf<<"ATOM "<<setw(5)<<ca_idx1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3189 <<" CA "<<line.substr(17,3)<<" A"<<line.substr(22,8) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3190 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3191 <<setw(8)<<x1[0]<<setw(8)<<x1[1]<<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3192 idx_vec.push_back(ca_idx1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3193 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3194 else if (line.compare(0,5,"loop_")==0) // PDBx/mmCIF |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3195 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3196 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3197 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3198 if (fin.good()) getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3199 else PrintErrorAndQuit("ERROR! Unexpected end of "+xname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3200 if (line.size()) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3201 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3202 if (line.compare(0,11,"_atom_site.")) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3203 _atom_site.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3204 atom_site_pos=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3205 _atom_site[line.substr(11,line.size()-12)]=atom_site_pos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3206 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3207 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3208 if (fin.good()) getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3209 else PrintErrorAndQuit("ERROR! Unexpected end of "+xname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3210 if (line.size()==0) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3211 if (line.compare(0,11,"_atom_site.")) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3212 _atom_site[line.substr(11,line.size()-12)]=++atom_site_pos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3213 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3214 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3215 if (is_mmcif==false) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3216 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3217 buf_pdb.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3218 is_mmcif=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3219 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3220 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3221 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3222 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3223 line_vec.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3224 split(line,line_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3225 if (line_vec[_atom_site["group_PDB"]]!="ATOM" && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3226 line_vec[_atom_site["group_PDB"]]!="HETATM") break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3227 if (_atom_site.count("pdbx_PDB_model_num")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3228 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3229 if (model_index.size() && model_index!= |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3230 line_vec[_atom_site["pdbx_PDB_model_num"]]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3231 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3232 model_index=line_vec[_atom_site["pdbx_PDB_model_num"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3233 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3234 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3235 x[0]=atof(line_vec[_atom_site["Cartn_x"]].c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3236 x[1]=atof(line_vec[_atom_site["Cartn_y"]].c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3237 x[2]=atof(line_vec[_atom_site["Cartn_z"]].c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3238 if (mirror_opt) x[2]=-x[2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3239 transform(t, u, x, x1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3240 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3241 if (_atom_site.count("label_alt_id")==0 || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3242 line_vec[_atom_site["label_alt_id"]]=="." || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3243 line_vec[_atom_site["label_alt_id"]]=="A") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3244 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3245 atom=line_vec[_atom_site["label_atom_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3246 if (atom[0]=='"') atom=atom.substr(1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3247 if (atom.size() && atom[atom.size()-1]=='"') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3248 atom=atom.substr(0,atom.size()-1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3249 if (atom.size()==0) atom=" "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3250 else if (atom.size()==1) atom=" "+atom+" "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3251 else if (atom.size()==2) atom=" "+atom+" "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3252 else if (atom.size()==3) atom=" "+atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3253 else if (atom.size()>=5) atom=atom.substr(0,4); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3254 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3255 AA=line_vec[_atom_site["label_comp_id"]]; // residue name |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3256 if (AA.size()==1) AA=" "+AA; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3257 else if (AA.size()==2) AA=" " +AA; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3258 else if (AA.size()>=4) AA=AA.substr(0,3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3259 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3260 if (_atom_site.count("auth_seq_id")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3261 resi=line_vec[_atom_site["auth_seq_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3262 else resi=line_vec[_atom_site["label_seq_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3263 while (resi.size()<4) resi=' '+resi; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3264 if (resi.size()>4) resi=resi.substr(0,4); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3265 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3266 inscode=' '; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3267 if (_atom_site.count("pdbx_PDB_ins_code") && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3268 line_vec[_atom_site["pdbx_PDB_ins_code"]]!="?") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3269 inscode=line_vec[_atom_site["pdbx_PDB_ins_code"]][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3270 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3271 if (_atom_site.count("auth_asym_id")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3272 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3273 if (ter_opt>=2 && ca_idx1 && asym_id.size() && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3274 asym_id!=line_vec[_atom_site["auth_asym_id"]]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3275 after_ter=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3276 asym_id=line_vec[_atom_site["auth_asym_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3277 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3278 else if (_atom_site.count("label_asym_id")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3279 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3280 if (ter_opt>=2 && ca_idx1 && asym_id.size() && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3281 asym_id!=line_vec[_atom_site["label_asym_id"]]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3282 after_ter=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3283 asym_id=line_vec[_atom_site["label_asym_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3284 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3285 buf_pdb<<left<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3286 <<line_vec[_atom_site["group_PDB"]]<<right |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3287 <<setw(5)<<lig_idx1%100000<<' '<<atom<<' ' |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3288 <<AA<<" "<<asym_id[asym_id.size()-1] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3289 <<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3290 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3291 <<setw(8)<<x1[0] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3292 <<setw(8)<<x1[1] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3293 <<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3294 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3295 if (after_ter==false || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3296 line_vec[_atom_site["group_pdb"]]=="HETATM") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3297 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3298 lig_idx1++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3299 buf_all_atm_lig<<left<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3300 <<line_vec[_atom_site["group_PDB"]]<<right |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3301 <<setw(5)<<lig_idx1%100000<<' '<<atom<<' ' |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3302 <<AA<<" A"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3303 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3304 <<setw(8)<<x1[0] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3305 <<setw(8)<<x1[1] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3306 <<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3307 if (after_ter==false && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3308 line_vec[_atom_site["group_PDB"]]=="ATOM") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3309 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3310 buf_all_atm<<"ATOM "<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3311 <<setw(5)<<lig_idx1%100000<<' '<<atom<<' ' |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3312 <<AA<<" A"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3313 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3314 <<setw(8)<<x1[0] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3315 <<setw(8)<<x1[1] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3316 <<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3317 if (find(resi_aln1.begin(),resi_aln1.end(),resi |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3318 )!=resi_aln1.end()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3319 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3320 buf_atm<<"ATOM "<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3321 <<setw(5)<<lig_idx1%100000<<' ' |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3322 <<atom<<' '<<AA<<" A"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3323 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3324 <<setw(8)<<x1[0] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3325 <<setw(8)<<x1[1] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3326 <<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3327 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3328 if (atom==" CA ") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3329 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3330 ca_idx1++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3331 buf_all<<"ATOM "<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3332 <<setw(5)<<ca_idx1%100000<<" CA " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3333 <<AA<<" A"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3334 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3335 <<setw(8)<<x1[0] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3336 <<setw(8)<<x1[1] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3337 <<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3338 if (find(resi_aln1.begin(),resi_aln1.end(),resi |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3339 )!=resi_aln1.end()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3340 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3341 buf<<"ATOM "<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3342 <<setw(5)<<ca_idx1%100000<<" CA " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3343 <<AA<<" A"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3344 <<setiosflags(ios::fixed)<<setprecision(3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3345 <<setw(8)<<x1[0] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3346 <<setw(8)<<x1[1] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3347 <<setw(8)<<x1[2]<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3348 idx_vec.push_back(ca_idx1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3349 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3350 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3351 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3352 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3353 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3354 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3355 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3356 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3357 if (fin.good()) getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3358 else break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3359 if (line.size()) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3360 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3361 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3362 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3363 else if (line.size() && is_mmcif==false) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3364 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3365 buf_pdb<<line<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3366 if (ter_opt>=1 && line.compare(0,3,"END")==0) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3367 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3368 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3369 fin.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3370 buf<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3371 buf_all<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3372 buf_atm<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3373 buf_all_atm<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3374 buf_all_atm_lig<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3375 for (i=1;i<ca_idx1;i++) buf_all<<"CONECT" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3376 <<setw(5)<<i%100000<<setw(5)<<(i+1)%100000<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3377 for (i=1;i<idx_vec.size();i++) buf<<"CONECT" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3378 <<setw(5)<<idx_vec[i-1]%100000<<setw(5)<<idx_vec[i]%100000<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3379 idx_vec.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3380 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3381 /* read second file */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3382 after_ter=false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3383 asym_id=""; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3384 fin.open(yname.c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3385 while (fin.good()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3386 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3387 getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3388 if (ter_opt>=3 && line.compare(0,3,"TER")==0) after_ter=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3389 if (line.size()>=54 && (line.compare(0, 6, "ATOM ")==0 || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3390 line.compare(0, 6, "HETATM")==0)) // PDB format |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3391 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3392 if (line[16]!='A' && line[16]!=' ') continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3393 if (after_ter && line.compare(0,6,"ATOM ")==0) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3394 lig_idx2++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3395 buf_all_atm_lig<<line.substr(0,6)<<setw(5)<<lig_idx1+lig_idx2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3396 <<line.substr(11,9)<<" B"<<line.substr(22,32)<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3397 if (after_ter || line.compare(0,6,"ATOM ")) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3398 if (ter_opt>=2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3399 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3400 if (ca_idx2 && asym_id.size() && asym_id!=line.substr(21,1)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3401 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3402 after_ter=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3403 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3404 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3405 asym_id=line[21]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3406 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3407 buf_all_atm<<"ATOM "<<setw(5)<<lig_idx1+lig_idx2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3408 <<line.substr(11,9)<<" B"<<line.substr(22,32)<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3409 if (find(resi_aln2.begin(),resi_aln2.end(),line.substr(22,4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3410 )!=resi_aln2.end()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3411 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3412 buf_atm<<"ATOM "<<setw(5)<<lig_idx1+lig_idx2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3413 <<line.substr(11,9)<<" B"<<line.substr(22,32)<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3414 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3415 if (line.substr(12,4)!=" CA ") continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3416 ca_idx2++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3417 buf_all<<"ATOM "<<setw(5)<<ca_idx1+ca_idx2<<" CA " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3418 <<line.substr(17,3)<<" B"<<line.substr(22,32)<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3419 if (find(resi_aln2.begin(),resi_aln2.end(),line.substr(22,4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3420 )==resi_aln2.end()) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3421 buf<<"ATOM "<<setw(5)<<ca_idx1+ca_idx2<<" CA " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3422 <<line.substr(17,3)<<" B"<<line.substr(22,32)<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3423 idx_vec.push_back(ca_idx1+ca_idx2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3424 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3425 else if (line.compare(0,5,"loop_")==0) // PDBx/mmCIF |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3426 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3427 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3428 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3429 if (fin.good()) getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3430 else PrintErrorAndQuit("ERROR! Unexpected end of "+yname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3431 if (line.size()) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3432 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3433 if (line.compare(0,11,"_atom_site.")) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3434 _atom_site.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3435 atom_site_pos=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3436 _atom_site[line.substr(11,line.size()-12)]=atom_site_pos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3437 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3438 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3439 if (fin.good()) getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3440 else PrintErrorAndQuit("ERROR! Unexpected end of "+yname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3441 if (line.size()==0) continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3442 if (line.compare(0,11,"_atom_site.")) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3443 _atom_site[line.substr(11,line.size()-12)]=++atom_site_pos; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3444 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3445 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3446 while(1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3447 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3448 line_vec.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3449 split(line,line_vec); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3450 if (line_vec[_atom_site["group_PDB"]]!="ATOM" && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3451 line_vec[_atom_site["group_PDB"]]!="HETATM") break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3452 if (_atom_site.count("pdbx_PDB_model_num")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3453 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3454 if (model_index.size() && model_index!= |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3455 line_vec[_atom_site["pdbx_PDB_model_num"]]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3456 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3457 model_index=line_vec[_atom_site["pdbx_PDB_model_num"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3458 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3459 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3460 if (_atom_site.count("label_alt_id")==0 || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3461 line_vec[_atom_site["label_alt_id"]]=="." || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3462 line_vec[_atom_site["label_alt_id"]]=="A") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3463 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3464 atom=line_vec[_atom_site["label_atom_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3465 if (atom[0]=='"') atom=atom.substr(1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3466 if (atom.size() && atom[atom.size()-1]=='"') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3467 atom=atom.substr(0,atom.size()-1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3468 if (atom.size()==0) atom=" "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3469 else if (atom.size()==1) atom=" "+atom+" "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3470 else if (atom.size()==2) atom=" "+atom+" "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3471 else if (atom.size()==3) atom=" "+atom; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3472 else if (atom.size()>=5) atom=atom.substr(0,4); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3473 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3474 AA=line_vec[_atom_site["label_comp_id"]]; // residue name |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3475 if (AA.size()==1) AA=" "+AA; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3476 else if (AA.size()==2) AA=" " +AA; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3477 else if (AA.size()>=4) AA=AA.substr(0,3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3478 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3479 if (_atom_site.count("auth_seq_id")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3480 resi=line_vec[_atom_site["auth_seq_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3481 else resi=line_vec[_atom_site["label_seq_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3482 while (resi.size()<4) resi=' '+resi; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3483 if (resi.size()>4) resi=resi.substr(0,4); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3484 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3485 inscode=' '; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3486 if (_atom_site.count("pdbx_PDB_ins_code") && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3487 line_vec[_atom_site["pdbx_PDB_ins_code"]]!="?") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3488 inscode=line_vec[_atom_site["pdbx_PDB_ins_code"]][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3489 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3490 if (ter_opt>=2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3491 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3492 if (_atom_site.count("auth_asym_id")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3493 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3494 if (ca_idx2 && asym_id.size() && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3495 asym_id!=line_vec[_atom_site["auth_asym_id"]]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3496 after_ter=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3497 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3498 asym_id=line_vec[_atom_site["auth_asym_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3499 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3500 else if (_atom_site.count("label_asym_id")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3501 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3502 if (ca_idx2 && asym_id.size() && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3503 asym_id!=line_vec[_atom_site["label_asym_id"]]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3504 after_ter=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3505 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3506 asym_id=line_vec[_atom_site["label_asym_id"]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3507 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3508 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3509 if (after_ter==false || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3510 line_vec[_atom_site["group_PDB"]]=="HETATM") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3511 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3512 lig_idx2++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3513 buf_all_atm_lig<<left<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3514 <<line_vec[_atom_site["group_PDB"]]<<right |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3515 <<setw(5)<<(lig_idx1+lig_idx2)%100000<<' ' |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3516 <<atom<<' '<<AA<<" B"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3517 <<setw(8)<<line_vec[_atom_site["Cartn_x"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3518 <<setw(8)<<line_vec[_atom_site["Cartn_y"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3519 <<setw(8)<<line_vec[_atom_site["Cartn_z"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3520 <<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3521 if (after_ter==false && |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3522 line_vec[_atom_site["group_PDB"]]=="ATOM") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3523 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3524 buf_all_atm<<"ATOM "<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3525 <<setw(5)<<(lig_idx1+lig_idx2)%100000<<' ' |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3526 <<atom<<' '<<AA<<" B"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3527 <<setw(8)<<line_vec[_atom_site["Cartn_x"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3528 <<setw(8)<<line_vec[_atom_site["Cartn_y"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3529 <<setw(8)<<line_vec[_atom_site["Cartn_z"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3530 <<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3531 if (find(resi_aln2.begin(),resi_aln2.end(),resi |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3532 )!=resi_aln2.end()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3533 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3534 buf_atm<<"ATOM "<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3535 <<setw(5)<<(lig_idx1+lig_idx2)%100000<<' ' |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3536 <<atom<<' '<<AA<<" B"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3537 <<setw(8)<<line_vec[_atom_site["Cartn_x"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3538 <<setw(8)<<line_vec[_atom_site["Cartn_y"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3539 <<setw(8)<<line_vec[_atom_site["Cartn_z"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3540 <<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3541 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3542 if (atom==" CA ") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3543 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3544 ca_idx2++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3545 buf_all<<"ATOM "<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3546 <<setw(5)<<(ca_idx1+ca_idx2)%100000 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3547 <<" CA "<<AA<<" B"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3548 <<setw(8)<<line_vec[_atom_site["Cartn_x"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3549 <<setw(8)<<line_vec[_atom_site["Cartn_y"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3550 <<setw(8)<<line_vec[_atom_site["Cartn_z"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3551 <<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3552 if (find(resi_aln2.begin(),resi_aln2.end(),resi |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3553 )!=resi_aln2.end()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3554 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3555 buf<<"ATOM "<<setw(6) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3556 <<setw(5)<<(ca_idx1+ca_idx2)%100000 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3557 <<" CA "<<AA<<" B"<<resi<<inscode<<" " |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3558 <<setw(8)<<line_vec[_atom_site["Cartn_x"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3559 <<setw(8)<<line_vec[_atom_site["Cartn_y"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3560 <<setw(8)<<line_vec[_atom_site["Cartn_z"]] |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3561 <<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3562 idx_vec.push_back(ca_idx1+ca_idx2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3563 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3564 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3565 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3566 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3567 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3568 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3569 if (fin.good()) getline(fin, line); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3570 else break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3571 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3572 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3573 else if (line.size()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3574 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3575 if (ter_opt>=1 && line.compare(0,3,"END")==0) break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3576 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3577 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3578 fin.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3579 buf<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3580 buf_all<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3581 buf_atm<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3582 buf_all_atm<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3583 buf_all_atm_lig<<"TER\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3584 for (i=ca_idx1+1;i<ca_idx1+ca_idx2;i++) buf_all<<"CONECT" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3585 <<setw(5)<<i%100000<<setw(5)<<(i+1)%100000<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3586 for (i=1;i<idx_vec.size();i++) buf<<"CONECT" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3587 <<setw(5)<<idx_vec[i-1]%100000<<setw(5)<<idx_vec[i]%100000<<'\n'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3588 idx_vec.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3589 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3590 /* write pymol script */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3591 ofstream fp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3592 vector<string> pml_list; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3593 pml_list.push_back(fname_super+""); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3594 pml_list.push_back(fname_super+"_atm"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3595 pml_list.push_back(fname_super+"_all"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3596 pml_list.push_back(fname_super+"_all_atm"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3597 pml_list.push_back(fname_super+"_all_atm_lig"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3598 for (i=0;i<pml_list.size();i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3599 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3600 buf_pymol<<"#!/usr/bin/env pymol\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3601 <<"load "<<pml_list[i]<<"\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3602 <<"hide all\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3603 <<((i==0 || i==2)?("show stick\n"):("show cartoon\n")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3604 <<"color blue, chain A\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3605 <<"color red, chain B\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3606 <<"set ray_shadow, 0\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3607 <<"set stick_radius, 0.3\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3608 <<"set sphere_scale, 0.25\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3609 <<"show stick, not polymer\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3610 <<"show sphere, not polymer\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3611 <<"bg_color white\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3612 <<"set transparency=0.2\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3613 <<"zoom polymer\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3614 <<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3615 fp.open((pml_list[i]+".pml").c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3616 fp<<buf_pymol.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3617 fp.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3618 buf_pymol.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3619 pml_list[i].clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3620 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3621 pml_list.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3622 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3623 /* write rasmol script */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3624 fp.open((fname_super).c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3625 fp<<buf.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3626 fp.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3627 fp.open((fname_super+"_all").c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3628 fp<<buf_all.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3629 fp.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3630 fp.open((fname_super+"_atm").c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3631 fp<<buf_atm.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3632 fp.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3633 fp.open((fname_super+"_all_atm").c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3634 fp<<buf_all_atm.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3635 fp.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3636 fp.open((fname_super+"_all_atm_lig").c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3637 fp<<buf_all_atm_lig.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3638 fp.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3639 fp.open((fname_super+".pdb").c_str()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3640 fp<<buf_pdb.str(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3641 fp.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3642 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3643 /* clear stream */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3644 buf.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3645 buf_all.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3646 buf_atm.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3647 buf_all_atm.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3648 buf_all_atm_lig.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3649 buf_pdb.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3650 buf_tm.str(string()); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3651 resi_aln1.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3652 resi_aln2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3653 asym_id.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3654 line_vec.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3655 atom.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3656 AA.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3657 resi.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3658 inscode.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3659 model_index.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3660 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3661 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3662 /* extract rotation matrix based on TMscore8 */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3663 void output_rotation_matrix(const char* fname_matrix, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3664 const double t[3], const double u[3][3]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3665 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3666 fstream fout; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3667 fout.open(fname_matrix, ios::out | ios::trunc); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3668 if (fout)// succeed |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3669 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3670 fout << "------ The rotation matrix to rotate Chain_1 to Chain_2 ------\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3671 char dest[1000]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3672 sprintf(dest, "m %18s %14s %14s %14s\n", "t[m]", "u[m][0]", "u[m][1]", "u[m][2]"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3673 fout << string(dest); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3674 for (int k = 0; k < 3; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3675 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3676 sprintf(dest, "%d %18.10f %14.10f %14.10f %14.10f\n", k, t[k], u[k][0], u[k][1], u[k][2]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3677 fout << string(dest); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3678 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3679 fout << "\nCode for rotating Structure A from (x,y,z) to (X,Y,Z):\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3680 "for(i=0; i<L; i++)\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3681 "{\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3682 " X[i] = t[0] + u[0][0]*x[i] + u[0][1]*y[i] + u[0][2]*z[i];\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3683 " Y[i] = t[1] + u[1][0]*x[i] + u[1][1]*y[i] + u[1][2]*z[i];\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3684 " Z[i] = t[2] + u[2][0]*x[i] + u[2][1]*y[i] + u[2][2]*z[i];\n" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3685 "}\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3686 fout.close(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3687 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3688 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3689 cout << "Open file to output rotation matrix fail.\n"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3690 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3691 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3692 //output the final results |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3693 void output_results( |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3694 const string xname, const string yname, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3695 const char *chainID1, const char *chainID2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3696 const int xlen, const int ylen, double t[3], double u[3][3], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3697 const double TM1, const double TM2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3698 const double TM3, const double TM4, const double TM5, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3699 const double rmsd, const double d0_out, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3700 const char *seqM, const char *seqxA, const char *seqyA, const double Liden, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3701 const int n_ali8, const int L_ali, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3702 const double TM_ali, const double rmsd_ali, const double TM_0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3703 const double d0_0, const double d0A, const double d0B, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3704 const double Lnorm_ass, const double d0_scale, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3705 const double d0a, const double d0u, const char* fname_matrix, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3706 const int outfmt_opt, const int ter_opt, const string fname_super, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3707 const int i_opt, const int a_opt, const bool u_opt, const bool d_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3708 const int mirror_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3709 const vector<string>&resi_vec1, const vector<string>&resi_vec2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3710 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3711 if (outfmt_opt<=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3712 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3713 printf("\nName of Chain_1: %s%s (to be superimposed onto Chain_2)\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3714 xname.c_str(), chainID1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3715 printf("Name of Chain_2: %s%s\n", yname.c_str(), chainID2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3716 printf("Length of Chain_1: %d residues\n", xlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3717 printf("Length of Chain_2: %d residues\n\n", ylen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3718 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3719 if (i_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3720 printf("User-specified initial alignment: TM/Lali/rmsd = %7.5lf, %4d, %6.3lf\n", TM_ali, L_ali, rmsd_ali); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3721 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3722 printf("Aligned length= %d, RMSD= %6.2f, Seq_ID=n_identical/n_aligned= %4.3f\n", n_ali8, rmsd, (n_ali8>0)?Liden/n_ali8:0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3723 printf("TM-score= %6.5f (if normalized by length of Chain_1, i.e., LN=%d, d0=%.2f)\n", TM2, xlen, d0B); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3724 printf("TM-score= %6.5f (if normalized by length of Chain_2, i.e., LN=%d, d0=%.2f)\n", TM1, ylen, d0A); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3725 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3726 if (a_opt==1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3727 printf("TM-score= %6.5f (if normalized by average length of two structures, i.e., LN= %.1f, d0= %.2f)\n", TM3, (xlen+ylen)*0.5, d0a); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3728 if (u_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3729 printf("TM-score= %6.5f (if normalized by user-specified LN=%.2f and d0=%.2f)\n", TM4, Lnorm_ass, d0u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3730 if (d_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3731 printf("TM-score= %6.5f (if scaled by user-specified d0= %.2f, and LN= %d)\n", TM5, d0_scale, ylen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3732 printf("(You should use TM-score normalized by length of the reference structure)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3733 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3734 //output alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3735 printf("\n(\":\" denotes residue pairs of d < %4.1f Angstrom, ", d0_out); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3736 printf("\".\" denotes other aligned residues)\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3737 printf("%s\n", seqxA); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3738 printf("%s\n", seqM); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3739 printf("%s\n", seqyA); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3740 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3741 else if (outfmt_opt==1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3742 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3743 printf(">%s%s\tL=%d\td0=%.2f\tseqID=%.3f\tTM-score=%.5f\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3744 xname.c_str(), chainID1, xlen, d0B, Liden/xlen, TM2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3745 printf("%s\n", seqxA); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3746 printf(">%s%s\tL=%d\td0=%.2f\tseqID=%.3f\tTM-score=%.5f\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3747 yname.c_str(), chainID2, ylen, d0A, Liden/ylen, TM1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3748 printf("%s\n", seqyA); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3749 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3750 printf("# Lali=%d\tRMSD=%.2f\tseqID_ali=%.3f\n", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3751 n_ali8, rmsd, (n_ali8>0)?Liden/n_ali8:0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3752 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3753 if (i_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3754 printf("# User-specified initial alignment: TM=%.5lf\tLali=%4d\trmsd=%.3lf\n", TM_ali, L_ali, rmsd_ali); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3755 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3756 if(a_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3757 printf("# TM-score=%.5f (normalized by average length of two structures: L=%.1f\td0=%.2f)\n", TM3, (xlen+ylen)*0.5, d0a); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3758 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3759 if(u_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3760 printf("# TM-score=%.5f (normalized by user-specified L=%.2f\td0=%.2f)\n", TM4, Lnorm_ass, d0u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3761 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3762 if(d_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3763 printf("# TM-score=%.5f (scaled by user-specified d0=%.2f\tL=%d)\n", TM5, d0_scale, ylen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3764 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3765 printf("$$$$\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3766 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3767 else if (outfmt_opt==2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3768 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3769 printf("%s%s\t%s%s\t%.4f\t%.4f\t%.2f\t%4.3f\t%4.3f\t%4.3f\t%d\t%d\t%d", |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3770 xname.c_str(), chainID1, yname.c_str(), chainID2, TM2, TM1, rmsd, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3771 Liden/xlen, Liden/ylen, (n_ali8>0)?Liden/n_ali8:0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3772 xlen, ylen, n_ali8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3773 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3774 cout << endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3775 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3776 if (strlen(fname_matrix)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3777 output_rotation_matrix(fname_matrix, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3778 if (fname_super.size()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3779 output_superpose(xname, yname, fname_super, t, u, ter_opt, mirror_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3780 seqM, seqxA, seqyA, resi_vec1, resi_vec2, chainID1, chainID2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3781 xlen, ylen, d0A, n_ali8, rmsd, TM1, Liden); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3782 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3783 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3784 double standard_TMscore(double **r1, double **r2, double **xtm, double **ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3785 double **xt, double **x, double **y, int xlen, int ylen, int invmap[], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3786 int& L_ali, double& RMSD, double D0_MIN, double Lnorm, double d0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3787 double d0_search, double score_d8, double t[3], double u[3][3], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3788 const int mol_type) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3789 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3790 D0_MIN = 0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3791 Lnorm = ylen; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3792 if (mol_type>0) // RNA |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3793 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3794 if (Lnorm<=11) d0=0.3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3795 else if(Lnorm>11 && Lnorm<=15) d0=0.4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3796 else if(Lnorm>15 && Lnorm<=19) d0=0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3797 else if(Lnorm>19 && Lnorm<=23) d0=0.6; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3798 else if(Lnorm>23 && Lnorm<30) d0=0.7; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3799 else d0=(0.6*pow((Lnorm*1.0-0.5), 1.0/2)-2.5); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3800 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3801 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3802 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3803 if (Lnorm > 21) d0=(1.24*pow((Lnorm*1.0-15), 1.0/3) -1.8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3804 else d0 = D0_MIN; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3805 if (d0 < D0_MIN) d0 = D0_MIN; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3806 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3807 double d0_input = d0;// Scaled by seq_min |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3808 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3809 double tmscore;// collected alined residues from invmap |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3810 int n_al = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3811 int i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3812 for (int j = 0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3813 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3814 i = invmap[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3815 if (i >= 0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3816 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3817 xtm[n_al][0] = x[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3818 xtm[n_al][1] = x[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3819 xtm[n_al][2] = x[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3820 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3821 ytm[n_al][0] = y[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3822 ytm[n_al][1] = y[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3823 ytm[n_al][2] = y[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3824 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3825 r1[n_al][0] = x[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3826 r1[n_al][1] = x[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3827 r1[n_al][2] = x[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3828 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3829 r2[n_al][0] = y[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3830 r2[n_al][1] = y[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3831 r2[n_al][2] = y[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3832 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3833 n_al++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3834 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3835 else if (i != -1) PrintErrorAndQuit("Wrong map!\n"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3836 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3837 L_ali = n_al; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3838 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3839 Kabsch(r1, r2, n_al, 0, &RMSD, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3840 RMSD = sqrt( RMSD/(1.0*n_al) ); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3841 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3842 int temp_simplify_step = 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3843 int temp_score_sum_method = 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3844 d0_search = d0_input; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3845 double rms = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3846 tmscore = TMscore8_search_standard(r1, r2, xtm, ytm, xt, n_al, t, u, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3847 temp_simplify_step, temp_score_sum_method, &rms, d0_input, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3848 score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3849 tmscore = tmscore * n_al / (1.0*Lnorm); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3850 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3851 return tmscore; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3852 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3853 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3854 /* copy the value of t and u into t0,u0 */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3855 void copy_t_u(double t[3], double u[3][3], double t0[3], double u0[3][3]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3856 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3857 int i,j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3858 for (i=0;i<3;i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3859 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3860 t0[i]=t[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3861 for (j=0;j<3;j++) u0[i][j]=u[i][j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3862 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3863 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3864 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3865 /* calculate approximate TM-score given rotation matrix */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3866 double approx_TM(const int xlen, const int ylen, const int a_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3867 double **xa, double **ya, double t[3], double u[3][3], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3868 const int invmap0[], const int mol_type) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3869 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3870 double Lnorm_0=ylen; // normalized by the second protein |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3871 if (a_opt==-2 && xlen>ylen) Lnorm_0=xlen; // longer |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3872 else if (a_opt==-1 && xlen<ylen) Lnorm_0=xlen; // shorter |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3873 else if (a_opt==1) Lnorm_0=(xlen+ylen)/2.; // average |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3874 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3875 double D0_MIN; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3876 double Lnorm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3877 double d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3878 double d0_search; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3879 parameter_set4final(Lnorm_0, D0_MIN, Lnorm, d0, d0_search, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3880 double TMtmp=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3881 double d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3882 double xtmp[3]={0,0,0}; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3883 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3884 for(int i=0,j=0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3885 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3886 i=invmap0[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3887 if(i>=0)//aligned |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3888 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3889 transform(t, u, &xa[i][0], &xtmp[0]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3890 d=sqrt(dist(&xtmp[0], &ya[j][0])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3891 TMtmp+=1/(1+(d/d0)*(d/d0)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3892 //if (d <= score_d8) TMtmp+=1/(1+(d/d0)*(d/d0)); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3893 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3894 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3895 TMtmp/=Lnorm_0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3896 return TMtmp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3897 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3898 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3899 void clean_up_after_approx_TM(int *invmap0, int *invmap, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3900 double **score, bool **path, double **val, double **xtm, double **ytm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3901 double **xt, double **r1, double **r2, const int xlen, const int minlen) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3902 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3903 delete [] invmap0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3904 delete [] invmap; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3905 DeleteArray(&score, xlen+1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3906 DeleteArray(&path, xlen+1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3907 DeleteArray(&val, xlen+1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3908 DeleteArray(&xtm, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3909 DeleteArray(&ytm, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3910 DeleteArray(&xt, xlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3911 DeleteArray(&r1, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3912 DeleteArray(&r2, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3913 return; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3914 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3915 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3916 /* Entry function for TM-align. Return TM-score calculation status: |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3917 * 0 - full TM-score calculation |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3918 * 1 - terminated due to exception |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3919 * 2-7 - pre-terminated due to low TM-score */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3920 int TMalign_main(double **xa, double **ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3921 const char *seqx, const char *seqy, const char *secx, const char *secy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3922 double t0[3], double u0[3][3], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3923 double &TM1, double &TM2, double &TM3, double &TM4, double &TM5, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3924 double &d0_0, double &TM_0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3925 double &d0A, double &d0B, double &d0u, double &d0a, double &d0_out, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3926 string &seqM, string &seqxA, string &seqyA, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3927 double &rmsd0, int &L_ali, double &Liden, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3928 double &TM_ali, double &rmsd_ali, int &n_ali, int &n_ali8, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3929 const int xlen, const int ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3930 const vector<string> sequence, const double Lnorm_ass, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3931 const double d0_scale, const int i_opt, const int a_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3932 const bool u_opt, const bool d_opt, const bool fast_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3933 const int mol_type, const double TMcut=-1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3934 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3935 double D0_MIN; //for d0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3936 double Lnorm; //normalization length |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3937 double score_d8,d0,d0_search,dcu0;//for TMscore search |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3938 double t[3], u[3][3]; //Kabsch translation vector and rotation matrix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3939 double **score; // Input score table for dynamic programming |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3940 bool **path; // for dynamic programming |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3941 double **val; // for dynamic programming |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3942 double **xtm, **ytm; // for TMscore search engine |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3943 double **xt; //for saving the superposed version of r_1 or xtm |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3944 double **r1, **r2; // for Kabsch rotation |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3945 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3946 /***********************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3947 /* allocate memory */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3948 /***********************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3949 int minlen = min(xlen, ylen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3950 NewArray(&score, xlen+1, ylen+1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3951 NewArray(&path, xlen+1, ylen+1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3952 NewArray(&val, xlen+1, ylen+1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3953 NewArray(&xtm, minlen, 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3954 NewArray(&ytm, minlen, 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3955 NewArray(&xt, xlen, 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3956 NewArray(&r1, minlen, 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3957 NewArray(&r2, minlen, 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3958 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3959 /***********************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3960 /* parameter set */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3961 /***********************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3962 parameter_set4search(xlen, ylen, D0_MIN, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3963 score_d8, d0, d0_search, dcu0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3964 int simplify_step = 40; //for similified search engine |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3965 int score_sum_method = 8; //for scoring method, whether only sum over pairs with dis<score_d8 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3966 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3967 int i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3968 int *invmap0 = new int[ylen+1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3969 int *invmap = new int[ylen+1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3970 double TM, TMmax=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3971 for(i=0; i<ylen; i++) invmap0[i]=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3972 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3973 double ddcc=0.4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3974 if (Lnorm <= 40) ddcc=0.1; //Lnorm was setted in parameter_set4search |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3975 double local_d0_search = d0_search; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3976 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3977 //************************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3978 // get initial alignment from user's input: // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3979 // Stick to the initial alignment // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3980 //************************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3981 bool bAlignStick = false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3982 if (i_opt==3)// if input has set parameter for "-I" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3983 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3984 // In the original code, this loop starts from 1, which is |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3985 // incorrect. Fortran starts from 1 but C++ should starts from 0. |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3986 for (int j = 0; j < ylen; j++)// Set aligned position to be "-1" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3987 invmap[j] = -1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3988 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3989 int i1 = -1;// in C version, index starts from zero, not from one |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3990 int i2 = -1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3991 int L1 = sequence[0].size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3992 int L2 = sequence[1].size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3993 int L = min(L1, L2);// Get positions for aligned residues |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3994 for (int kk1 = 0; kk1 < L; kk1++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3995 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3996 if (sequence[0][kk1] != '-') i1++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3997 if (sequence[1][kk1] != '-') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3998 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
3999 i2++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4000 if (i2 >= ylen || i1 >= xlen) kk1 = L; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4001 else if (sequence[0][kk1] != '-') invmap[i2] = i1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4002 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4003 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4004 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4005 //--------------- 2. Align proteins from original alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4006 double prevD0_MIN = D0_MIN;// stored for later use |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4007 int prevLnorm = Lnorm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4008 double prevd0 = d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4009 TM_ali = standard_TMscore(r1, r2, xtm, ytm, xt, xa, ya, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4010 invmap, L_ali, rmsd_ali, D0_MIN, Lnorm, d0, d0_search, score_d8, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4011 t, u, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4012 D0_MIN = prevD0_MIN; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4013 Lnorm = prevLnorm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4014 d0 = prevd0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4015 TM = detailed_search_standard(r1, r2, xtm, ytm, xt, xa, ya, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4016 invmap, t, u, 40, 8, local_d0_search, true, Lnorm, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4017 if (TM > TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4018 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4019 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4020 for (i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4021 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4022 bAlignStick = true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4023 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4024 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4025 /******************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4026 /* get initial alignment with gapless threading */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4027 /******************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4028 if (!bAlignStick) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4029 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4030 get_initial(r1, r2, xtm, ytm, xa, ya, xlen, ylen, invmap0, d0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4031 d0_search, fast_opt, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4032 TM = detailed_search(r1, r2, xtm, ytm, xt, xa, ya, xlen, ylen, invmap0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4033 t, u, simplify_step, score_sum_method, local_d0_search, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4034 score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4035 if (TM>TMmax) TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4036 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4037 //run dynamic programing iteratively to find the best alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4038 TM = DP_iter(r1, r2, xtm, ytm, xt, path, val, xa, ya, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4039 t, u, invmap, 0, 2, (fast_opt)?2:30, local_d0_search, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4040 D0_MIN, Lnorm, d0, score_d8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4041 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4042 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4043 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4044 for (int i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4045 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4046 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4047 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4048 if (TMcut>0) // pre-terminate if TM-score is too low |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4049 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4050 double TMtmp=approx_TM(xlen, ylen, a_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4051 xa, ya, t0, u0, invmap0, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4052 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4053 if (TMtmp<0.5*TMcut) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4054 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4055 TM1=TM2=TM3=TM4=TM5=TMtmp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4056 clean_up_after_approx_TM(invmap0, invmap, score, path, val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4057 xtm, ytm, xt, r1, r2, xlen, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4058 return 2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4059 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4060 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4061 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4062 /************************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4063 /* get initial alignment based on secondary structure */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4064 /************************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4065 get_initial_ss(path, val, secx, secy, xlen, ylen, invmap); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4066 TM = detailed_search(r1, r2, xtm, ytm, xt, xa, ya, xlen, ylen, invmap, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4067 t, u, simplify_step, score_sum_method, local_d0_search, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4068 score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4069 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4070 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4071 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4072 for (int i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4073 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4074 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4075 if (TM > TMmax*0.2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4076 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4077 TM = DP_iter(r1, r2, xtm, ytm, xt, path, val, xa, ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4078 xlen, ylen, t, u, invmap, 0, 2, (fast_opt)?2:30, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4079 local_d0_search, D0_MIN, Lnorm, d0, score_d8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4080 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4081 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4082 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4083 for (int i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4084 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4085 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4086 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4087 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4088 if (TMcut>0) // pre-terminate if TM-score is too low |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4089 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4090 double TMtmp=approx_TM(xlen, ylen, a_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4091 xa, ya, t0, u0, invmap0, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4092 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4093 if (TMtmp<0.52*TMcut) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4094 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4095 TM1=TM2=TM3=TM4=TM5=TMtmp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4096 clean_up_after_approx_TM(invmap0, invmap, score, path, val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4097 xtm, ytm, xt, r1, r2, xlen, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4098 return 3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4099 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4100 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4101 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4102 /************************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4103 /* get initial alignment based on local superposition */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4104 /************************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4105 //=initial5 in original TM-align |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4106 if (get_initial5( r1, r2, xtm, ytm, path, val, xa, ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4107 xlen, ylen, invmap, d0, d0_search, fast_opt, D0_MIN)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4108 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4109 TM = detailed_search(r1, r2, xtm, ytm, xt, xa, ya, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4110 invmap, t, u, simplify_step, score_sum_method, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4111 local_d0_search, Lnorm, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4112 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4113 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4114 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4115 for (int i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4116 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4117 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4118 if (TM > TMmax*ddcc) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4119 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4120 TM = DP_iter(r1, r2, xtm, ytm, xt, path, val, xa, ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4121 xlen, ylen, t, u, invmap, 0, 2, 2, local_d0_search, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4122 D0_MIN, Lnorm, d0, score_d8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4123 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4124 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4125 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4126 for (int i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4127 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4128 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4129 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4130 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4131 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4132 cerr << "\n\nWarning: initial alignment from local superposition fail!\n\n" << endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4133 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4134 if (TMcut>0) // pre-terminate if TM-score is too low |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4135 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4136 double TMtmp=approx_TM(xlen, ylen, a_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4137 xa, ya, t0, u0, invmap0, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4138 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4139 if (TMtmp<0.54*TMcut) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4140 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4141 TM1=TM2=TM3=TM4=TM5=TMtmp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4142 clean_up_after_approx_TM(invmap0, invmap, score, path, val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4143 xtm, ytm, xt, r1, r2, xlen, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4144 return 4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4145 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4146 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4147 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4148 /********************************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4149 /* get initial alignment by local superposition+secondary structure */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4150 /********************************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4151 //=initial3 in original TM-align |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4152 get_initial_ssplus(r1, r2, score, path, val, secx, secy, xa, ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4153 xlen, ylen, invmap0, invmap, D0_MIN, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4154 TM = detailed_search(r1, r2, xtm, ytm, xt, xa, ya, xlen, ylen, invmap, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4155 t, u, simplify_step, score_sum_method, local_d0_search, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4156 score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4157 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4158 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4159 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4160 for (i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4161 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4162 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4163 if (TM > TMmax*ddcc) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4164 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4165 TM = DP_iter(r1, r2, xtm, ytm, xt, path, val, xa, ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4166 xlen, ylen, t, u, invmap, 0, 2, (fast_opt)?2:30, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4167 local_d0_search, D0_MIN, Lnorm, d0, score_d8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4168 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4169 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4170 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4171 for (i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4172 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4173 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4174 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4175 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4176 if (TMcut>0) // pre-terminate if TM-score is too low |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4177 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4178 double TMtmp=approx_TM(xlen, ylen, a_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4179 xa, ya, t0, u0, invmap0, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4180 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4181 if (TMtmp<0.56*TMcut) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4182 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4183 TM1=TM2=TM3=TM4=TM5=TMtmp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4184 clean_up_after_approx_TM(invmap0, invmap, score, path, val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4185 xtm, ytm, xt, r1, r2, xlen, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4186 return 5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4187 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4188 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4189 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4190 /*******************************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4191 /* get initial alignment based on fragment gapless threading */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4192 /*******************************************************************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4193 //=initial4 in original TM-align |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4194 get_initial_fgt(r1, r2, xtm, ytm, xa, ya, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4195 invmap, d0, d0_search, dcu0, fast_opt, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4196 TM = detailed_search(r1, r2, xtm, ytm, xt, xa, ya, xlen, ylen, invmap, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4197 t, u, simplify_step, score_sum_method, local_d0_search, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4198 score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4199 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4200 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4201 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4202 for (i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4203 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4204 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4205 if (TM > TMmax*ddcc) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4206 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4207 TM = DP_iter(r1, r2, xtm, ytm, xt, path, val, xa, ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4208 xlen, ylen, t, u, invmap, 1, 2, 2, local_d0_search, D0_MIN, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4209 Lnorm, d0, score_d8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4210 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4211 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4212 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4213 for (i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4214 if (TMcut>0) copy_t_u(t, u, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4215 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4216 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4217 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4218 if (TMcut>0) // pre-terminate if TM-score is too low |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4219 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4220 double TMtmp=approx_TM(xlen, ylen, a_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4221 xa, ya, t0, u0, invmap0, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4222 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4223 if (TMtmp<0.58*TMcut) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4224 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4225 TM1=TM2=TM3=TM4=TM5=TMtmp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4226 clean_up_after_approx_TM(invmap0, invmap, score, path, val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4227 xtm, ytm, xt, r1, r2, xlen, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4228 return 6; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4229 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4230 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4231 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4232 //************************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4233 // get initial alignment from user's input: // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4234 //************************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4235 if (i_opt==1)// if input has set parameter for "-i" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4236 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4237 for (int j = 0; j < ylen; j++)// Set aligned position to be "-1" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4238 invmap[j] = -1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4239 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4240 int i1 = -1;// in C version, index starts from zero, not from one |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4241 int i2 = -1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4242 int L1 = sequence[0].size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4243 int L2 = sequence[1].size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4244 int L = min(L1, L2);// Get positions for aligned residues |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4245 for (int kk1 = 0; kk1 < L; kk1++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4246 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4247 if (sequence[0][kk1] != '-') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4248 i1++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4249 if (sequence[1][kk1] != '-') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4250 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4251 i2++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4252 if (i2 >= ylen || i1 >= xlen) kk1 = L; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4253 else if (sequence[0][kk1] != '-') invmap[i2] = i1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4254 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4255 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4256 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4257 //--------------- 2. Align proteins from original alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4258 double prevD0_MIN = D0_MIN;// stored for later use |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4259 int prevLnorm = Lnorm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4260 double prevd0 = d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4261 TM_ali = standard_TMscore(r1, r2, xtm, ytm, xt, xa, ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4262 xlen, ylen, invmap, L_ali, rmsd_ali, D0_MIN, Lnorm, d0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4263 d0_search, score_d8, t, u, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4264 D0_MIN = prevD0_MIN; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4265 Lnorm = prevLnorm; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4266 d0 = prevd0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4267 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4268 TM = detailed_search_standard(r1, r2, xtm, ytm, xt, xa, ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4269 xlen, ylen, invmap, t, u, 40, 8, local_d0_search, true, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4270 score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4271 if (TM > TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4272 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4273 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4274 for (i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4275 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4276 // Different from get_initial, get_initial_ss and get_initial_ssplus |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4277 TM = DP_iter(r1, r2, xtm, ytm, xt, path, val, xa, ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4278 xlen, ylen, t, u, invmap, 0, 2, (fast_opt)?2:30, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4279 local_d0_search, D0_MIN, Lnorm, d0, score_d8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4280 if (TM>TMmax) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4281 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4282 TMmax = TM; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4283 for (i = 0; i<ylen; i++) invmap0[i] = invmap[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4284 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4285 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4286 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4287 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4288 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4289 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4290 //*******************************************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4291 // The alignment will not be changed any more in the following // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4292 //*******************************************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4293 //check if the initial alignment is generated approriately |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4294 bool flag=false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4295 for(i=0; i<ylen; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4296 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4297 if(invmap0[i]>=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4298 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4299 flag=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4300 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4301 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4302 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4303 if(!flag) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4304 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4305 cout << "There is no alignment between the two proteins!" << endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4306 cout << "Program stop with no result!" << endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4307 return 1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4308 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4309 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4310 /* last TM-score pre-termination */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4311 if (TMcut>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4312 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4313 double TMtmp=approx_TM(xlen, ylen, a_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4314 xa, ya, t0, u0, invmap0, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4315 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4316 if (TMtmp<0.6*TMcut) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4317 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4318 TM1=TM2=TM3=TM4=TM5=TMtmp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4319 clean_up_after_approx_TM(invmap0, invmap, score, path, val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4320 xtm, ytm, xt, r1, r2, xlen, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4321 return 7; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4322 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4323 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4324 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4325 //********************************************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4326 // Detailed TMscore search engine --> prepare for final TMscore // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4327 //********************************************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4328 //run detailed TMscore search engine for the best alignment, and |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4329 //extract the best rotation matrix (t, u) for the best alginment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4330 simplify_step=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4331 if (fast_opt) simplify_step=40; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4332 score_sum_method=8; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4333 TM = detailed_search_standard(r1, r2, xtm, ytm, xt, xa, ya, xlen, ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4334 invmap0, t, u, simplify_step, score_sum_method, local_d0_search, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4335 false, Lnorm, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4336 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4337 //select pairs with dis<d8 for final TMscore computation and output alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4338 int k=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4339 int *m1, *m2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4340 double d; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4341 m1=new int[xlen]; //alignd index in x |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4342 m2=new int[ylen]; //alignd index in y |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4343 do_rotation(xa, xt, xlen, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4344 k=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4345 for(int j=0; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4346 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4347 i=invmap0[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4348 if(i>=0)//aligned |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4349 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4350 n_ali++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4351 d=sqrt(dist(&xt[i][0], &ya[j][0])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4352 if (d <= score_d8 || (i_opt == 3)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4353 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4354 m1[k]=i; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4355 m2[k]=j; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4356 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4357 xtm[k][0]=xa[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4358 xtm[k][1]=xa[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4359 xtm[k][2]=xa[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4360 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4361 ytm[k][0]=ya[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4362 ytm[k][1]=ya[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4363 ytm[k][2]=ya[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4364 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4365 r1[k][0] = xt[i][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4366 r1[k][1] = xt[i][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4367 r1[k][2] = xt[i][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4368 r2[k][0] = ya[j][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4369 r2[k][1] = ya[j][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4370 r2[k][2] = ya[j][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4371 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4372 k++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4373 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4374 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4375 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4376 n_ali8=k; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4377 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4378 Kabsch(r1, r2, n_ali8, 0, &rmsd0, t, u);// rmsd0 is used for final output, only recalculate rmsd0, not t & u |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4379 rmsd0 = sqrt(rmsd0 / n_ali8); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4380 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4381 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4382 //****************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4383 // Final TMscore // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4384 // Please set parameters for output // |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4385 //****************************************// |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4386 double rmsd; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4387 simplify_step=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4388 score_sum_method=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4389 double Lnorm_0=ylen; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4390 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4391 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4392 //normalized by length of structure A |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4393 parameter_set4final(Lnorm_0, D0_MIN, Lnorm, d0, d0_search, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4394 d0A=d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4395 d0_0=d0A; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4396 local_d0_search = d0_search; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4397 TM1 = TMscore8_search(r1, r2, xtm, ytm, xt, n_ali8, t0, u0, simplify_step, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4398 score_sum_method, &rmsd, local_d0_search, Lnorm, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4399 TM_0 = TM1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4400 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4401 //normalized by length of structure B |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4402 parameter_set4final(xlen+0.0, D0_MIN, Lnorm, d0, d0_search, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4403 d0B=d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4404 local_d0_search = d0_search; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4405 TM2 = TMscore8_search(r1, r2, xtm, ytm, xt, n_ali8, t, u, simplify_step, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4406 score_sum_method, &rmsd, local_d0_search, Lnorm, score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4407 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4408 double Lnorm_d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4409 if (a_opt>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4410 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4411 //normalized by average length of structures A, B |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4412 Lnorm_0=(xlen+ylen)*0.5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4413 parameter_set4final(Lnorm_0, D0_MIN, Lnorm, d0, d0_search, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4414 d0a=d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4415 d0_0=d0a; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4416 local_d0_search = d0_search; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4417 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4418 TM3 = TMscore8_search(r1, r2, xtm, ytm, xt, n_ali8, t0, u0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4419 simplify_step, score_sum_method, &rmsd, local_d0_search, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4420 score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4421 TM_0=TM3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4422 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4423 if (u_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4424 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4425 //normalized by user assigned length |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4426 parameter_set4final(Lnorm_ass, D0_MIN, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4427 d0, d0_search, mol_type); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4428 d0u=d0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4429 d0_0=d0u; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4430 Lnorm_0=Lnorm_ass; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4431 local_d0_search = d0_search; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4432 TM4 = TMscore8_search(r1, r2, xtm, ytm, xt, n_ali8, t0, u0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4433 simplify_step, score_sum_method, &rmsd, local_d0_search, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4434 score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4435 TM_0=TM4; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4436 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4437 if (d_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4438 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4439 //scaled by user assigned d0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4440 parameter_set4scale(ylen, d0_scale, Lnorm, d0, d0_search); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4441 d0_out=d0_scale; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4442 d0_0=d0_scale; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4443 //Lnorm_0=ylen; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4444 Lnorm_d0=Lnorm_0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4445 local_d0_search = d0_search; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4446 TM5 = TMscore8_search(r1, r2, xtm, ytm, xt, n_ali8, t0, u0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4447 simplify_step, score_sum_method, &rmsd, local_d0_search, Lnorm, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4448 score_d8, d0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4449 TM_0=TM5; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4450 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4451 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4452 /* derive alignment from superposition */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4453 int ali_len=xlen+ylen; //maximum length of alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4454 seqxA.assign(ali_len,'-'); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4455 seqM.assign( ali_len,' '); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4456 seqyA.assign(ali_len,'-'); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4457 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4458 //do_rotation(xa, xt, xlen, t, u); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4459 do_rotation(xa, xt, xlen, t0, u0); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4460 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4461 int kk=0, i_old=0, j_old=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4462 d=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4463 for(int k=0; k<n_ali8; k++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4464 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4465 for(int i=i_old; i<m1[k]; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4466 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4467 //align x to gap |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4468 seqxA[kk]=seqx[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4469 seqyA[kk]='-'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4470 seqM[kk]=' '; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4471 kk++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4472 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4473 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4474 for(int j=j_old; j<m2[k]; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4475 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4476 //align y to gap |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4477 seqxA[kk]='-'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4478 seqyA[kk]=seqy[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4479 seqM[kk]=' '; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4480 kk++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4481 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4482 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4483 seqxA[kk]=seqx[m1[k]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4484 seqyA[kk]=seqy[m2[k]]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4485 Liden+=(seqxA[kk]==seqyA[kk]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4486 d=sqrt(dist(&xt[m1[k]][0], &ya[m2[k]][0])); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4487 if(d<d0_out) seqM[kk]=':'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4488 else seqM[kk]='.'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4489 kk++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4490 i_old=m1[k]+1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4491 j_old=m2[k]+1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4492 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4493 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4494 //tail |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4495 for(int i=i_old; i<xlen; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4496 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4497 //align x to gap |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4498 seqxA[kk]=seqx[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4499 seqyA[kk]='-'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4500 seqM[kk]=' '; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4501 kk++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4502 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4503 for(int j=j_old; j<ylen; j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4504 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4505 //align y to gap |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4506 seqxA[kk]='-'; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4507 seqyA[kk]=seqy[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4508 seqM[kk]=' '; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4509 kk++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4510 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4511 seqxA=seqxA.substr(0,kk); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4512 seqyA=seqyA.substr(0,kk); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4513 seqM =seqM.substr(0,kk); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4514 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4515 /* free memory */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4516 clean_up_after_approx_TM(invmap0, invmap, score, path, val, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4517 xtm, ytm, xt, r1, r2, xlen, minlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4518 delete [] m1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4519 delete [] m2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4520 return 0; // zero for no exception |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4521 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4522 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4523 /* entry function for TM-align with circular permutation |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4524 * i_opt, a_opt, u_opt, d_opt, TMcut are not implemented yet */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4525 int CPalign_main(double **xa, double **ya, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4526 const char *seqx, const char *seqy, const char *secx, const char *secy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4527 double t0[3], double u0[3][3], |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4528 double &TM1, double &TM2, double &TM3, double &TM4, double &TM5, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4529 double &d0_0, double &TM_0, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4530 double &d0A, double &d0B, double &d0u, double &d0a, double &d0_out, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4531 string &seqM, string &seqxA, string &seqyA, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4532 double &rmsd0, int &L_ali, double &Liden, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4533 double &TM_ali, double &rmsd_ali, int &n_ali, int &n_ali8, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4534 const int xlen, const int ylen, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4535 const vector<string> sequence, const double Lnorm_ass, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4536 const double d0_scale, const int i_opt, const int a_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4537 const bool u_opt, const bool d_opt, const bool fast_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4538 const int mol_type, const double TMcut=-1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4539 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4540 char *seqx_cp, *seqy_cp; // for the protein sequence |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4541 char *secx_cp, *secy_cp; // for the secondary structure |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4542 double **xa_cp, **ya_cp; // coordinates |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4543 string seqxA_cp,seqyA_cp; // alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4544 int i,r; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4545 int cp_point=0; // position of circular permutation |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4546 int cp_aln_best=0; // amount of aligned residue in sliding window |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4547 int cp_aln_current;// amount of aligned residue in sliding window |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4548 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4549 /* duplicate structure */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4550 NewArray(&xa_cp, xlen*2, 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4551 seqx_cp = new char[xlen*2 + 1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4552 secx_cp = new char[xlen*2 + 1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4553 for (r=0;r<xlen;r++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4554 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4555 xa_cp[r+xlen][0]=xa_cp[r][0]=xa[r][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4556 xa_cp[r+xlen][1]=xa_cp[r][1]=xa[r][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4557 xa_cp[r+xlen][2]=xa_cp[r][2]=xa[r][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4558 seqx_cp[r+xlen]=seqx_cp[r]=seqx[r]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4559 secx_cp[r+xlen]=secx_cp[r]=secx[r]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4560 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4561 seqx_cp[2*xlen]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4562 secx_cp[2*xlen]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4563 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4564 /* fTM-align alignment */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4565 double TM1_cp,TM2_cp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4566 TMalign_main(xa_cp, ya, seqx_cp, seqy, secx_cp, secy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4567 t0, u0, TM1_cp, TM2_cp, TM3, TM4, TM5, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4568 d0_0, TM_0, d0A, d0B, d0u, d0a, d0_out, seqM, seqxA_cp, seqyA_cp, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4569 rmsd0, L_ali, Liden, TM_ali, rmsd_ali, n_ali, n_ali8, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4570 xlen*2, ylen, sequence, Lnorm_ass, d0_scale, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4571 0, false, false, false, true, mol_type, -1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4572 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4573 /* delete gap in seqxA_cp */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4574 r=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4575 seqxA=seqxA_cp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4576 seqyA=seqyA_cp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4577 for (i=0;i<seqxA_cp.size();i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4578 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4579 if (seqxA_cp[i]!='-') |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4580 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4581 seqxA[r]=seqxA_cp[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4582 seqyA[r]=seqyA_cp[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4583 r++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4584 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4585 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4586 seqxA=seqxA.substr(0,r); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4587 seqyA=seqyA.substr(0,r); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4588 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4589 /* count the number of aligned residues in each window |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4590 * r - residue index in the original unaligned sequence |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4591 * i - position in the alignment */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4592 for (r=0;r<xlen-1;r++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4593 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4594 cp_aln_current=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4595 for (i=r;i<r+xlen;i++) cp_aln_current+=(seqyA[i]!='-'); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4596 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4597 if (cp_aln_current>cp_aln_best) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4598 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4599 cp_aln_best=cp_aln_current; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4600 cp_point=r; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4601 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4602 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4603 seqM.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4604 seqxA.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4605 seqyA.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4606 seqxA_cp.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4607 seqyA_cp.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4608 rmsd0=Liden=n_ali=n_ali8=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4609 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4610 /* fTM-align alignment */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4611 TMalign_main(xa, ya, seqx, seqy, secx, secy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4612 t0, u0, TM1, TM2, TM3, TM4, TM5, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4613 d0_0, TM_0, d0A, d0B, d0u, d0a, d0_out, seqM, seqxA, seqyA, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4614 rmsd0, L_ali, Liden, TM_ali, rmsd_ali, n_ali, n_ali8, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4615 xlen, ylen, sequence, Lnorm_ass, d0_scale, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4616 0, false, false, false, true, mol_type, -1); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4617 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4618 /* do not use cricular permutation of number of aligned residues is not |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4619 * larger than sequence-order dependent alignment */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4620 if (n_ali8>cp_aln_best) cp_point=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4621 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4622 /* prepare structure for final alignment */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4623 seqM.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4624 seqxA.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4625 seqyA.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4626 rmsd0=Liden=n_ali=n_ali8=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4627 if (cp_point!=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4628 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4629 for (r=0;r<xlen;r++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4630 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4631 xa_cp[r][0]=xa_cp[r+cp_point][0]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4632 xa_cp[r][1]=xa_cp[r+cp_point][1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4633 xa_cp[r][2]=xa_cp[r+cp_point][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4634 seqx_cp[r]=seqx_cp[r+cp_point]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4635 secx_cp[r]=secx_cp[r+cp_point]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4636 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4637 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4638 seqx_cp[xlen]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4639 secx_cp[xlen]=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4640 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4641 /* full TM-align */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4642 TMalign_main(xa_cp, ya, seqx_cp, seqy, secx_cp, secy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4643 t0, u0, TM1, TM2, TM3, TM4, TM5, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4644 d0_0, TM_0, d0A, d0B, d0u, d0a, d0_out, seqM, seqxA_cp, seqyA_cp, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4645 rmsd0, L_ali, Liden, TM_ali, rmsd_ali, n_ali, n_ali8, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4646 xlen, ylen, sequence, Lnorm_ass, d0_scale, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4647 i_opt, a_opt, u_opt, d_opt, fast_opt, mol_type, TMcut); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4648 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4649 /* correct alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4650 * r - residue index in the original unaligned sequence |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4651 * i - position in the alignment */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4652 if (cp_point>0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4653 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4654 r=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4655 for (i=0;i<seqxA_cp.size();i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4656 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4657 r+=(seqxA_cp[i]!='-'); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4658 if (r>=(xlen-cp_point)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4659 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4660 i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4661 break; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4662 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4663 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4664 seqxA=seqxA_cp.substr(0,i)+'*'+seqxA_cp.substr(i); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4665 seqM =seqM.substr(0,i) +' '+seqM.substr(i); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4666 seqyA=seqyA_cp.substr(0,i)+'-'+seqyA_cp.substr(i); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4667 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4668 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4669 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4670 seqxA=seqxA_cp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4671 seqyA=seqyA_cp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4672 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4673 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4674 /* clean up */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4675 delete[]seqx_cp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4676 delete[]secx_cp; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4677 DeleteArray(&xa_cp,xlen*2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4678 seqxA_cp.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4679 seqyA_cp.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4680 return cp_point; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4681 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4682 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4683 int main(int argc, char *argv[]) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4684 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4685 if (argc < 2) print_help(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4686 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4687 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4688 clock_t t1, t2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4689 t1 = clock(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4690 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4691 /**********************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4692 /* get argument */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4693 /**********************/ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4694 string xname = ""; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4695 string yname = ""; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4696 string fname_super = ""; // file name for superposed structure |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4697 string fname_lign = ""; // file name for user alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4698 string fname_matrix= ""; // file name for output matrix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4699 vector<string> sequence; // get value from alignment file |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4700 double Lnorm_ass, d0_scale; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4701 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4702 bool h_opt = false; // print full help message |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4703 bool v_opt = false; // print version |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4704 bool m_opt = false; // flag for -m, output rotation matrix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4705 int i_opt = 0; // 1 for -i, 3 for -I |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4706 bool o_opt = false; // flag for -o, output superposed structure |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4707 int a_opt = 0; // flag for -a, do not normalized by average length |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4708 bool u_opt = false; // flag for -u, normalized by user specified length |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4709 bool d_opt = false; // flag for -d, user specified d0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4710 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4711 double TMcut =-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4712 int infmt1_opt=-1; // PDB or PDBx/mmCIF format for chain_1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4713 int infmt2_opt=-1; // PDB or PDBx/mmCIF format for chain_2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4714 int ter_opt =3; // TER, END, or different chainID |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4715 int split_opt =0; // do not split chain |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4716 int outfmt_opt=0; // set -outfmt to full output |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4717 bool fast_opt =false; // flags for -fast, fTM-align algorithm |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4718 int cp_opt =0; // do not check circular permutation |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4719 int mirror_opt=0; // do not align mirror |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4720 int het_opt=0; // do not read HETATM residues |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4721 string atom_opt ="auto";// use C alpha atom for protein and C3' for RNA |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4722 string mol_opt ="auto";// auto-detect the molecule type as protein/RNA |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4723 string suffix_opt=""; // set -suffix to empty |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4724 string dir_opt =""; // set -dir to empty |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4725 string dir1_opt =""; // set -dir1 to empty |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4726 string dir2_opt =""; // set -dir2 to empty |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4727 int byresi_opt=0; // set -byresi to 0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4728 vector<string> chain1_list; // only when -dir1 is set |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4729 vector<string> chain2_list; // only when -dir2 is set |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4730 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4731 for(int i = 1; i < argc; i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4732 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4733 if ( !strcmp(argv[i],"-o") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4734 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4735 fname_super = argv[i + 1]; o_opt = true; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4736 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4737 else if ( (!strcmp(argv[i],"-u") || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4738 !strcmp(argv[i],"-L")) && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4739 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4740 Lnorm_ass = atof(argv[i + 1]); u_opt = true; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4741 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4742 else if ( !strcmp(argv[i],"-a") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4743 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4744 if (!strcmp(argv[i + 1], "T")) a_opt=true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4745 else if (!strcmp(argv[i + 1], "F")) a_opt=false; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4746 else |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4747 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4748 a_opt=atoi(argv[i + 1]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4749 if (a_opt!=-2 && a_opt!=-1 && a_opt!=1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4750 PrintErrorAndQuit("-a must be -2, -1, 1, T or F"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4751 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4752 i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4753 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4754 else if ( !strcmp(argv[i],"-d") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4755 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4756 d0_scale = atof(argv[i + 1]); d_opt = true; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4757 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4758 else if ( !strcmp(argv[i],"-v") ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4759 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4760 v_opt = true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4761 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4762 else if ( !strcmp(argv[i],"-h") ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4763 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4764 h_opt = true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4765 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4766 else if ( !strcmp(argv[i],"-i") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4767 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4768 if (i_opt==3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4769 PrintErrorAndQuit("ERROR! -i and -I cannot be used together"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4770 fname_lign = argv[i + 1]; i_opt = 1; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4771 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4772 else if (!strcmp(argv[i], "-I") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4773 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4774 if (i_opt==1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4775 PrintErrorAndQuit("ERROR! -I and -i cannot be used together"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4776 fname_lign = argv[i + 1]; i_opt = 3; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4777 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4778 else if (!strcmp(argv[i], "-m") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4779 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4780 fname_matrix = argv[i + 1]; m_opt = true; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4781 }// get filename for rotation matrix |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4782 else if (!strcmp(argv[i], "-fast")) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4783 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4784 fast_opt = true; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4785 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4786 else if ( !strcmp(argv[i],"-infmt1") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4787 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4788 infmt1_opt=atoi(argv[i + 1]); i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4789 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4790 else if ( !strcmp(argv[i],"-infmt2") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4791 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4792 infmt2_opt=atoi(argv[i + 1]); i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4793 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4794 else if ( !strcmp(argv[i],"-ter") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4795 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4796 ter_opt=atoi(argv[i + 1]); i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4797 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4798 else if ( !strcmp(argv[i],"-split") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4799 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4800 split_opt=atoi(argv[i + 1]); i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4801 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4802 else if ( !strcmp(argv[i],"-atom") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4803 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4804 atom_opt=argv[i + 1]; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4805 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4806 else if ( !strcmp(argv[i],"-mol") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4807 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4808 mol_opt=argv[i + 1]; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4809 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4810 else if ( !strcmp(argv[i],"-dir") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4811 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4812 dir_opt=argv[i + 1]; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4813 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4814 else if ( !strcmp(argv[i],"-dir1") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4815 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4816 dir1_opt=argv[i + 1]; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4817 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4818 else if ( !strcmp(argv[i],"-dir2") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4819 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4820 dir2_opt=argv[i + 1]; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4821 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4822 else if ( !strcmp(argv[i],"-suffix") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4823 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4824 suffix_opt=argv[i + 1]; i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4825 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4826 else if ( !strcmp(argv[i],"-outfmt") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4827 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4828 outfmt_opt=atoi(argv[i + 1]); i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4829 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4830 else if ( !strcmp(argv[i],"-TMcut") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4831 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4832 TMcut=atof(argv[i + 1]); i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4833 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4834 else if ( !strcmp(argv[i],"-byresi") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4835 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4836 byresi_opt=atoi(argv[i + 1]); i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4837 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4838 else if ( !strcmp(argv[i],"-cp") ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4839 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4840 cp_opt=1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4841 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4842 else if ( !strcmp(argv[i],"-mirror") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4843 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4844 mirror_opt=atoi(argv[i + 1]); i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4845 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4846 else if ( !strcmp(argv[i],"-het") && i < (argc-1) ) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4847 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4848 het_opt=atoi(argv[i + 1]); i++; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4849 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4850 else if (xname.size() == 0) xname=argv[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4851 else if (yname.size() == 0) yname=argv[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4852 else PrintErrorAndQuit(string("ERROR! Undefined option ")+argv[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4853 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4854 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4855 if(xname.size()==0 || (yname.size()==0 && dir_opt.size()==0) || |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4856 (yname.size() && dir_opt.size())) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4857 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4858 if (h_opt) print_help(h_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4859 if (v_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4860 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4861 print_version(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4862 exit(EXIT_FAILURE); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4863 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4864 if (xname.size()==0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4865 PrintErrorAndQuit("Please provide input structures"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4866 else if (yname.size()==0 && dir_opt.size()==0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4867 PrintErrorAndQuit("Please provide structure B"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4868 else if (yname.size() && dir_opt.size()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4869 PrintErrorAndQuit("Please provide only one file name if -dir is set"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4870 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4871 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4872 if (suffix_opt.size() && dir_opt.size()+dir1_opt.size()+dir2_opt.size()==0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4873 PrintErrorAndQuit("-suffix is only valid if -dir, -dir1 or -dir2 is set"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4874 if ((dir_opt.size() || dir1_opt.size() || dir2_opt.size())) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4875 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4876 if (m_opt || o_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4877 PrintErrorAndQuit("-m or -o cannot be set with -dir, -dir1 or -dir2"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4878 else if (dir_opt.size() && (dir1_opt.size() || dir2_opt.size())) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4879 PrintErrorAndQuit("-dir cannot be set with -dir1 or -dir2"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4880 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4881 if (atom_opt.size()!=4) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4882 PrintErrorAndQuit("ERROR! atom name must have 4 characters, including space."); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4883 if (mol_opt!="auto" && mol_opt!="protein" && mol_opt!="RNA") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4884 PrintErrorAndQuit("ERROR! molecule type must be either RNA or protein."); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4885 else if (mol_opt=="protein" && atom_opt=="auto") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4886 atom_opt=" CA "; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4887 else if (mol_opt=="RNA" && atom_opt=="auto") |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4888 atom_opt=" C3'"; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4889 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4890 if (u_opt && Lnorm_ass<=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4891 PrintErrorAndQuit("Wrong value for option -u! It should be >0"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4892 if (d_opt && d0_scale<=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4893 PrintErrorAndQuit("Wrong value for option -d! It should be >0"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4894 if (outfmt_opt>=2 && (a_opt || u_opt || d_opt)) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4895 PrintErrorAndQuit("-outfmt 2 cannot be used with -a, -u, -L, -d"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4896 if (byresi_opt!=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4897 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4898 if (i_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4899 PrintErrorAndQuit("-byresi >=1 cannot be used with -i or -I"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4900 if (byresi_opt<0 || byresi_opt>3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4901 PrintErrorAndQuit("-byresi can only be 0, 1, 2 or 3"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4902 if (byresi_opt>=2 && ter_opt>=2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4903 PrintErrorAndQuit("-byresi >=2 should be used with -ter <=1"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4904 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4905 if (split_opt==1 && ter_opt!=0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4906 PrintErrorAndQuit("-split 1 should be used with -ter 0"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4907 else if (split_opt==2 && ter_opt!=0 && ter_opt!=1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4908 PrintErrorAndQuit("-split 2 should be used with -ter 0 or 1"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4909 if (split_opt<0 || split_opt>2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4910 PrintErrorAndQuit("-split can only be 0, 1 or 2"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4911 if (cp_opt!=0 && cp_opt!=1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4912 PrintErrorAndQuit("-cp can only be 0 or 1"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4913 if (cp_opt && i_opt) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4914 PrintErrorAndQuit("-cp cannot be used with -i or -I"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4915 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4916 /* read initial alignment file from 'align.txt' */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4917 if (i_opt) read_user_alignment(sequence, fname_lign, i_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4918 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4919 if (byresi_opt) i_opt=3; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4920 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4921 if (m_opt && fname_matrix == "") // Output rotation matrix: matrix.txt |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4922 PrintErrorAndQuit("ERROR! Please provide a file name for option -m!"); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4923 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4924 /* parse file list */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4925 if (dir1_opt.size()+dir_opt.size()==0) chain1_list.push_back(xname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4926 else file2chainlist(chain1_list, xname, dir_opt+dir1_opt, suffix_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4927 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4928 if (dir_opt.size()) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4929 for (int i=0;i<chain1_list.size();i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4930 chain2_list.push_back(chain1_list[i]); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4931 else if (dir2_opt.size()==0) chain2_list.push_back(yname); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4932 else file2chainlist(chain2_list, yname, dir2_opt, suffix_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4933 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4934 if (outfmt_opt==2) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4935 cout<<"#PDBchain1\tPDBchain2\tTM1\tTM2\t" |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4936 <<"RMSD\tID1\tID2\tIDali\tL1\tL2\tLali"<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4937 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4938 /* declare previously global variables */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4939 vector<vector<string> >PDB_lines1; // text of chain1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4940 vector<vector<string> >PDB_lines2; // text of chain2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4941 vector<int> mol_vec1; // molecule type of chain1, RNA if >0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4942 vector<int> mol_vec2; // molecule type of chain2, RNA if >0 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4943 vector<string> chainID_list1; // list of chainID1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4944 vector<string> chainID_list2; // list of chainID2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4945 int i,j; // file index |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4946 int chain_i,chain_j; // chain index |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4947 int r; // residue index |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4948 int xlen, ylen; // chain length |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4949 int xchainnum,ychainnum;// number of chains in a PDB file |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4950 char *seqx, *seqy; // for the protein sequence |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4951 char *secx, *secy; // for the secondary structure |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4952 double **xa, **ya; // for input vectors xa[0...xlen-1][0..2] and |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4953 // ya[0...ylen-1][0..2], in general, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4954 // ya is regarded as native structure |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4955 // --> superpose xa onto ya |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4956 vector<string> resi_vec1; // residue index for chain1 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4957 vector<string> resi_vec2; // residue index for chain2 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4958 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4959 /* loop over file names */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4960 for (i=0;i<chain1_list.size();i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4961 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4962 /* parse chain 1 */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4963 xname=chain1_list[i]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4964 xchainnum=get_PDB_lines(xname, PDB_lines1, chainID_list1, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4965 mol_vec1, ter_opt, infmt1_opt, atom_opt, split_opt, het_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4966 if (!xchainnum) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4967 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4968 cerr<<"Warning! Cannot parse file: "<<xname |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4969 <<". Chain number 0."<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4970 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4971 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4972 for (chain_i=0;chain_i<xchainnum;chain_i++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4973 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4974 xlen=PDB_lines1[chain_i].size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4975 mol_vec1[chain_i]=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4976 if (!xlen) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4977 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4978 cerr<<"Warning! Cannot parse file: "<<xname |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4979 <<". Chain length 0."<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4980 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4981 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4982 else if (xlen<3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4983 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4984 cerr<<"Sequence is too short <3!: "<<xname<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4985 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4986 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4987 NewArray(&xa, xlen, 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4988 seqx = new char[xlen + 1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4989 secx = new char[xlen + 1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4990 xlen = read_PDB(PDB_lines1[chain_i], xa, seqx, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4991 resi_vec1, byresi_opt?byresi_opt:o_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4992 if (mirror_opt) for (r=0;r<xlen;r++) xa[r][2]=-xa[r][2]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4993 make_sec(xa, xlen, secx); // secondary structure assignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4994 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4995 for (j=(dir_opt.size()>0)*(i+1);j<chain2_list.size();j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4996 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4997 /* parse chain 2 */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4998 if (PDB_lines2.size()==0) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
4999 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5000 yname=chain2_list[j]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5001 ychainnum=get_PDB_lines(yname, PDB_lines2, chainID_list2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5002 mol_vec2, ter_opt, infmt2_opt, atom_opt, split_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5003 het_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5004 if (!ychainnum) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5005 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5006 cerr<<"Warning! Cannot parse file: "<<yname |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5007 <<". Chain number 0."<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5008 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5009 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5010 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5011 for (chain_j=0;chain_j<ychainnum;chain_j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5012 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5013 ylen=PDB_lines2[chain_j].size(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5014 mol_vec2[chain_j]=-1; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5015 if (!ylen) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5016 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5017 cerr<<"Warning! Cannot parse file: "<<yname |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5018 <<". Chain length 0."<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5019 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5020 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5021 else if (ylen<3) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5022 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5023 cerr<<"Sequence is too short <3!: "<<yname<<endl; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5024 continue; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5025 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5026 NewArray(&ya, ylen, 3); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5027 seqy = new char[ylen + 1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5028 secy = new char[ylen + 1]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5029 ylen = read_PDB(PDB_lines2[chain_j], ya, seqy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5030 resi_vec2, byresi_opt?byresi_opt:o_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5031 make_sec(ya, ylen, secy); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5032 if (byresi_opt) extract_aln_from_resi(sequence, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5033 seqx,seqy,resi_vec1,resi_vec2,byresi_opt); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5034 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5035 /* declare variable specific to this pair of TMalign */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5036 double t0[3], u0[3][3]; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5037 double TM1, TM2; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5038 double TM3, TM4, TM5; // for a_opt, u_opt, d_opt |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5039 double d0_0, TM_0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5040 double d0A, d0B, d0u, d0a; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5041 double d0_out=5.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5042 string seqM, seqxA, seqyA;// for output alignment |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5043 double rmsd0 = 0.0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5044 int L_ali; // Aligned length in standard_TMscore |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5045 double Liden=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5046 double TM_ali, rmsd_ali; // TMscore and rmsd in standard_TMscore |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5047 int n_ali=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5048 int n_ali8=0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5049 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5050 /* entry function for structure alignment */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5051 if (cp_opt) CPalign_main( |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5052 xa, ya, seqx, seqy, secx, secy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5053 t0, u0, TM1, TM2, TM3, TM4, TM5, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5054 d0_0, TM_0, d0A, d0B, d0u, d0a, d0_out, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5055 seqM, seqxA, seqyA, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5056 rmsd0, L_ali, Liden, TM_ali, rmsd_ali, n_ali, n_ali8, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5057 xlen, ylen, sequence, Lnorm_ass, d0_scale, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5058 i_opt, a_opt, u_opt, d_opt, fast_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5059 mol_vec1[chain_i]+mol_vec2[chain_j],TMcut); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5060 else TMalign_main( |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5061 xa, ya, seqx, seqy, secx, secy, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5062 t0, u0, TM1, TM2, TM3, TM4, TM5, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5063 d0_0, TM_0, d0A, d0B, d0u, d0a, d0_out, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5064 seqM, seqxA, seqyA, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5065 rmsd0, L_ali, Liden, TM_ali, rmsd_ali, n_ali, n_ali8, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5066 xlen, ylen, sequence, Lnorm_ass, d0_scale, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5067 i_opt, a_opt, u_opt, d_opt, fast_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5068 mol_vec1[chain_i]+mol_vec2[chain_j],TMcut); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5069 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5070 /* print result */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5071 if (outfmt_opt==0) print_version(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5072 output_results( |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5073 xname.substr(dir1_opt.size()), |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5074 yname.substr(dir2_opt.size()), |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5075 chainID_list1[chain_i].c_str(), |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5076 chainID_list2[chain_j].c_str(), |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5077 xlen, ylen, t0, u0, TM1, TM2, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5078 TM3, TM4, TM5, rmsd0, d0_out, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5079 seqM.c_str(), seqxA.c_str(), seqyA.c_str(), Liden, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5080 n_ali8, L_ali, TM_ali, rmsd_ali, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5081 TM_0, d0_0, d0A, d0B, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5082 Lnorm_ass, d0_scale, d0a, d0u, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5083 (m_opt?fname_matrix+chainID_list1[chain_i]:"").c_str(), |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5084 outfmt_opt, ter_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5085 (o_opt?fname_super+chainID_list1[chain_i]:"").c_str(), |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5086 i_opt, a_opt, u_opt, d_opt,mirror_opt, |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5087 resi_vec1,resi_vec2); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5088 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5089 /* Done! Free memory */ |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5090 seqM.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5091 seqxA.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5092 seqyA.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5093 DeleteArray(&ya, ylen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5094 delete [] seqy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5095 delete [] secy; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5096 resi_vec2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5097 } // chain_j |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5098 if (chain2_list.size()>1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5099 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5100 yname.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5101 for (chain_j=0;chain_j<ychainnum;chain_j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5102 PDB_lines2[chain_j].clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5103 PDB_lines2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5104 chainID_list2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5105 mol_vec2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5106 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5107 } // j |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5108 PDB_lines1[chain_i].clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5109 DeleteArray(&xa, xlen); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5110 delete [] seqx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5111 delete [] secx; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5112 resi_vec1.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5113 } // chain_i |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5114 xname.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5115 PDB_lines1.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5116 chainID_list1.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5117 mol_vec1.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5118 } // i |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5119 if (chain2_list.size()==1) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5120 { |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5121 yname.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5122 for (chain_j=0;chain_j<ychainnum;chain_j++) |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5123 PDB_lines2[chain_j].clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5124 PDB_lines2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5125 resi_vec2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5126 chainID_list2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5127 mol_vec2.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5128 } |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5129 chain1_list.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5130 chain2_list.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5131 sequence.clear(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5132 |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5133 t2 = clock(); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5134 float diff = ((float)t2 - (float)t1)/CLOCKS_PER_SEC; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5135 printf("Total CPU time is %5.2f seconds\n", diff); |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5136 return 0; |
c790d25086dc
"planemo upload commit b0ede77caf410ab69043d33a44e190054024d340-dirty"
guerler
parents:
diff
changeset
|
5137 } |