From c770cdd88378ccff36bd257edcf29dd16b084a38 Mon Sep 17 00:00:00 2001 From: mdehoon Date: Tue, 20 Apr 2021 17:06:57 +0900 Subject: [PATCH] Replace remaining python2-style print commands by python3-style print function (#3533) * updated print function * one more --- Bio/Align/AlignInfo.py | 2 +- Bio/AlignIO/EmbossIO.py | 2 +- Bio/AlignIO/Interfaces.py | 6 ++-- Bio/AlignIO/PhylipIO.py | 2 +- Bio/Blast/NCBIWWW.py | 2 +- Bio/Data/CodonTable.py | 4 +-- Bio/Graphics/GenomeDiagram/_CircularDrawer.py | 10 +++--- Bio/Graphics/GenomeDiagram/_Graph.py | 2 +- Bio/Graphics/GenomeDiagram/_LinearDrawer.py | 36 +++++++++---------- Bio/Nexus/Nexus.py | 14 ++++---- Bio/SearchIO/_legacy/NCBIStandalone.py | 10 +++--- Bio/motifs/jaspar/db.py | 2 +- BioSQL/Loader.py | 8 ++--- Tests/test_codonalign.py | 2 +- 14 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Bio/Align/AlignInfo.py b/Bio/Align/AlignInfo.py index 1527b25d0a2..95a4e69507d 100644 --- a/Bio/Align/AlignInfo.py +++ b/Bio/Align/AlignInfo.py @@ -367,7 +367,7 @@ def information_content( e_freq_table, random_expected, ) - # print freq_dict, + # print(freq_dict, end="") column_score = self._get_column_info_content( freq_dict, e_freq_table, log_base, random_expected ) diff --git a/Bio/AlignIO/EmbossIO.py b/Bio/AlignIO/EmbossIO.py index 4dd77695a60..b1ebd4d9aa5 100644 --- a/Bio/AlignIO/EmbossIO.py +++ b/Bio/AlignIO/EmbossIO.py @@ -175,7 +175,7 @@ def __next__(self): index = 0 else: # just a start value, this is just alignment annotation (?) - # print "Skipping: " + line.rstrip() + # print("Skipping: " + line.rstrip()) pass elif line.strip() == "": # Just a spacer? diff --git a/Bio/AlignIO/Interfaces.py b/Bio/AlignIO/Interfaces.py index 605e92dbb27..b53de301113 100644 --- a/Bio/AlignIO/Interfaces.py +++ b/Bio/AlignIO/Interfaces.py @@ -61,10 +61,10 @@ def __iter__(self): with open("many.phy","r") as myFile: for alignment in PhylipIterator(myFile): - print "New alignment:" + print("New alignment:") for record in alignment: - print record.id - print record.seq + print(record.id) + print(record.seq) """ return iter(self.__next__, None) diff --git a/Bio/AlignIO/PhylipIO.py b/Bio/AlignIO/PhylipIO.py index 1f7b5a9dfe8..cc3f6655658 100644 --- a/Bio/AlignIO/PhylipIO.py +++ b/Bio/AlignIO/PhylipIO.py @@ -247,7 +247,7 @@ def __next__(self): self._header = line break - # print "New block..." + # print("New block...") for i in range(number_of_seqs): s = line.strip().replace(" ", "") if "." in s: diff --git a/Bio/Blast/NCBIWWW.py b/Bio/Blast/NCBIWWW.py index 38bb9b82160..4bcca3fb471 100644 --- a/Bio/Blast/NCBIWWW.py +++ b/Bio/Blast/NCBIWWW.py @@ -323,7 +323,7 @@ def _parse_qblast_ref_page(handle): msg = s[i:].split("<", 1)[0].split("\n", 1)[0].strip() raise ValueError("Error message from NCBI: %s" % msg) # We didn't recognise the error layout :( - # print s + # print(s) raise ValueError( "No RID and no RTOE found in the 'please wait' page, " "there was probably an error in your request but we " diff --git a/Bio/Data/CodonTable.py b/Bio/Data/CodonTable.py index 6c1814d5595..bc006ee785b 100644 --- a/Bio/Data/CodonTable.py +++ b/Bio/Data/CodonTable.py @@ -312,7 +312,7 @@ def list_ambiguous_codons(codons, ambiguous_nucleotide_values): if codon not in candidates and codon not in codons: candidates.append(codon) answer = codons[:] # copy - # print "Have %i new candidates" % len(candidates) + # print("Have %i new candidates" % len(candidates)) for ambig_codon in candidates: wanted = True # e.g. 'TRR' -> 'TAA', 'TAG', 'TGA', 'TGG' @@ -325,7 +325,7 @@ def list_ambiguous_codons(codons, ambiguous_nucleotide_values): if codon not in codons: # This ambiguous codon can code for a non-stop, exclude it! wanted = False - # print "Rejecting %s" % ambig_codon + # print("Rejecting %s" % ambig_codon) continue if wanted: answer.append(ambig_codon) diff --git a/Bio/Graphics/GenomeDiagram/_CircularDrawer.py b/Bio/Graphics/GenomeDiagram/_CircularDrawer.py index a7f04646fdc..b090fd9f398 100644 --- a/Bio/Graphics/GenomeDiagram/_CircularDrawer.py +++ b/Bio/Graphics/GenomeDiagram/_CircularDrawer.py @@ -257,7 +257,7 @@ def draw_track(self, track): def draw_feature_set(self, set): """Return list of feature elements and list of labels for them.""" - # print 'draw feature set' + # print('draw feature set') feature_elements = [] # Holds diagram elements belonging to the features label_elements = [] # Holds diagram elements belonging to feature labels @@ -420,8 +420,8 @@ def get_feature_sigil(self, feature, locstart, locend, **kwargs): # No label required labelgroup = None # if locstart > locend: - # print locstart, locend, feature.strand, sigil, feature.name - # print locstart, locend, feature.name + # print(locstart, locend, feature.strand, sigil, feature.name) + # print(locstart, locend, feature.name) return sigil, labelgroup def draw_cross_link(self, cross_link): @@ -522,7 +522,7 @@ def draw_graph_set(self, set): - set GraphSet object """ - # print 'draw graph set' + # print('draw graph set') elements = [] # Holds graph elements # Distribution dictionary for how to draw the graph @@ -1176,7 +1176,7 @@ def _draw_arc_line( a = ( (start_angle + x * (angle_diff)) * pi / 180 ) # to radians for sin/cos - # print x0+r*cos(a), y0+r*sin(a) + # print(x0+r*cos(a), y0+r*sin(a)) path.lineTo(x0 + r * cos(a), y0 + r * sin(a)) x += dx a = end_angle * pi / 180 diff --git a/Bio/Graphics/GenomeDiagram/_Graph.py b/Bio/Graphics/GenomeDiagram/_Graph.py index d7ef19cbc6a..7f99ef9fe25 100644 --- a/Bio/Graphics/GenomeDiagram/_Graph.py +++ b/Bio/Graphics/GenomeDiagram/_Graph.py @@ -130,7 +130,7 @@ def range(self): """ positions = sorted(self.data) # i.e. dict keys # Return first and last positions in graph - # print len(self.data) + # print(len(self.data)) return (positions[0], positions[-1]) def mean(self): diff --git a/Bio/Graphics/GenomeDiagram/_LinearDrawer.py b/Bio/Graphics/GenomeDiagram/_LinearDrawer.py index d0a66e6d7bd..36012adf2bf 100644 --- a/Bio/Graphics/GenomeDiagram/_LinearDrawer.py +++ b/Bio/Graphics/GenomeDiagram/_LinearDrawer.py @@ -670,7 +670,7 @@ def draw_feature_set(self, set): Returns a tuple (list of elements describing features, list of labels for elements). """ - # print 'draw feature set' + # print("draw feature set") feature_elements = [] # Holds diagram elements belonging to the features label_elements = [] # Holds diagram elements belonging to feature labels @@ -721,9 +721,9 @@ def draw_feature_location(self, feature, locstart, locend): # Get start and end positions for feature/subfeatures start_fragment, start_offset = self.canvas_location(locstart) end_fragment, end_offset = self.canvas_location(locend) - # print "start_fragment, start_offset", start_fragment, start_offset - # print "end_fragment, end_offset", end_fragment, end_offset - # print "start, end", locstart, locend + # print("start_fragment, start_offset", start_fragment, start_offset) + # print("end_fragment, end_offset", end_fragment, end_offset) + # print("start, end", locstart, locend) # Note that there is a strange situation where a feature may be in # several parts, and one or more of those parts may end up being @@ -731,7 +731,7 @@ def draw_feature_location(self, feature, locstart, locend): # end fragments do actually exist in terms of the drawing allowed_fragments = list(self.fragment_limits.keys()) if start_fragment in allowed_fragments and end_fragment in allowed_fragments: - # print feature.name, feature.start, feature.end, start_offset, end_offset + # print(feature.name, feature.start, feature.end, start_offset, end_offset) if start_fragment == end_fragment: # Feature is found on one fragment feature_box, label = self.get_feature_sigil( feature, start_offset, end_offset, start_fragment @@ -746,7 +746,7 @@ def draw_feature_location(self, feature, locstart, locend): # The bit that runs up to the end of the first fragment, # and any bits that subsequently span whole fragments while self.fragment_limits[fragment][1] < locend: - # print fragment, self.fragment_limits[fragment][1], locend + # print(fragment, self.fragment_limits[fragment][1], locend) feature_box, label = self.get_feature_sigil( feature, start, self.pagewidth, fragment ) @@ -758,14 +758,14 @@ def draw_feature_location(self, feature, locstart, locend): # if label is not None: # There's a label for the feature # label_elements.append(label) # The last bit of the feature - # print locend, self.end, fragment - # print self.fragment_bases, self.length + # print(locend, self.end, fragment) + # print(self.fragment_bases, self.length) feature_box, label = self.get_feature_sigil( feature, 0, end_offset, fragment ) feature_boxes.append((feature_box, label)) # if locstart > locend: - # print locstart, locend, feature.strand, feature_boxes, feature.name + # print(locstart, locend, feature.strand, feature_boxes, feature.name) return feature_boxes def draw_cross_link(self, cross_link): @@ -1169,7 +1169,7 @@ def draw_graph_set(self, set): Returns tuple (list of graph elements, list of graph labels). """ - # print 'draw graph set' + # print('draw graph set') elements = [] # Holds graph elements # Distribution dictionary for how to draw the graph @@ -1191,7 +1191,7 @@ def draw_line_graph(self, graph): - graph Graph object """ - # print '\tdraw_line_graph' + # print('\tdraw_line_graph') line_elements = [] # Holds drawable elements # Get graph data @@ -1284,7 +1284,7 @@ def draw_line_graph(self, graph): def draw_heat_graph(self, graph): """Return a list of drawable elements for the heat graph.""" - # print '\tdraw_heat_graph' + # print('\tdraw_heat_graph') # At each point contained in the graph data, we draw a box that is the # full height of the track, extending from the midpoint between the # previous and current data points to the midpoint between the current @@ -1312,7 +1312,7 @@ def draw_heat_graph(self, graph): fragment0, x0 = self.canvas_location(pos0) fragment1, x1 = self.canvas_location(pos1) x0, x1 = self.x0 + x0, self.x0 + x1 # account for margin - # print 'x1 before:', x1 + # print('x1 before:', x1) # Calculate the heat color, based on the differential between # the value and the median value @@ -1326,8 +1326,8 @@ def draw_heat_graph(self, graph): x1 = self.xlim ttop = top + self.fragment_lines[fragment0][0] tbtm = btm + self.fragment_lines[fragment0][0] - # print 'equal', pos0, pos1, val - # print pos0, pos1, fragment0, fragment1 + # print('equal', pos0, pos1, val) + # print(pos0, pos1, fragment0, fragment1) heat_elements.append( draw_box((x0, tbtm), (x1, ttop), color=heat, border=None) ) @@ -1337,7 +1337,7 @@ def draw_heat_graph(self, graph): fragment = fragment0 start_x = x0 while self.fragment_limits[fragment][1] <= pos1: - # print pos0, self.fragment_limits[fragment][1], pos1 + # print(pos0, self.fragment_limits[fragment][1], pos1) ttop = top + self.fragment_lines[fragment][0] tbtm = btm + self.fragment_lines[fragment][0] heat_elements.append( @@ -1350,7 +1350,7 @@ def draw_heat_graph(self, graph): ttop = top + self.fragment_lines[fragment][0] tbtm = btm + self.fragment_lines[fragment][0] # Add the last part of the bar - # print 'x1 after:', x1, '\n' + # print('x1 after:', x1, '\n') heat_elements.append( draw_box((self.x0, tbtm), (x1, ttop), color=heat, border=None) ) @@ -1359,7 +1359,7 @@ def draw_heat_graph(self, graph): def draw_bar_graph(self, graph): """Return list of drawable elements for a bar graph.""" - # print '\tdraw_bar_graph' + # print('\tdraw_bar_graph') # At each point contained in the graph data, we draw a vertical bar # from the track center to the height of the datapoint value (positive # values go up in one color, negative go down in the alternative diff --git a/Bio/Nexus/Nexus.py b/Bio/Nexus/Nexus.py index c8fedb06573..ea39bab9fb8 100644 --- a/Bio/Nexus/Nexus.py +++ b/Bio/Nexus/Nexus.py @@ -997,7 +997,7 @@ def _charstatelabels(self, options): def _statelabels(self, options): # self.charlabels = options - # print 'Command statelabels is not supported and will be ignored.' + # print("Command statelabels is not supported and will be ignored.") pass def _matrix(self, options): @@ -1855,9 +1855,9 @@ def constant(self, matrix=None, delete=(), exclude=()): for taxon in undelete[1:]: newconstant = [] for site in constant: - # print '%d (paup=%d)' % (site[0],site[0]+1), + # print("%d (paup=%d)" % (site[0],site[0]+1), end="") seqsite = matrix[taxon][site[0]].upper() - # print seqsite,'checked against',site[1],'\t', + # print(seqsite,"checked against",site[1],"\t", end="") if ( seqsite == self.missing or ( @@ -1887,11 +1887,11 @@ def constant(self, matrix=None, delete=(), exclude=()): ) if intersect: newconstant.append((site[0], "".join(intersect))) - # print 'ok' + # print("ok") # else: - # print 'failed' + # print("failed") # else: - # print 'failed' + # print("failed") constant = newconstant cpos = [s[0] for s in constant] return cpos @@ -1996,7 +1996,7 @@ def add_sequence(self, name, sequence): if name in self.taxlabels: unique_name = _unique_label(self.taxlabels, name) - # print "WARNING: Sequence name %s is already present. Sequence was added as %s." % (name,unique_name) + # print("WARNING: Sequence name %s is already present. Sequence was added as %s." % (name,unique_name)) else: unique_name = name diff --git a/Bio/SearchIO/_legacy/NCBIStandalone.py b/Bio/SearchIO/_legacy/NCBIStandalone.py index c1f7645809f..378da3928dc 100644 --- a/Bio/SearchIO/_legacy/NCBIStandalone.py +++ b/Bio/SearchIO/_legacy/NCBIStandalone.py @@ -1778,11 +1778,11 @@ def __next__(self): if query and "BLAST" not in lines[0]: # Cheat and re-insert the header - # print "-"*50 - # print "".join(self._header) - # print "-"*50 - # print "".join(lines) - # print "-"*50 + # print("-"*50) + # print("".join(self._header)) + # print("-"*50) + # print("".join(lines)) + # print("-"*50) lines = self._header + lines if not lines: diff --git a/Bio/motifs/jaspar/db.py b/Bio/motifs/jaspar/db.py index 77a785f3a12..fc27305e692 100644 --- a/Bio/motifs/jaspar/db.py +++ b/Bio/motifs/jaspar/db.py @@ -729,7 +729,7 @@ def _fetch_internal_id_list( if where_clauses: sql = "".join([sql, " where ", " and ".join(where_clauses)]) - # print "sql = %s" % sql + # print("sql = %s" % sql) cur.execute(sql) rows = cur.fetchall() diff --git a/BioSQL/Loader.py b/BioSQL/Loader.py index 5c10c5f6c1b..9093c8e0795 100644 --- a/BioSQL/Loader.py +++ b/BioSQL/Loader.py @@ -650,8 +650,8 @@ def _load_bioentry_table(self, record): %s, %s, %s)""" - # print self.dbid, taxon_id, record.name, accession, identifier, \ - # division, description, version + # print(self.dbid, taxon_id, record.name, accession, identifier, \ + # division, description, version) self.adaptor.execute( sql, ( @@ -795,8 +795,8 @@ def _load_annotations(self, record, bioentry_id): self.adaptor.execute(mono_sql, (bioentry_id, term_id, str(value))) else: pass - # print "Ignoring annotation '%s' entry of type '%s'" \ - # % (key, type(value)) + # print("Ignoring annotation '%s' entry of type '%s'" \ + # % (key, type(value))) def _load_reference(self, reference, rank, bioentry_id): """Record SeqRecord's annotated references in the database (PRIVATE). diff --git a/Tests/test_codonalign.py b/Tests/test_codonalign.py index 3d0eb4d54d2..e0ae3a7c3c9 100644 --- a/Tests/test_codonalign.py +++ b/Tests/test_codonalign.py @@ -173,7 +173,7 @@ def setUp(self): def test_IO(self): self.assertEqual(len(self.alns), 6) - # print temp_dir + # print(temp_dir) for n, i in enumerate(self.alns): aln = i.toMultipleSeqAlignment() AlignIO.write(aln, temp_dir + "/aln" + str(n) + ".clw", "clustal")