ObjectAlignment.cpp (pymol-open-source-2.2.0) | : | ObjectAlignment.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 17 | skipping to change at line 17 | |||
E* It is unlawful to modify or remove this copyright notice. | E* It is unlawful to modify or remove this copyright notice. | |||
F* ------------------------------------------------------------------- | F* ------------------------------------------------------------------- | |||
G* Please see the accompanying LICENSE file for further information. | G* Please see the accompanying LICENSE file for further information. | |||
H* ------------------------------------------------------------------- | H* ------------------------------------------------------------------- | |||
I* Additional authors of this source file include: | I* Additional authors of this source file include: | |||
-* | -* | |||
-* | -* | |||
-* | -* | |||
Z* ------------------------------------------------------------------- | Z* ------------------------------------------------------------------- | |||
*/ | */ | |||
#include <set> | ||||
#include"os_python.h" | #include"os_python.h" | |||
#include"os_predef.h" | #include"os_predef.h" | |||
#include"os_std.h" | #include"os_std.h" | |||
#include"os_gl.h" | #include"os_gl.h" | |||
#include"OOMac.h" | #include"OOMac.h" | |||
#include"ObjectAlignment.h" | #include"ObjectAlignment.h" | |||
#include"Base.h" | #include"Base.h" | |||
#include"MemoryDebug.h" | #include"MemoryDebug.h" | |||
skipping to change at line 124 | skipping to change at line 127 | |||
if(n_more_plus_one > 0) { | if(n_more_plus_one > 0) { | |||
ai0++; | ai0++; | |||
if(!AtomInfoSameResidueP(G, ai, ai0)) | if(!AtomInfoSameResidueP(G, ai, ai0)) | |||
break; | break; | |||
} else | } else | |||
break; | break; | |||
} | } | |||
return result; | return result; | |||
} | } | |||
/* | ||||
* Get single letter abbreviation for CLUSTAL output. | ||||
* | ||||
* See also: | ||||
* pymol.exporting._resn_to_aa | ||||
* AtomInfoKnownNucleicResName | ||||
* AtomInfoKnownProteinResName | ||||
* SeekerGetAbbr | ||||
*/ | ||||
static char get_abbr(PyMOLGlobals * G, const AtomInfoType * ai) { | ||||
const char * resn = LexStr(G, ai->resn); | ||||
const char unknown = ((ai->flags & cAtomFlag_polymer)) ? '?' : 0; | ||||
if ((ai->flags & cAtomFlag_nucleic)) { | ||||
if (resn[0] == 'D') { | ||||
++resn; | ||||
} | ||||
if (strlen(resn) != 1) { | ||||
return unknown; | ||||
} | ||||
return resn[0]; | ||||
} | ||||
return SeekerGetAbbr(G, resn, 0, unknown); | ||||
} | ||||
int ObjectAlignmentAsStrVLA(PyMOLGlobals * G, ObjectAlignment * I, int state, in t format, | int ObjectAlignmentAsStrVLA(PyMOLGlobals * G, ObjectAlignment * I, int state, in t format, | |||
char **str_vla) | char **str_vla) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
ov_size len = 0; | ov_size len = 0; | |||
char *vla = VLAlloc(char, 1000); | char *vla = VLAlloc(char, 1000); | |||
int force_update = false; | int force_update = false; | |||
int active_only = false; | int active_only = false; | |||
int max_name_len = 12; /* default indentation */ | int max_name_len = 12; /* default indentation */ | |||
skipping to change at line 164 | skipping to change at line 195 | |||
int align_sele = SelectorIndexByName(G, I->Obj.Name); | int align_sele = SelectorIndexByName(G, I->Obj.Name); | |||
if(align_sele >= 0) { | if(align_sele >= 0) { | |||
int nRow = 0; | int nRow = 0; | |||
ov_size nCol = 0; | ov_size nCol = 0; | |||
CSeqRow *row_vla = NULL, *row; | CSeqRow *row_vla = NULL, *row; | |||
char *cons_str = NULL; | char *cons_str = NULL; | |||
void *hidden = NULL; | void *hidden = NULL; | |||
ObjectMolecule *obj; | ObjectMolecule *obj; | |||
if(align_sele < 0) { | { | |||
align_sele = ExecutiveGetActiveAlignmentSele(G); | ||||
} | ||||
if(align_sele >= 0) { | ||||
row_vla = VLACalloc(CSeqRow, 10); | row_vla = VLACalloc(CSeqRow, 10); | |||
/* first, find out which objects are included in the | /* first, find out which objects are included in the | |||
alignment and count the name length */ | alignment and count the name length */ | |||
while(ExecutiveIterateObjectMolecule(G, &obj, &hidden)) { | while(ExecutiveIterateObjectMolecule(G, &obj, &hidden)) { | |||
if((obj->Obj.Enabled || !active_only) && (obj->Obj.Name[0] != '_') ) { | if((obj->Obj.Enabled || !active_only) && (obj->Obj.Name[0] != '_') ) { | |||
int a; | int a; | |||
AtomInfoType *ai = obj->AtomInfo; | AtomInfoType *ai = obj->AtomInfo; | |||
for(a = 0; a < obj->NAtom; a++) { | for(a = 0; a < obj->NAtom; a++) { | |||
skipping to change at line 210 | skipping to change at line 238 | |||
int min_tag = -1; | int min_tag = -1; | |||
int untagged_col = false; | int untagged_col = false; | |||
done = true; | done = true; | |||
for(a = 0; a < nRow; a++) { | for(a = 0; a < nRow; a++) { | |||
row = row_vla + a; | row = row_vla + a; | |||
while(row->cCol < row->nCol) { /* advance to next tag i n each row & find lowest */ | while(row->cCol < row->nCol) { /* advance to next tag i n each row & find lowest */ | |||
AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | |||
done = false; | done = false; | |||
if(AtomInfoSameResidueP(G, row->last_ai, ai)) { | if(AtomInfoSameResidueP(G, row->last_ai, ai)) { | |||
row->cCol++; | row->cCol++; | |||
} else if(!SeekerGetAbbr(G, LexStr(G, ai->resn), 0, 0)) { /* not a known residue type */ | } else if(!get_abbr(G, ai)) { /* not a polymer residue */ | |||
row->cCol++; | row->cCol++; | |||
} else { | } else { | |||
int tag = | int tag = | |||
AlignmentFindTag(G, ai, align_sele, row->nCol - row->cCo l); | AlignmentFindTag(G, ai, align_sele, row->nCol - row->cCo l); | |||
if(tag) { /* we're at a tagged atom... */ | if(tag) { /* we're at a tagged atom... */ | |||
if(min_tag > tag) | if(min_tag > tag) | |||
min_tag = tag; | min_tag = tag; | |||
else if(min_tag < 0) | else if(min_tag < 0) | |||
min_tag = tag; | min_tag = tag; | |||
break; | break; | |||
skipping to change at line 294 | skipping to change at line 322 | |||
int min_tag = -1; | int min_tag = -1; | |||
int untagged_col = false; | int untagged_col = false; | |||
done = true; | done = true; | |||
for(a = 0; a < nRow; a++) { | for(a = 0; a < nRow; a++) { | |||
row = row_vla + a; | row = row_vla + a; | |||
while(row->cCol < row->nCol) { /* advance to next tag i n each row & find lowest */ | while(row->cCol < row->nCol) { /* advance to next tag i n each row & find lowest */ | |||
AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | |||
done = false; | done = false; | |||
if(AtomInfoSameResidueP(G, row->last_ai, ai)) { | if(AtomInfoSameResidueP(G, row->last_ai, ai)) { | |||
row->cCol++; | row->cCol++; | |||
} else if(!SeekerGetAbbr(G, LexStr(G, ai->resn), 0, 0)) { /* not a known residue type */ | } else if(!get_abbr(G, ai)) { /* not a polymer residue */ | |||
row->cCol++; | row->cCol++; | |||
} else { | } else { | |||
int tag = | int tag = | |||
AlignmentFindTag(G, ai, align_sele, row->nCol - row->cCo l); | AlignmentFindTag(G, ai, align_sele, row->nCol - row->cCo l); | |||
if(tag) { /* we're at a tagged atom... */ | if(tag) { /* we're at a tagged atom... */ | |||
if(min_tag > tag) | if(min_tag > tag) | |||
min_tag = tag; | min_tag = tag; | |||
else if(min_tag < 0) | else if(min_tag < 0) | |||
min_tag = tag; | min_tag = tag; | |||
break; | break; | |||
skipping to change at line 323 | skipping to change at line 351 | |||
/* increment all untagged atoms */ | /* increment all untagged atoms */ | |||
for(a = 0; a < nRow; a++) { | for(a = 0; a < nRow; a++) { | |||
row = row_vla + a; | row = row_vla + a; | |||
if(row->cCol < row->nCol) { | if(row->cCol < row->nCol) { | |||
AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | |||
int tag = | int tag = | |||
AlignmentFindTag(G, ai, align_sele, row->nCol - row->cCo l); | AlignmentFindTag(G, ai, align_sele, row->nCol - row->cCo l); | |||
if(!tag) { | if(!tag) { | |||
if(!AtomInfoSameResidueP(G, row->last_ai, ai)) { | if(!AtomInfoSameResidueP(G, row->last_ai, ai)) { | |||
row->last_ai = ai; | row->last_ai = ai; | |||
row->txt[row->len] = SeekerGetAbbr(G, LexStr(G, ai->re sn), ' ', 'X'); | row->txt[row->len] = get_abbr(G, ai); | |||
} else { | } else { | |||
row->txt[row->len] = '-'; | row->txt[row->len] = '-'; | |||
} | } | |||
row->len++; | row->len++; | |||
row->cCol++; | row->cCol++; | |||
} else { | } else { | |||
row->txt[row->len] = '-'; | row->txt[row->len] = '-'; | |||
row->len++; | row->len++; | |||
} | } | |||
} else { | } else { | |||
skipping to change at line 354 | skipping to change at line 382 | |||
for(a = 0; a < nRow; a++) { | for(a = 0; a < nRow; a++) { | |||
row = row_vla + a; | row = row_vla + a; | |||
if(row->cCol < row->nCol) { | if(row->cCol < row->nCol) { | |||
AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | |||
int tag = | int tag = | |||
AlignmentFindTag(G, ai, align_sele, row->nCol - row->cCo l); | AlignmentFindTag(G, ai, align_sele, row->nCol - row->cCo l); | |||
if(tag == min_tag) { /* advance past this tag */ | if(tag == min_tag) { /* advance past this tag */ | |||
char abbr; | char abbr; | |||
if(!AtomInfoSameResidueP(G, row->last_ai, ai)) { | if(!AtomInfoSameResidueP(G, row->last_ai, ai)) { | |||
row->last_ai = ai; | row->last_ai = ai; | |||
abbr = SeekerGetAbbr(G, LexStr(G, ai->resn), ' ', 'X') ; | abbr = get_abbr(G, ai); | |||
if(cons_abbr == ' ') | if(cons_abbr == ' ') | |||
cons_abbr = abbr; | cons_abbr = abbr; | |||
else if(cons_abbr != abbr) | else if(cons_abbr != abbr) | |||
cons_abbr = 0; | cons_abbr = 0; | |||
abbr_cnt++; | abbr_cnt++; | |||
} else { | } else { | |||
abbr = '-'; | abbr = '-'; | |||
cons_abbr = 0; | cons_abbr = 0; | |||
} | } | |||
row->txt[row->len] = abbr; | row->txt[row->len] = abbr; | |||
skipping to change at line 461 | skipping to change at line 489 | |||
/* curVLA and newVLA must be properly sized and zero terminated... */ | /* curVLA and newVLA must be properly sized and zero terminated... */ | |||
int *result = NULL; | int *result = NULL; | |||
int n_result = 0; | int n_result = 0; | |||
{ | { | |||
{ | { | |||
int n_cur = VLAGetSize(curVLA); | int n_cur = VLAGetSize(curVLA); | |||
int n_new = VLAGetSize(newVLA); | int n_new = VLAGetSize(newVLA); | |||
/* now we can take unique IDs to specific atoms */ | // get the set of non-guide objects in the new alignment, they need | |||
// to be flushed (removed) from the current alignment | ||||
std::set<const ObjectMolecule*> flushobjects; | ||||
if (flush) { | ||||
flushobjects.insert(flush); | ||||
} else { | ||||
for (const int *it = newVLA, *it_end = it + n_new; it != it_end; ++it) { | ||||
if (*it) { | ||||
auto eoo = ExecutiveUniqueIDAtomDictGet(G, *it); | ||||
if (eoo && eoo->obj != guide) { | ||||
flushobjects.insert(eoo->obj); | ||||
} | ||||
} | ||||
} | ||||
} | ||||
/* first, go through and eliminate old matching atoms between guide and fl ush (if any) */ | /* first, go through and eliminate old matching atoms between guide and fl ush (if any) */ | |||
{ | { | |||
int cur_start = 0; | int cur_start = 0; | |||
while(cur_start < n_cur) { | while(cur_start < n_cur) { | |||
while((cur_start < n_cur) && !curVLA[cur_start]) { | while((cur_start < n_cur) && !curVLA[cur_start]) { | |||
cur_start++; | cur_start++; | |||
} | } | |||
skipping to change at line 484 | skipping to change at line 526 | |||
int flush_seen = false; | int flush_seen = false; | |||
ObjectMolecule *obj; | ObjectMolecule *obj; | |||
{ | { | |||
int cur = cur_start; | int cur = cur_start; | |||
int id; | int id; | |||
while((id = curVLA[cur])) { | while((id = curVLA[cur])) { | |||
auto eoo = ExecutiveUniqueIDAtomDictGet(G, id); | auto eoo = ExecutiveUniqueIDAtomDictGet(G, id); | |||
if (eoo) { | if (eoo) { | |||
obj = eoo->obj; | obj = eoo->obj; | |||
if(obj == flush) { | if(flushobjects.count(obj)) { | |||
flush_seen = true; | flush_seen = true; | |||
} else { | } else { | |||
other_seen++; | other_seen++; | |||
} | } | |||
} | } | |||
cur++; | cur++; | |||
} | } | |||
} | } | |||
if(flush_seen) { /* eliminate flush atoms */ | if(flush_seen) { /* eliminate flush atoms */ | |||
int cur = cur_start; | int cur = cur_start; | |||
int id; | int id; | |||
while((id = curVLA[cur])) { | while((id = curVLA[cur])) { | |||
auto eoo = ExecutiveUniqueIDAtomDictGet(G, id); | auto eoo = ExecutiveUniqueIDAtomDictGet(G, id); | |||
if (eoo) { | if (eoo) { | |||
obj = eoo->obj; | obj = eoo->obj; | |||
if(obj == flush) { | if(flushobjects.count(obj)) { | |||
int tmp = cur; | int tmp = cur; | |||
while(curVLA[tmp]) { | while(curVLA[tmp]) { | |||
curVLA[tmp] = curVLA[tmp + 1]; | curVLA[tmp] = curVLA[tmp + 1]; | |||
tmp++; | tmp++; | |||
} | } | |||
} | } | |||
} | } | |||
cur++; | cur++; | |||
} | } | |||
} | } | |||
skipping to change at line 1043 | skipping to change at line 1085 | |||
return (I->NState); | return (I->NState); | |||
} | } | |||
/*========================================================================*/ | /*========================================================================*/ | |||
static void ObjectAlignmentRender(ObjectAlignment * I, RenderInfo * info) | static void ObjectAlignmentRender(ObjectAlignment * I, RenderInfo * info) | |||
{ | { | |||
PyMOLGlobals *G = I->Obj.G; | PyMOLGlobals *G = I->Obj.G; | |||
int state = info->state; | int state = info->state; | |||
CRay *ray = info->ray; | CRay *ray = info->ray; | |||
Picking **pick = info->pick; | auto pick = info->pick; | |||
int pass = info->pass; | int pass = info->pass; | |||
ObjectAlignmentState *sobj = NULL; | ObjectAlignmentState *sobj = NULL; | |||
const float *color; | const float *color; | |||
ObjectPrepareContext(&I->Obj, info); | ObjectPrepareContext(&I->Obj, info); | |||
color = ColorGet(G, I->Obj.Color); | color = ColorGet(G, I->Obj.Color); | |||
if (pick) | if (pick) | |||
return; | return; | |||
End of changes. 11 change blocks. | ||||
12 lines changed or deleted | 54 lines changed or added |