"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer3/Selector.cpp" between
pymol-v1.8.6.0.tar.bz2 and pymol-v2.1.0.tar.bz2

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

Selector.cpp  (pymol-v1.8.6.0.tar.bz2):Selector.cpp  (pymol-v2.1.0.tar.bz2)
skipping to change at line 406 skipping to change at line 406
#define SELE_STRO ( 0x4B00 | STYP_SEL1 | 0x80 ) #define SELE_STRO ( 0x4B00 | STYP_SEL1 | 0x80 )
#define SELE_METz ( 0x4C00 | STYP_SEL0 | 0x90 ) #define SELE_METz ( 0x4C00 | STYP_SEL0 | 0x90 )
#define SELE_BB_z ( 0x4D00 | STYP_SEL0 | 0x90 ) #define SELE_BB_z ( 0x4D00 | STYP_SEL0 | 0x90 )
#define SELE_SC_z ( 0x4E00 | STYP_SEL0 | 0x90 ) #define SELE_SC_z ( 0x4E00 | STYP_SEL0 | 0x90 )
#define SELE_PROP ( 0x4F00 | STYP_SEL3 | 0x80 ) #define SELE_PROP ( 0x4F00 | STYP_SEL3 | 0x80 )
#define SELE_XVLx ( 0x5000 | STYP_SEL2 | 0x80 ) #define SELE_XVLx ( 0x5000 | STYP_SEL2 | 0x80 )
#define SELE_YVLx ( 0x5100 | STYP_SEL2 | 0x80 ) #define SELE_YVLx ( 0x5100 | STYP_SEL2 | 0x80 )
#define SELE_ZVLx ( 0x5200 | STYP_SEL2 | 0x80 ) #define SELE_ZVLx ( 0x5200 | STYP_SEL2 | 0x80 )
#define SELE_CUST ( 0x5300 | STYP_SEL1 | 0x80 ) #define SELE_CUST ( 0x5300 | STYP_SEL1 | 0x80 )
#define SELE_RING ( 0x5400 | STYP_OPR1 | 0x20 ) #define SELE_RING ( 0x5400 | STYP_OPR1 | 0x20 )
#define SELE_LABs ( 0x5500 | STYP_SEL1 | 0x80 )
#define SELE_PROz ( 0x5600 | STYP_SEL0 | 0x90 )
#define SELE_NUCz ( 0x5700 | STYP_SEL0 | 0x90 )
#define SEL_PREMAX 0x8 #define SEL_PREMAX 0x8
static WordKeyValue Keyword[] = { static WordKeyValue Keyword[] = {
{"not", SELE_NOT1}, {"not", SELE_NOT1},
{"!", SELE_NOT1}, {"!", SELE_NOT1},
{"neighbor", SELE_NGH1}, {"neighbor", SELE_NGH1},
{"nbr;", SELE_NGH1}, /* deprecated */ {"nbr;", SELE_NGH1}, /* deprecated */
{"nbr.", SELE_NGH1}, {"nbr.", SELE_NGH1},
skipping to change at line 538 skipping to change at line 541
{"gap", SELE_GAP_}, {"gap", SELE_GAP_},
{"partial_charge", SELE_PCHx}, {"partial_charge", SELE_PCHx},
{"pc;", SELE_PCHx}, /* deprecated */ {"pc;", SELE_PCHx}, /* deprecated */
{"pc.", SELE_PCHx}, {"pc.", SELE_PCHx},
{"masked", SELE_MSKz}, {"masked", SELE_MSKz},
{"msk.", SELE_MSKz}, {"msk.", SELE_MSKz},
{"protected", SELE_PTDz}, {"protected", SELE_PTDz},
{"pr.", SELE_PTDz},
{"formal_charge", SELE_FCHx}, {"formal_charge", SELE_FCHx},
{"fc;", SELE_FCHx}, /* deprecated */ {"fc;", SELE_FCHx}, /* deprecated */
{"fc.", SELE_FCHx}, {"fc.", SELE_FCHx},
{"numeric_type", SELE_NTYs}, {"numeric_type", SELE_NTYs},
{"nt;", SELE_NTYs}, /* deprecated */ {"nt;", SELE_NTYs}, /* deprecated */
{"nt.", SELE_NTYs}, {"nt.", SELE_NTYs},
{"text_type", SELE_TTYs}, {"text_type", SELE_TTYs},
skipping to change at line 618 skipping to change at line 620
{"fixed", SELE_FXDz}, {"fixed", SELE_FXDz},
{"fxd.", SELE_FXDz}, {"fxd.", SELE_FXDz},
{"restrained", SELE_RSTz}, {"restrained", SELE_RSTz},
{"rst.", SELE_RSTz}, {"rst.", SELE_RSTz},
{"polymer", SELE_POLz}, {"polymer", SELE_POLz},
{"pol.", SELE_POLz}, {"pol.", SELE_POLz},
{"polymer.protein", SELE_PROz},
{"polymer.nucleic", SELE_NUCz},
#if 0
// User survey winners. Not activated (yet) but ObjectMakeValidName
// prints a deprecation warning if these names are used to name
// objects or selections.
{"protein", SELE_PROz},
{"nucleic", SELE_NUCz},
{"pro.", SELE_PROz},
{"nuc.", SELE_NUCz},
#endif
{"organic", SELE_ORGz}, {"organic", SELE_ORGz},
{"org.", SELE_ORGz}, {"org.", SELE_ORGz},
{"inorganic", SELE_INOz}, {"inorganic", SELE_INOz},
{"ino.", SELE_INOz}, {"ino.", SELE_INOz},
{"solvent", SELE_SOLz}, {"solvent", SELE_SOLz},
{"sol.", SELE_SOLz}, {"sol.", SELE_SOLz},
{"guide", SELE_GIDz}, {"guide", SELE_GIDz},
skipping to change at line 658 skipping to change at line 674
{"bb.", SELE_BB_z}, {"bb.", SELE_BB_z},
{"sidechain", SELE_SC_z}, {"sidechain", SELE_SC_z},
{"sc.", SELE_SC_z}, {"sc.", SELE_SC_z},
{"x", SELE_XVLx}, {"x", SELE_XVLx},
{"y", SELE_YVLx}, {"y", SELE_YVLx},
{"z", SELE_ZVLx}, {"z", SELE_ZVLx},
{"byring", SELE_RING}, {"byring", SELE_RING},
{"label", SELE_LABs},
{"", 0} {"", 0}
}; };
#define SCMP_GTHN 0x01 #define SCMP_GTHN 0x01
#define SCMP_LTHN 0x02 #define SCMP_LTHN 0x02
#define SCMP_RANG 0x03 #define SCMP_RANG 0x03
#define SCMP_EQAL 0x04 #define SCMP_EQAL 0x04
static WordKeyValue AtOper[] = { static WordKeyValue AtOper[] = {
skipping to change at line 709 skipping to change at line 726
if(obj_nAtom) { if(obj_nAtom) {
int *flag = Calloc(int, obj_nAtom); int *flag = Calloc(int, obj_nAtom);
if(!flag) { if(!flag) {
result = -1; result = -1;
} else { } else {
AtomInfoType *ai = obj->AtomInfo; AtomInfoType *ai = obj->AtomInfo;
int a; int a;
for(a = 0; a < obj_nAtom; a++) { for(a = 0; a < obj_nAtom; a++) {
if(SelectorIsMember(G, ai->selEntry, sele)) { if(SelectorIsMember(G, ai->selEntry, sele)) {
flag[a] = true; flag[a] = true;
result = true;
} }
ai++; ai++;
} }
if (!result && !force) {
// nothing selected, no need to continue
return 0;
}
result = ObjectMoleculeRenameAtoms(obj, flag, force); result = ObjectMoleculeRenameAtoms(obj, flag, force);
} }
FreeP(flag); FreeP(flag);
} }
return result; return result;
} }
int SelectorResidueVLAsTo3DMatchScores(PyMOLGlobals * G, CMatch * match, int SelectorResidueVLAsTo3DMatchScores(PyMOLGlobals * G, CMatch * match,
int *vla1, int n1, int state1, int *vla1, int n1, int state1,
int *vla2, int n2, int state2, int *vla2, int n2, int state2,
skipping to change at line 1235 skipping to change at line 1257
ai1 = obj1->AtomInfo + I->Table[a1].atom; ai1 = obj1->AtomInfo + I->Table[a1].atom;
if(!AtomInfoSameResidue(G, ai1, ai)) if(!AtomInfoSameResidue(G, ai1, ai))
break; break;
a1++; a1++;
} }
a0++; a0++;
a1--; a1--;
mask = 0; mask = 0;
if(AtomInfoKnownPolymerResName(LexStr(G, ai->resn)) && (!ai->hetatm)) if(!ai->hetatm && AtomInfoKnownProteinResName(LexStr(G, ai->resn)))
mask = cAtomFlag_polymer; mask = cAtomFlag_polymer | cAtomFlag_protein;
else if(!ai->hetatm && AtomInfoKnownNucleicResName(LexStr(G, ai->resn)))
mask = cAtomFlag_polymer | cAtomFlag_nucleic;
else if(AtomInfoKnownWaterResName(G, LexStr(G, ai->resn))) else if(AtomInfoKnownWaterResName(G, LexStr(G, ai->resn)))
mask = cAtomFlag_solvent; mask = cAtomFlag_solvent;
else { else {
/* does this residue have a canonical atoms? */ /* does this residue have a canonical atoms? */
int found_ca = false; int found_ca = false;
int found_n = false; int found_n = false;
int found_c = false; int found_c = false;
int found_o = false; int found_o = false;
skipping to change at line 1373 skipping to change at line 1397
found_p_bond = found_p_bond =
(ObjectMoleculeIsAtomBondedToName(obj, I->Table[aa].atom, "O3* ", 0) (ObjectMoleculeIsAtomBondedToName(obj, I->Table[aa].atom, "O3* ", 0)
|| ObjectMoleculeIsAtomBondedToName(obj, I->Table[aa].atom, " O3'", 0)); || ObjectMoleculeIsAtomBondedToName(obj, I->Table[aa].atom, " O3'", 0));
break; break;
} }
} }
} }
ai0++; ai0++;
} }
if((found_ca && found_n && found_c && found_o && (found_cn_bond || found if(found_ca && found_n && found_c && found_o && (found_cn_bond || found_
_nc_bond)) nc_bond)) {
|| (found_o3star && found_c3star && found_c4star && found_c5star mask = cAtomFlag_polymer | cAtomFlag_protein;
&& found_o5star && (found_o3_bond || found_p_bond))) { } else if (found_o3star && found_c3star && found_c4star && found_c5star
mask = cAtomFlag_polymer; && found_o5star && (found_o3_bond || found_p_bond)) {
mask = cAtomFlag_polymer | cAtomFlag_nucleic;
} else if(found_carbon) } else if(found_carbon)
mask = cAtomFlag_organic; mask = cAtomFlag_organic;
else if((found_o || found_oh2) && (a1 == a0)) else if((found_o || found_oh2) && (a1 == a0))
mask = cAtomFlag_solvent; mask = cAtomFlag_solvent;
else else
mask = cAtomFlag_inorganic; mask = cAtomFlag_inorganic;
} }
/* mark which atoms we can write to */ /* mark which atoms we can write to */
skipping to change at line 1416 skipping to change at line 1441
} else if (mask & cAtomFlag_polymer) { } else if (mask & cAtomFlag_polymer) {
ai0->visRep = (ai0->visRep & auto_show_mask) | visRep_polymer_ob j; ai0->visRep = (ai0->visRep & auto_show_mask) | visRep_polymer_ob j;
} }
} }
ai0->flags = (ai0->flags & cAtomFlag_class_mask) | mask; ai0->flags = (ai0->flags & cAtomFlag_class_mask) | mask;
} }
ai0++; ai0++;
} }
} }
if((!guide_atom) && (mask == cAtomFlag_polymer)) { if((mask & cAtomFlag_polymer)) {
ai0 = obj->AtomInfo + I->Table[a0].atom; ai0 = obj->AtomInfo + I->Table[a0].atom;
for(aa = a0; aa <= a1; aa++) { for(aa = a0; !guide_atom && aa <= a1; aa++) {
if(ai0->protons == cAN_C) { if(ai0->protons == cAN_C) {
const char *name = LexStr(G, ai0->name); const char *name = LexStr(G, ai0->name);
switch (name[0]) { switch (name[0]) {
case 'C': case 'C':
switch (name[1]) { switch (name[1]) {
case 'A': case 'A':
switch (name[2]) { switch (name[2]) {
case 0: case 0:
guide_atom = ai0; guide_atom = ai0;
break; break;
} }
break;
case '4': case '4':
switch (name[2]) { /* use C4* as guide atom for nucleic aci ds */ switch (name[2]) { /* use C4* as guide atom for nucleic aci ds */
case '*': case '*':
case '\'': case '\'':
guide_atom = ai0; guide_atom = ai0;
break; break;
} }
break; break;
} }
} }
skipping to change at line 1912 skipping to change at line 1938
res = VLACalloc(SSResi, 1000); res = VLACalloc(SSResi, 1000);
if(state_value < 0) { if(state_value < 0) {
if(state_value == -4) if(state_value == -4)
consensus = false; consensus = false;
if(state_value == -5) if(state_value == -5)
first_last_only = true; first_last_only = true;
state_start = 0; state_start = 0;
state_stop = SelectorGetSeleNCSet(G, target); state_stop = SelectorGetSeleNCSet(G, target);
if (state_value == -2) {
/* api: state=-1: current global state */
StateIterator iter(G, NULL, state_value, state_stop);
if (iter.next()) {
state_start = iter.state;
state_stop = iter.state + 1;
}
}
} else { } else {
state_start = state_value; state_start = state_value;
state_stop = state_value + 1; state_stop = state_value + 1;
} }
for(state = state_start; state < state_stop; state++) { for(state = state_start; state < state_stop; state++) {
int a; int a;
ObjectMolecule *obj; ObjectMolecule *obj;
int aa, a0, a1, at, idx; int aa, a0, a1, at, idx;
AtomInfoType *ai, *ai0, *ai1; AtomInfoType *ai, *ai0, *ai1;
CoordSet *cs; CoordSet *cs;
skipping to change at line 3336 skipping to change at line 3371
int ok = true; int ok = true;
CSelector *I = G->Selector; CSelector *I = G->Selector;
ov_size a, b; ov_size a, b;
ov_diff n; ov_diff n;
int m, sele; int m, sele;
ov_size ll; ov_size ll;
PyObject *obj_list = NULL; PyObject *obj_list = NULL;
PyObject *idx_list = NULL, *tag_list; PyObject *idx_list = NULL, *tag_list;
ov_size n_obj = 0, n_idx = 0; ov_size n_obj = 0, n_idx = 0;
int idx, tag; int idx, tag;
char *oname; const char *oname;
ObjectMolecule *obj; ObjectMolecule *obj;
int singleAtomFlag = true; int singleAtomFlag = true;
int singleObjectFlag = true; int singleObjectFlag = true;
ObjectMolecule *singleObject = NULL; ObjectMolecule *singleObject = NULL;
int singleAtom = -1; int singleAtom = -1;
AtomInfoType *ai; AtomInfoType *ai;
if(ok) if(ok)
ok = PyList_Check(list); ok = PyList_Check(list);
if(ok) if(ok)
skipping to change at line 6807 skipping to change at line 6842
if(singletons < 0) if(singletons < 0)
singletons = static_singletons; singletons = static_singletons;
ob = ExecutiveFindObjectByName(G, name); ob = ExecutiveFindObjectByName(G, name);
if(ob) if(ob)
if(ob->type == cObjectMolecule) if(ob->type == cObjectMolecule)
targ = (ObjectMolecule *) ob; targ = (ObjectMolecule *) ob;
c = 0; c = 0;
if(source < 0) {
SelectorUpdateTable(G, cSelectorUpdateTableAllStates, -1);
} else {
SelectorUpdateTable(G, source, -1); SelectorUpdateTable(G, source, -1);
}
if(!targ) { if(!targ) {
isNew = true; isNew = true;
if(discrete < 0) if(discrete < 0)
discrete = SelectorIsSelectionDiscrete(G, sele, false); discrete = SelectorIsSelectionDiscrete(G, sele, false);
targ = ObjectMoleculeNew(G, discrete); targ = ObjectMoleculeNew(G, discrete);
targ->Bond = VLACalloc(BondType, 1); targ->Bond = VLACalloc(BondType, 1);
{ {
/* copy object color of previous object (if any) */ /* copy object color of previous object (if any) */
ObjectMolecule *singleObj = NULL; ObjectMolecule *singleObj = NULL;
skipping to change at line 6919 skipping to change at line 6950
ObjectMoleculeMerge(targ, atInfo, cs, false, cAIC_AllMask, true); /* will free atInfo */ ObjectMoleculeMerge(targ, atInfo, cs, false, cAIC_AllMask, true); /* will free atInfo */
/* cs->IdxToAtm will now have the reverse mapping from the new subset /* cs->IdxToAtm will now have the reverse mapping from the new subset
to the new merged molecule */ to the new merged molecule */
ObjectMoleculeExtendIndices(targ, -1); ObjectMoleculeExtendIndices(targ, -1);
ObjectMoleculeUpdateIDNumbers(targ); ObjectMoleculeUpdateIDNumbers(targ);
ObjectMoleculeUpdateNonbonded(targ); ObjectMoleculeUpdateNonbonded(targ);
if(!isNew) { /* recreate selection table */ if(!isNew) { /* recreate selection table */
if(source < 0) {
SelectorUpdateTable(G, cSelectorUpdateTableAllStates, -1);
} else {
SelectorUpdateTable(G, source, -1); SelectorUpdateTable(G, source, -1);
}
} }
/* get maximum state index for the selection...note that /* get maximum state index for the selection...note that
we'll be creating states from 1 up to the maximum required to we'll be creating states from 1 up to the maximum required to
capture atoms in the selection capture atoms in the selection
*/ */
nCSet = 0; nCSet = 0;
skipping to change at line 6954 skipping to change at line 6981
nCSet = obj->NCSet; nCSet = obj->NCSet;
c++; c++;
} }
} }
} }
if(c != nAtom) if(c != nAtom)
ErrFatal(G, "SelectorCreate", "inconsistent selection."); ErrFatal(G, "SelectorCreate", "inconsistent selection.");
/* cs->IdxToAtm now has the relevant indexes for the coordinate transfer */ /* cs->IdxToAtm now has the relevant indexes for the coordinate transfer */
for(d = 0; d < nCSet; d++) { /* iterate through states */ for(StateIterator iter(G, NULL, source, nCSet); iter.next();) {
if((source < 0) || (source == d)) { d = iter.state;
{
cs2 = CoordSetNew(G); cs2 = CoordSetNew(G);
c = 0; c = 0;
cs2->Coord = VLAlloc(float, 3 * nAtom); cs2->Coord = VLAlloc(float, 3 * nAtom);
cs2->AtmToIdx = VLACalloc(int, targ->NAtom + 1); cs2->AtmToIdx = VLACalloc(int, targ->NAtom + 1);
for(a = 0; a < targ->NAtom; a++) for(a = 0; a < targ->NAtom; a++)
cs2->AtmToIdx[a] = -1; cs2->AtmToIdx[a] = -1;
cs2->NAtIndex = targ->NAtom; cs2->NAtIndex = targ->NAtom;
cs2->IdxToAtm = VLACalloc(int, nAtom); cs2->IdxToAtm = VLACalloc(int, nAtom);
for(a = cNDummyAtoms; a < I->NAtom; a++) /* any selected atoms in this st ate? */ for(a = cNDummyAtoms; a < I->NAtom; a++) /* any selected atoms in this st ate? */
if(I->Table[a].index >= 0) { if(I->Table[a].index >= 0) {
skipping to change at line 6990 skipping to change at line 7018
cs2->IdxToAtm[c] = a2; cs2->IdxToAtm[c] = a2;
cs2->AtmToIdx[a2] = c; cs2->AtmToIdx[a2] = c;
c++; c++;
} }
} }
} }
VLASize(cs2->IdxToAtm, int, c); VLASize(cs2->IdxToAtm, int, c);
VLASize(cs2->Coord, float, c * 3); VLASize(cs2->Coord, float, c * 3);
cs2->NIndex = c; cs2->NIndex = c;
if(target >= 0) { if(target >= 0) {
if(source < 0) if(source == -1)
ts = target + d; ts = target + d;
else else
ts = target; ts = target;
} else { } else {
ts = d; ts = d;
} }
VLACheck(targ->CSet, CoordSet *, ts); VLACheck(targ->CSet, CoordSet *, ts);
if(targ->NCSet <= ts) if(targ->NCSet <= ts)
targ->NCSet = ts + 1; targ->NCSet = ts + 1;
if(targ->CSet[ts]) if(targ->CSet[ts])
skipping to change at line 7311 skipping to change at line 7339
{ {
int count = 0; int count = 0;
CSelector *I = G->Selector; CSelector *I = G->Selector;
store[0] = 0; store[0] = 0;
// trivial (but valid) case: empty selection string // trivial (but valid) case: empty selection string
ok_assert(1, input[0]); ok_assert(1, input[0]);
// if object molecule or named selection, then don't create a temp selection // if object molecule or named selection, then don't create a temp selection
if (ExecutiveIsMoleculeOrSelection(G, input)) { if (ExecutiveIsMoleculeOrSelection(G, input)
&& strncmp(input, cSelectorTmpPrefix, cSelectorTmpPrefixLen) != 0) {
strcpy(store, input); strcpy(store, input);
return 0; return 0;
} }
// evaluate expression and create a temp selection // evaluate expression and create a temp selection
sprintf(store, "%s%d", cSelectorTmpPrefix, I->TmpCounter++); sprintf(store, "%s%d", cSelectorTmpPrefix, I->TmpCounter++);
count = SelectorCreate(G, store, input, NULL, quiet, NULL); count = SelectorCreate(G, store, input, NULL, quiet, NULL);
if(count < 0) if(count < 0)
store[0] = 0; store[0] = 0;
skipping to change at line 7563 skipping to change at line 7592
if(sname[0] == '%') if(sname[0] == '%')
strcpy(name, &sname[1]); strcpy(name, &sname[1]);
else else
strcpy(name, sname); strcpy(name, sname);
if(WordMatchExact(G, cKeywordAll, name, ignore_case)) { if(WordMatchExact(G, cKeywordAll, name, ignore_case)) {
name[0] = 0; /* force error */ name[0] = 0; /* force error */
} }
UtilCleanStr(name); UtilCleanStr(name);
/* name was invalid, output error msg to user */ /* name was invalid, output error msg to user */
if(!name[0]) { if(!name[0]) {
if (!quiet){
PRINTFB(G, FB_Selector, FB_Errors) PRINTFB(G, FB_Selector, FB_Errors)
"Selector-Error: Invalid selection name \"%s\".\n", sname ENDFB(G); "Selector-Error: Invalid selection name \"%s\".\n", sname ENDFB(G);
// moved to only !quiet B.B. 11/12 - not sure why this is in there, caused
unwanted cr to print during test
OrthoRestorePrompt(G);
}
} }
if(ok) { if(ok) {
if(sele) { if(sele) {
atom = SelectorSelect(G, sele, state, domain, quiet); atom = SelectorSelect(G, sele, state, domain, quiet);
if(!atom) if(!atom)
ok = false; ok = false;
} else if(id2tag) { } else if(id2tag) {
atom = SelectorSelectFromTagDict(G, id2tag); atom = SelectorSelectFromTagDict(G, id2tag);
} else if(obj && obj[0]) { /* optimized full-object selection */ } else if(obj && obj[0]) { /* optimized full-object selection */
if(n_obj <= 0) { if(n_obj <= 0) {
skipping to change at line 7684 skipping to change at line 7709
int SelectorCreateWithStateDomain(PyMOLGlobals * G, const char *sname, const cha r *sele, int SelectorCreateWithStateDomain(PyMOLGlobals * G, const char *sname, const cha r *sele,
ObjectMolecule * obj, int quiet, Multipick * m p, ObjectMolecule * obj, int quiet, Multipick * m p,
int state, const char *domain) int state, const char *domain)
{ {
int domain_sele = -1; int domain_sele = -1;
ObjectNameType valid_name; ObjectNameType valid_name;
UtilNCopy(valid_name, sname, sizeof(valid_name)); UtilNCopy(valid_name, sname, sizeof(valid_name));
if(SettingGetGlobal_b(G, cSetting_validate_object_names)) { if(SettingGetGlobal_b(G, cSetting_validate_object_names)) {
ObjectMakeValidName(valid_name); ObjectMakeValidName(G, valid_name);
sname = valid_name; sname = valid_name;
} }
if(domain && domain[0]) { if(domain && domain[0]) {
if(!WordMatchExact(G, cKeywordAll, domain, true)) { /* allow domain=all */ if(!WordMatchExact(G, cKeywordAll, domain, true)) { /* allow domain=all */
domain_sele = SelectorIndexByName(G, domain); domain_sele = SelectorIndexByName(G, domain);
if(domain_sele < 0) { if(domain_sele < 0) {
PRINTFB(G, FB_Selector, FB_Errors) PRINTFB(G, FB_Selector, FB_Errors)
"Selector-Error: Invalid domain selection name \"%s\".\n", domain ENDF B(G); "Selector-Error: Invalid domain selection name \"%s\".\n", domain ENDF B(G);
skipping to change at line 8337 skipping to change at line 8362
/*========================================================================*/ /*========================================================================*/
static int SelectorSelect0(PyMOLGlobals * G, EvalElem * passed_base) static int SelectorSelect0(PyMOLGlobals * G, EvalElem * passed_base)
{ {
CSelector *I = G->Selector; CSelector *I = G->Selector;
TableRec *i_table = I->Table; TableRec *i_table = I->Table;
ObjectMolecule **i_obj = I->Obj; ObjectMolecule **i_obj = I->Obj;
int a, b, flag; int a, b, flag;
EvalElem *base = passed_base; EvalElem *base = passed_base;
int c = 0; int c = 0;
int state; int state;
int static_singletons;
ObjectMolecule *obj, *cur_obj = NULL; ObjectMolecule *obj, *cur_obj = NULL;
CoordSet *cs; CoordSet *cs;
base->type = STYP_LIST; base->type = STYP_LIST;
base->sele = Calloc(int, I->NAtom); base->sele = Calloc(int, I->NAtom);
ErrChkPtr(G, base->sele); ErrChkPtr(G, base->sele);
switch (base->code) { switch (base->code) {
case SELE_HBAs: case SELE_HBAs:
case SELE_HBDs: case SELE_HBDs:
skipping to change at line 8395 skipping to change at line 8419
case SELE_HETz: case SELE_HETz:
for(a = cNDummyAtoms; a < I->NAtom; a++) for(a = cNDummyAtoms; a < I->NAtom; a++)
base[0].sele[a] = i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].hetat m; base[0].sele[a] = i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].hetat m;
break; break;
case SELE_HYDz: case SELE_HYDz:
for(a = cNDummyAtoms; a < I->NAtom; a++) for(a = cNDummyAtoms; a < I->NAtom; a++)
base[0].sele[a] = i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].isHyd rogen(); base[0].sele[a] = i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].isHyd rogen();
break; break;
case SELE_METz: case SELE_METz:
for(a = cNDummyAtoms; a < I->NAtom; a++) { for(a = cNDummyAtoms; a < I->NAtom; a++) {
b = i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].protons; base[0].sele[a] = i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].isMet
base[0].sele[a] = ( al();
(b > 2 && b < 5) ||
(b > 10 && b < 14) ||
(b > 18 && b < 32) ||
(b > 36 && b < 51) ||
(b > 54 && b < 85) ||
b > 86);
} }
break; break;
case SELE_BB_z: case SELE_BB_z:
case SELE_SC_z: case SELE_SC_z:
{ {
AtomInfoType *ai; AtomInfoType *ai;
flag = (base->code == SELE_BB_z); flag = (base->code == SELE_BB_z);
for(a = cNDummyAtoms; a < I->NAtom; a++) { for(a = cNDummyAtoms; a < I->NAtom; a++) {
ai = i_obj[i_table[a].model]->AtomInfo + i_table[a].atom; ai = i_obj[i_table[a].model]->AtomInfo + i_table[a].atom;
if(!(ai->flags & cAtomFlag_polymer)) { if(!(ai->flags & cAtomFlag_polymer)) {
skipping to change at line 8441 skipping to change at line 8458
case SELE_RSTz: case SELE_RSTz:
for(a = cNDummyAtoms; a < I->NAtom; a++) for(a = cNDummyAtoms; a < I->NAtom; a++)
base[0].sele[a] = base[0].sele[a] =
i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_res train; i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_res train;
break; break;
case SELE_POLz: case SELE_POLz:
for(a = cNDummyAtoms; a < I->NAtom; a++) for(a = cNDummyAtoms; a < I->NAtom; a++)
base[0].sele[a] = base[0].sele[a] =
i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_pol ymer; i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_pol ymer;
break; break;
case SELE_PROz:
for(a = cNDummyAtoms; a < I->NAtom; a++)
base[0].sele[a] =
i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_pro
tein;
break;
case SELE_NUCz:
for(a = cNDummyAtoms; a < I->NAtom; a++)
base[0].sele[a] =
i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_nuc
leic;
break;
case SELE_SOLz: case SELE_SOLz:
for(a = cNDummyAtoms; a < I->NAtom; a++) for(a = cNDummyAtoms; a < I->NAtom; a++)
base[0].sele[a] = base[0].sele[a] =
i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_sol vent; i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_sol vent;
break; break;
case SELE_PTDz: case SELE_PTDz:
for(a = cNDummyAtoms; a < I->NAtom; a++) for(a = cNDummyAtoms; a < I->NAtom; a++)
base[0].sele[a] = i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].prote kted; base[0].sele[a] = i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].prote kted;
break; break;
case SELE_MSKz: case SELE_MSKz:
skipping to change at line 8471 skipping to change at line 8498
base[0].sele[a] = base[0].sele[a] =
i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_ino rganic; i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_ino rganic;
break; break;
case SELE_GIDz: case SELE_GIDz:
for(a = cNDummyAtoms; a < I->NAtom; a++) for(a = cNDummyAtoms; a < I->NAtom; a++)
base[0].sele[a] = base[0].sele[a] =
i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_gui de; i_obj[i_table[a].model]->AtomInfo[i_table[a].atom].flags & cAtomFlag_gui de;
break; break;
case SELE_PREz: case SELE_PREz:
state = SceneGetState(G);
static_singletons = SettingGetGlobal_b(G, cSetting_static_singletons);
flag = false; flag = false;
cs = NULL; cs = NULL;
for(a = cNDummyAtoms; a < I->NAtom; a++) { for(a = cNDummyAtoms; a < I->NAtom; a++) {
base[0].sele[a] = false; base[0].sele[a] = false;
obj = i_obj[i_table[a].model]; obj = i_obj[i_table[a].model];
if(obj != cur_obj) { /* different object */ if(obj != cur_obj) { /* different object */
state = obj->getState();
if(state >= obj->NCSet) if(state >= obj->NCSet)
flag = false; flag = false;
else if(state < 0)
flag = false;
else if(!obj->CSet[state]) else if(!obj->CSet[state])
flag = false; flag = false;
else { else {
cs = obj->CSet[state]; cs = obj->CSet[state];
flag = true; /* valid state */ flag = true; /* valid state */
} }
if(!flag)
if(I->NCSet == 1)
if(static_singletons) {
cs = obj->CSet[0];
flag = true;
}
cur_obj = obj; cur_obj = obj;
} }
if(flag && cs) { if(flag && cs) {
if(cs->atmToIdx(i_table[a].atom) >= 0) { if(cs->atmToIdx(i_table[a].atom) >= 0) {
base[0].sele[a] = true; base[0].sele[a] = true;
c++; c++;
} }
} }
} }
break; break;
skipping to change at line 8838 skipping to change at line 8860
base_0_sele_a++; base_0_sele_a++;
} }
WordMatcherFree(matcher); WordMatcherFree(matcher);
} }
} }
break; break;
case SELE_STRO: case SELE_STRO:
{ {
CWordMatchOptions options; CWordMatchOptions options;
int prevmodel; int prevmodel;
char mmstereotype[2];
mmstereotype[1] = 0;
WordMatchOptionsConfigAlphaList(&options, wildcard[0], ignore_case); WordMatchOptionsConfigAlphaList(&options, wildcard[0], ignore_case);
table_a = i_table + cNDummyAtoms; table_a = i_table + cNDummyAtoms;
base_0_sele_a = &base[0].sele[cNDummyAtoms]; base_0_sele_a = &base[0].sele[cNDummyAtoms];
if((matcher = WordMatcherNew(G, base[1].text, &options, true))) { if((matcher = WordMatcherNew(G, base[1].text, &options, true))) {
table_a = i_table + cNDummyAtoms; table_a = i_table + cNDummyAtoms;
base_0_sele_a = &base[0].sele[cNDummyAtoms]; base_0_sele_a = &base[0].sele[cNDummyAtoms];
prevmodel = -1; prevmodel = -1;
for(a = cNDummyAtoms; a < I_NAtom; a++) { for(a = cNDummyAtoms; a < I_NAtom; a++) {
#ifndef NO_MMLIBS #ifndef NO_MMLIBS
#endif #endif
mmstereotype[0] = convertStereoToChar(i_obj[table_a->model]->AtomInfo[t const char * mmstereotype =
able_a->atom].stereo); AtomInfoGetStereoAsStr(i_obj[table_a->model]->AtomInfo + table_a->at
om);
if((*base_0_sele_a = if((*base_0_sele_a =
WordMatcherMatchAlpha(matcher,mmstereotype))) WordMatcherMatchAlpha(matcher,mmstereotype)))
c++; c++;
table_a++; table_a++;
base_0_sele_a++; base_0_sele_a++;
} }
WordMatcherFree(matcher); WordMatcherFree(matcher);
} }
} }
break; break;
skipping to change at line 8911 skipping to change at line 8932
base[0].sele[a] = true; base[0].sele[a] = true;
c++; c++;
} }
} }
} }
} }
break; break;
case SELE_CHNs: case SELE_CHNs:
case SELE_SEGs: case SELE_SEGs:
case SELE_CUST: case SELE_CUST:
case SELE_LABs:
{ {
CWordMatchOptions options; CWordMatchOptions options;
WordMatchOptionsConfigAlphaList(&options, wildcard[0], ignore_case_chain); WordMatchOptionsConfigAlphaList(&options, wildcard[0], ignore_case_chain);
table_a = i_table + cNDummyAtoms; table_a = i_table + cNDummyAtoms;
base_0_sele_a = &base[0].sele[cNDummyAtoms]; base_0_sele_a = &base[0].sele[cNDummyAtoms];
int offset = 0; int offset = 0;
switch (base->code) { switch (base->code) {
case SELE_CHNs: case SELE_CHNs:
offset = offsetof(AtomInfoType, chain); offset = offsetof(AtomInfoType, chain);
break; break;
case SELE_SEGs: case SELE_SEGs:
offset = offsetof(AtomInfoType, segi); offset = offsetof(AtomInfoType, segi);
break; break;
case SELE_CUST: case SELE_CUST:
offset = offsetof(AtomInfoType, custom); offset = offsetof(AtomInfoType, custom);
break; break;
case SELE_LABs:
offset = offsetof(AtomInfoType, label);
break;
default: default:
printf("coding error: missing case\n"); printf("coding error: missing case\n");
} }
if((matcher = WordMatcherNew(G, base[1].text, &options, true))) { if((matcher = WordMatcherNew(G, base[1].text, &options, true))) {
table_a = i_table + cNDummyAtoms; table_a = i_table + cNDummyAtoms;
base_0_sele_a = &base[0].sele[cNDummyAtoms]; base_0_sele_a = &base[0].sele[cNDummyAtoms];
for(a = cNDummyAtoms; a < I_NAtom; a++) { for(a = cNDummyAtoms; a < I_NAtom; a++) {
if((*base_0_sele_a = if((*base_0_sele_a =
skipping to change at line 8984 skipping to change at line 9009
} }
WordMatcherFree(matcher); WordMatcherFree(matcher);
} }
} }
break; break;
case SELE_STAs: case SELE_STAs:
sscanf(base[1].text, "%d", &state); sscanf(base[1].text, "%d", &state);
state = state - 1; state = state - 1;
obj = NULL; obj = NULL;
if(state < 0) { {
for(a = cNDummyAtoms; a < I_NAtom; a++) auto state_arg = state;
base[0].sele[a] = false;
} else {
for(a = cNDummyAtoms; a < I_NAtom; a++) { for(a = cNDummyAtoms; a < I_NAtom; a++) {
base[0].sele[a] = false; base[0].sele[a] = false;
obj = i_obj[i_table[a].model]; obj = i_obj[i_table[a].model];
if(obj != cur_obj) { /* different object */ if(obj != cur_obj) { /* different object */
if (state_arg == cSelectorUpdateTableCurrentState)
state = obj->getState();
if(state >= obj->NCSet) if(state >= obj->NCSet)
flag = false; flag = false;
else if(state < 0)
flag = false;
else if(!obj->CSet[state]) else if(!obj->CSet[state])
flag = false; flag = false;
else { else {
cs = obj->CSet[state]; cs = obj->CSet[state];
flag = true; /* valid state */ flag = true; /* valid state */
} }
cur_obj = obj; cur_obj = obj;
} }
if(flag && cs) { if(flag && cs) {
if(cs->atmToIdx(i_table[a].atom) >= 0) { if(cs->atmToIdx(i_table[a].atom) >= 0) {
skipping to change at line 9233 skipping to change at line 9260
(CObject *) last _obj); (CObject *) last _obj);
} }
if((base[0].sele[a] = last_was_member)) if((base[0].sele[a] = last_was_member))
c++; c++;
} }
ExecutiveFreeGroupList(G, group_list_id); ExecutiveFreeGroupList(G, group_list_id);
} else if(base[1].text[0] == '?') { /* undefined ?sele allowed */ } else if(base[1].text[0] == '?') { /* undefined ?sele allowed */
for(a = cNDummyAtoms; a < I_NAtom; a++) for(a = cNDummyAtoms; a < I_NAtom; a++)
base[0].sele[a] = false; base[0].sele[a] = false;
} else { } else {
if (!quiet){
PRINTFB(G, FB_Selector, FB_Errors) PRINTFB(G, FB_Selector, FB_Errors)
"Selector-Error: Invalid selection name \"%s\".\n", word ENDFB(G) ; "Selector-Error: Invalid selection name \"%s\".\n", word ENDFB(G) ;
}
ok = false; ok = false;
} }
} }
} }
} }
break; break;
case SELE_MODs: case SELE_MODs:
/* need to change this to handle wildcarded model names */ /* need to change this to handle wildcarded model names */
skipping to change at line 10758 skipping to change at line 10783
c--; c--;
} }
} }
} }
break; break;
} }
if(ok) if(ok)
c++; /* go onto next word */ c++; /* go onto next word */
} }
if(level > 0){ if(level > 0){
if (!quiet)
ok = ErrMessage(G, "Selector", "Malformed selection."); ok = ErrMessage(G, "Selector", "Malformed selection.");
else
ok = 0;
} }
if(ok) { /* this is the main operation loop */ if(ok) { /* this is the main operation loop */
totDepth = depth; totDepth = depth;
opFlag = true; opFlag = true;
maxLevel = -1; maxLevel = -1;
for(a = 1; a <= totDepth; a++) { for(a = 1; a <= totDepth; a++) {
PRINTFD(G, FB_Selector) PRINTFD(G, FB_Selector)
" Selector initial stack %d-%p lv: %x co: %d type: %x sele %p\n", " Selector initial stack %d-%p lv: %x co: %d type: %x sele %p\n",
a, (void *) (Stack + a), Stack[a].level, Stack[a].code, a, (void *) (Stack + a), Stack[a].level, Stack[a].code,
Stack[a].type, (void *) Stack[a].sele ENDFD; Stack[a].type, (void *) Stack[a].sele ENDFD;
skipping to change at line 10944 skipping to change at line 10966
} }
if(level) if(level)
level--; level--;
else else
break; break;
} }
depth = totDepth; depth = totDepth;
} }
if(ok) { if(ok) {
if(depth != 1) { if(depth != 1) {
if (!quiet)
ok = ErrMessage(G, "Selector", "Malformed selection."); ok = ErrMessage(G, "Selector", "Malformed selection.");
else
ok = 0;
} else if(Stack[depth].type != STYP_LIST) } else if(Stack[depth].type != STYP_LIST)
if (!quiet)
ok = ErrMessage(G, "Selector", "Invalid selection."); ok = ErrMessage(G, "Selector", "Invalid selection.");
else
ok = 0;
else else
result = Stack[totDepth].sele; /* return the selection list */ result = Stack[totDepth].sele; /* return the selection list */
} }
if(!ok) { if(!ok) {
for(a = 1; a <= depth; a++) { for(a = 1; a <= depth; a++) {
PRINTFD(G, FB_Selector) PRINTFD(G, FB_Selector)
" Selector: releasing %d %x %p\n", a, Stack[a].type, (void *) Stack[a].s ele ENDFD; " Selector: releasing %d %x %p\n", a, Stack[a].type, (void *) Stack[a].s ele ENDFD;
if(Stack[a].type == STYP_LIST) if(Stack[a].type == STYP_LIST)
FreeP(Stack[a].sele); FreeP(Stack[a].sele);
} }
depth = 0; depth = 0;
{ {
OrthoLineType line; OrthoLineType line;
for(a = 0; a <= c; a++) { for(a = 0; a <= c; a++) {
q = line; q = line;
if(a && word[a][0]) if(a && word[a][0])
q = UtilConcat(q, " "); q = UtilConcat(q, " ");
q = UtilConcat(q, word[a]); q = UtilConcat(q, word[a]);
if (!quiet){
PRINTFB(G, FB_Selector, FB_Errors) PRINTFB(G, FB_Selector, FB_Errors)
"%s", line ENDFB(G); "%s", line ENDFB(G);
}
} }
q = line; q = line;
q = UtilConcat(q, "<--"); q = UtilConcat(q, "<--");
if (!quiet){
PRINTFB(G, FB_Selector, FB_Errors) PRINTFB(G, FB_Selector, FB_Errors)
"%s", line ENDFB(G); "%s\n", line ENDFB(G);
// moved to only !quiet B.B. 11/12 - not sure why this is in there, cause
d unwanted cr to print during test
OrthoRestorePrompt(G);
}
} }
} }
VLAFreeP(Stack); VLAFreeP(Stack);
if(!ok) { if(!ok) {
FreeP(result); FreeP(result);
result = NULL; result = NULL;
} }
return (result); return (result);
} }
 End of changes. 49 change blocks. 
73 lines changed or deleted 84 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)