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

remove Python2 crumbs #3741

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions bcbio/bam/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Functionality to query and extract information from aligned BAM files.
"""
from __future__ import print_function
import collections
import os
import signal
Expand All @@ -10,7 +9,7 @@
import pybedtools
import pysam
import toolz as tz
from six.moves import zip_longest
from itertools import zip_longest

from bcbio import broad, utils
from bcbio.bam import ref
Expand Down
1 change: 0 additions & 1 deletion bcbio/bam/counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
These are useful for plotting comparisons between BAM files to look at
differences in defined or random regions.
"""
from __future__ import print_function
import random
import collections

Expand Down
5 changes: 2 additions & 3 deletions bcbio/bam/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import os

import six
import pandas as pd
import pybedtools

Expand Down Expand Up @@ -121,9 +120,9 @@ def plot_multiple_regions_coverage(samples, out_file, data, region_bed=None, ste
return out_file
in_bams = [dd.get_align_bam(x) for x in samples]
samplenames = [dd.get_sample_name(x) for x in samples]
if isinstance(region_bed, six.string_types):
if isinstance(region_bed, str):
region_bed = pybedtools.BedTool(region_bed)
if isinstance(stem_bed, six.string_types):
if isinstance(stem_bed, str):
stem_bed = pybedtools.BedTool(stem_bed)
if stem_bed is not None: # tabix indexed bedtools eval to false
stem_bed = stem_bed.tabix()
Expand Down
4 changes: 1 addition & 3 deletions bcbio/bam/fastq.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Utilities for working with fastq files.
"""

import six
from six.moves import zip
from itertools import product
import os
import random
Expand Down Expand Up @@ -250,7 +248,7 @@ def downsample(f1, f2, N, quick=False):
out_files = (outf1, outf2) if outf2 else (outf1)

with file_transaction(out_files) as tx_out_files:
if isinstance(tx_out_files, six.string_types):
if isinstance(tx_out_files, str):
tx_out_f1 = tx_out_files
else:
tx_out_f1, tx_out_f2 = tx_out_files
Expand Down
1 change: 0 additions & 1 deletion bcbio/chipseq/macs2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import glob
import subprocess
import sys

from bcbio import utils
from bcbio.provenance import do
Expand Down
8 changes: 3 additions & 5 deletions bcbio/cwl/create.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Create Common Workflow Language (CWL) runnable files and tools from a world object.
"""
from __future__ import print_function
import collections
import copy
import dateutil
Expand All @@ -12,7 +11,6 @@
import tarfile

import requests
import six
import toolz as tz
import yaml

Expand Down Expand Up @@ -402,7 +400,7 @@ def _get_cur_remotes(path):
elif isinstance(path, dict):
for v in path.values():
cur_remotes |= _get_cur_remotes(v)
elif path and isinstance(path, six.string_types):
elif path and isinstance(path, str):
if path.startswith(tuple(INTEGRATION_MAP.keys())):
cur_remotes.add(INTEGRATION_MAP.get(path.split(":")[0] + ":"))
return cur_remotes
Expand Down Expand Up @@ -624,7 +622,7 @@ def _get_avro_type(val):
elif val is None:
return ["null"]
# encode booleans as string True/False and unencode on other side
elif isinstance(val, bool) or isinstance(val, six.string_types) and val.lower() in ["true", "false", "none"]:
elif isinstance(val, bool) or isinstance(val, str) and val.lower() in ["true", "false", "none"]:
return ["string", "null", "boolean"]
elif isinstance(val, int):
return "long"
Expand Down Expand Up @@ -747,7 +745,7 @@ def _item_to_cwldata(x, get_retriever, indexes=None):
"""
if isinstance(x, (list, tuple)):
return [_item_to_cwldata(subx, get_retriever) for subx in x]
elif (x and isinstance(x, six.string_types) and
elif (x and isinstance(x, str) and
(((os.path.isfile(x) or os.path.isdir(x)) and os.path.exists(x)) or
objectstore.is_remote(x))):
if _file_local_or_remote(x, get_retriever):
Expand Down
5 changes: 2 additions & 3 deletions bcbio/cwl/cwlutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import pprint
import tarfile

import six
import toolz as tz

from bcbio import bam, utils
Expand Down Expand Up @@ -58,7 +57,7 @@ def normalize_missing(xs):
xs[k] = normalize_missing(v)
elif isinstance(xs, (list, tuple)):
xs = [normalize_missing(x) for x in xs]
elif isinstance(xs, six.string_types):
elif isinstance(xs, str):
if xs.lower() in ["none", "null"]:
xs = None
elif xs.lower() == "true":
Expand All @@ -81,7 +80,7 @@ def unpack_tarballs(xs, data, use_subdir=True):
xs[k] = unpack_tarballs(v, data, use_subdir)
elif isinstance(xs, (list, tuple)):
xs = [unpack_tarballs(x, data, use_subdir) for x in xs]
elif isinstance(xs, six.string_types):
elif isinstance(xs, str):
if os.path.isfile(xs.encode("utf-8", "ignore")) and xs.endswith("-wf.tar.gz"):
if use_subdir:
tarball_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data), "wf-inputs"))
Expand Down
1 change: 0 additions & 1 deletion bcbio/cwl/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Handles wrapping and integrating with multiple tools making it easier
to run bcbio in a standard way in many environments.
"""
from __future__ import print_function
import glob
import json
import os
Expand Down
9 changes: 4 additions & 5 deletions bcbio/cwl/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import copy
import pprint

import six
import toolz as tz

from bcbio.pipeline import alignment
Expand Down Expand Up @@ -234,7 +233,7 @@ def _flatten_nested_input(v):
for x in v["type"]:
if isinstance(x, dict) and x["type"] == "array":
new_type = x["items"]
elif isinstance(x, six.string_types) and x == "null":
elif isinstance(x, str) and x == "null":
want_null = True
else:
new_type = x
Expand Down Expand Up @@ -272,15 +271,15 @@ def _clean_output(v):
return out

def _get_string_vid(vid):
if isinstance(vid, six.string_types):
if isinstance(vid, str):
return vid
assert isinstance(vid, (list, tuple)), vid
return "__".join(vid)

def _get_variable(vid, variables):
"""Retrieve an input variable from our existing pool of options.
"""
if isinstance(vid, six.string_types):
if isinstance(vid, str):
vid = get_base_id(vid)
else:
vid = _get_string_vid(vid)
Expand Down Expand Up @@ -426,7 +425,7 @@ def _create_variable(orig_v, step, variables):
v = _get_variable(orig_v["id"], variables)
except ValueError:
v = copy.deepcopy(orig_v)
if not isinstance(v["id"], six.string_types):
if not isinstance(v["id"], str):
v["id"] = _get_string_vid(v["id"])
for key, val in orig_v.items():
if key not in ["id", "type"]:
Expand Down
7 changes: 2 additions & 5 deletions bcbio/distributed/objectstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import time
import zlib

import six

from bcbio.distributed.transaction import file_transaction
from bcbio.provenance import do
Expand All @@ -23,8 +22,7 @@
BIODATA_INFO = {"s3": "s3://biodata/prepped/{build}/{build}-{target}.tar.gz"}
REGIONS_NEWPERMS = {"s3": ["eu-central-1"]}

@six.add_metaclass(abc.ABCMeta)
class FileHandle(object):
class FileHandle(metaclass=abc.ABCMeta):

"""Contract class for the file handle."""

Expand Down Expand Up @@ -221,8 +219,7 @@ def close(self):
pass


@six.add_metaclass(abc.ABCMeta)
class StorageManager(object):
class StorageManager(metaclass=abc.ABCMeta):

"""The contract class for all the storage managers."""

Expand Down
5 changes: 2 additions & 3 deletions bcbio/distributed/runfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import pprint
import shutil

import six
import toolz as tz
import yaml

Expand Down Expand Up @@ -129,7 +128,7 @@ def _add_resources(data, runtime):
data["config"] = {}
# Convert input resources, which may be a JSON string
resources = data.get("resources", {}) or {}
if isinstance(resources, six.string_types) and resources.startswith(("{", "[")):
if isinstance(resources, str) and resources.startswith(("{", "[")):
resources = json.loads(resources)
data["resources"] = resources
assert isinstance(resources, dict), (resources, data)
Expand Down Expand Up @@ -561,7 +560,7 @@ def _file_and_exists(val, input_files):
def _to_cwl(val, input_files):
"""Convert a value into CWL formatted JSON, handling files and complex things.
"""
if isinstance(val, six.string_types):
if isinstance(val, str):
if _file_and_exists(val, input_files):
val = {"class": "File", "path": val}
secondary = []
Expand Down
3 changes: 1 addition & 2 deletions bcbio/distributed/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""
import collections

import six

from bcbio import utils

Expand Down Expand Up @@ -60,7 +59,7 @@ def parallel_split_combine(args, split_fn, parallel_fn,
split_args, combine_map, finished_out, extras = _get_split_tasks(args, split_fn, file_key,
split_outfile_i)
split_output = parallel_fn(parallel_name, split_args)
if isinstance(combiner, six.string_types):
if isinstance(combiner, str):
combine_args, final_args = _organize_output(split_output, combine_map,
file_key, combine_arg_keys)
parallel_fn(combiner, combine_args)
Expand Down
3 changes: 2 additions & 1 deletion bcbio/galaxy/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Access Galaxy NGLIMS functionality via the standard API.
"""
from six.moves import urllib
import urllib.parse
import urllib.request
import json
import time

Expand Down
4 changes: 1 addition & 3 deletions bcbio/galaxy/nglims.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Integration with Galaxy nglims.
"""
from __future__ import print_function
import collections
import copy
import glob
Expand All @@ -9,7 +8,6 @@
import subprocess

import joblib
import six
import yaml

from bcbio import utils
Expand Down Expand Up @@ -106,7 +104,7 @@ def _select_default_algorithm(analysis):
def _relative_paths(xs, base_path):
"""Adjust paths to be relative to the provided base path.
"""
if isinstance(xs, six.string_types):
if isinstance(xs, str):
if xs.startswith(base_path):
return xs.replace(base_path + "/", "", 1)
else:
Expand Down
1 change: 0 additions & 1 deletion bcbio/graph/graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function

from datetime import datetime
import collections
Expand Down
1 change: 0 additions & 1 deletion bcbio/heterogeneity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
to infer these sub-clones to help improve variant calls and interpretation
especially in complex cancer samples.
"""
from __future__ import print_function
import collections
import os

Expand Down
1 change: 0 additions & 1 deletion bcbio/heterogeneity/bubbletree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
http://www.bioconductor.org/packages/release/bioc/html/BubbleTree.html
http://www.bioconductor.org/packages/release/bioc/vignettes/BubbleTree/inst/doc/BubbleTree-vignette.html
"""
from __future__ import print_function
import collections
import csv
import os
Expand Down
11 changes: 5 additions & 6 deletions bcbio/heterogeneity/loh.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import uuid

import pandas as pd
import six
from six import StringIO
from io import StringIO
import toolz as tz
import yaml

Expand Down Expand Up @@ -59,7 +58,7 @@ def _matches(tocheck, target):
def _civic_regions(civic_file, variant_types=None, diseases=None, drugs=None):
"""Retrieve gene regions and names filtered by variant_types and diseases.
"""
if isinstance(diseases, six.string_types):
if isinstance(diseases, str):
diseases = [diseases]
with utils.open_gzipsafe(civic_file) as in_handle:
reader = csv.reader(in_handle, delimiter="\t")
Expand Down Expand Up @@ -369,15 +368,15 @@ def __read_token(self):
cp = c
c = self.__read_fd(1)
e = c
v = unicode(''.join(buf).decode('unicode-escape'))
v = str(''.join(buf).decode('unicode-escape'))

elif t == "datetime":
## skip "inst"
self.__read_fd(4)

## read next value as string
s = self.__read_token()
if not isinstance(s, six.string_types):
if not isinstance(s, str):
raise ValueError('Str expected, but got %s' % str(s))

## remove read string from the value_stack
Expand All @@ -392,7 +391,7 @@ def __read_token(self):

## read next value as string
s = self.__read_token()
if not isinstance(s, six.string_types):
if not isinstance(s, str):
raise ValueError('Str expected, but got %s' % str(s))

## remove read string from the value_stack
Expand Down
1 change: 0 additions & 1 deletion bcbio/heterogeneity/phylowgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
https://github.com/morrislab/phylowgs
http://genomebiology.com/2015/16/1/35
"""
from __future__ import print_function
import collections
import os
import sys
Expand Down
1 change: 0 additions & 1 deletion bcbio/hla/optitype.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import glob
import os
import re
import sys
import shutil

import toolz as tz
Expand Down
4 changes: 2 additions & 2 deletions bcbio/hmmer/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

https://github.com/nickloman/entrezajax
"""
from __future__ import print_function
from six.moves import urllib
import urllib.parse
import urllib.request
import logging

class SmartRedirectHandler(urllib.request.HTTPRedirectHandler):
Expand Down
Loading