6#ifndef NURI_TOOLS_TM_H_
7#define NURI_TOOLS_TM_H_
13#include <absl/base/attributes.h>
24 void remap_helper(AlignedXY &xy,
const Pred &pred)
noexcept;
28 AlignedXY(ConstRef<Matrix3Xd> x, ConstRef<Matrix3Xd> y,
const int l_min)
29 : x_(x), y_(y), xtm_(3, l_min), ytm_(3, l_min), y2x_(y.cols()),
32 void remap(ConstRef<ArrayXi> y2x)
noexcept;
34 void remap(ArrayXi &&y2x)
noexcept;
36 void remap_final(ConstRef<Matrix3Xd> x_aln,
double score_d8sq)
noexcept;
38 void swap_remap(ArrayXi &y2x)
noexcept;
40 void swap_align_with(ArrayXi &y2x)
noexcept;
42 void reset() noexcept {
47 ConstRef<Matrix3Xd> x()
const {
return x_; }
49 auto xtm() {
return xtm_.leftCols(l_ali_); }
50 auto xtm()
const {
return xtm_.leftCols(l_ali_); }
52 ConstRef<Matrix3Xd> y()
const {
return y_; }
54 auto ytm() {
return ytm_.leftCols(l_ali_); }
55 auto ytm()
const {
return ytm_.leftCols(l_ali_); }
57 int l_ali()
const {
return l_ali_; }
59 int l_min()
const {
return static_cast<int>(xtm_.cols()); }
61 ArrayXi &y2x() {
return y2x_; }
62 const ArrayXi &y2x()
const {
return y2x_; }
66 friend void remap_helper(AlignedXY &xy,
const Pred &pred)
noexcept;
68 Eigen::Ref<const Matrix3Xd> x_;
69 Eigen::Ref<const Matrix3Xd> y_;
78 enum class SecStr :
char {
93 extern SecStr assign_secstr_approx(ConstRef<Array33d> dists);
105 extern ArrayXc assign_secstr_approx_full(ConstRef<Matrix3Xd> pts,
109 extern double tm_initial_gt(Matrix3Xd &rx, Matrix3Xd &ry, ArrayXd &dsqs,
110 ConstRef<Matrix3Xd> x, ConstRef<Matrix3Xd> y,
111 ArrayXi &y2x,
double d0sq_inv,
114 extern void tm_initial_ss(ArrayXi &y2x, ArrayXXc &path, ArrayXXd &val,
115 ConstRef<ArrayXc> secx, ConstRef<ArrayXc> secy);
118 extern double tm_initial_local(Matrix3Xd &rx, Matrix3Xd &ry, ArrayXd &dsqs,
119 ArrayXXc &path, ArrayXXd &val, AlignedXY &xy,
120 ArrayXi &y2x, ArrayXi &buf,
double d0sq_inv,
121 double d01sq_inv,
double d0sq_search);
124 extern bool tm_initial_ssplus(Matrix3Xd &rx, Matrix3Xd &ry, ArrayXXc &path,
125 ArrayXXd &val,
const AlignedXY &xy,
126 ArrayXi &y2x, ConstRef<ArrayXc> secx,
127 ConstRef<ArrayXc> secy,
double d01sq_inv);
130 extern double tm_initial_fgt(Matrix3Xd &rx, Matrix3Xd &ry, ArrayXd &dsqs,
131 ConstRef<Matrix3Xd> x, ConstRef<Matrix3Xd> y,
132 ArrayXi &y2x,
double dcu0_sq,
double d0sq_inv,
135 extern double tm_realign_calculate_msd(AlignedXY &xy, Matrix3Xd &rx,
136 Matrix3Xd &ry,
const Isometry3d &xform,
138 bool keep_alignment);
213 TMAlign(ConstRef<Matrix3Xd> query, ConstRef<Matrix3Xd> templ);
241 ConstRef<ArrayXc> secy);
258 bool initialize(ConstRef<ArrayXi> y2x,
bool keep_alignment =
true);
273 std::pair<Isometry3d, double>
tm_score(
int l_norm = -1,
double d0 = -1);
296 int l_ali()
const {
return xy_.l_ali(); }
305 ConstRef<Matrix3Xd> query()
const {
return xy_.x(); }
306 ConstRef<Matrix3Xd> templ()
const {
return xy_.y(); }
308 int l_min()
const {
return l_minmax_.first; }
309 int l_max()
const {
return l_minmax_.second; }
311 ArrayXi &y2x_local() {
return y2x_buf1_; }
312 ArrayXi &y2x_buf() {
return y2x_buf2_; }
314 ArrayXi &i_ali() {
return y2x_buf1_; }
315 ArrayXi &j_ali() {
return y2x_buf2_; }
317 std::pair<int, int> l_minmax_;
318 internal::AlignedXY xy_;
320 Isometry3d best_xform_;
325 ArrayXi y2x_buf1_, y2x_buf2_;
367tm_align(ConstRef<Matrix3Xd> query, ConstRef<Matrix3Xd> templ,
369 int l_norm = -1,
double d0 = -1);
389tm_align(ConstRef<Matrix3Xd> query, ConstRef<Matrix3Xd> templ,
390 ConstRef<ArrayXc> secx, ConstRef<ArrayXc> secy,
392 int l_norm = -1,
double d0 = -1);
418 ConstRef<Matrix3Xd> templ, ConstRef<ArrayXi> y2x,
419 int l_norm = -1,
double d0 = -1,
420 bool keep_alignment =
true);
424 extern std::pair<int, double>
425 tmalign_score_fun8(
const Matrix3Xd &x,
const Matrix3Xd &y, ArrayXi &aligned,
426 double d_cutoff,
double d0sq_inv,
427 double score_d8sq_cutoff);
429 extern std::pair<int, double>
430 tmalign_score_fun8(
const Matrix3Xd &x,
const Matrix3Xd &y, ArrayXi &aligned,
431 double d_cutoff,
double d0sq_inv);
433 extern std::pair<Isometry3d, double>
434 tmalign_tmscore8_search(
const AlignedXY &xy,
int simplify_step,
435 double local_d0_search,
double score_d8sq_cutoff,
438 extern void tmalign_dp_iter(Isometry3d &xform_best,
double &tmscore_max,
439 AlignedXY &xy, ArrayXi &y2x_best,
int g1,
int g2,
440 int max_iter,
int simplify_step,
441 double local_d0_search,
double score_d8sq_cutoff,
444 extern double tmalign_get_score_fast(
const Matrix3Xd &x,
const Matrix3Xd &y,
445 double d0sq_inv,
double d0_search);
int l_ali() const
Get the length of the aligned region.
Definition tm.h:296
TMAlign(ConstRef< Matrix3Xd > query, ConstRef< Matrix3Xd > templ)
Prepare TM-align algorithm with the given structures.
InitFlags
Initialization flags for TM-align algorithm.
Definition tm.h:178
@ kNone
Definition tm.h:179
@ kDefault
Default initialization flags, combination of all initialization methods.
Definition tm.h:201
@ kGaplessThreading
Enable gapless threading.
Definition tm.h:182
@ kLocalPlusSecStr
Definition tm.h:195
@ kFragmentGaplessThreading
Enable fragment gapless threading.
Definition tm.h:198
@ kSecStr
Definition tm.h:186
@ kLocal
Definition tm.h:191
ABSL_MUST_USE_RESULT bool initialize(ConstRef< ArrayXi > y2x, bool keep_alignment=true)
Initialize the TM-align algorithm with user-provided alignment.
double aligned_msd() const
Get the mean square deviation of the aligned region.
Definition tm.h:302
bool initialized() const
Definition tm.h:260
ArrayXi && templ_to_query() &&
Final alignment of the structures (move version).
Definition tm.h:290
const ArrayXi & templ_to_query() const &
Final alignment of the structures.
Definition tm.h:281
std::pair< Isometry3d, double > tm_score(int l_norm=-1, double d0=-1)
Calculate TM-score using the current alignment.
ABSL_MUST_USE_RESULT bool initialize(InitFlags flags, ConstRef< ArrayXc > secx, ConstRef< ArrayXc > secy)
Initialize the TM-align algorithm with user-provided secondary structures.
ABSL_MUST_USE_RESULT bool initialize(InitFlags flags=InitFlags::kDefault)
Initialize the TM-align algorithm.
TMAlignResult tm_align(ConstRef< Matrix3Xd > query, ConstRef< Matrix3Xd > templ, TMAlign::InitFlags flags=TMAlign::InitFlags::kDefault, int l_norm=-1, double d0=-1)
Align two structures using TM-align algorithm.
Result of TM-align algorithm.
Definition tm.h:334
Isometry3d xform
The transformation matrix.
Definition tm.h:336
double msd
The mean square deviation of the aligned region.
Definition tm.h:343
ArrayXi templ_to_query
Definition tm.h:340
double tm_score
The TM-score of the alignment.
Definition tm.h:346