Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace super(Class, self) => super() #672

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jcvi/annotation/depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BinFile(BaseFile):
"""

def __init__(self, binfile, dtype=np.uint8):
super(BinFile, self).__init__(binfile)
super().__init__(binfile)
assert op.exists(
binfile
), "Binary file `{0}` not found. Rerun depth.count().".format(binfile)
Expand Down
4 changes: 2 additions & 2 deletions jcvi/annotation/maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __str__(self):

class CTLFile(LineFile):
def __init__(self, filename):
super(CTLFile, self).__init__(filename)
super().__init__(filename)
fp = open(filename)
for row in fp:
self.append(CTLine(row))
Expand Down Expand Up @@ -90,7 +90,7 @@ def write_file(self, filename):

class DatastoreIndexFile(BaseFile):
def __init__(self, filename):
super(DatastoreIndexFile, self).__init__(filename)
super().__init__(filename)
scaffold_status = {}
failed = []

Expand Down
2 changes: 1 addition & 1 deletion jcvi/apps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class OptionParser(ArgumentParser):

def __init__(self, doc: Optional[str]):
usage = doc.replace("%prog", "%(prog)s") if doc else None
super(OptionParser, self).__init__(usage=usage, epilog=JCVIHELP)
super().__init__(usage=usage, epilog=JCVIHELP)

def parse_args(self, args=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion jcvi/apps/bowtie.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BowtieLogFile(BaseFile):

def __init__(self, filename):

super(BowtieLogFile, self).__init__(filename)
super().__init__(filename)
fp = open(filename)
self.total = int(first_tag(fp))
self.unpaired = int(first_tag(fp))
Expand Down
2 changes: 1 addition & 1 deletion jcvi/apps/cdhit.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, row):

class ClstrFile(LineFile):
def __init__(self, filename):
super(ClstrFile, self).__init__(filename)
super().__init__(filename)
assert filename.endswith(".clstr")

fp = open(filename)
Expand Down
6 changes: 3 additions & 3 deletions jcvi/apps/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ class Queue(Queue):
"""

def __init__(self, *args, **kwargs):
super(Queue, self).__init__(*args, **kwargs, ctx=get_context())
super().__init__(*args, **kwargs, ctx=get_context())
self.size = SharedCounter(0)

def put(self, *args, **kwargs):
self.size.increment(1)
super(Queue, self).put(*args, **kwargs)
super().put(*args, **kwargs)

def get(self, *args, **kwargs):
self.size.increment(-1)
return super(Queue, self).get(*args, **kwargs)
return super().get(*args, **kwargs)

def qsize(self):
"""Reliable implementation of multiprocessing.Queue.qsize()"""
Expand Down
8 changes: 4 additions & 4 deletions jcvi/apps/uclust.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

class ClustFile(BaseFile):
def __init__(self, filename):
super(ClustFile, self).__init__(filename)
super().__init__(filename)

def __iter__(self):
nstacks = 0
Expand All @@ -87,7 +87,7 @@ def __iter__(self):

class Clust(list):
def __init__(self):
super(Clust, self).__init__(self)
super().__init__(self)

def __str__(self):
s = []
Expand All @@ -98,7 +98,7 @@ def __str__(self):

