diff --git a/lib/bx/align/core.py b/lib/bx/align/core.py index 21aa53c..5034976 100644 --- a/lib/bx/align/core.py +++ b/lib/bx/align/core.py @@ -312,9 +312,7 @@ def reverse_complement(self): if self.empty: text = None else: - comp = [ch for ch in self.text.translate(DNA_COMP)] - comp.reverse() - text = "".join(comp) + text = self.text.translate(DNA_COMP)[::-1] new = Component(self.src, start, self.size, strand, self._src_size, text) if self.empty: new.empty = True @@ -386,7 +384,7 @@ def coord_to_col(self, pos): if pos < start or pos > end: raise ValueError("Range error: %d not in %d-%d" % (pos, start, end)) if not self.index: - self.index = list() + self.index = [] if self.strand == "-": # nota bene: for - strand self.index[x] maps to one column # higher than is actually associated with the position; thus diff --git a/lib/bx/align/lav.py b/lib/bx/align/lav.py index 50e7d34..d3e4a7e 100644 --- a/lib/bx/align/lav.py +++ b/lib/bx/align/lav.py @@ -476,7 +476,7 @@ def write(self, alignment): self.block += 1 def close(self): - keys = [key for key in self.blockHash] + keys = list(self.blockHash) keys = sort_keys_by_chrom(keys) for key in keys: (src1, strand1, src2, strand2) = key diff --git a/lib/bx/align/score.py b/lib/bx/align/score.py index 0aa1f9b..89897a1 100644 --- a/lib/bx/align/score.py +++ b/lib/bx/align/score.py @@ -33,9 +33,9 @@ def __init__( if gap2 is None: gap2 = gap1 # (scheme with gap1=gap2=None is legit) if isinstance(alphabet1, str): - alphabet1 = [ch for ch in alphabet1] + alphabet1 = list(alphabet1) if isinstance(alphabet2, str): - alphabet2 = [ch for ch in alphabet2] + alphabet2 = list(alphabet2) self.table = ones((text1_range, text2_range), typecode) self.table *= default self.gap_open = gap_open @@ -143,7 +143,7 @@ def read_scoring_scheme(f, gap_open, gap_extend, gap1="-", gap2=None, **kwargs): if isinstance(f, str): f = open(f) close_it = True - ss = build_scoring_scheme("".join([line for line in f]), gap_open, gap_extend, gap1=gap1, gap2=gap2, **kwargs) + ss = build_scoring_scheme("".join(list(f)), gap_open, gap_extend, gap1=gap1, gap2=gap2, **kwargs) if close_it: f.close() return ss diff --git a/lib/bx/align/sitemask/cpg.py b/lib/bx/align/sitemask/cpg.py index 7b3be2e..a01d3eb 100644 --- a/lib/bx/align/sitemask/cpg.py +++ b/lib/bx/align/sitemask/cpg.py @@ -83,13 +83,13 @@ def __call__(self, block): def mask_columns(masklist, text, mask): - templist = list() + templist = [] for position in masklist: if text[position] != "-": templist.append(position) templist.append(len(text)) # Add the end of the text # cut string - newtext = list() + newtext = [] c = 0 for position in templist: newtext.append(text[c:position]) diff --git a/lib/bx/bitset_builders.py b/lib/bx/bitset_builders.py index d8657c1..16ebebb 100644 --- a/lib/bx/bitset_builders.py +++ b/lib/bx/bitset_builders.py @@ -28,7 +28,7 @@ def binned_bitsets_from_file( """ last_chrom = None last_bitset = None - bitsets = dict() + bitsets = {} for line in f: if line.startswith("#") or line.isspace(): continue @@ -68,7 +68,7 @@ def binned_bitsets_from_bed_file( """ last_chrom = None last_bitset = None - bitsets = dict() + bitsets = {} offset = 0 for line in f: if line.startswith("#") or line.isspace(): @@ -108,7 +108,7 @@ def binned_bitsets_proximity(f, chrom_col=0, start_col=1, end_col=2, strand_col= """Read a file into a dictionary of bitsets""" last_chrom = None last_bitset = None - bitsets = dict() + bitsets = {} for line in f: if line.startswith("#"): continue @@ -143,7 +143,7 @@ def binned_bitsets_from_list(list=[]): """Read a list into a dictionary of bitsets""" last_chrom = None last_bitset = None - bitsets = dict() + bitsets = {} for l in list: chrom = l[0] if chrom != last_chrom: diff --git a/lib/bx/cookbook/argparse.py b/lib/bx/cookbook/argparse.py index 849b938..4bb7999 100644 --- a/lib/bx/cookbook/argparse.py +++ b/lib/bx/cookbook/argparse.py @@ -304,15 +304,15 @@ def _format_usage(self, usage, actions, groups, prefix): # if usage is specified, use that if usage is not None: - usage = usage % dict(prog=self._prog) + usage = usage % {"prog": self._prog} # if no optionals or positionals are available, usage is just prog elif usage is None and not actions: - usage = "%(prog)s" % dict(prog=self._prog) + usage = "%(prog)s" % {"prog": self._prog} # if optionals and positionals are available, calculate usage elif usage is None: - prog = "%(prog)s" % dict(prog=self._prog) + prog = "%(prog)s" % {"prog": self._prog} # split optionals from positionals optionals = [] @@ -486,7 +486,7 @@ def _format_actions_usage(self, actions, groups): def _format_text(self, text): if "%(prog)" in text: - text = text % dict(prog=self._prog) + text = text % {"prog": self._prog} text_width = self._width - self._current_indent indent = " " * self._current_indent return self._fill_text(text, text_width, indent) + "\n\n" @@ -704,7 +704,7 @@ def __str__(self): format = "%(message)s" else: format = "argument %(argument_name)s: %(message)s" - return format % dict(message=self.message, argument_name=self.argument_name) + return format % {"message": self.message, "argument_name": self.argument_name} class ArgumentTypeError(Exception): diff --git a/lib/bx/cookbook/doc_optparse.py b/lib/bx/cookbook/doc_optparse.py index 81f9afc..af8ecc8 100644 --- a/lib/bx/cookbook/doc_optparse.py +++ b/lib/bx/cookbook/doc_optparse.py @@ -85,7 +85,7 @@ def parse(docstring, arglist=None): action = "store" k = k.split("=")[0] opt_strings.append(k) - p.add_option(*opt_strings, **dict(action=action, help=help.strip())) + p.add_option(*opt_strings, **{"action": action, "help": help.strip()}) except (IndexError, ValueError): raise ParsingError("Cannot parse the option string correctly") return p.parse_args(arglist) diff --git a/lib/bx/filter.py b/lib/bx/filter.py index b130271..f71b34c 100644 --- a/lib/bx/filter.py +++ b/lib/bx/filter.py @@ -28,7 +28,7 @@ def __call__(self, block): class Pipeline(Filter): def __init__(self, **kwargs): - self.pipeline = list() + self.pipeline = [] def __call__(self, block): for function in self.pipeline: diff --git a/lib/bx/interval_index_file.py b/lib/bx/interval_index_file.py index 03a1cc8..fb5372c 100644 --- a/lib/bx/interval_index_file.py +++ b/lib/bx/interval_index_file.py @@ -178,7 +178,7 @@ def new_indexed_access(self, data_filename, index_filename=None, keep_open=False return self.indexed_access_class(data_filename, index_filename, keep_open, **kwargs) def get(self, src, start, end): - return [block for block in self.get_as_iterator(src, start, end)] + return list(self.get_as_iterator(src, start, end)) def get_as_iterator(self, src, start, end): for block, _index, _offset in self.get_as_iterator_with_index_and_offset(src, start, end): @@ -257,7 +257,7 @@ def open_data(self): return f def get(self, src, start, end): - return [val for val in self.get_as_iterator(src, start, end)] + return list(self.get_as_iterator(src, start, end)) def get_as_iterator(self, src, start, end): for val, _index, _offset in self.get_as_iterator_with_index_and_offset(src, start, end): @@ -287,7 +287,7 @@ class Indexes: """A set of indexes, each identified by a unique name""" def __init__(self, filename=None): - self.indexes = dict() + self.indexes = {} if filename is not None: self.open(filename) @@ -312,7 +312,7 @@ def find(self, name, start, end): def open(self, filename): self.filename = filename - self.offsets = dict() # (will map key to (offset,value_size)) + self.offsets = {} # (will map key to (offset,value_size)) with open(filename, "rb") as f: magic, version, length = read_packed(f, ">3I") if magic != MAGIC: diff --git a/lib/bx/intervals/cluster_tests.py b/lib/bx/intervals/cluster_tests.py index 1fa0957..d973a1c 100644 --- a/lib/bx/intervals/cluster_tests.py +++ b/lib/bx/intervals/cluster_tests.py @@ -49,7 +49,7 @@ def test_large_sorted(self): pairs = [(2 * i + 1, 2 * i + 2) for i in range(upto)] self.insertpairs(pairs) self.tree.insert(0, upto * 3, upto) - self.assertEqual([(0, upto * 3, [x for x in range(upto + 1)])], self.tree.getregions()) + self.assertEqual([(0, upto * 3, list(range(upto + 1)))], self.tree.getregions()) def test_minregions(self): self.tree = ClusterTree(0, 2) @@ -92,7 +92,7 @@ def test_larger(self): ] self.insertpairs(pairs) - self.assertEqual([(1, 20, [x for x in range(14)]), (21, 22, [14])], self.tree.getregions()) + self.assertEqual([(1, 20, list(range(14))), (21, 22, [14])], self.tree.getregions()) def test_another(self): pairs = [ @@ -116,7 +116,7 @@ def test_another(self): for s, e, i in pairs: self.tree.insert(s, e, i) - self.assertEqual([(1, 20, [x for x in range(14)]), (21, 22, [14])], self.tree.getregions()) + self.assertEqual([(1, 20, list(range(14))), (21, 22, [14])], self.tree.getregions()) def test_none(self): pairs = [] diff --git a/lib/bx/intervals/intersection_tests.py b/lib/bx/intervals/intersection_tests.py index 45febc1..c719661 100644 --- a/lib/bx/intervals/intersection_tests.py +++ b/lib/bx/intervals/intersection_tests.py @@ -160,13 +160,13 @@ def setUp(self): iv = IntervalTree() n = 0 for i in range(1, 1000, 80): - iv.insert(i, i + 10, dict(value=i * i)) + iv.insert(i, i + 10, {"value": i * i}) # add is synonym for insert. - iv.add(i + 20, i + 30, dict(astr=str(i * i))) + iv.add(i + 20, i + 30, {"astr": str(i * i)}) # or insert/add an interval object with start, end attrs. - iv.insert_interval(Interval(i + 40, i + 50, value=dict(astr=str(i * i)))) - iv.add_interval(Interval(i + 60, i + 70, value=dict(astr=str(i * i)))) + iv.insert_interval(Interval(i + 40, i + 50, value={"astr": str(i * i)})) + iv.add_interval(Interval(i + 60, i + 70, value={"astr": str(i * i)})) n += 4 self.intervals = self.iv = iv diff --git a/lib/bx/intervals/io.py b/lib/bx/intervals/io.py index e41f6a9..08eca9e 100644 --- a/lib/bx/intervals/io.py +++ b/lib/bx/intervals/io.py @@ -194,7 +194,7 @@ def binned_bitsets(self, upstream_pad=0, downstream_pad=0, lens=None): lens = {} last_chrom = None last_bitset = None - bitsets = dict() + bitsets = {} for interval in self: if isinstance(interval, GenomicInterval): chrom = interval[self.chrom_col] diff --git a/lib/bx/intervals/operations/find_clusters.py b/lib/bx/intervals/operations/find_clusters.py index 2940646..fb9fb5c 100644 --- a/lib/bx/intervals/operations/find_clusters.py +++ b/lib/bx/intervals/operations/find_clusters.py @@ -18,8 +18,8 @@ def find_clusters(reader, mincols=1, minregions=2): - extra = dict() - chroms = dict() + extra = {} + chroms = {} linenum = -1 for interval in reader: linenum += 1 diff --git a/lib/bx/intervals/operations/join.py b/lib/bx/intervals/operations/join.py index 2112d90..62a0956 100644 --- a/lib/bx/intervals/operations/join.py +++ b/lib/bx/intervals/operations/join.py @@ -68,7 +68,7 @@ def report_unvisited(node, results): results = [] rightTree.traverse(lambda x: report_unvisited(x, results)) for item in results: - outfields = list() + outfields = [] for x in range(leftlen): outfields.append(".") outfields.extend(item.other) diff --git a/lib/bx/misc/seekbzip2.py b/lib/bx/misc/seekbzip2.py index 03372e0..c654841 100644 --- a/lib/bx/misc/seekbzip2.py +++ b/lib/bx/misc/seekbzip2.py @@ -149,7 +149,7 @@ def readable(self): return True def readlines(self, sizehint=-1): - return [ln for ln in self] + return list(self) def seekable(self): return True diff --git a/lib/bx/pwm/position_weight_matrix.py b/lib/bx/pwm/position_weight_matrix.py index b661f1f..d8c5f1e 100755 --- a/lib/bx/pwm/position_weight_matrix.py +++ b/lib/bx/pwm/position_weight_matrix.py @@ -228,7 +228,7 @@ def __init__(self, id, rows, alphabet, background=None, score_correction=True): # scale counts to integers for i in range(len(rows)): - hashRows.append(dict()) + hashRows.append({}) for x, sym in enumerate(alphabet): (w, s) = rows[i][x] hashRows[i][sym] = w * scale / s diff --git a/lib/bx/pwm/pwm_tests.py b/lib/bx/pwm/pwm_tests.py index b2b7dfd..db143c1 100644 --- a/lib/bx/pwm/pwm_tests.py +++ b/lib/bx/pwm/pwm_tests.py @@ -66,18 +66,11 @@ class PWMTestCase(unittest.TestCase): def testReader(self): # test basic format: i.e. for jaspar - wms = [ - wm for wm in pwm.Reader(StringIO(basicPwm), format="basic", background=background, score_correction=False) - ] + wms = list(pwm.Reader(StringIO(basicPwm), format="basic", background=background, score_correction=False)) assert len(wms) == 1 # test transfac format - wms = [ - wm - for wm in pwm.Reader( - StringIO(transfacPwm), format="transfac", background=background, score_correction=False - ) - ] + wms = list(pwm.Reader(StringIO(transfacPwm), format="transfac", background=background, score_correction=False)) assert len(wms) == 1 wm = wms[0] @@ -87,7 +80,7 @@ def testReader(self): qdSeq = [] for ix, nt in enumerate(dSeq): - qdSeq.append(dict()) + qdSeq.append({}) qdSeq[ix][nt] = 1.0 qScores = wm.score_seq(qdSeq) assert len(qScores) == 2 diff --git a/lib/bx/seq/seq.py b/lib/bx/seq/seq.py index 81cc92e..16cc047 100644 --- a/lib/bx/seq/seq.py +++ b/lib/bx/seq/seq.py @@ -106,9 +106,7 @@ def raw_fetch(self, start, length): return self.text[start : start + length] def reverse_complement(self, text): - comp = [ch for ch in text.translate(DNA_COMP)] - comp.reverse() - return "".join(comp) + return text.translate(DNA_COMP)[::-1] class SeqReader: diff --git a/lib/bx/seq/twobit.py b/lib/bx/seq/twobit.py index 36e0571..5f69a6d 100644 --- a/lib/bx/seq/twobit.py +++ b/lib/bx/seq/twobit.py @@ -84,7 +84,7 @@ def __init__(self, file: BinaryIO, do_mask: bool = True): # Header contains some reserved space self.reserved = self.read("L") # Read index of sequence names to offsets - index: Dict[str, TwoBitSequence] = dict() + index: Dict[str, TwoBitSequence] = {} for _ in range(self.seq_count): name = self.read_p_string() offset = self.read("L") diff --git a/lib/bx_extras/pyparsing.py b/lib/bx_extras/pyparsing.py index ae1b882..0a33d14 100644 --- a/lib/bx_extras/pyparsing.py +++ b/lib/bx_extras/pyparsing.py @@ -318,7 +318,7 @@ def __init__(self, toklist, name=None, asList=True, modal=True): self.__toklist = toklist[:] else: self.__toklist = [toklist] - self.__tokdict = dict() + self.__tokdict = {} # this line is related to debugging the asXML bug # ~ asList = False @@ -355,13 +355,13 @@ def __getitem__(self, i): def __setitem__(self, k, v): if isinstance(v, _ParseResultsWithOffset): - self.__tokdict[k] = self.__tokdict.get(k, list()) + [v] + self.__tokdict[k] = self.__tokdict.get(k, []) + [v] sub = v[0] elif isinstance(k, int): self.__toklist[k] = v sub = v else: - self.__tokdict[k] = self.__tokdict.get(k, list()) + [_ParseResultsWithOffset(v, 0)] + self.__tokdict[k] = self.__tokdict.get(k, []) + [_ParseResultsWithOffset(v, 0)] sub = v if isinstance(sub, ParseResults): sub.__parent = wkref(self) @@ -698,7 +698,7 @@ def setDefaultWhitespaceChars(chars): setDefaultWhitespaceChars = staticmethod(setDefaultWhitespaceChars) def __init__(self, savelist=False): - self.parseAction = list() + self.parseAction = [] self.failAction = None # ~ self.name = "" # don't define self.name, let subclasses try/except upcall self.strRepr = None @@ -709,7 +709,7 @@ def __init__(self, savelist=False): self.copyDefaultWhiteChars = True self.mayReturnEmpty = False # used when checking for left-recursion self.keepTabs = False - self.ignoreExprs = list() + self.ignoreExprs = [] self.debug = False self.streamlined = False self.mayIndexError = True # used to optimize exception handling for subclasses that don't advance parse index @@ -2585,7 +2585,7 @@ def parseImpl(self, instring, loc, doActions=True): raise ParseException(instring, loc, "Missing one or more required elements (%s)" % missing) # add any unmatched Optionals, in case they have default values defined - matchOrder += list(e for e in self.exprs if isinstance(e, Optional) and e.expr in tmpOpt) + matchOrder += [e for e in self.exprs if isinstance(e, Optional) and e.expr in tmpOpt] resultlist = [] for e in matchOrder: @@ -3531,7 +3531,7 @@ def withAttribute(*args, **attrDict): attrs = args[:] else: attrs = attrDict.items() - attrs = [(k, v) for k, v in attrs] + attrs = list(attrs) def pa(s, l, tokens): for attrName, attrValue in attrs: diff --git a/pyproject.toml b/pyproject.toml index 8c4a108..48a27d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,7 +84,7 @@ target-version = "py38" # flake8-implicit-str-concat (ISC), NumPy-specific rules (NPY) # and pyupgrade (UP) #select = ["E", "F", "B", "C4", "G", "ISC", "NPY", "UP"] -select = ["E", "F", "G", "ISC", "NPY"] +select = ["E", "F", "C4", "G", "ISC", "NPY"] # Exceptions: # B9 flake8-bugbear opinionated warnings # E501 is line length (delegated to black) diff --git a/script_tests/base/__init__.py b/script_tests/base/__init__.py index ad42a6a..60e47cf 100644 --- a/script_tests/base/__init__.py +++ b/script_tests/base/__init__.py @@ -39,8 +39,8 @@ class BaseScriptTest: def test_script(self): # Accumulate parameters - input_files = dict() - output_files = dict() + input_files = {} + output_files = {} out_dir = None stdin = stdout = stderr = None for key in dir(self): @@ -60,9 +60,9 @@ def test_script(self): out_dir = getattr(self, key) assert os.path.isdir(out_dir) # Build the command line - input_fnames = dict() - output_fnames = dict() - all_fnames = dict() + input_fnames = {} + output_fnames = {} + all_fnames = {} for key, value in input_files.items(): input_fnames[key] = value.filename all_fnames[key] = input_fnames[key] diff --git a/scripts/aggregate_scores_in_intervals.py b/scripts/aggregate_scores_in_intervals.py index d5eabb0..2f7f0f4 100755 --- a/scripts/aggregate_scores_in_intervals.py +++ b/scripts/aggregate_scores_in_intervals.py @@ -36,7 +36,7 @@ class FileBinnedArrayDir(Mapping): def __init__(self, dir): self.dir = dir - self.cache = dict() + self.cache = {} def __getitem__(self, key): value = None @@ -63,7 +63,7 @@ def load_scores_wiggle(fname): Read a wiggle file and return a dict of BinnedArray objects keyed by chromosome. """ - scores_by_chrom = dict() + scores_by_chrom = {} for chrom, pos, val in bx.wiggle.Reader(misc.open_compressed(fname)): if chrom not in scores_by_chrom: scores_by_chrom[chrom] = BinnedArray() diff --git a/scripts/bed_complement.py b/scripts/bed_complement.py index 3ae3030..b9607ca 100755 --- a/scripts/bed_complement.py +++ b/scripts/bed_complement.py @@ -14,7 +14,7 @@ def read_len(f): """Read a 'LEN' file and return a mapping from chromosome to length""" - mapping = dict() + mapping = {} for line in f: fields = line.split() mapping[fields[0]] = int(fields[1]) diff --git a/scripts/bed_coverage_by_interval.py b/scripts/bed_coverage_by_interval.py index 13f89ff..fe8c269 100755 --- a/scripts/bed_coverage_by_interval.py +++ b/scripts/bed_coverage_by_interval.py @@ -25,7 +25,7 @@ def clone(bits): if len(sys.argv) > 3: mask_fname = sys.argv[3] mask = binned_bitsets_from_file(open(mask_fname)) - new_bitsets = dict() + new_bitsets = {} for key in bitsets: if key in mask: b = clone(mask[key]) diff --git a/scripts/bed_diff_basewise_summary.py b/scripts/bed_diff_basewise_summary.py index 0b33d02..f8d91ec 100755 --- a/scripts/bed_diff_basewise_summary.py +++ b/scripts/bed_diff_basewise_summary.py @@ -30,7 +30,7 @@ def coverage(bitsets): bits1_covered = coverage(bits1) bits2_covered = coverage(bits2) -bitsets = dict() +bitsets = {} for key in bits1: if key in bits2: diff --git a/scripts/bed_intersect_basewise.py b/scripts/bed_intersect_basewise.py index 42045eb..7a78f0f 100755 --- a/scripts/bed_intersect_basewise.py +++ b/scripts/bed_intersect_basewise.py @@ -20,7 +20,7 @@ bits1 = binned_bitsets_from_file(open(in_fname)) bits2 = binned_bitsets_from_file(open(in2_fname)) -bitsets = dict() +bitsets = {} for key in bits1: if key in bits2: diff --git a/scripts/get_scores_in_intervals.py b/scripts/get_scores_in_intervals.py index 60d1081..54c0919 100755 --- a/scripts/get_scores_in_intervals.py +++ b/scripts/get_scores_in_intervals.py @@ -18,7 +18,7 @@ def read_scores(f): - scores_by_chrom = dict() + scores_by_chrom = {} for chrom, pos, val in bx.wiggle.Reader(f): if chrom not in scores_by_chrom: scores_by_chrom[chrom] = BinnedArray() diff --git a/scripts/mMK_bitset.py b/scripts/mMK_bitset.py index 00a312a..671cc1b 100644 --- a/scripts/mMK_bitset.py +++ b/scripts/mMK_bitset.py @@ -33,8 +33,8 @@ def main(): neutral_bitsets = binned_bitsets_from_file(open(neutral_filename)) # Generate divergence bitset from maf file - AR_div_bitsets = dict() - chr_lens = dict() + AR_div_bitsets = {} + chr_lens = {} reader = bx.align.maf.Reader(open(maf_filename)) for block in reader: @@ -69,12 +69,12 @@ def main(): pos += 1 # Copy div and snp bitsets - nonAR_snp_bitsets = dict() + nonAR_snp_bitsets = {} for chr in AR_snp_bitsets: nonAR_snp_bitsets[chr] = bx.bitset.BinnedBitSet() nonAR_snp_bitsets[chr].ior(AR_snp_bitsets[chr]) - nonAR_div_bitsets = dict() + nonAR_div_bitsets = {} for chr in AR_div_bitsets: nonAR_div_bitsets[chr] = bx.bitset.BinnedBitSet() nonAR_div_bitsets[chr].ior(AR_div_bitsets[chr]) diff --git a/scripts/maf_covered_regions.py b/scripts/maf_covered_regions.py index 0099e88..ce23526 100755 --- a/scripts/maf_covered_regions.py +++ b/scripts/maf_covered_regions.py @@ -35,7 +35,7 @@ def block_pid(comp1, comp2): def main(): out_prefix = sys.argv[1] print(out_prefix) - out_files = dict() + out_files = {} for block in bx.align.maf.Reader(sys.stdin): ref_comp = block.components[0] ref_chrom = ref_comp.src.split(".")[1] diff --git a/scripts/maf_extract_chrom_ranges.py b/scripts/maf_extract_chrom_ranges.py index 07c252f..58b5566 100755 --- a/scripts/maf_extract_chrom_ranges.py +++ b/scripts/maf_extract_chrom_ranges.py @@ -46,7 +46,7 @@ def __main__(): # Load Intervals - intersecters = dict() + intersecters = {} for line in open(range_filename): fields = line.split() src = prefix + fields[0] diff --git a/scripts/mask_quality.py b/scripts/mask_quality.py index e97fa58..66df4cc 100644 --- a/scripts/mask_quality.py +++ b/scripts/mask_quality.py @@ -50,7 +50,7 @@ def main(): for entry in specieslist: fields = entry.split(",") lenstream = fileinput.FileInput(fields[1]) - lendict = dict() + lendict = {} for line in lenstream: region = line.split() lendict[region[0]] = int(region[1]) diff --git a/scripts/table_add_column.py b/scripts/table_add_column.py index f845963..2d096ea 100755 --- a/scripts/table_add_column.py +++ b/scripts/table_add_column.py @@ -38,7 +38,7 @@ def __main__(): if keep_comments: print(element) else: - val = eval(expr, dict(row=element)) + val = eval(expr, {"row": element}) print(str(element) + "\t" + str(val)) diff --git a/scripts/table_filter.py b/scripts/table_filter.py index 3138404..16a872b 100755 --- a/scripts/table_filter.py +++ b/scripts/table_filter.py @@ -61,7 +61,7 @@ def __main__(): if keep_comments: print(element) else: - if expr is None or bool(eval(expr, dict(row=element))): + if expr is None or bool(eval(expr, {"row": element})): if cols: print("\t".join(element[c] for c in cols)) else: diff --git a/setup.py b/setup.py index 0d2d152..72d8b61 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def main(): - metadata = dict(scripts=glob("scripts/*.py"), cmdclass=command_classes) + metadata = {"scripts": glob("scripts/*.py"), "cmdclass": command_classes} if len(sys.argv) >= 2 and ( "--help" in sys.argv[1:] or sys.argv[1] in ("--help-commands", "egg_info", "--version", "clean")