1- from __future__ import print_function
2-
31import sys
42import os
53import argparse
6- import re
74
85import ccp4mg
96import mmdb2
107import ccp4srs
118
12- from rdkit import Chem
13- from rdkit .Chem import AllChem
14- import rdkit
15-
169from gemmi import cif
1710
1811from .dictFileToMonomer import dictFileToMonomer
@@ -27,11 +20,15 @@ def changeDictionaryAtomNames(doc, changes):
2720 col = block .find_values (tag )
2821 for i , atomId in enumerate (col ):
2922 if atomId in changes :
30- col [i ] = cif .quote (changes [atomId ])
23+ newId = changes [atomId ]
24+ if "'" in newId or '"' in newId :
25+ col [i ] = cif .quote (newId )
26+ else :
27+ col [i ] = newId
3128
3229def replaceMatchesInDict (matches ,theDict ,outfile ):
3330 #Gemmi returns the vaules in the cif document with no leading/trailing whitespace.
34- matches = {k .strip (): v for k , v in matches .items ()}
31+ matches = {k .strip (): v . strip () for k , v in matches .items ()}
3532 try :
3633 doc = cif .read_file (theDict )
3734 changeDictionaryAtomNames (doc ,matches )
@@ -369,10 +366,3 @@ def matchAtoms(ifname,ofname=None,dictMatchName=None,selection="",dictFileName=N
369366 dictFileName = args .f
370367 retMatches = matchAtoms (ifname ,ofname ,dictMatchName ,selection ,dictFileName )
371368 print (retMatches )
372-
373- """
374- mol = Chem.rdmolfiles.MolFromPDBFile(sys.argv[1],removeHs=False)
375- print mol
376- This is how we'd get to PDB file from RDKit.
377- print Chem.rdmolfiles.MolToPDBBlock(mol)
378- """
0 commit comments