class ClustStore(BaseFile):
def __init__(self, consensfile):
super(ClustStore, self).__init__(consensfile)
super().__init__(consensfile)
binfile = consensfile + ".bin"
idxfile = consensfile + ".idx"
self.bin = np.fromfile(binfile, dtype=np.uint16)
Expand Down Expand Up @@ -180,7 +180,7 @@ class ClustStores(dict):
"""

def __init__(self, consensfiles):
super(ClustStores, self).__init__(self)
super().__init__(self)
for cs in consensfiles:
name = op.basename(cs).split(".")[0]
self[name] = ClustStore(cs)
Expand Down
4 changes: 2 additions & 2 deletions jcvi/assembly/allmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def __init__(
remove_outliers=False,
function=(lambda x: x.rank),
):
super(Map, self).__init__()
super().__init__()
bed = Bed(filename)
for b in bed:
self.append(Marker(b))
Expand Down Expand Up @@ -635,7 +635,7 @@ def export_table(self, r, mapname, total):

class Weights(DictFile):
def __init__(self, filename, mapnames, cast=int):
super(Weights, self).__init__(filename, cast=cast)
super().__init__(filename, cast=cast)
self.maps = [x.split()[0] for x in must_open(filename)]
self.update_maps(mapnames)
pivot_weight, o, pivot = self.get_pivot(mapnames)
Expand Down
2 changes: 1 addition & 1 deletion jcvi/assembly/allpaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class PairsFile(BaseFile):
def __init__(self, filename):
super(PairsFile, self).__init__(filename)
super().__init__(filename)

fp = open(filename, "rb")
(binwrite,) = unpack("8s", fp.read(8))
Expand Down
2 changes: 1 addition & 1 deletion jcvi/assembly/automaton.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def guess(self):

class MetaFile(LineFile):
def __init__(self, filename):
super(MetaFile, self).__init__(filename)
super().__init__(filename)
fp = open(filename)
for row in fp:
genome, tag, fastq = row.split()
Expand Down
2 changes: 1 addition & 1 deletion jcvi/assembly/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, bedfile, sizesfile):

filename = coveragefile
assert filename.endswith(".coverage")
super(Coverage, self).__init__(filename)
super().__init__(filename)

def get_plot_data(self, ctg, bins=None):
import numpy as np
Expand Down
4 changes: 2 additions & 2 deletions jcvi/assembly/geneticmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

class BinMap(BaseFile, dict):
def __init__(self, filename):
super(BinMap, self).__init__(filename)
super().__init__(filename)

fp = open(filename)
for header, seq in read_block(fp, "group "):
Expand Down Expand Up @@ -111,7 +111,7 @@ def bedline(self):

class MSTMap(LineFile):
def __init__(self, filename):
super(MSTMap, self).__init__(filename)
super().__init__(filename)
fp = open(filename)
startidx = 1
for row in fp:
Expand Down
2 changes: 1 addition & 1 deletion jcvi/assembly/goldenpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class Certificate(BaseFile):

def __init__(self, filename):

super(Certificate, self).__init__(filename)
super().__init__(filename)

fp = open(filename)
self.lines = [CertificateLine(x) for x in fp.readlines()]
Expand Down
2 changes: 1 addition & 1 deletion jcvi/assembly/hic.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ContigOrdering(LineFile):
"""

def __init__(self, filename):
super(ContigOrdering, self).__init__(filename)
super().__init__(filename)
fp = open(filename)
for row in fp:
if row[0] == "#":
Expand Down
2 changes: 1 addition & 1 deletion jcvi/assembly/kmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

class KmerSpectrum(BaseFile):
def __init__(self, histfile):
super(KmerSpectrum, self).__init__(histfile)
super().__init__(histfile)
self.load_data(histfile)

def load_data(self, histfile):
Expand Down
2 changes: 1 addition & 1 deletion jcvi/assembly/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

class FastQCdata(BaseFile, dict):
def __init__(self, filename, human=False):
super(FastQCdata, self).__init__(filename)
super().__init__(filename)
if not op.exists(filename):
logger.debug("File `%s` not found.", filename)
# Sample_RF37-1/RF37-1_GATCAG_L008_R2_fastqc =>
Expand Down
2 changes: 1 addition & 1 deletion jcvi/assembly/syntenypath.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def tag(self):

class OVL(LineFile):
def __init__(self, filename):
super(OVL, self).__init__(filename)
super().__init__(filename)
fp = must_open(filename)
contained = set()
alledges = defaultdict(list)
Expand Down
2 changes: 1 addition & 1 deletion jcvi/compara/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class AnchorFile(BaseFile):
def __init__(self, filename, minsize=0):
super(AnchorFile, self).__init__(filename)
super().__init__(filename)
self.blocks = list(self.iter_blocks(minsize=minsize))

def iter_blocks(self, minsize=0):
Expand Down
2 changes: 1 addition & 1 deletion jcvi/compara/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

class OMGFile(BaseFile):
def __init__(self, filename):
super(OMGFile, self).__init__(filename)
super().__init__(filename)
fp = open(filename)
inblock = False
components = []
Expand Down
4 changes: 2 additions & 2 deletions jcvi/compara/ks.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __str__(self):

class Layout(AbstractLayout):
def __init__(self, filename, delimiter=",", seed: Optional[int] = None):
super(Layout, self).__init__(filename)
super().__init__(filename)
if not op.exists(filename):
ksfiles = iglob(".", "*.ks")
header = "Ks file|ncomponents|label|color|marker".split("|")
Expand Down Expand Up @@ -934,7 +934,7 @@ def anchorline(self):

class KsFile(LineFile):
def __init__(self, filename, strip_names=False):
super(KsFile, self).__init__(filename)
super().__init__(filename)

fp = open(filename)
for row in fp:
Expand Down
2 changes: 1 addition & 1 deletion jcvi/compara/synteny.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BlockFile(BaseFile):
"""Parse .blocks file which is the mcscan output with multiple columns as 'tracks'"""

def __init__(self, filename, defaultcolor="#fb8072", header=False):
super(BlockFile, self).__init__(filename)
super().__init__(filename)
fp = must_open(filename)
hd = next(fp).rstrip().split("\t")
ncols = len(hd)
Expand Down
6 changes: 3 additions & 3 deletions jcvi/formats/agp.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def gline(cls, object, gap, unknown=100):

