From 4c316bf060e5f4a835c64ddfd5c96c6e4eb51dde Mon Sep 17 00:00:00 2001 From: Gerardo Tauriello <gerardo.tauriello@unibas.ch> Date: Tue, 9 Jul 2019 18:25:05 +0200 Subject: [PATCH] SCHWED-4246: use quoted chain names in PDBize and qsscoring. --- modules/io/pymod/__init__.py | 4 +++- modules/mol/alg/pymod/qsscoring.py | 17 ++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/modules/io/pymod/__init__.py b/modules/io/pymod/__init__.py index 70a196663..98d952269 100644 --- a/modules/io/pymod/__init__.py +++ b/modules/io/pymod/__init__.py @@ -381,7 +381,9 @@ def _PDBize(biounit, asu, seqres=None, min_polymer_size=10, tmp_ops.append(tp) trans_matrices = tmp_ops # select chains into a view as basis for each transformation - assu = asu.Select('cname='+','.join(chains[c_intvls[i][0]:c_intvls[i][1]])) + assu = asu.Select('cname='+','.join(mol.QueryQuoteName(name) \ + for name in \ + chains[c_intvls[i][0]:c_intvls[i][1]])) pdbizer.Add(assu, trans_matrices, ss) pdb_bu = pdbizer.Finish(transformation) if transformation: diff --git a/modules/mol/alg/pymod/qsscoring.py b/modules/mol/alg/pymod/qsscoring.py index 565768efb..3ed23ae9e 100644 --- a/modules/mol/alg/pymod/qsscoring.py +++ b/modules/mol/alg/pymod/qsscoring.py @@ -1462,18 +1462,6 @@ def _AlignAtomSeqs(seq_1, seq_2): LogWarning('%s: %s' % (seq_2.name, seq_2.string)) return aln -def _FixSelectChainName(ch_name): - """ - :return: String to be used with Select(cname=<RETURN>). Takes care of putting - quotation marks where needed. - :rtype: :class:`str` - :param ch_name: Single chain name (:class:`str`). - """ - if ch_name in ['-', '_', ' ']: - return '"%c"' % ch_name - else: - return ch_name - def _FixSelectChainNames(ch_names): """ :return: String to be used with Select(cname=<RETURN>). Takes care of joining @@ -1481,8 +1469,7 @@ def _FixSelectChainNames(ch_names): :rtype: :class:`str` :param ch_names: Some iterable list of chain names (:class:`str` items). """ - chain_set = set([_FixSelectChainName(ch_name) for ch_name in ch_names]) - return ','.join(chain_set) + return ','.join(mol.QueryQuoteName(ch_name) for ch_name in ch_names) # QS entity @@ -1507,7 +1494,7 @@ def _CleanInputEntity(ent): # remove them from *ent* if removed_chains: - view = ent.Select('cname!=%s' % _FixSelectChainNames(removed_chains)) + view = ent.Select('cname!=%s' % _FixSelectChainNames(set(removed_chains))) ent_new = mol.CreateEntityFromView(view, True) ent_new.SetName(ent.GetName()) else: -- GitLab