| 1 | /* |
| 2 | * ligand/smith-waterman.hh |
| 3 | * |
| 4 | * Copyright 2021 by Medical Research Council |
| 5 | * Author: Paul Emsley |
| 6 | * |
| 7 | * This file is part of Coot |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU Lesser General Public License as published |
| 11 | * by the Free Software Foundation; either version 3 of the License, or (at |
| 12 | * your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Lesser General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copies of the GNU General Public License and |
| 20 | * the GNU Lesser General Public License along with this program; if not, |
| 21 | * write to the Free Software Foundation, Inc., 51 Franklin Street, |
| 22 | * Fifth Floor, Boston, MA, 02110-1301, USA. |
| 23 | * See http://www.gnu.org/licenses/ |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #ifndef SMITH_WATERMAN_HH |
| 28 | #define SMITH_WATERMAN_HHcxx . . $ `ligand/smith-waterman.hh:28:9`! |
| 29 | |
| 30 | #include <vector> |
| 31 | #include <string> |
| 32 | #include <map> |
| 33 | |
| 34 | #include <mmdb2/mmdb_manager.h> |
| 35 | #include <clipper/core/xmap.h> |
| 36 | #include "geometry/protein-geometry.hh"cxx . . $ `<file>/geometry/protein-geometry.hh`/ |
| 37 | |
| 38 | // delte this on merge |
| 39 | stdcxx . . $ std/::stringcxx . . $ std/string# coot_util_single_letter_to_3_letter_codecxx . . $ coot_util_single_letter_to_3_letter_code(19fb849b05fb51c6).(char code); |
| 40 | |
| 41 | namespace sm_watcxx . . $ sm_wat/ { |
| 42 | |
| 43 | // --------------------------------------------------------------------- |
| 44 | // the testing/devel interface |
| 45 | // --------------------------------------------------------------------- |
| 46 | |
| 47 | float H_i_jcxx . . $ sm_wat/H_i_j(f1423a19767d39ff).(int i, int j, |
| 48 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 49 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_1, |
| 50 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_2); |
| 51 | |
| 52 | void print_Hcxx . . $ sm_wat/print_H(ba3a9dee6c744893).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H); |
| 53 | void fill_scoring_matrixcxx . . $ sm_wat/fill_scoring_matrix(15f5a77e3cccf11b).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 54 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_1, |
| 55 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_2); |
| 56 | float H_i_jcxx . . $ sm_wat/H_i_j(f1423a19767d39ff).(int i, int j, |
| 57 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 58 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_1, |
| 59 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_2); |
| 60 | |
| 61 | float score_with_method_1cxx . . $ sm_wat/score_with_method_1(f1423a19767d39ff).(int i, int j, |
| 62 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 63 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_1, |
| 64 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_2); |
| 65 | float score_with_method_2cxx . . $ sm_wat/score_with_method_2(f1423a19767d39ff).(int i, int j, |
| 66 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 67 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_1, |
| 68 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_2); |
| 69 | float score_with_method_3cxx . . $ sm_wat/score_with_method_3(f1423a19767d39ff).(int i, int j, |
| 70 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 71 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_1, |
| 72 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_2); |
| 73 | |
| 74 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > construct_Hcxx . . $ sm_wat/construct_H(8aac89eb221fcc71).(const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_1, |
| 75 | const stdcxx . . $ std/::stringcxx . . $ std/string# &seq_2); |
| 76 | float score_against_typecxx . . $ sm_wat/score_against_type(9310a3e4fb2f32aa).(char c, const stdcxx . . $ std/::stringcxx . . $ std/string# &type); |
| 77 | float score_against_typecxx . . $ sm_wat/score_against_type(87eac08ec0050689).(int idx, const stdcxx . . $ std/::stringcxx . . $ std/string# &seq, const stdcxx . . $ std/::stringcxx . . $ std/string# &type); |
| 78 | |
| 79 | stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>, stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> > backtrack_seqcxx . . $ sm_wat/backtrack_seq(414b31ba86f1c72a).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H); |
| 80 | |
| 81 | // --------------------------------------------------------------------- |
| 82 | // the real interface |
| 83 | // --------------------------------------------------------------------- |
| 84 | |
| 85 | class cell_tcxx . . $ sm_wat/cell_t# { |
| 86 | public: |
| 87 | int icxx . . $ sm_wat/cell_t#i.; |
| 88 | int jcxx . . $ sm_wat/cell_t#j.; |
| 89 | cell_tcxx . . $ sm_wat/cell_t#cell_t(49f6e7a06ebc5aa8).() { icxx . . $ sm_wat/cell_t#i.=-1; jcxx . . $ sm_wat/cell_t#j.=-1; } |
| 90 | cell_tcxx . . $ sm_wat/cell_t#cell_t(f27ff5a0a080eb8a).(const int &ii, const int &jj) : icxx . . $ sm_wat/cell_t#i.(ii), jcxx . . $ sm_wat/cell_t#j.(jj) {} |
| 91 | bool operatorcxx . . $ sm_wat/cell_t#`operator==`(5c4afe7e5badb6b1).==(const cell_tcxx . . $ sm_wat/cell_t# &other) const { |
| 92 | if (other.icxx . . $ sm_wat/cell_t#i. == icxx . . $ sm_wat/cell_t#i.) |
| 93 | if (other.jcxx . . $ sm_wat/cell_t#j. == jcxx . . $ sm_wat/cell_t#j.) |
| 94 | return true; |
| 95 | return false; |
| 96 | } |
| 97 | bool non_zero_indexedcxx . . $ sm_wat/cell_t#non_zero_indexed(50ce9a9e25b4a850).() const { |
| 98 | if (icxx . . $ sm_wat/cell_t#i. > 0) |
| 99 | if (jcxx . . $ sm_wat/cell_t#j. > 0) |
| 100 | return true; |
| 101 | return false; |
| 102 | } |
| 103 | }; |
| 104 | |
| 105 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<cell_tcxx . . $ sm_wat/cell_t#> smith_watermancxx . . $ sm_wat/smith_waterman(5ab979c43a0bea5c).(const stdcxx . . $ std/::stringcxx . . $ std/string# &sequence, |
| 106 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > &scored_residues); |
| 107 | |
| 108 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > construct_Hcxx . . $ sm_wat/construct_H(c7c82cdab9af6af9).(const stdcxx . . $ std/::stringcxx . . $ std/string# &target_sequence); |
| 109 | float scxx . . $ sm_wat/s(dfb6e31d3a1aa160).(char a, const stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > &b); |
| 110 | float W_gap_sequencecxx . . $ sm_wat/W_gap_sequence(5cde91ea12d43f46).(int k); |
| 111 | float W_gap_residuescxx . . $ sm_wat/W_gap_residues(5cde91ea12d43f46).(int k); |
| 112 | |
| 113 | float score_with_method_1cxx . . $ sm_wat/score_with_method_1(8c18082b14898c4a).(int seq_idx, |
| 114 | int types_idx, |
| 115 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 116 | const stdcxx . . $ std/::stringcxx . . $ std/string# &target_sequence, |
| 117 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > &scored_residues); |
| 118 | |
| 119 | float score_with_method_2cxx . . $ sm_wat/score_with_method_2(8c18082b14898c4a).(int seq_idx, |
| 120 | int types_idx, |
| 121 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 122 | const stdcxx . . $ std/::stringcxx . . $ std/string# &target_sequence, |
| 123 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > &scored_residues); |
| 124 | |
| 125 | float score_with_method_3cxx . . $ sm_wat/score_with_method_3(8c18082b14898c4a).(int seq_idx, |
| 126 | int types_idx, |
| 127 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 128 | const stdcxx . . $ std/::stringcxx . . $ std/string# &target_sequence, |
| 129 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > &scored_residues); |
| 130 | |
| 131 | void fill_scoring_matrixcxx . . $ sm_wat/fill_scoring_matrix(f5d636d781fa064a).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 132 | const stdcxx . . $ std/::stringcxx . . $ std/string# &target_sequence, |
| 133 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > &scored_residues); |
| 134 | |
| 135 | float H_i_jcxx . . $ sm_wat/H_i_j(8c18082b14898c4a).(int seq_idx, int types_idx, const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 136 | const stdcxx . . $ std/::stringcxx . . $ std/string# &target_sequence, |
| 137 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > &scored_residues); |
| 138 | |
| 139 | stdcxx . . $ std/::paircxx . . $ std/pair#<float, stdcxx . . $ std/::vectorcxx . . $ std/vector#<sm_watcxx . . $ sm_wat/::cell_tcxx . . $ sm_wat/cell_t#> > |
| 140 | backtrackcxx . . $ sm_wat/backtrack(db6274172f879dd4).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H); |
| 141 | |
| 142 | // backtrack non-top (the passed cell vector is the trace(s) from better scoring traces) |
| 143 | stdcxx . . $ std/::paircxx . . $ std/pair#<float, stdcxx . . $ std/::vectorcxx . . $ std/vector#<sm_watcxx . . $ sm_wat/::cell_tcxx . . $ sm_wat/cell_t#> > |
| 144 | backtrack_otherscxx . . $ sm_wat/backtrack_others(610a84f56132d21).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > &H, |
| 145 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<cell_tcxx . . $ sm_wat/cell_t#> &cells_from_better_traces); |
| 146 | |
| 147 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<bool, float> > > construct_Hcxx . . $ sm_wat/construct_H(5272cde88b88ec3).(const stdcxx . . $ std/::stringcxx . . $ std/string# &target_sequence, |
| 148 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > &scored_residues); |
| 149 | |
| 150 | void print_alignmentcxx . . $ sm_wat/print_alignment(73ce7e7a11668a54).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<cell_tcxx . . $ sm_wat/cell_t#> &indexed_sequences, // currently reverse order |
| 151 | const stdcxx . . $ std/::stringcxx . . $ std/string# &sequence, |
| 152 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > &scored_residues); |
| 153 | |
| 154 | |
| 155 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > |
| 156 | get_side_chain_density_scores_for_residuescxx . . $ sm_wat/get_side_chain_density_scores_for_residues(4b26bbad5e71e108).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *> &a_run_of_residues, |
| 157 | const clippercxx . . $ clipper/::Xmapcxx . . $ clipper/Xmap#<float> &xmap); |
| 158 | |
| 159 | |
| 160 | void apply_alignment_to_modelcxx . . $ sm_wat/apply_alignment_to_model(73ce7e7a11668a54).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<sm_watcxx . . $ sm_wat/::cell_tcxx . . $ sm_wat/cell_t#> &alignment, |
| 161 | const stdcxx . . $ std/::stringcxx . . $ std/string# &target_sequence, |
| 162 | const stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<mmdbcxx . . $ mmdb/::Residuecxx . . $ mmdb/Residue# *, stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, double> > > > &scored_residues); |
| 163 | |
| 164 | |
| 165 | // this is the API function that you want |
| 166 | void align_and_mutate_and_backrubcxx . . $ sm_wat/align_and_mutate_and_backrub(ca7889116dd5b4e2).(mmdbcxx . . $ mmdb/::Managercxx . . $ mmdb/Manager# *mol, const stdcxx . . $ std/::stringcxx . . $ std/string# &seq, const clippercxx . . $ clipper/::Xmapcxx . . $ clipper/Xmap#<float> &xmap, |
| 167 | const cootcxx . . $ coot/::protein_geometrycxx . . $ coot/protein_geometry# &pg); |
| 168 | |
| 169 | } |
| 170 | |
| 171 | |
| 172 | |
| 173 | #endif // SMITH_WATERMAN_HH |