diff --git a/modules/bindings/pymod/dockq.py b/modules/bindings/pymod/dockq.py index ff920f627e7f6332986f0a0d093e5a2face5641d..f096b868ed77251334fd25d4728a2d70b0270bde 100644 --- a/modules/bindings/pymod/dockq.py +++ b/modules/bindings/pymod/dockq.py @@ -91,10 +91,6 @@ def _Setup(mdl, ref, mdl_ch1, mdl_ch2, ref_ch1, ref_ch2): # Interface with more chains... raise NotImplementedError("DockQ computations beyond two interacting " "chains has not been properly tested...") - #mdl_chain_names = mdl_ch1 + mdl_ch2 - #ref_chain_names = ref_ch1 + ref_ch2 - #mdl_to_dump = mdl_to_dump.Select(f"cname={','.join(mdl_chain_names)}") - #ref_to_dump = ref_to_dump.Select(f"cname={','.join(ref_chain_names)}") # first write structures to string, only create a tmpdir and the actual # files if this succeeds diff --git a/modules/mol/alg/pymod/contact_score.py b/modules/mol/alg/pymod/contact_score.py index b5ddeb10b7d3d3b7072e2a9bbbac28b9a78d9c4b..5dd7e48a8f5ba71dd3d4624af06688650783e275 100644 --- a/modules/mol/alg/pymod/contact_score.py +++ b/modules/mol/alg/pymod/contact_score.py @@ -200,9 +200,9 @@ class ContactEntity: for cname in self.chain_names: # q1 selects stuff in current chain that is close to any other chain - q1 = f"cname={cname} and {self.contact_d} <> [cname!={cname}]" + q1 = f"cname={mol.QueryQuoteName(cname)} and {self.contact_d} <> [cname!={mol.QueryQuoteName(cname)}]" # q2 selects stuff in other chains that is close to current chain - q2 = f"cname!={cname} and {self.contact_d} <> [cname={cname}]" + q2 = f"cname!={mol.QueryQuoteName(cname)} and {self.contact_d} <> [cname={mol.QueryQuoteName(cname)}]" v1 = self.view.Select(q1) v2 = self.view.Select(q2) v1_p = [geom.Vec3List([a.pos for a in r.atoms]) for r in v1.residues] diff --git a/modules/mol/alg/pymod/dockq.py b/modules/mol/alg/pymod/dockq.py index d3695c1de54ea43bda7cb9a61af332b4dca9023f..2db14d1f6aeafed2bb182ed7760aa4388c8c9ef7 100644 --- a/modules/mol/alg/pymod/dockq.py +++ b/modules/mol/alg/pymod/dockq.py @@ -44,11 +44,11 @@ def _PreprocessStructures(mdl, ref, mdl_ch1, mdl_ch2, ref_ch1, ref_ch2, tmp = ch1_aln.GetSequence(0) ref_s1 = seq.CreateSequence(tmp.GetName(), str(tmp)) ref_s1.SetOffset(tmp.GetOffset()) - ref_s1.AttachView(ref.Select(f"cname={ref_ch1}")) + ref_s1.AttachView(ref.Select(f"cname={mol.QueryQuoteName(ref_ch1)}")) tmp = ch1_aln.GetSequence(1) mdl_s1 = seq.CreateSequence(tmp.GetName(), str(tmp)) mdl_s1.SetOffset(tmp.GetOffset()) - mdl_s1.AttachView(mdl.Select(f"cname={mdl_ch1}")) + mdl_s1.AttachView(mdl.Select(f"cname={mol.QueryQuoteName(mdl_ch1)}")) new_ch1_aln = seq.CreateAlignment(ref_s1, mdl_s1) for col in new_ch1_aln: if col[0] != '-' and col[1] != '-': @@ -69,11 +69,11 @@ def _PreprocessStructures(mdl, ref, mdl_ch1, mdl_ch2, ref_ch1, ref_ch2, tmp = ch2_aln.GetSequence(0) ref_s2 = seq.CreateSequence(tmp.GetName(), str(tmp)) ref_s2.SetOffset(tmp.GetOffset()) - ref_s2.AttachView(ref.Select(f"cname={ref_ch2}")) + ref_s2.AttachView(ref.Select(f"cname={mol.QueryQuoteName(ref_ch2)}")) tmp = ch2_aln.GetSequence(1) mdl_s2 = seq.CreateSequence(tmp.GetName(), str(tmp)) mdl_s2.SetOffset(tmp.GetOffset()) - mdl_s2.AttachView(mdl.Select(f"cname={mdl_ch2}")) + mdl_s2.AttachView(mdl.Select(f"cname={mol.QueryQuoteName(mdl_ch2)}")) new_ch2_aln = seq.CreateAlignment(ref_s2, mdl_s2) for col in new_ch2_aln: if col[0] != '-' and col[1] != '-': @@ -92,7 +92,7 @@ def _PreprocessStructures(mdl, ref, mdl_ch1, mdl_ch2, ref_ch1, ref_ch2, dockq_idx += 1 else: # go by residue numbers - for mdl_r in mdl.Select(f"cname={mdl_ch1}").residues: + for mdl_r in mdl.Select(f"cname={mol.QueryQuoteName(mdl_ch1)}").residues: ref_r = ref.FindResidue(ref_ch1, mdl_r.GetNumber()) if ref_r.IsValid(): ref_r.SetIntProp("dockq_idx", dockq_idx) @@ -100,7 +100,7 @@ def _PreprocessStructures(mdl, ref, mdl_ch1, mdl_ch2, ref_ch1, ref_ch2, ref_r.SetIntProp("dockq_mapped", 1) mdl_r.SetIntProp("dockq_mapped", 1) dockq_idx += 1 - for mdl_r in mdl.Select(f"cname={mdl_ch2}").residues: + for mdl_r in mdl.Select(f"cname={mol.QueryQuoteName(mdl_ch2)}").residues: ref_r = ref.FindResidue(ref_ch2, mdl_r.GetNumber()) if ref_r.IsValid(): ref_r.SetIntProp("dockq_idx", dockq_idx) @@ -124,8 +124,8 @@ def _PreprocessStructures(mdl, ref, mdl_ch1, mdl_ch2, ref_ch1, ref_ch2, dockq_idx += 1 def _GetContacts(ent, ch1, ch2, dist_thresh): - int1 = ent.Select(f"cname={ch1} and {dist_thresh} <> [cname={ch2}]") - int2 = ent.Select(f"cname={ch2} and {dist_thresh} <> [cname={ch1}]") + int1 = ent.Select(f"cname={mol.QueryQuoteName(ch1)} and {dist_thresh} <> [cname={mol.QueryQuoteName(ch2)}]") + int2 = ent.Select(f"cname={mol.QueryQuoteName(ch2)} and {dist_thresh} <> [cname={mol.QueryQuoteName(ch1)}]") contacts = set() int1_p = [geom.Vec3List([a.pos for a in r.atoms]) for r in int1.residues] int2_p = [geom.Vec3List([a.pos for a in r.atoms]) for r in int2.residues] @@ -160,8 +160,8 @@ def _RMSDScores(mdl, ref, mdl_ch1, mdl_ch2, ref_ch1, ref_ch2, dist_thresh=10.0): sup_atoms = ['CA','C','N','O'] # make mapped residues accessible by the dockq_idx property - mapped_mdl = mdl.Select(f"cname={mdl_ch1},{mdl_ch2} and grdockq_mapped=1") - mapped_ref = ref.Select(f"cname={ref_ch1},{ref_ch2} and grdockq_mapped=1") + mapped_mdl = mdl.Select(f"cname={mol.QueryQuoteName(mdl_ch1)},{mol.QueryQuoteName(mdl_ch2)} and grdockq_mapped=1") + mapped_ref = ref.Select(f"cname={mol.QueryQuoteName(ref_ch1)},{mol.QueryQuoteName(ref_ch2)} and grdockq_mapped=1") ch = mapped_mdl.FindChain(mdl_ch1) mdl_ch1_residues = {r.GetIntProp("dockq_idx"): r for r in ch.residues} ch = mapped_mdl.FindChain(mdl_ch2) @@ -173,8 +173,8 @@ def _RMSDScores(mdl, ref, mdl_ch1, mdl_ch2, ref_ch1, ref_ch2, dist_thresh=10.0): # iRMSD ####### - int1 = ref.Select(f"cname={ref_ch1} and {dist_thresh} <> [cname={ref_ch2}]") - int2 = ref.Select(f"cname={ref_ch2} and {dist_thresh} <> [cname={ref_ch1}]") + int1 = ref.Select(f"cname={mol.QueryQuoteName(ref_ch1)} and {dist_thresh} <> [cname={mol.QueryQuoteName(ref_ch2)}]") + int2 = ref.Select(f"cname={mol.QueryQuoteName(ref_ch2)} and {dist_thresh} <> [cname={mol.QueryQuoteName(ref_ch1)}]") ref_pos = geom.Vec3List() mdl_pos = geom.Vec3List() for r in int1.residues: diff --git a/modules/mol/alg/pymod/ligand_scoring.py b/modules/mol/alg/pymod/ligand_scoring.py index b56e2dbe61f98cc0b5b10393c4ed3938198b5cdd..f94e1740edbc4bf6a455276d569a54f79a19b2e8 100644 --- a/modules/mol/alg/pymod/ligand_scoring.py +++ b/modules/mol/alg/pymod/ligand_scoring.py @@ -1537,8 +1537,8 @@ class LigandScorer: for ref_ch, mdl_ch in zip(ref_group, mdl_group): if ref_ch is not None and mdl_ch is not None: aln = ref_mdl_alns[(ref_ch, mdl_ch)] - trg_view = chain_mapper.target.Select(f"cname={ref_ch}") - mdl_view = mdl.Select(f"cname={mdl_ch}") + trg_view = chain_mapper.target.Select(f"cname={mol.QueryQuoteName(ref_ch)}") + mdl_view = mdl.Select(f"cname={mol.QueryQuoteName(mdl_ch)}") aln.AttachView(0, trg_view) aln.AttachView(1, mdl_view) alns[(ref_ch, mdl_ch)] = aln diff --git a/modules/mol/alg/pymod/scoring.py b/modules/mol/alg/pymod/scoring.py index 0f8e3ee560849f6fb60d60c8a07f663e8a8fe822..d0d3cf84de72cdcbda735b59362374968dcd6bd3 100644 --- a/modules/mol/alg/pymod/scoring.py +++ b/modules/mol/alg/pymod/scoring.py @@ -1368,14 +1368,14 @@ class Scorer: cname = ch.GetName() s = ''.join([r.one_letter_code for r in ch.residues]) s = seq.CreateSequence(ch.GetName(), s) - s.AttachView(target.Select(f"cname='{cname}'")) + s.AttachView(target.Select(f"cname={mol.QueryQuoteName(cname)}")) trg_seqs[ch.GetName()] = s mdl_seqs = dict() for ch in model.chains: cname = ch.GetName() s = ''.join([r.one_letter_code for r in ch.residues]) s = seq.CreateSequence(cname, s) - s.AttachView(model.Select(f"cname='{cname}'")) + s.AttachView(model.Select(f"cname={mol.QueryQuoteName(cname)}")) mdl_seqs[ch.GetName()] = s alns = list() @@ -1767,7 +1767,7 @@ class Scorer: result = {ch.GetName(): list() for ch in ent.chains} for ch in ent.chains: cname = ch.GetName() - sel = repr_ent.Select(f"(cname='{cname}' and 8 <> [cname!='{cname}'])") + sel = repr_ent.Select(f"(cname={mol.QueryQuoteName(cname)} and 8 <> [cname!={mol.QueryQuoteName(cname)}])") result[cname] = [r.GetNumber() for r in sel.residues] return result @@ -1834,9 +1834,9 @@ class Scorer: # => all residues within 8A of r and within 12A of any other chain # q1 selects for everything in same chain and within 8A of r_pos - q1 = f"(cname='{mdl_ch}' and 8 <> {{{r_pos[0]},{r_pos[1]},{r_pos[2]}}})" + q1 = f"(cname={mol.QueryQuoteName(mdl_ch)} and 8 <> {{{r_pos[0]},{r_pos[1]},{r_pos[2]}}})" # q2 selects for everything within 12A of any other chain - q2 = f"(12 <> [cname!={mdl_ch}])" + q2 = f"(12 <> [cname!={mol.QueryQuoteName(mdl_ch)}])" mdl_patch_one = self.model.CreateEmptyView() sel = repr_mdl.Select(" and ".join([q1, q2])) for r in sel.residues: @@ -1847,7 +1847,7 @@ class Scorer: # the closest residue to r is identified in any other chain, and the # patch is filled with residues that are within 8A of that residue and # within 12A of chain from r - sel = repr_mdl.Select(f"(cname!='{mdl_ch}')") + sel = repr_mdl.Select(f"(cname!={mol.QueryQuoteName(mdl_ch)})") close_stuff = sel.FindWithin(r_pos, 8) min_pos = None min_dist = 42.0 @@ -1858,9 +1858,9 @@ class Scorer: min_dist = dist # q1 selects for everything not in mdl_ch but within 8A of min_pos - q1 = f"(cname!='{mdl_ch}' and 8 <> {{{min_pos[0]},{min_pos[1]},{min_pos[2]}}})" + q1 = f"(cname!={mol.QueryQuoteName(mdl_ch)} and 8 <> {{{min_pos[0]},{min_pos[1]},{min_pos[2]}}})" # q2 selects for everything within 12A of mdl_ch - q2 = f"(12 <> [cname='{mdl_ch}'])" + q2 = f"(12 <> [cname={mol.QueryQuoteName(mdl_ch)}])" mdl_patch_two = self.model.CreateEmptyView() sel = repr_mdl.Select(" and ".join([q1, q2])) for r in sel.residues: @@ -2111,8 +2111,8 @@ class Scorer: for ref_ch, mdl_ch in zip(ref_group, mdl_group): if ref_ch is not None and mdl_ch is not None: aln = ref_mdl_alns[(ref_ch, mdl_ch)] - trg_view = chain_mapper.target.Select(f"cname='{ref_ch}'") - mdl_view = mdl.Select(f"cname='{mdl_ch}'") + trg_view = chain_mapper.target.Select(f"cname={mol.QueryQuoteName(ref_ch)}") + mdl_view = mdl.Select(f"cname={mol.QueryQuoteName(mdl_ch)}") aln.AttachView(0, trg_view) aln.AttachView(1, mdl_view) alns[(ref_ch, mdl_ch)] = aln diff --git a/modules/mol/alg/src/biounit.cc b/modules/mol/alg/src/biounit.cc index 72e2cc97034f2fa48a78e980797bc78e3bc51aa2..e21f0a58bc5cb6a2855e6f1f37af198f36196b22 100644 --- a/modules/mol/alg/src/biounit.cc +++ b/modules/mol/alg/src/biounit.cc @@ -255,9 +255,9 @@ ost::mol::EntityHandle CreateBU(const ost::mol::EntityHandle& asu, // derive all bonds related to that chain_intvl // potentially also interchain bonds std::stringstream query_ss; - query_ss << "cname=" << au_chains[chain_intvl][0]; + query_ss << "cname=" << mol::QueryQuoteName(au_chains[chain_intvl][0]); for(uint i = 1; i < au_chains[chain_intvl].size(); ++i) { - query_ss << ',' << au_chains[chain_intvl][i]; + query_ss << ',' << mol::QueryQuoteName(au_chains[chain_intvl][i]); } ost::mol::EntityView asu_view = asu.Select(query_ss.str()); const ost::mol::BondHandleList& bond_list = asu_view.GetBondList();