class AGP(LineFile):
def __init__(self, filename, nogaps=False, validate=True, sorted=True):
super(AGP, self).__init__(filename)
super().__init__(filename)

fp = must_open(filename)
self.header = []
Expand Down Expand Up @@ -653,7 +653,7 @@ def isCloneGap(self):

class TPF(LineFile):
def __init__(self, filename):
super(TPF, self).__init__(filename)
super().__init__(filename)
fp = open(filename)
for row in fp:
if row[0] == "#":
Expand Down Expand Up @@ -693,7 +693,7 @@ def __init__(self, id, component_id, component_size, strand):

class OO(LineFile):
def __init__(self, filename=None, ctgsizes=None):
super(OO, self).__init__(filename)
super().__init__(filename)

if filename is None:
return
Expand Down
4 changes: 2 additions & 2 deletions jcvi/formats/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LineFile(BaseFile, list):
"""

def __init__(self, filename, comment=None, load=False):
super(LineFile, self).__init__(filename)
super().__init__(filename)

if load:
fp = must_open(filename)
Expand Down Expand Up @@ -117,7 +117,7 @@ def num_columns(cls, filename, delimiter=None):

class SetFile(BaseFile, set):
def __init__(self, filename, column=-1, delimiter=None):
super(SetFile, self).__init__(filename)
super().__init__(filename)
fp = open(filename)
for row in fp:
if not row.strip():
Expand Down
2 changes: 1 addition & 1 deletion jcvi/formats/bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def gffline(self, type="match", source="default"):

class Bed(LineFile):
def __init__(self, filename=None, key=None, sorted=True, juncs=False, include=None):
super(Bed, self).__init__(filename)
super().__init__(filename)

# the sorting key provides some flexibility in ordering the features
# for example, user might not like the lexico-order of seqid
Expand Down
8 changes: 4 additions & 4 deletions jcvi/formats/blast.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BlastSlow(LineFile):
"""

def __init__(self, filename, sorted=False):
super(BlastSlow, self).__init__(filename)
super().__init__(filename)
fp = must_open(filename)
for row in fp:
self.append(BlastLine(row))
Expand Down Expand Up @@ -75,7 +75,7 @@ class Blast(BaseFile):
"""

def __init__(self, filename):
super(Blast, self).__init__(filename)
super().__init__(filename)
self.fp = must_open(filename)

def __iter__(self):
Expand Down Expand Up @@ -141,7 +141,7 @@ class BlastLineByConversion(BlastLine):

def __init__(self, sline, mode="1" * 12):
if int(mode, 2) == 4095:
super(BlastLineByConversion, self).__init__(sline)
super().__init__(sline)
elif 3072 <= int(mode, 2) < 4095:
args = sline.split("\t")
atoms = args[:2]
Expand All @@ -159,7 +159,7 @@ def __init__(self, sline, mode="1" * 12):
else:
atoms.append("-1")
sline = "\t".join(atoms)
super(BlastLineByConversion, self).__init__(sline)
super().__init__(sline)
else:
m = "mode can only contain 0 or 1 \n"
m += "first two fields (query, subject) cannot be empty"
Expand Down
2 changes: 1 addition & 1 deletion jcvi/formats/cdt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class CDT(BaseFile):
def __init__(self, filename):
super(CDT, self).__init__(filename)
super().__init__(filename)

pf = filename.rsplit(".", 1)[0]
self.gtrfile = pf + ".gtr"
Expand Down
2 changes: 1 addition & 1 deletion jcvi/formats/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, chain, lines):

class Chain(BaseFile):
def __init__(self, filename):
super(Chain, self).__init__(filename)
super().__init__(filename)
self.chains = list(self.iter_chain())

self.ungapped = sum(x.ungapped for x in self.chains)
Expand Down
2 changes: 1 addition & 1 deletion jcvi/formats/contig.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __str__(self):

class ContigFile(BaseFile):
def __init__(self, filename):
super(ContigFile, self).__init__(filename)
super().__init__(filename)
self.fp = open(filename)

def iter_records(self):
Expand Down
2 changes: 1 addition & 1 deletion jcvi/formats/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def __init__(self, filename, sorted=False, header=False):
fromdelta([filename])
filename = coordsfile

super(Coords, self).__init__(filename)
super().__init__(filename)

fp = open(filename)
if header:
Expand Down
2 changes: 1 addition & 1 deletion jcvi/formats/fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class Fasta(BaseFile, dict):
def __init__(self, filename, index=False, key_function=None, lazy=False):
super(Fasta, self).__init__(filename)
super().__init__(filename)
self.key_function = key_function

if lazy: # do not incur the overhead
Expand Down
Loading
Loading