[med-svn] [Git][med-team/macsyfinder][master] 2 commits: Use 2to3 to port to Python3
Andreas Tille
gitlab at salsa.debian.org
Fri Sep 6 09:55:52 BST 2019
Andreas Tille pushed to branch master at Debian Med / macsyfinder
Commits:
a26a252e by Andreas Tille at 2019-09-06T08:44:35Z
Use 2to3 to port to Python3
- - - - -
994f55a1 by Andreas Tille at 2019-09-06T08:55:01Z
Attempt to use 2to3 to port to Python3 failed
- - - - -
5 changed files:
- debian/changelog
- debian/control
- + debian/patches/2to3.patch
- debian/patches/series
- debian/rules
Changes:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+macsyfinder (1.0.5-4) UNRELEASED; urgency=medium
+
+ * Attempt to use 2to3 to port to Python3 failed
+ not yet closed: #936977
+ See also https://github.com/gem-pasteur/macsyfinder/issues/21
+
+ -- Andreas Tille <tille at debian.org> Fri, 06 Sep 2019 10:40:05 +0200
+
macsyfinder (1.0.5-3) unstable; urgency=medium
* Team upload.
=====================================
debian/control
=====================================
@@ -5,7 +5,7 @@ Section: science
Priority: optional
Build-Depends: debhelper-compat (= 12),
dh-python,
- python,
+ python3,
python3-sphinx,
texlive-latex-recommended,
texlive-plain-generic,
@@ -21,7 +21,7 @@ Homepage: https://github.com/gem-pasteur/macsyfinder
Package: macsyfinder
Architecture: all
-Depends: ${python:Depends},
+Depends: ${python3:Depends},
${misc:Depends},
hmmer,
ncbi-blast+,
=====================================
debian/patches/2to3.patch
=====================================
@@ -0,0 +1,888 @@
+Description: Use 2to3 to port to Python3
+ Unfortunately it is more complex than just 2to3
+Bug-Debian: https://bugs.debian.org/936977
+Author: Andreas Tille <tille at debian.org>
+Last-Update: Fri, 06 Sep 2019 10:40:05 +0200
+
+diff --git a/README.md b/README.md
+index 6387b97..d21701e 100644
+--- a/README.md
++++ b/README.md
+@@ -41,22 +41,22 @@ cd macsyfinder-x.x
+ 3. Build
+
+ ```bash
+-python setup.py build
++python3 setup.py build
+ ```
+
+ 4. Test
+
+ ```bash
+-python setup.py test -vv
++python3 setup.py test -vv
+ ```
+
+ 5. Install
+
+ ```bash
+-sudo python setup.py install
++sudo python3 setup.py install
+ ```
+
+- To see all installation options "python setup.py --help"
++ To see all installation options "python3 setup.py --help"
+
+ See the INSTALL file for more details.
+
+diff --git a/bin/macsyfinder b/bin/macsyfinder
+index a676991..8cce1e7 100755
+--- a/bin/macsyfinder
++++ b/bin/macsyfinder
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+
+ ################################################################################
+diff --git a/doc/conf.py b/doc/conf.py
+index 172fba7..b2146d9 100644
+--- a/doc/conf.py
++++ b/doc/conf.py
+@@ -48,9 +48,9 @@ source_suffix = '.rst'
+ master_doc = 'index'
+
+ # General information about the project.
+-project = u'MacSyFinder'
++project = 'MacSyFinder'
+ #copyright = u'2014, Sophie Abby, Bertrand Néron'
+-copyright = u'2014, Sophie Abby, Bertrand Néron'
++copyright = '2014, Sophie Abby, Bertrand Néron'
+
+ # The version info for the project you're documenting, acts as replacement for
+ # |version| and |release|, also used in various other places throughout the
+@@ -192,8 +192,8 @@ latex_elements = {
+ # Grouping the document tree into LaTeX files. List of tuples
+ # (source start file, target name, title, author, documentclass [howto/manual]).
+ latex_documents = [
+- ('index', 'Macsyfinder.tex', u'MacSyFinder Documentation',
+- u'Sophie Abby, Bertrand Néron', 'manual'),
++ ('index', 'Macsyfinder.tex', 'MacSyFinder Documentation',
++ 'Sophie Abby, Bertrand Néron', 'manual'),
+ ]
+
+ # The name of an image file (relative to this directory) to place at the top of
+@@ -222,8 +222,8 @@ latex_use_parts = True
+ # One entry per manual page. List of tuples
+ # (source start file, name, description, authors, manual section).
+ man_pages = [
+- ('index', 'macsyfinder', u'MacsSyFinder Documentation',
+- [u'Sophie Abby, Bertrand Néron'], 1)
++ ('index', 'macsyfinder', 'MacsSyFinder Documentation',
++ ['Sophie Abby, Bertrand Néron'], 1)
+ ]
+
+ # If true, show URL addresses after external links.
+@@ -236,8 +236,8 @@ man_pages = [
+ # (source start file, target name, title, author,
+ # dir menu entry, description, category)
+ texinfo_documents = [
+- ('index', 'MacSyFinder', u'MacSyFinder Documentation',
+- u'Sophie Abby, Bertrand Néron', 'MacSyFinder', 'A tool for macromolecular systems\' modelling and detection.',
++ ('index', 'MacSyFinder', 'MacSyFinder Documentation',
++ 'Sophie Abby, Bertrand Néron', 'MacSyFinder', 'A tool for macromolecular systems\' modelling and detection.',
+ 'Miscellaneous'),
+ ]
+
+diff --git a/macsypy/config.py b/macsypy/config.py
+index 013606e..6286a56 100644
+--- a/macsypy/config.py
++++ b/macsypy/config.py
+@@ -16,7 +16,7 @@ import os
+ import sys
+ import inspect
+ from time import strftime
+-from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError
++from configparser import SafeConfigParser, NoSectionError, NoOptionError
+
+ _prefix_path = '$PREFIX'
+ _prefix_conf = '$PREFIXCONF'
+@@ -361,7 +361,7 @@ class Config(object):
+ it = iter(inter_gene_max_space)
+ try:
+ for system in it:
+- interval = it.next()
++ interval = next(it)
+ try:
+ interval = int(interval)
+ options['inter_gene_max_space'][system] = interval
+@@ -390,7 +390,7 @@ class Config(object):
+ it = iter(min_mandatory_genes_required)
+ try:
+ for system in it:
+- quorum_mandatory_genes = it.next()
++ quorum_mandatory_genes = next(it)
+ try:
+ quorum_mandatory_genes = int(quorum_mandatory_genes)
+ options['min_mandatory_genes_required'][system] = quorum_mandatory_genes
+@@ -421,7 +421,7 @@ class Config(object):
+ it = iter(min_genes_required)
+ try:
+ for system in it:
+- quorum_genes = it.next()
++ quorum_genes = next(it)
+ try:
+ quorum_genes = int(quorum_genes)
+ options['min_genes_required'][system] = quorum_genes
+@@ -450,7 +450,7 @@ class Config(object):
+ it = iter(max_nb_genes)
+ try:
+ for system in it:
+- max_genes = it.next()
++ max_genes = next(it)
+ try:
+ max_genes = int(max_genes)
+ options['max_nb_genes'][system] = max_genes
+@@ -634,7 +634,7 @@ class Config(object):
+ if self.options[directive] is not None:
+ if directive in ('inter_gene_max_space', 'min_mandatory_genes_required', 'min_genes_required', 'max_nb_genes'):
+ s = ''
+- for system, space in self.options[directive].items():
++ for system, space in list(self.options[directive].items()):
+ s += " {0} {1}".format(system, space)
+ parser.set(section, directive, s)
+ elif directive != 'log_file' or self.options[directive] != os.path.join(self.options['working_dir'], 'macsyfinder.log'):
+diff --git a/macsypy/database.py b/macsypy/database.py
+index a547a19..391de5f 100644
+--- a/macsypy/database.py
++++ b/macsypy/database.py
+@@ -42,7 +42,7 @@ def fasta_iter(fasta_file):
+ header = header.split()
+ _id = header[0]
+ comment = ' '.join(header[1:])
+- seq = ''.join(s.strip() for s in faiter.next())
++ seq = ''.join(s.strip() for s in next(faiter))
+ length = len(seq)
+ yield _id, comment, length
+
+@@ -339,7 +339,7 @@ class RepliconDB(object):
+ replicons = (x[1] for x in groupby(idx_f, grp_replicon))
+ for replicon in replicons:
+ genes = []
+- entry = replicon.next()
++ entry = next(replicon)
+ replicon_name, seq_name, seq_length, _min = parse_entry(entry)
+ genes.append((seq_name, seq_length))
+ for entry in replicon:
+@@ -392,21 +392,21 @@ class RepliconDB(object):
+ """
+ :return: a copy of the RepliconDB as a list of (replicon_name, RepliconInfo) pairs
+ """
+- return self._DB.items()
++ return list(self._DB.items())
+
+
+ def iteritems(self):
+ """
+ :return: an iterator over the RepliconDB as a list (replicon_name, RepliconInfo) pairs
+ """
+- return self._DB.iteritems()
++ return iter(self._DB.items())
+
+
+ def replicon_names(self):
+ """
+ :return: a copy of the RepliconDB as a list of replicon_names
+ """
+- return self._DB.keys()
++ return list(self._DB.keys())
+
+
+ def replicon_infos(self):
+@@ -414,4 +414,4 @@ class RepliconDB(object):
+ :return: a copy of the RepliconDB as list of replicons info
+ :rtype: RepliconInfo instance
+ """
+- return self._DB.values()
++ return list(self._DB.values())
+diff --git a/macsypy/gene.py b/macsypy/gene.py
+index e94d80c..7b4d0da 100644
+--- a/macsypy/gene.py
++++ b/macsypy/gene.py
+@@ -53,13 +53,13 @@ class GeneBank(object):
+ :return: True if the gene is in, False otherwise
+ :rtype: boolean
+ """
+- return gene in self._genes_bank.values()
++ return gene in list(self._genes_bank.values())
+
+ def __iter__(self):
+ """
+ Return an iterator object on the genes contained in the bank
+ """
+- return self._genes_bank.itervalues()
++ return iter(self._genes_bank.values())
+
+ def add_gene(self, gene):
+ """
+diff --git a/macsypy/report.py b/macsypy/report.py
+index 3e4af27..6f8b36f 100644
+--- a/macsypy/report.py
++++ b/macsypy/report.py
+@@ -23,7 +23,7 @@ from itertools import groupby
+ from .database import Indexes, RepliconDB
+
+
+-class HMMReport(object):
++class HMMReport(object, metaclass=abc.ABCMeta):
+ """
+ Handle the results from the HMM search. Extract a synthetic report from the raw hmmer output,
+ after having applied a hit filtering.
+@@ -32,8 +32,6 @@ class HMMReport(object):
+ or not ("unordered" or "unordered_replicon" db_type).
+ """
+
+- __metaclass__ = abc.ABCMeta
+-
+ def __init__(self, gene, hmmer_output, cfg):
+ """
+ :param gene: the gene corresponding to the profile search reported here
+@@ -182,7 +180,7 @@ class HMMReport(object):
+ :rtype: list of :class:`macsypy.report.Hit` objects
+
+ """
+- first_line = b_grp.next()
++ first_line = next(b_grp)
+ if not first_line.startswith(' # score'):
+ return []
+ else:
+@@ -252,7 +250,7 @@ class GeneralHMMReport(HMMReport):
+ gene_profile_lg = len(self.gene.profile)
+ hmm_hits = (x[1] for x in groupby(hmm_out, self._hit_start))
+ # drop summary
+- hmm_hits.next()
++ next(hmm_hits)
+ for hmm_hit in hmm_hits:
+ hit_id = self._parse_hmm_header(hmm_hit)
+ seq_lg, position_hit = my_db[hit_id]
+@@ -260,7 +258,7 @@ class GeneralHMMReport(HMMReport):
+ # replicon_name = self.cfg. # Define a variable in further devt
+ replicon_name = "Unordered"
+
+- body = hmm_hits.next()
++ body = next(hmm_hits)
+ h = self._parse_hmm_body(hit_id, gene_profile_lg, seq_lg, coverage_threshold,
+ replicon_name, position_hit, i_evalue_sel, body)
+ self.hits += h
+@@ -298,13 +296,13 @@ class OrderedHMMReport(HMMReport):
+ gene_profile_lg = len(self.gene.profile)
+ hmm_hits = (x[1] for x in groupby(hmm_out, self._hit_start))
+ # drop summary
+- hmm_hits.next()
++ next(hmm_hits)
+ for hmm_hit in hmm_hits:
+ hit_id = self._parse_hmm_header(hmm_hit)
+ seq_lg, position_hit = my_db[hit_id]
+ replicon_name = RepliconDB.ordered_replicon_name
+
+- body = hmm_hits.next()
++ body = next(hmm_hits)
+ h = self._parse_hmm_body(hit_id, gene_profile_lg, seq_lg, coverage_threshold,
+ replicon_name, position_hit, i_evalue_sel, body)
+ self.hits += h
+@@ -341,12 +339,12 @@ class GembaseHMMReport(HMMReport):
+ gene_profile_lg = len(self.gene.profile)
+ hmm_hits = (x[1] for x in groupby(hmm_out, self._hit_start))
+ # drop summary
+- hmm_hits.next()
++ next(hmm_hits)
+ for hmm_hit in hmm_hits:
+ hit_id = self._parse_hmm_header(hmm_hit)
+ seq_lg, position_hit = my_db[hit_id]
+ replicon_name = "_".join(hit_id.split('_')[:-1])
+- body = hmm_hits.next()
++ body = next(hmm_hits)
+ h = self._parse_hmm_body(hit_id, gene_profile_lg, seq_lg, coverage_threshold,
+ replicon_name, position_hit, i_evalue_sel, body)
+ self.hits += h
+diff --git a/macsypy/search_systems.py b/macsypy/search_systems.py
+index d523290..b13995c 100644
+--- a/macsypy/search_systems.py
++++ b/macsypy/search_systems.py
+@@ -21,9 +21,9 @@ import itertools
+ import operator
+ import json
+
+-from macsypy_error import MacsypyError, SystemDetectionError
+-from database import RepliconDB
+-from system import system_bank
++from .macsypy_error import MacsypyError, SystemDetectionError
++from .database import RepliconDB
++from .system import system_bank
+
+ _log = logging.getLogger('macsyfinder.' + __name__)
+
+@@ -303,7 +303,7 @@ class Cluster(object):
+ # Version with hits "reference" systems
+ for h in self.hits:
+ syst = h.system.name
+- if not systems.has_key(syst):
++ if syst not in systems:
+ systems[syst] = 1
+ #systems_object[syst]=h.system
+ else:
+@@ -316,7 +316,7 @@ class Cluster(object):
+ # Useless ?! Or change?
+ max_syst = 0
+ tmp_syst_name = ""
+- for x, y in systems.iteritems():
++ for x, y in systems.items():
+ if y >= max_syst:
+ tmp_syst_name = x
+ max_syst = y
+@@ -332,7 +332,7 @@ class Cluster(object):
+ #syst_list=h.gene.get_compatible_systems(self.systems_to_detect, True) # Need the list of systems (obj!) to be detected... in the cfg? # tmp before yep
+ for syst in syst_list:
+ syst_name = syst.name
+- if not systems_compat.has_key(syst_name):
++ if syst_name not in systems_compat:
+ systems_compat[syst_name] = 1
+ #systems_object[syst]=h.system
+ else:
+@@ -342,7 +342,7 @@ class Cluster(object):
+
+ #print systems_compat
+ # We sort the list of compatible systems per decreasing nb of systems occurrences
+- systems_compat = OrderedDict(sorted(systems_compat.items(), reverse=True, key=lambda t: t[1]))
++ systems_compat = OrderedDict(sorted(list(systems_compat.items()), reverse=True, key=lambda t: t[1]))
+ #print systems_compat
+ #print self
+
+@@ -354,10 +354,10 @@ class Cluster(object):
+ # Also deal with foreign "exchangeable" genes for the same reasons... NB !!
+ # Maybe just not add the system to the list if exchangeable?
+ #if len(systems.keys()) == 1:
+- if len(systems_compat.keys()) == 1:
++ if len(list(systems_compat.keys())) == 1:
+ self._state = "clear"
+ #syst = systems.keys()[0]
+- syst = systems_compat.keys()[0]
++ syst = list(systems_compat.keys())[0]
+ #print syst
+ self._putative_system = syst
+ #self._compatible_systems.append(system_bank[syst])
+@@ -416,7 +416,7 @@ class Cluster(object):
+
+ # Sort systems to consider by decreasing counts.
+ cluster_compatible_systems = []
+- for putative_system in systems_compat.keys():
++ for putative_system in list(systems_compat.keys()):
+ # Add that it has to be done first from the most rep systems by decreasing order of systems.values.
+ state = try_system(self.hits, putative_system, systems_compat)
+ if state == "clear":
+@@ -577,20 +577,20 @@ class SystemOccurence(object):
+ out = ""
+ if self.mandatory_genes:
+ out += "Mandatory genes: \n"
+- for k, g in self.mandatory_genes.iteritems():
++ for k, g in self.mandatory_genes.items():
+ out += "{0}\t{1:d}\n".format(k, g)
+ if self.accessory_genes:
+ out += "Accessory genes: \n"
+- for k, g in self.accessory_genes.iteritems():
++ for k, g in self.accessory_genes.items():
+ out += "{0}\t{1:d}\n".format(k, g)
+ if self.forbidden_genes:
+ out += "Forbidden genes: \n"
+- for k, g in self.forbidden_genes.iteritems():
++ for k, g in self.forbidden_genes.items():
+ out += "{0}\t{1:d}\n".format(k, g)
+ # NEW
+ if self.multi_syst_genes:
+ out += "Multi_syst genes:\n"
+- for k, g in self.multi_syst_genes.iteritems():
++ for k, g in self.multi_syst_genes.items():
+ out += "{0}\t{1:d}\n".format(k, g)
+ return out
+
+@@ -697,7 +697,7 @@ class SystemOccurence(object):
+ :rtype: integer
+ """
+ total = 0
+- for v in gene_dict.values():
++ for v in list(gene_dict.values()):
+ if v > 0:
+ total += 1
+ return total
+@@ -711,7 +711,7 @@ class SystemOccurence(object):
+ :rtype: integer
+ """
+ total = 0
+- for v in gene_dict.values():
++ for v in list(gene_dict.values()):
+ total += v
+ return total
+
+@@ -723,7 +723,7 @@ class SystemOccurence(object):
+ :rtype: list
+ """
+ missing = []
+- for k, v in gene_dict.iteritems():
++ for k, v in gene_dict.items():
+ if v == 0:
+ missing.append(k)
+ return missing
+@@ -897,16 +897,16 @@ class SystemOccurence(object):
+ self.forbidden_genes[hit.gene.name] += 1
+ included = False
+ else:
+- if hit.gene.name in self.exmandatory_genes.keys():
++ if hit.gene.name in list(self.exmandatory_genes.keys()):
+ self.mandatory_genes[self.exmandatory_genes[hit.gene.name]] += 1
+ valid_hit = validSystemHit(hit, self.system_name, "mandatory")
+ self.valid_hits.append(valid_hit)
+- elif hit.gene.name in self.exaccessory_genes.keys():
++ elif hit.gene.name in list(self.exaccessory_genes.keys()):
+ self.accessory_genes[self.exaccessory_genes[hit.gene.name]] += 1
+ valid_hit = validSystemHit(hit, self.system_name, "accessory")
+ self.valid_hits.append(valid_hit)
+ # NEW: exforbidden_genes considered
+- elif hit.gene.name in self.exforbidden_genes.keys():
++ elif hit.gene.name in list(self.exforbidden_genes.keys()):
+ self.forbidden_genes[self.exforbidden_genes[hit.gene.name]] += 1
+ valid_hit = validSystemHit(hit, self.system_name, "forbidden")
+ self.valid_hits.append(valid_hit)
+@@ -954,16 +954,16 @@ class SystemOccurence(object):
+ valid_hit = validSystemHit(hit, self.system_name, "forbidden")
+ self.valid_hits.append(valid_hit)
+ else:
+- if hit.gene.name in self.exmandatory_genes.keys():
++ if hit.gene.name in list(self.exmandatory_genes.keys()):
+ self.mandatory_genes[self.exmandatory_genes[hit.gene.name]] += 1
+ valid_hit = validSystemHit(hit, self.system_name, "mandatory")
+ self.valid_hits.append(valid_hit)
+- elif hit.gene.name in self.exaccessory_genes.keys():
++ elif hit.gene.name in list(self.exaccessory_genes.keys()):
+ self.accessory_genes[self.exaccessory_genes[hit.gene.name]] += 1
+ valid_hit = validSystemHit(hit, self.system_name, "accessory")
+ self.valid_hits.append(valid_hit)
+ # NEW: exforbidden_genes considered
+- elif hit.gene.name in self.exforbidden_genes.keys():
++ elif hit.gene.name in list(self.exforbidden_genes.keys()):
+ self.forbidden_genes[self.exforbidden_genes[hit.gene.name]] += 1
+ valid_hit = validSystemHit(hit, self.system_name, "forbidden")
+ self.valid_hits.append(valid_hit)
+@@ -988,14 +988,14 @@ class SystemOccurence(object):
+ #if g in multi_gene_names in [multi_gene.name for multi_gene in [hit.gene for hit in multi_systems_hits]]:
+ if g in [multi_gene.name for multi_gene in [hit.gene for hit in multi_systems_hits]]:
+ # If so, then the SystemOccurrence is filled with this:
+- if g in self.accessory_genes.keys():
++ if g in list(self.accessory_genes.keys()):
+ self.accessory_genes[g] += 1
+ # Add a valid_hit with a special status? e.g "accessory_multi_system"?
+ #self.accessory_genes[hit.gene.name]+=1
+ #valid_hit=validSystemHit(hit, self.system_name, "accessory")
+ #self.valid_hits.append(valid_hit)
+
+- elif g in self.mandatory_genes.keys():
++ elif g in list(self.mandatory_genes.keys()):
+ self.mandatory_genes[g] += 1
+ # Add a valid_hit with a special status? e.g "mandatory_multi_system"?
+ #self.mandatory_genes[hit.gene.name]+=1
+@@ -1018,7 +1018,7 @@ class SystemOccurence(object):
+
+ - "\single_locus\" when a complete system in the form of a single cluster was found
+ - "\multi_loci\" when a complete system in the form of several clusters was found
+- - "\uncomplete\" when no system was assessed (quorum not reached)
++ - "\\uncomplete\" when no system was assessed (quorum not reached)
+ - "\empty\" when no gene for this system was found
+ - "\exclude\" when no system was assessed (at least one forbidden gene was found)
+
+@@ -1151,9 +1151,7 @@ class validSystemHit(object):
+
+
+
+-class systemDetectionReport(object):
+-
+- __metaclass__ = abc.ABCMeta
++class systemDetectionReport(object, metaclass=abc.ABCMeta):
+
+ def __init__(self, systems_occurrences_list, cfg):
+ self._systems_occurrences_list = systems_occurrences_list
+@@ -1425,10 +1423,10 @@ class systemDetectionReportOrdered(systemDetectionReport):
+ else:
+ pos_max = rep_info.max
+ if pos_min < pos_max:
+- pos_in_bk_2_display = range(pos_min, pos_max + 1)
++ pos_in_bk_2_display = list(range(pos_min, pos_max + 1))
+ else:
+- before_orig = range(pos_min, rep_info.max + 1)
+- after_orig = range(rep_info.min, pos_max + 1)
++ before_orig = list(range(pos_min, rep_info.max + 1))
++ after_orig = list(range(rep_info.min, pos_max + 1))
+ pos_in_bk_2_display = before_orig + after_orig
+ pos_in_rep_2_display = [pos - rep_info.min for pos in pos_in_bk_2_display]
+ for curr_position in pos_in_rep_2_display:
+@@ -1673,7 +1671,7 @@ def disambiguate_cluster(cluster):
+ #print cur_cluster
+ res_clusters.append(cur_cluster)
+ for syst in cur_compatible: # Good list of compatible??
+- if not counter_genes_compat_systems.has_key(syst.name):
++ if syst.name not in counter_genes_compat_systems:
+ counter_genes_compat_systems[syst.name] = len(cur_cluster.hits)
+ else:
+ counter_genes_compat_systems[syst.name] += len(cur_cluster.hits)
+@@ -1686,7 +1684,7 @@ def disambiguate_cluster(cluster):
+ #h_compat = h_clust.gene.get_compatible_systems(cluster.systems_to_detect) # tmp before yep
+ h_compat = h_clust.gene.get_compatible_systems(cluster.systems_to_detect, False) # tmp before nope
+ for syst in h_compat:
+- if not counter_genes_compat_systems.has_key(syst.name):
++ if syst.name not in counter_genes_compat_systems:
+ counter_genes_compat_systems[syst.name] = 1
+ else:
+ counter_genes_compat_systems[syst.name] += 1
+@@ -1705,7 +1703,7 @@ def disambiguate_cluster(cluster):
+ res_clusters.append(cur_cluster)
+ for syst in cur_compatible: # Good list of compatible??
+ #print syst.name
+- if not counter_genes_compat_systems.has_key(syst.name):
++ if syst.name not in counter_genes_compat_systems:
+ counter_genes_compat_systems[syst.name] = len(cur_cluster.hits)
+ else:
+ counter_genes_compat_systems[syst.name] += len(cur_cluster.hits)
+@@ -1717,7 +1715,7 @@ def disambiguate_cluster(cluster):
+ h_compat = h_clust.gene.get_compatible_systems(cluster.systems_to_detect, False) # tmp before nope
+ for syst in h_compat:
+ #print syst.name
+- if not counter_genes_compat_systems.has_key(syst.name):
++ if syst.name not in counter_genes_compat_systems:
+ counter_genes_compat_systems[syst.name] = 1
+ else:
+ counter_genes_compat_systems[syst.name] += 1
+@@ -1804,11 +1802,11 @@ def analyze_clusters_replicon(clusters, systems, multi_systems_genes):
+ #for putative_system in clust.compatible_systems:
+ for putative_system in [s.name for s in systems_to_consider]:
+ _log_out.info("Considering {}: ".format(putative_system))
+- if putative_system in syst_dict.keys():
++ if putative_system in list(syst_dict.keys()):
+ so = SystemOccurence(syst_dict[putative_system])
+ so.fill_with_cluster(clust)
+ # NEW!
+- if putative_system in multi_systems_genes.keys():
++ if putative_system in list(multi_systems_genes.keys()):
+ so.fill_with_multi_systems_genes(multi_systems_genes[putative_system])
+ msg = so.decision_rule()
+ so_state = so.state
+@@ -1949,7 +1947,7 @@ def build_clusters(hits, systems_to_detect, rep_info):
+ positions.append(prev.position)
+ # New : Storage of multi_system genes:
+ if prev.gene.multi_system:
+- if not prev.system.name in multi_system_genes_system_wise.keys():
++ if not prev.system.name in list(multi_system_genes_system_wise.keys()):
+ multi_system_genes_system_wise[prev.system.name] = []
+ multi_system_genes_system_wise[prev.system.name].append(prev)
+
+@@ -1959,7 +1957,7 @@ def build_clusters(hits, systems_to_detect, rep_info):
+ positions.append(cur.position)
+ # New : Storage of multi_system genes:
+ if cur.gene.multi_system:
+- if not cur.system.name in multi_system_genes_system_wise.keys():
++ if not cur.system.name in list(multi_system_genes_system_wise.keys()):
+ multi_system_genes_system_wise[cur.system.name] = []
+ multi_system_genes_system_wise[cur.system.name].append(cur)
+
+@@ -2000,7 +1998,7 @@ def build_clusters(hits, systems_to_detect, rep_info):
+
+ # New : Storage of multi_system genes:
+ if prev.gene.multi_system:
+- if not prev.system.name in multi_system_genes_system_wise.keys():
++ if not prev.system.name in list(multi_system_genes_system_wise.keys()):
+ multi_system_genes_system_wise[prev.system.name] = []
+ multi_system_genes_system_wise[prev.system.name].append(prev)
+
+@@ -2025,7 +2023,7 @@ def build_clusters(hits, systems_to_detect, rep_info):
+ clusters.add(cur_cluster)
+ # New : Storage of multi_system genes:
+ if prev.gene.multi_system:
+- if not prev.system.name in multi_system_genes_system_wise.keys():
++ if not prev.system.name in list(multi_system_genes_system_wise.keys()):
+ multi_system_genes_system_wise[prev.system.name] = []
+ multi_system_genes_system_wise[prev.system.name].append(prev)
+
+diff --git a/macsypy/system.py b/macsypy/system.py
+index cd37926..a0f584e 100644
+--- a/macsypy/system.py
++++ b/macsypy/system.py
+@@ -52,13 +52,13 @@ class SystemBank(object):
+ :return: True if the system is in the System factory, False otherwise
+ :rtype: boolean
+ """
+- return system in self._system_bank.values()
++ return system in list(self._system_bank.values())
+
+ def __iter__(self):
+ """
+ Return an iterator object on the systems contained in the bank
+ """
+- return self._system_bank.itervalues()
++ return iter(self._system_bank.values())
+
+ def __len__(self):
+ """
+diff --git a/macsypy/system_parser.py b/macsypy/system_parser.py
+index 2b8bd01..ad6bce0 100644
+--- a/macsypy/system_parser.py
++++ b/macsypy/system_parser.py
+@@ -60,7 +60,7 @@ class SystemParser(object):
+ diff_sys_2 = list(set(sys_2_parse.keys()) - set(parsed_systems.keys()))
+ diff_sys += diff_sys_2
+ if diff_sys == []:
+- return sys_2_parse.keys()
++ return list(sys_2_parse.keys())
+ else:
+ for system_name in diff_sys:
+ parsed_systems[system_name] = None
+diff --git a/setup.py b/setup.py
+index c9ae28b..bea8faa 100644
+--- a/setup.py
++++ b/setup.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+
+ ################################################################################
+@@ -17,7 +17,7 @@ import time
+ import sys
+ import os
+
+-from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError
++from configparser import SafeConfigParser, NoSectionError, NoOptionError
+ try:
+ import warnings
+ except ImportError:
+@@ -51,13 +51,13 @@ class check_and_build( build ):
+ build.run(self)
+ log.info("""
+ Unit tests are available. It is _highly_ recommended to run tests now.
+-to run test, run 'python setup.py test -vv'""")
++to run test, run 'python3 setup.py test -vv'""")
+
+ def check_python(self, req):
+ chk = VersionPredicate(req)
+ ver = '.'.join([str(v) for v in sys.version_info[:2]])
+ if not chk.satisfied_by(ver):
+- log.error("Invalid python version, expected {0}".format(req))
++ log.error("Invalid python3 version, expected {0}".format(req))
+ return False
+ return True
+
+@@ -147,7 +147,7 @@ class test(Command):
+
+ plat_specifier = ".{0}-{1}".format(self.plat_name, sys.version[0:3])
+
+- # Make it so Python 2.x and Python 2.x with --with-pydebug don't
++ # Make it so Python 3.x and Python 3.x with --with-pydebug don't
+ # share the same build directories. Doing so confuses the build
+ # process for C modules
+ if hasattr(sys, 'gettotalrefcount'):
+@@ -200,7 +200,7 @@ class test(Command):
+ unit_res = unit_main.run(self.build_lib, [], verbosity=self.verbosity)
+ for test in unit_res.skipped:
+ kind_of_skipped[test[1]] = True
+- for skip_reason in kind_of_skipped.keys():
++ for skip_reason in list(kind_of_skipped.keys()):
+ if skip_reason == "neither makeblast nor formatdb found in PATH":
+ msg = """
+ #####################################################################
+@@ -228,7 +228,7 @@ hmmsearch in config file or command line to run macsyfinder
+ if all(result_all_tests):
+ sys.exit(0)
+ else:
+- sys.exit("some tests fails. Run python setup.py test -vv to have more details")
++ sys.exit("some tests fails. Run python3 setup.py test -vv to have more details")
+
+
+
+@@ -552,7 +552,7 @@ class Uninstall(Command):
+ def clean_tree(_dir):
+ find_prefix = False
+ for prefix in prefixes:
+- print "== ", prefix, ".find(", _dir, ") = ", prefix.find(_dir)
++ print("== ", prefix, ".find(", _dir, ") = ", prefix.find(_dir))
+ if prefix.find(_dir) != -1:
+ find_prefix = True
+ return prefix
+@@ -612,7 +612,7 @@ class sdist_macsy(sdist):
+ def run(self):
+ inst = self.distribution.command_options.get('sdist')
+ self.macsyview_link_name = 'macsyview'
+- if not inst.has_key('macsyview_dir'):
++ if 'macsyview_dir' not in inst:
+ self.must_clean = False
+ if not os.path.exists(self.macsyview_link_name):
+ sys.exit('Missing mandatory macsyview-dir to specify the location of macsyview project')
+@@ -710,11 +710,11 @@ def subst_vars(src, dst, vars):
+ try:
+ src_file = open(src, "r")
+ except os.error as err:
+- raise DistutilsFileError, "could not open '{0}': {1)".format(src, err)
++ raise DistutilsFileError("could not open '{0}': {1)".format(src, err))
+ try:
+ dest_file = open(dst, "w")
+ except os.error as err:
+- raise DistutilsFileError, "could not create '{0}': {1}".format(dst, err)
++ raise DistutilsFileError("could not create '{0}': {1}".format(dst, err))
+ with src_file:
+ with dest_file:
+ for line in src_file:
+@@ -722,7 +722,7 @@ def subst_vars(src, dst, vars):
+ dest_file.write(new_line)
+
+
+-require_python = ['python (>=2.7, <3.0)']
++require_python = ['python (>=3.0, <4.0)']
+ require_packages = []
+
+ version='1.0.5'
+@@ -737,7 +737,7 @@ in protein datasets using systems modelling and similarity search""",
+ author_email="sabby at pasteur.fr, bneron at pasteur.fr",
+ classifiers=[
+ 'Operating System :: POSIX',
+- 'Programming Language :: Python :: 2.7 :: Only',
++ 'Programming Language :: Python :: 3.7 :: Only',
+ 'Topic :: Bioinformatics',
+ ],
+ packages=['macsypy'],
+diff --git a/tests.py b/tests.py
+index eb2a93d..c87af19 100644
+--- a/tests.py
++++ b/tests.py
+@@ -117,9 +117,9 @@ if __name__ == '__main__':
+ result_all_tests = []
+
+ if args.unit:
+- print "\n", "#" * 70
+- print "Test Runner: Unit tests"
+- print "#" * 70
++ print("\n", "#" * 70)
++ print("Test Runner: Unit tests")
++ print("#" * 70)
+
+ old_path = sys.path
+ if 'MACSY_HOME' in os.environ:
+@@ -131,9 +131,9 @@ if __name__ == '__main__':
+ sys.path = old_path
+
+ if args.functional:
+- print "\n", "#" * 70
+- print "Test Runner: Functional tests"
+- print "#" * 70
++ print("\n", "#" * 70)
++ print("Test Runner: Functional tests")
++ print("#" * 70)
+
+ old_path = sys.path
+ if 'MACSY_HOME' in os.environ:
+@@ -154,9 +154,9 @@ if __name__ == '__main__':
+ sys.path = old_path
+
+ if args.integration:
+- print "\n", "#" * 70
+- print "Test Runner: Integration tests"
+- print "#" * 70
++ print("\n", "#" * 70)
++ print("Test Runner: Integration tests")
++ print("#" * 70)
+ old_path = sys.path
+ integration_results = run_integration_tests(args.tests, verbosity=args.verbosity)
+ result_all_tests.append(integration_results)
+diff --git a/tests/functional/main.py b/tests/functional/main.py
+index 4ee53a9..72ff690 100755
+--- a/tests/functional/main.py
++++ b/tests/functional/main.py
+@@ -1,4 +1,4 @@
+-#! /usr/bin/env python
++#!/usr/bin/python3
+ # -*- coding: utf-8 -*-
+
+ ################################################################################
+diff --git a/tests/functional/test_first_test.py b/tests/functional/test_first_test.py
+index a851578..501da19 100644
+--- a/tests/functional/test_first_test.py
++++ b/tests/functional/test_first_test.py
+@@ -84,8 +84,8 @@ class Test(MacsyTest):
+ )
+ except Exception as err:
+ msg = "macsyfinder execution failed: command = {0} : {1}".format(command, err)
+- print
+- print msg
++ print()
++ print(msg)
+ raise err
+
+ macsy_process.wait()
+diff --git a/tests/unit/main.py b/tests/unit/main.py
+index 1b66b0e..a086ff2 100755
+--- a/tests/unit/main.py
++++ b/tests/unit/main.py
+@@ -1,4 +1,4 @@
+-#! /usr/bin/env python
++#! /usr/bin/python3
+ # -*- coding: utf-8 -*-
+
+ ################################################################################
+diff --git a/tests/unit/test_Config.py b/tests/unit/test_Config.py
+index 3350bfd..b180482 100644
+--- a/tests/unit/test_Config.py
++++ b/tests/unit/test_Config.py
+@@ -544,7 +544,7 @@ class Test(MacsyTest):
+ shutil.rmtree(out_dir)
+ except:
+ pass
+- os.makedirs(out_dir, 0775)
++ os.makedirs(out_dir, 0o775)
+ f = open(os.path.join(out_dir, 'fake'), 'w')
+ f.close()
+ kwargs = {'cfg_file': "nimportnaoik",
+@@ -559,7 +559,7 @@ class Test(MacsyTest):
+ shutil.rmtree(out_dir)
+ self.tearDown()
+
+- os.makedirs(out_dir, 0775)
++ os.makedirs(out_dir, 0o775)
+ self.cfg = Config(cfg_file="nimportnaoik",
+ sequence_db=os.path.join(self._data_dir, "base", "test_base.fa"),
+ db_type='gembase',
+diff --git a/tests/unit/test_Indexes.py b/tests/unit/test_Indexes.py
+index 57deb7d..b97734c 100644
+--- a/tests/unit/test_Indexes.py
++++ b/tests/unit/test_Indexes.py
+@@ -219,5 +219,5 @@ class Test(MacsyTest):
+ idx_dir = os.path.join(os.path.dirname(self.cfg.sequence_db))
+ os.chmod(idx_dir, 0000)
+ self.assertRaises(IOError, idx.build)
+- os.chmod(idx_dir, 0777)
++ os.chmod(idx_dir, 0o777)
+
+diff --git a/tests/unit/test_RepliconDB.py b/tests/unit/test_RepliconDB.py
+index d6843be..167cbdc 100644
+--- a/tests/unit/test_RepliconDB.py
++++ b/tests/unit/test_RepliconDB.py
+@@ -120,7 +120,7 @@ class Test(MacsyTest):
+ 'PSAE001c01' : 'linear'
+ }
+ with open(self.cfg.topology_file , 'w') as f:
+- for k, v in db_send.items():
++ for k, v in list(db_send.items()):
+ f.write('{0} : {1}\n'.format(k,v))
+ RepliconDB.__init__ = self.fake_init
+ db = RepliconDB(self.cfg)
+@@ -245,5 +245,5 @@ class Test(MacsyTest):
+ ESCO030p01 = RepliconInfo(self.cfg.replicon_topology, 1, 67, self.ESCO030p01_genes)
+ PSAE001c01 = RepliconInfo(self.cfg.replicon_topology, 68, 133, self.PSAE001c01_genes)
+ NCXX = RepliconInfo("circular", 134, 141, self.NCDB_genes)
+- self.assertItemsEqual(db.items(), [('ESCO030p01',ESCO030p01), ('NC_xxxxx_xx',NCXX),
++ self.assertItemsEqual(list(db.items()), [('ESCO030p01',ESCO030p01), ('NC_xxxxx_xx',NCXX),
+ ('PSAE001c01',PSAE001c01)])
+\ No newline at end of file
=====================================
debian/patches/series
=====================================
@@ -1 +1,2 @@
skip_tests.patch
+# 2to3.patch # deactivate - its more complex than this
=====================================
debian/rules
=====================================
@@ -4,21 +4,21 @@
#export DH_VERBOSE=1
%:
- dh $@ --with python2 --buildsystem=pybuild
+ dh $@ --with python3 --buildsystem=pybuild
override_dh_auto_install:
cd doc && make html
cd doc && make latexpdf
- ln -sf $(shell pybuild --print build_dir --interpreter python) build/lib.$(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)-$(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)-$(shell pyversions -vs)
- python setup.py install --prefix=debian/macsyfinder/usr/ --install-conf=debian/macsyfinder/etc/ --no-viewer
+ ln -sf $(shell pybuild --print build_dir --interpreter python3) build/lib.$(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)-$(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)-$(shell py3versions -vs)
+ python3 setup.py install --prefix=debian/macsyfinder/usr/ --install-conf=debian/macsyfinder/etc/ --no-viewer
# The better solution would be to use
# dh_auto_install -- --prefix=/usr --install-conf=/etc --no-viewer
# and fiy setup.py to use --root as install location (which is ignored unfortunately)
# Since I have no idea how to fix setup.py here the broken config files are hacked afterwards
for conffile in \
etc/macsyfinder/macsyfinder.conf.new \
- usr/lib/python2.7/site-packages/macsypy/config.py \
- usr/lib/python2.7/site-packages/macsypy/registries.py \
+ usr/lib/python3*/site-packages/macsypy/config.py \
+ usr/lib/python3*/site-packages/macsypy/registries.py \
; do \
sed -i 's:debian/macsyfinder::g' debian/macsyfinder/$${conffile} ; \
done
View it on GitLab: https://salsa.debian.org/med-team/macsyfinder/compare/15a3838e173bbbdf8a2de52119d50165ea66d0db...994f55a1c15bca7567d6e6cde968499c54efbf82
--
View it on GitLab: https://salsa.debian.org/med-team/macsyfinder/compare/15a3838e173bbbdf8a2de52119d50165ea66d0db...994f55a1c15bca7567d6e6cde968499c54efbf82
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190906/40b2b13e/attachment-0001.html>
More information about the debian-med-commit
mailing list