Seeker.cpp (pymol-open-source-2.2.0) | : | Seeker.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 120 | skipping to change at line 120 | |||
atom_vla[n_at++] = at_idx; | atom_vla[n_at++] = at_idx; | |||
} | } | |||
} | } | |||
} | } | |||
VLACheck(atom_vla, int, n_at); | VLACheck(atom_vla, int, n_at); | |||
atom_vla[n_at] = -1; | atom_vla[n_at] = -1; | |||
SeekerBuildSeleFromAtomList(G, row->name, atom_vla, cTempSeekerSele, true) ; | SeekerBuildSeleFromAtomList(G, row->name, atom_vla, cTempSeekerSele, true) ; | |||
VLAFreeP(atom_vla); | VLAFreeP(atom_vla); | |||
{ | { | |||
char *sele_mode_kw; | const char *sele_mode_kw; | |||
sele_mode_kw = SceneGetSeleModeKeyword(G); | sele_mode_kw = SceneGetSeleModeKeyword(G); | |||
if(logging) | if(logging) | |||
SelectorLogSele(G, cTempSeekerSele); | SelectorLogSele(G, cTempSeekerSele); | |||
{ | { | |||
ExecutiveGetActiveSeleName(G, selName, true, logging); | ExecutiveGetActiveSeleName(G, selName, true, logging); | |||
/* selection or deselecting? */ | /* selection or deselecting? */ | |||
skipping to change at line 190 | skipping to change at line 190 | |||
int *atom_list; | int *atom_list; | |||
char prefix[3] = ""; | char prefix[3] = ""; | |||
int logging = SettingGetGlobal_i(G, cSetting_logging); | int logging = SettingGetGlobal_i(G, cSetting_logging); | |||
if(logging == cPLog_pml) | if(logging == cPLog_pml) | |||
strcpy(prefix, "_ "); | strcpy(prefix, "_ "); | |||
row = rowVLA + row_num; | row = rowVLA + row_num; | |||
col = row->col + col_num; | col = row->col + col_num; | |||
if(!col->spacer) | if(!col->spacer) | |||
if(ExecutiveFindObjectByName(G, row->name)) { | if(ExecutiveFindObjectByName(G, row->name)) { | |||
char *sele_mode_kw; | const char *sele_mode_kw; | |||
atom_list = row->atom_lists + col->atom_at; | atom_list = row->atom_lists + col->atom_at; | |||
/* build up a selection consisting of residue atoms */ | /* build up a selection consisting of residue atoms */ | |||
SeekerBuildSeleFromAtomList(G, row->name, atom_list, cTempSeekerSele, tr ue); | SeekerBuildSeleFromAtomList(G, row->name, atom_list, cTempSeekerSele, tr ue); | |||
sele_mode_kw = SceneGetSeleModeKeyword(G); | sele_mode_kw = SceneGetSeleModeKeyword(G); | |||
if(logging) | if(logging) | |||
SelectorLogSele(G, cTempSeekerSele); | SelectorLogSele(G, cTempSeekerSele); | |||
skipping to change at line 1025 | skipping to change at line 1025 | |||
break; | break; | |||
} | } | |||
if(do_break) | if(do_break) | |||
break; | break; | |||
} else | } else | |||
break; | break; | |||
} | } | |||
return result; | return result; | |||
} | } | |||
PyObject *SeekerGetRawAlignment(PyMOLGlobals * G, int align_sele, int active_onl | ||||
y) | ||||
{ | ||||
#ifdef _PYMOL_NOPY | ||||
return NULL; | ||||
#else | ||||
PyObject *result = NULL; | ||||
int nRow = 0; | ||||
int nCol = 0; | ||||
CSeqRow *row_vla = NULL, *row; | ||||
void *hidden = NULL; | ||||
ObjectMolecule *obj; | ||||
if(align_sele < 0) { | ||||
align_sele = ExecutiveGetActiveAlignmentSele(G); | ||||
} | ||||
if(align_sele >= 0) { | ||||
row_vla = VLACalloc(CSeqRow, 10); | ||||
/* first, find out which objects are included in the alignment */ | ||||
while(ExecutiveIterateObjectMolecule(G, &obj, &hidden)) { | ||||
if((obj->Obj.Enabled || !active_only) && (obj->Obj.Name[0] != '_')) { | ||||
int a; | ||||
AtomInfoType *ai = obj->AtomInfo; | ||||
for(a = 0; a < obj->NAtom; a++) { | ||||
if(SelectorIsMember(G, ai->selEntry, align_sele)) { | ||||
VLACheck(row_vla, CSeqRow, nRow); | ||||
row = row_vla + nRow; | ||||
row->obj = obj; | ||||
row->nCol = obj->NAtom; | ||||
nRow++; | ||||
break; | ||||
} | ||||
ai++; | ||||
} | ||||
} | ||||
} | ||||
/* next, figure out how many aligned columns exist */ | ||||
{ | ||||
int done = false; | ||||
while(!done) { | ||||
int a; | ||||
int min_tag = -1; | ||||
done = true; | ||||
for(a = 0; a < nRow; a++) { | ||||
row = row_vla + a; | ||||
while(row->cCol < row->nCol) { /* advance to next tag in each r | ||||
ow & find lowest */ | ||||
AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | ||||
int tag = SelectorIsMember(G, ai->selEntry, align_sele); | ||||
if(!tag) { | ||||
row->cCol++; | ||||
} else { /* we're at a tagged atom... */ | ||||
if(min_tag > tag) | ||||
min_tag = tag; | ||||
else if(min_tag < 0) | ||||
min_tag = tag; | ||||
done = false; | ||||
break; | ||||
} | ||||
} | ||||
} | ||||
if(min_tag >= 0) { | ||||
nCol++; | ||||
for(a = 0; a < nRow; a++) { | ||||
row = row_vla + a; | ||||
if(row->cCol < row->nCol) { | ||||
AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | ||||
int tag = SelectorIsMember(G, ai->selEntry, align_sele); | ||||
if(tag == min_tag) { /* advance past this tag */ | ||||
row->cCol++; | ||||
} | ||||
} | ||||
} | ||||
} | ||||
} | ||||
} | ||||
/* now populate the table */ | ||||
result = PyList_New(nCol); | ||||
if(nCol) { | ||||
int done = false; | ||||
nCol = 0; | ||||
{ /* reset start points for our second pass */ | ||||
int a; | ||||
for(a = 0; a < nRow; a++) { | ||||
row = row_vla + a; | ||||
row->cCol = 0; | ||||
} | ||||
} | ||||
while(!done) { | ||||
int a; | ||||
int min_tag = -1; | ||||
done = true; | ||||
for(a = 0; a < nRow; a++) { | ||||
row = row_vla + a; | ||||
while(row->cCol < row->nCol) { /* advance to next tag in each r | ||||
ow & find lowest */ | ||||
AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | ||||
int tag = SelectorIsMember(G, ai->selEntry, align_sele); | ||||
if(!tag) { | ||||
row->cCol++; | ||||
} else { /* we're at a tagged atom... */ | ||||
if(min_tag > tag) | ||||
min_tag = tag; | ||||
else if(min_tag < 0) | ||||
min_tag = tag; | ||||
done = false; | ||||
break; | ||||
} | ||||
} | ||||
} | ||||
if(min_tag >= 0) { | ||||
int n_member = 0; | ||||
for(a = 0; a < nRow; a++) { | ||||
row = row_vla + a; | ||||
if(row->cCol < row->nCol) { | ||||
AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | ||||
int tag = SelectorIsMember(G, ai->selEntry, align_sele); | ||||
if(tag == min_tag) { /* participates */ | ||||
n_member++; | ||||
} | ||||
} | ||||
} | ||||
{ | ||||
PyObject *column_list = PyList_New(n_member); | ||||
n_member = 0; | ||||
for(a = 0; a < nRow; a++) { | ||||
row = row_vla + a; | ||||
if(row->cCol < row->nCol) { | ||||
AtomInfoType *ai = row->obj->AtomInfo + row->cCol; | ||||
int tag = SelectorIsMember(G, ai->selEntry, align_sele); | ||||
if(tag == min_tag) { /* participates */ | ||||
PyObject *tup = PyTuple_New(2); | ||||
PyTuple_SetItem(tup, 0, PyString_FromString(row->obj->Obj.Name | ||||
)); | ||||
PyTuple_SetItem(tup, 1, PyInt_FromLong(row->cCol + 1)); | ||||
/* +1, for 1-based PyMOL atom "index" */ | ||||
PyList_SetItem(column_list, n_member, tup); | ||||
row->cCol++; /* advance past this tag */ | ||||
n_member++; | ||||
} | ||||
} | ||||
} | ||||
PyList_SetItem(result, nCol, column_list); | ||||
} | ||||
nCol++; | ||||
} | ||||
} | ||||
} | ||||
} | ||||
VLAFreeP(row_vla); | ||||
return result; | ||||
#endif | ||||
} | ||||
void SeekerUpdate(PyMOLGlobals * G) | void SeekerUpdate(PyMOLGlobals * G) | |||
{ | { | |||
/* CObject *o = NULL; | /* CObject *o = NULL; | |||
int s; */ | int s; */ | |||
void *hidden = NULL; | void *hidden = NULL; | |||
AtomInfoType *ai; | AtomInfoType *ai; | |||
ObjectMolecule *obj; | ObjectMolecule *obj; | |||
int nRow = 0; | int nRow = 0; | |||
int label_mode = 0; | int label_mode = 0; | |||
int codes = 0; | int codes = 0; | |||
int max_row = 50; | int max_row = 50; | |||
int default_color = 0; | int default_color = 0; | |||
int align_sele = -1; /* alignment selection */ | int align_sele = -1; /* alignment selection */ | |||
const int MAXCONSECUTIVEGAPS = 9; | ||||
CSeqRow *row_vla, *row, *lab = NULL; | CSeqRow *row_vla, *row, *lab = NULL; | |||
row_vla = VLACalloc(CSeqRow, 10); | row_vla = VLACalloc(CSeqRow, 10); | |||
/* FIRST PASS: get all the residues represented properly */ | /* FIRST PASS: get all the residues represented properly */ | |||
label_mode = SettingGetGlobal_i(G, cSetting_seq_view_label_mode); | label_mode = SettingGetGlobal_i(G, cSetting_seq_view_label_mode); | |||
align_sele = ExecutiveGetActiveAlignmentSele(G); | align_sele = ExecutiveGetActiveAlignmentSele(G); | |||
while(ExecutiveIterateObjectMolecule(G, &obj, &hidden)) { | while(ExecutiveIterateObjectMolecule(G, &obj, &hidden)) { | |||
if(obj->Obj.Enabled && (SettingGet_b(G, obj->Obj.Setting, NULL, cSetting_seq _view)) && | if(obj->Obj.Enabled && (SettingGet_b(G, obj->Obj.Setting, NULL, cSetting_seq _view)) && | |||
(obj->Obj.Name[0] != '_')) { | (obj->Obj.Name[0] != '_')) { | |||
skipping to change at line 1225 | skipping to change at line 1065 | |||
int last_spacer = false; | int last_spacer = false; | |||
int nCol = 0; | int nCol = 0; | |||
int nListEntries = 1; /* first list starts at 1 always... */ | int nListEntries = 1; /* first list starts at 1 always... */ | |||
int est_col = obj->NAtom / 5 + 1; | int est_col = obj->NAtom / 5 + 1; | |||
int est_char = obj->NAtom * 4; | int est_char = obj->NAtom * 4; | |||
int first_atom_in_label; | int first_atom_in_label; | |||
int missing_color = SettingGet_i(G, obj->Obj.Setting, NULL, cSetting_seq_v iew_fill_color); | int missing_color = SettingGet_i(G, obj->Obj.Setting, NULL, cSetting_seq_v iew_fill_color); | |||
CoordSet *cs = obj->DiscreteFlag ? NULL : ObjectMoleculeGetCoordSet(obj, s td::max(0, obj->getState())); | CoordSet *cs = obj->DiscreteFlag ? NULL : ObjectMoleculeGetCoordSet(obj, s td::max(0, obj->getState())); | |||
bool atom_in_state; | bool atom_in_state; | |||
int gapMode = SettingGet_i(G, obj->Obj.Setting, nullptr, cSetting_seq_view _gap_mode); | ||||
int min_pad = -1; | int min_pad = -1; | |||
CSeqCol *r1 = NULL, *l1 = NULL; /* *col */ | CSeqCol *r1 = NULL, *l1 = NULL; /* *col */ | |||
if(nRow >= max_row) | if(nRow >= max_row) | |||
break; | break; | |||
codes = SettingGet_i(G, obj->Obj.Setting, NULL, cSetting_seq_view_format); | codes = SettingGet_i(G, obj->Obj.Setting, NULL, cSetting_seq_view_format); | |||
if(obj->DiscreteFlag && SettingGet_b(G, | if(obj->DiscreteFlag && SettingGet_b(G, | |||
obj->Obj.Setting, | obj->Obj.Setting, | |||
NULL, cSetting_seq_view_discrete_by_s tate)) | NULL, cSetting_seq_view_discrete_by_s tate)) | |||
skipping to change at line 1445 | skipping to change at line 1286 | |||
for (int v = ai->resv; v; v /= 10) { | for (int v = ai->resv; v; v /= 10) { | |||
min_pad++; | min_pad++; | |||
} | } | |||
if (ai->inscode) { | if (ai->inscode) { | |||
min_pad++; | min_pad++; | |||
} | } | |||
} | } | |||
atom_in_state = (cs && a < cs->NAtIndex && cs->AtmToIdx[a] >= 0); | atom_in_state = (cs && a < cs->NAtIndex && cs->AtmToIdx[a] >= 0); | |||
int gapsNeeded{0}; | ||||
if(gapMode != GapMode::NONE | ||||
&& AtomInfoSameChainP(G, ai, last) | ||||
&& (ai->flags & last->flags & cAtomFlag_polymer) | ||||
&& align_sele < 0){ | ||||
gapsNeeded = ai->resv - last->resv - 1; | ||||
if(gapsNeeded > 1 && gapMode == GapMode::SINGLE){ | ||||
gapsNeeded = 1; | ||||
} | ||||
} | ||||
auto push_gap = [&](const char* str) | ||||
{ | ||||
auto str_size = strlen(str); | ||||
UtilConcatVLA(&row->txt, &row->len, str); | ||||
VLACheck(row->col, CSeqCol, nCol + str_size); | ||||
r1 = row->col + nCol; | ||||
for(int i = 0; i < str_size; i++){ | ||||
r1->color = missing_color; | ||||
r1->spacer = true; | ||||
r1->stop = r1->start + 1; | ||||
auto lastStop = r1->stop; | ||||
nCol++; | ||||
r1 = row->col + nCol; | ||||
r1->start = lastStop; | ||||
} | ||||
}; | ||||
switch (codes) { | switch (codes) { | |||
case 0: /* one letter residue codes */ | case 0: /* one letter residue codes */ | |||
if(!AtomInfoSameResidueP(G, last, ai)) { | if(!AtomInfoSameResidueP(G, last, ai)) { | |||
char abbr[2] = "1"; | char abbr[2] = "1"; | |||
last = ai; | last = ai; | |||
VLACheck(row->col, CSeqCol, nCol); | VLACheck(row->col, CSeqCol, nCol); | |||
r1 = row->col + nCol; | r1 = row->col + nCol; | |||
r1->start = row->len; | r1->start = row->len; | |||
//Only include non-consecutive gaps when not doing alignment | ||||
if(gapsNeeded > 0 && gapsNeeded <= MAXCONSECUTIVEGAPS){ | ||||
for(int g = 0; g < gapsNeeded; ++g){ | ||||
push_gap("-"); | ||||
} | ||||
} | ||||
else if(gapsNeeded > MAXCONSECUTIVEGAPS){ | ||||
push_gap("---...---"); | ||||
} | ||||
if(obj->DiscreteFlag) | if(obj->DiscreteFlag) | |||
r1->state = ai->discrete_state; | r1->state = ai->discrete_state; | |||
first_atom_in_label = true; | first_atom_in_label = true; | |||
// single letter codes for polymer/solvent | // single letter codes for polymer/solvent | |||
if (!(ai->flags & (cAtomFlag_organic | cAtomFlag_inorganic))) { | if (!(ai->flags & (cAtomFlag_organic | cAtomFlag_inorganic))) { | |||
abbr[0] = SeekerGetAbbr(G, LexStr(G, ai->resn), 'O', 0); | abbr[0] = SeekerGetAbbr(G, LexStr(G, ai->resn), 'O', 0); | |||
} else { | } else { | |||
abbr[0] = 0; | abbr[0] = 0; | |||
skipping to change at line 1515 | skipping to change at line 1396 | |||
if(!AtomInfoSameResidueP(G, last, ai)) { | if(!AtomInfoSameResidueP(G, last, ai)) { | |||
last = ai; | last = ai; | |||
VLACheck(row->col, CSeqCol, nCol); | VLACheck(row->col, CSeqCol, nCol); | |||
r1 = row->col + nCol; | r1 = row->col + nCol; | |||
r1->start = row->len; | r1->start = row->len; | |||
if(obj->DiscreteFlag) | if(obj->DiscreteFlag) | |||
r1->state = ai->discrete_state; | r1->state = ai->discrete_state; | |||
first_atom_in_label = true; | first_atom_in_label = true; | |||
//Only include non-consecutive gaps when not doing alignment | ||||
if(gapsNeeded > 0 && gapsNeeded <= MAXCONSECUTIVEGAPS){ | ||||
for(int g = 0; g < gapsNeeded; ++g){ | ||||
push_gap("--- "); | ||||
} | ||||
} | ||||
else if(gapsNeeded > MAXCONSECUTIVEGAPS){ | ||||
push_gap("---...--- "); | ||||
} | ||||
if(ai->resn) | if(ai->resn) | |||
UtilConcatVLA(&row->txt, &row->len, LexStr(G, ai->resn)); | UtilConcatVLA(&row->txt, &row->len, LexStr(G, ai->resn)); | |||
else | else | |||
UtilConcatVLA(&row->txt, &row->len, "''"); | UtilConcatVLA(&row->txt, &row->len, "''"); | |||
r1->stop = row->len; | r1->stop = row->len; | |||
if(!atom_in_state) | if(!atom_in_state) | |||
r1->color = missing_color; | r1->color = missing_color; | |||
else if(default_color < 0) | else if(default_color < 0) | |||
r1->color = SeekerFindColor(G, ai, obj->NAtom - a); | r1->color = SeekerFindColor(G, ai, obj->NAtom - a); | |||
skipping to change at line 2011 | skipping to change at line 1902 | |||
int n_skipped = 0; | int n_skipped = 0; | |||
int last_resv = -1; | int last_resv = -1; | |||
AtomInfoType *last_ai = NULL; | AtomInfoType *last_ai = NULL; | |||
ObjectMolecule *obj; | ObjectMolecule *obj; | |||
AtomInfoType *ai; | AtomInfoType *ai; | |||
row = lab + 1; | row = lab + 1; | |||
nCol = row->nCol; | nCol = row->nCol; | |||
obj = row->obj; | obj = row->obj; | |||
div = SettingGet_i(G, obj->Obj.Setting, NULL, cSetting_seq_view_label_sp acing); | div = SettingGet_i(G, obj->Obj.Setting, NULL, cSetting_seq_view_label_sp acing); | |||
sub = SettingGet_i(G, obj->Obj.Setting, NULL, cSetting_seq_view_label_st art); | sub = SettingGet_i(G, obj->Obj.Setting, NULL, cSetting_seq_view_label_st art); | |||
for(b = 0; b < nCol; b++) { | for(b = 0; b < nCol; b++) { | |||
CSeqCol *r1 = row->col + b; | CSeqCol *r1 = row->col + b; | |||
CSeqCol *l1 = lab->col + b; | CSeqCol *l1 = lab->col + b; | |||
ai = NULL; | ai = NULL; | |||
if(r1->atom_at) { | if(r1->atom_at) { | |||
atom_list = row->atom_lists + r1->atom_at; | atom_list = row->atom_lists + r1->atom_at; | |||
if(*atom_list >= 0) | if(*atom_list >= 0) | |||
ai = obj->AtomInfo + (*atom_list); /* get first atom in lis t */ | ai = obj->AtomInfo + (*atom_list); /* get first atom in lis t */ | |||
} | } | |||
End of changes. 9 change blocks. | ||||
168 lines changed or deleted | 55 lines changed or added |