00001 // $Id: mmdb_seqsuperpose.h $ 00002 // ================================================================= 00003 // 00004 // CCP4 Coordinate Library: support of coordinate-related 00005 // functionality in protein crystallography applications. 00006 // 00007 // Copyright (C) Eugene Krissinel 2000-2013. 00008 // 00009 // This library is free software: you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License version 3, modified in accordance with the provisions 00012 // of the license to address the requirements of UK law. 00013 // 00014 // You should have received a copy of the modified GNU Lesser 00015 // General Public License along with this library. If not, copies 00016 // may be downloaded from http://www.ccp4.ac.uk/ccp4license.php 00017 // 00018 // This program is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 // GNU Lesser General Public License for more details. 00022 // 00023 // ================================================================= 00024 // 00025 // 19.09.13 <-- Date of Last Modification. 00026 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00027 // ----------------------------------------------------------------- 00028 // 00029 // **** Module : SeqSuperpose <interface> 00030 // ~~~~~~~~~ 00031 // **** Classes : mmdb::SeqSuperpose 00032 // ~~~~~~~~~ 00033 // 00034 // (C) E.Krissinel 2005-2013 00035 // 00036 // ================================================================= 00037 // 00038 00039 #ifndef __Seq_Superpose__ 00040 #define __Seq_Superpose__ 00041 00042 #include "mmdb_manager.h" 00043 #include "mmdb_math_align.h" 00044 00045 namespace mmdb { 00046 00047 // ================================================================= 00048 00049 enum SEQSP_RC { 00050 SEQSP_Ok = 0, 00051 SEQSP_IterLimit = 100, 00052 SEQSP_SeqThreshold = 101 00053 }; 00054 00055 DefineClass(SeqSuperpose); 00056 00057 class SeqSuperpose { 00058 00059 public : 00060 mat44 TMatrix; // superposes Ca1 over Ca2: |T*Ca1 - Ca2|->min 00061 realtype Q; // Q-score 00062 realtype rmsd; // rmsd 00063 realtype seqId; // sequence identity in structure alignment 00064 realtype _seqId; // sequence identity in sequence alignment 00065 int Nalign; // alignment length in structure alignment 00066 ivector c1; // sup-n vector: Ca1[i]->Ca2[c1[i]] if c1[i]>=0 00067 ivector c2; // sup-n vector: Ca2[i]->Ca1[c2[i]] if c2[i]>=0 00068 00069 SeqSuperpose(); 00070 ~SeqSuperpose(); 00071 00072 // Given two sets of atoms, Calpha1 and Calpha2, Superpose(...) 00073 // calculates the rotational-translational matrix TMatrix such 00074 // that |TMatrix*Calpha1 - Calpha2| is minimal in least-square 00075 // terms. 00076 // In difference of a full-scale SSM, this simplified version 00077 // uses initial superposition from sequence alignment, hence 00078 // it should be applied only to similar chains where calculation 00079 // time is crucial. seqThreshold specifies a threshold of 00080 // sequence identity (0<=seqThreshold<=1), below which 00081 // structural alignment is not performed and Superpose(..) 00082 // returns SEQSP_SeqThreshold. 00083 // 00084 // If keepBricks is set True, then space bricks are not 00085 // removed in MMDB and may be used in the next call if 00086 // vector Calpha2 does not change. This saves computation 00087 // time. 00088 // 00089 // The alignment results return in public fields above: 00090 // TMatrix - transformation matrix (1 if not aligned) 00091 // Q - quality Q-score (-1 if not aligned) 00092 // rmsd - r.m.s.d (MaxReal if not aligned) 00093 // seqId - sequence identity in structure alignment 00094 // (0 if not aligned) 00095 // Nalign - alignment length in structure alignment 00096 // (0 if not aligned) 00097 // c1,c2 - atom corrspondences: 00098 // Calpha1[i] <=> Calpha2[c1[i]] 00099 // Calpha2[i] <=> Calpha1[c2[i]] 00100 // 00101 // Upon success, Superpose(...) returns SEQSP_Ok 00102 // 00103 int Superpose ( PManager MMDB, 00104 PPAtom Calpha1, int nCalpha1, 00105 PPAtom Calpha2, int nCalpha2, 00106 realtype seqThreshold, 00107 bool keepBricks ); 00108 00109 protected : 00110 math::PAlignment Align; 00111 PManager M; // pointers to 00112 PPAtom Ca1,Ca2; // the input data 00113 int nCa1,nCa2; // copy chain lengths 00114 ivector cn1,cn2; // temporary contact arrays 00115 realtype Rmsd0; // quality optimization parameter 00116 realtype maxContact; // maximal Calpha-pair contact parameter 00117 PContact contact; 00118 int ncontacts; 00119 00120 void SeqSuperposeInit(); 00121 void FreeMemory (); 00122 realtype MatchQuality ( int Nalign, realtype Rmsd, 00123 int nres1, int nres2 ); 00124 realtype MatchQuality2 ( int Nalign, realtype dist2, 00125 int nres1, int nres2 ); 00126 void MakeContacts ( mat44 & TM, realtype cont_est ); 00127 int makeStructAlignment ( realtype seqThreshold, 00128 bool keepBricks ); 00129 00130 }; 00131 00132 } // namespace mmdb 00133 00134 #endif
1.7.2