diff --git a/Contrib/Glare/glare.py b/Contrib/Glare/glare.py index 51348589f..d05844102 100755 --- a/Contrib/Glare/glare.py +++ b/Contrib/Glare/glare.py @@ -205,7 +205,7 @@ class Library: max_subsets = max(partitions) enumeration_indices = [] - for i in xrange(max_subsets): + for i in range(max_subsets): combinations = [] for size in partitions: combinations.append( i % size ) diff --git a/Contrib/fraggle/rdkit_tversky.py b/Contrib/fraggle/rdkit_tversky.py index 4e605e107..ef4b4f891 100644 --- a/Contrib/fraggle/rdkit_tversky.py +++ b/Contrib/fraggle/rdkit_tversky.py @@ -97,7 +97,7 @@ for line in sys.stdin: res = DataStructs.BulkTverskySimilarity(mfp, queries, 0, 1, False) #query_frag_smiles,query_smiles,query_id,retrieved_smi,retrieved_id,tversky_sim - for i in xrange(fragments): + for i in range(fragments): if (res[i] >= options.cutoff): print("%s,%s,%s,%s,%s,%s" % (query_info[i][2], query_info[i][0], query_info[i][1], smi, id, res[i])) diff --git a/rdkit/Chem/Fingerprints/ClusterMols.py b/rdkit/Chem/Fingerprints/ClusterMols.py index d4d392949..4f1ff8ccf 100755 --- a/rdkit/Chem/Fingerprints/ClusterMols.py +++ b/rdkit/Chem/Fingerprints/ClusterMols.py @@ -48,8 +48,8 @@ def GetDistanceMatrix(data, metric, isSimilarity=1): nPts = len(data) res = numpy.zeros((nPts * (nPts - 1) / 2), numpy.float) nSoFar = 0 - for col in xrange(1, nPts): - for row in xrange(col): + for col in range(1, nPts): + for row in range(col): fp1 = data[col][1] fp2 = data[row][1] if fp1.GetNumBits() > fp2.GetNumBits(): diff --git a/rdkit/Chem/MolSurf.py b/rdkit/Chem/MolSurf.py index 77dcd7ab2..f3b9529bd 100755 --- a/rdkit/Chem/MolSurf.py +++ b/rdkit/Chem/MolSurf.py @@ -72,7 +72,7 @@ def _pyLabuteHelper(mol, includeHs=1, force=0): # 0 contains the H information rads[0] = numTable[1][radCol] - for i in xrange(nAts): + for i in range(nAts): rads[i + 1] = numTable[mol.GetAtomWithIdx(i).GetAtomicNum()][radCol] # start with explicit bonds @@ -94,14 +94,14 @@ def _pyLabuteHelper(mol, includeHs=1, force=0): if includeHs: j = 0 Rj = rads[j] - for i in xrange(1, nAts + 1): + for i in range(1, nAts + 1): Ri = rads[i] bij = Ri + Rj dij = min(max(abs(Ri - Rj), bij), Ri + Rj) Vi[i] += Rj * Rj - (Ri - dij)**2 / dij Vi[j] += Ri * Ri - (Rj - dij)**2 / dij - for i in xrange(nAts + 1): + for i in range(nAts + 1): Ri = rads[i] Vi[i] = 4 * math.pi * Ri**2 - math.pi * Ri * Vi[i] diff --git a/rdkit/Chem/UnitTestDescriptors.py b/rdkit/Chem/UnitTestDescriptors.py index db9d9304e..3eb62de6d 100644 --- a/rdkit/Chem/UnitTestDescriptors.py +++ b/rdkit/Chem/UnitTestDescriptors.py @@ -44,7 +44,7 @@ class TestCase(unittest.TestCase): except Exception: import traceback traceback.print_exc() - raise AssertionError('SMILES: %s' % smi) + raise AssertionError('SMILES: %s; Descriptor: %s' % (smi, nm)) def testMolFormula(self): for (smiles, expected) in (("[NH4+]", "H4N+"), diff --git a/rdkit/Chem/fmcs/fmcs.py b/rdkit/Chem/fmcs/fmcs.py index e1a7b1500..873ca07f3 100644 --- a/rdkit/Chem/fmcs/fmcs.py +++ b/rdkit/Chem/fmcs/fmcs.py @@ -1047,7 +1047,7 @@ def find_duplicates(cangen_nodes, start, end): result = [] prev_value = -1 count = 0 - for index in xrange(start, end): + for index in range(start, end): node = cangen_nodes[index] if node.value == prev_value: count += 1 @@ -2461,19 +2461,19 @@ def parse_select(s): m = range_pat.match(s, start) if m is not None: # Selected from 'left' to (and including) 'right' - # Convert into xrange fields, starting from 0 + # Convert into range fields, starting from 0 left = int(m.group(1)) right = m.group(2) if not right: ranges.append(starting_from(left - 1)) else: - ranges.append(xrange(left - 1, int(right))) + ranges.append(range(left - 1, int(right))) else: # Selected a single value m = value_pat.match(s, start) if m is not None: val = int(m.group(1)) - ranges.append(xrange(val - 1, val)) + ranges.append(range(val - 1, val)) else: raise argparse.ArgumentTypeError("Unknown character at position %d of %r" % (start + 1, s)) start = m.end() diff --git a/rdkit/Dbase/DbConnection.py b/rdkit/Dbase/DbConnection.py index 0b96dd363..039ead18d 100755 --- a/rdkit/Dbase/DbConnection.py +++ b/rdkit/Dbase/DbConnection.py @@ -66,7 +66,7 @@ class DbConnect(object): self.user = self.userEntry.GetValue() self.password = self.passwdEntry.GetValue() self.dbName = self.dbBrowseButton.GetValue() - for i in xrange(self.dbTableChoice.Number()): + for i in range(self.dbTableChoice.Number()): self.dbTableChoice.Delete(0) names = self.GetTableNames() diff --git a/rdkit/sping/PDF/pdfmetrics.py b/rdkit/sping/PDF/pdfmetrics.py index ba84594f6..729a23d1a 100755 --- a/rdkit/sping/PDF/pdfmetrics.py +++ b/rdkit/sping/PDF/pdfmetrics.py @@ -251,12 +251,12 @@ def parseAFMfile(filename): metriclines = [] between = 0 for line in alllines: - if string.find(string.lower(line), 'endcharmetrics') > -1: + if string.find(line.lower(), 'endcharmetrics') > -1: between = 0 break if between: metriclines.append(line) - if string.find(string.lower(line), 'startcharmetrics') > -1: + if string.find(line.lower(), 'startcharmetrics') > -1: between = 1 # break up - very shaky assumption about array size @@ -307,7 +307,7 @@ class FontCache: return self.getfont('courier') def stringwidth(self, text, font): - widths = self.getfont(string.lower(font)) + widths = self.getfont(font.lower()) w = 0 for char in text: w = w + widths[ord(char)] diff --git a/rdkit/sping/PDF/pidPDF.py b/rdkit/sping/PDF/pidPDF.py index 907f92ee5..3e01b392f 100755 --- a/rdkit/sping/PDF/pidPDF.py +++ b/rdkit/sping/PDF/pidPDF.py @@ -221,7 +221,7 @@ class PDFCanvas(Canvas): if not font.face: face = 'serif' else: - face = string.lower(font.face) + face = font.face.lower() while face in font_face_map: face = font_face_map[face] #step 2, - resolve bold/italic to get the right PS font name diff --git a/rdkit/sping/PS/psmetrics.py b/rdkit/sping/PS/psmetrics.py index b3888a24b..f9874c344 100755 --- a/rdkit/sping/PS/psmetrics.py +++ b/rdkit/sping/PS/psmetrics.py @@ -219,10 +219,10 @@ _Widths = {'StandardEncoding': _stdenc_widths, 'Latin1Encoding': latin1MetricsCa def stringwidth(text, font, encoding): if font in fontinfo.NonRomanFonts: - widths = _Widths['StandardEncoding'][string.lower(font)] + widths = _Widths['StandardEncoding'][font.lower()] else: try: - widths = _Widths[encoding][string.lower(font)] + widths = _Widths[encoding][font.lower()] except Exception: raise KeyError("Improper encoding {0} or font name {1}".format(encoding, font)) w = 0 diff --git a/rdkit/sping/Pyart/Fontmapping.py b/rdkit/sping/Pyart/Fontmapping.py index 410e69b0c..45bfd95e9 100755 --- a/rdkit/sping/Pyart/Fontmapping.py +++ b/rdkit/sping/Pyart/Fontmapping.py @@ -74,7 +74,7 @@ def getPyartName(pidfont): face = pidfont.face or DefaultFace # print "pidfont.face = %s" % pidfont.face - face = string.lower(face) + face = face.lower() if face in PidLegalFonts: return MapPid2PyartFontName[(PidLegalFonts[face], shape)] else: @@ -93,7 +93,7 @@ getPdfName = getPyartName # face = pidfont.face or DefaultFace # # print "pidfont.face = %s" % pidfont.face -# face = string.lower(face) +# face = face.lower() # if face in PidLegalFonts: # return PDFFontMapping[ ( PidLegalFonts[face], shape) ] # else: diff --git a/rdkit/sping/Pyart/pidPyart.py b/rdkit/sping/Pyart/pidPyart.py index e95532c7f..51f776be6 100755 --- a/rdkit/sping/Pyart/pidPyart.py +++ b/rdkit/sping/Pyart/pidPyart.py @@ -124,7 +124,7 @@ class PyartCanvas(Canvas): } try: - face = piddle_font_map[string.lower(font.face)] + face = piddle_font_map[font.face.lower()] except Exception: return 'Helvetica' diff --git a/rdkit/sping/SVG/pidSVG.py b/rdkit/sping/SVG/pidSVG.py index 23f03fae8..170e177a8 100755 --- a/rdkit/sping/SVG/pidSVG.py +++ b/rdkit/sping/SVG/pidSVG.py @@ -74,7 +74,7 @@ def _PointListToSVG(points, dupFirst=0): """ outStr = '' - for i in xrange(len(points)): + for i in range(len(points)): outStr = outStr + '%.2f,%.2f ' % (points[i][0], points[i][1]) # add back on the first point. This is not required in the spec, # but Adobe's beta-quality viewer seems to not like it being skipped @@ -130,9 +130,9 @@ class SVGCanvas(Canvas): } try: - face = piddle_font_map[string.lower(font.face)] + face = piddle_font_map[font.face.lower()] except Exception: - return piddle_font_map[string.lower('sansserif')] + return piddle_font_map['sansserif'] name = face + '-' if font.bold and face in ['Courier', 'Helvetica', 'Times']: @@ -170,7 +170,7 @@ class SVGCanvas(Canvas): familyStr = '\'%s\'' % (face) else: familyStr = face - for i in xrange(1, len(font.face)): + for i in range(1, len(font.face)): face = font.face[i] if len(string.split(face)) > 1: familyStr = ', \'%s\'' % (face) @@ -609,7 +609,7 @@ class SVGCanvas(Canvas): into SVG is to read it from a file. So we'll save out to a PNG file, then set a link to that in the SVG. """ - imageFileName = '%s-%d.%s' % (self.name, self._nImages, string.lower(self._imageFormat)) + imageFileName = '%s-%d.%s' % (self.name, self._nImages, self._imageFormat.lower()) self._nImages = self._nImages + 1 image.save(imageFileName, format=self._imageFormat) diff --git a/rdkit/sping/TK/pidTK.py b/rdkit/sping/TK/pidTK.py index 1bc5b84fb..802897152 100755 --- a/rdkit/sping/TK/pidTK.py +++ b/rdkit/sping/TK/pidTK.py @@ -135,7 +135,7 @@ class FontManager: if font.face: # check if the user specified a generic face type # like serif or monospaced. check is case-insenstive. - f = string.lower(font.face) + f = font.face.lower() if f in self.__alt_faces: family = self.__alt_faces[f] else: