diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 534905c..0c40ecd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,3 +20,6 @@ jobs: - name: Run tests run: pytest tests/ -v + + - name: Lint + run: pylint assemblytics/ --fail-under=9.0 diff --git a/README.md b/README.md index 9f0b942..6ddd3a9 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,9 @@ This runs `python3 -m build --wheel` and copies the result into `public/`. If yo To re-run the pipeline on each input and diff its variant calls against the matching example output: ```bash +pip3 uninstall assemblytics # remove whatever's installed +pip3 install -e . # install editable from current directory + # E. coli (uses a smaller unique anchor length since it's a small genome) assemblytics -d input_examples/ecoli.delta.gz -o /tmp/assemblytics_test/ecoli -l 1000 diff <(tail -n +2 /tmp/assemblytics_test/ecoli/assemblytics_structural_variants.bed | sort) \ diff --git a/assemblytics/dot_prep.py b/assemblytics/dot_prep.py index a0dae87..acce686 100755 --- a/assemblytics/dot_prep.py +++ b/assemblytics/dot_prep.py @@ -93,7 +93,7 @@ def index_for_dot(reference_lengths, fields_by_query, output_prefix, max_overvie # orientation: flip = sum_reverse > sum_forward - flip_by_query[query_name] = "-" if (flip == True) else "+" + flip_by_query[query_name] = "-" if flip else "+" for tag in ordered_tags: @@ -103,7 +103,7 @@ def index_for_dot(reference_lengths, fields_by_query, output_prefix, max_overvie for fields in lines: if fields[8] == tag: - if flip == True: + if flip: fields[2] = int(fields[5]) - int(fields[2]) fields[3] = int(fields[5]) - int(fields[3]) @@ -138,7 +138,7 @@ def index_for_dot(reference_lengths, fields_by_query, output_prefix, max_overvie f_out_index.write("#query\n") f_out_index.write("query,query_length,orientation,bytePosition_unique,bytePosition_repetitive,bytePosition_end,unique_matching_refs,matching_refs\n") # relative_ref_position_by_query is sorted by rel_pos - for query,rel_pos in relative_ref_position_by_query: + for query,_ in relative_ref_position_by_query: f_out_index.write("%s,%d,%s,%d,%d,%d,%s,%s\n" % (query, query_lengths[query], flip_by_query[query], query_byte_positions[(query,"unique")], query_byte_positions[(query,"repetitive")] - query_byte_positions[(query,"unique")], query_byte_positions[(query,"end")] - query_byte_positions[(query,"repetitive")], "~".join(unique_references_by_query[query]), "~".join(all_references_by_query[query]))) f_out_index.write("#overview\n") diff --git a/assemblytics/dotplot.py b/assemblytics/dotplot.py index 0da19d0..df78e6f 100644 --- a/assemblytics/dotplot.py +++ b/assemblytics/dotplot.py @@ -5,7 +5,6 @@ import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt -import numpy as np import os def run(output_dir): diff --git a/assemblytics/nchart.py b/assemblytics/nchart.py index b89581f..7524380 100644 --- a/assemblytics/nchart.py +++ b/assemblytics/nchart.py @@ -5,7 +5,6 @@ import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt -import numpy as np import os def bp_format(num): diff --git a/assemblytics/uniq_anchor.py b/assemblytics/uniq_anchor.py index 7e33b19..4ca68b6 100755 --- a/assemblytics/uniq_anchor.py +++ b/assemblytics/uniq_anchor.py @@ -30,11 +30,9 @@ def run(args): try: f = gzip.open(filename, 'rt') header1 = f.readline().strip() - # Detected gzipped delta file. - except: + except Exception: # noqa: BLE001 — fallback for uncompressed delta f = open(filename, 'r') header1 = f.readline().strip() - # Detected uncompressed delta file. # Skip the second line f.readline() @@ -97,11 +95,9 @@ def run(args): try: f = gzip.open(filename, 'rt') header1 = f.readline() - # Detected gzipped delta file. - except: + except Exception: # noqa: BLE001 — fallback for uncompressed delta f = open(filename, 'r') header1 = f.readline() - # Detected uncompressed delta file. fout.write(header1) fout.write(f.readline()) @@ -112,6 +108,7 @@ def run(args): list_of_alignments_to_keep = [] alignment_counter = {} keep_printing = False + query = "" # For coords: current_query_name = "" @@ -152,7 +149,7 @@ def run(args): for index in list_of_alignments_to_keep: if line.strip() == header_lines_by_query[query][index]: header_needed = True - if header_needed == True: + if header_needed: fout.write(line) # if we have any alignments under this header, print the header alignment_counter[query] = alignment_counter.get(query,0) @@ -204,7 +201,7 @@ def run(args): ) alignment_counter[query] = alignment_counter[query] + 1 - elif keep_printing == True: + elif keep_printing: fout.write(line) fcoords_out_tab.close() diff --git a/pyproject.toml b/pyproject.toml index bf65600..e4722c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,10 +31,38 @@ Repository = "https://github.com/MariaNattestad/assemblytics" assemblytics = "assemblytics.cli:main" [project.optional-dependencies] -dev = ["pytest"] +dev = ["pytest", "pylint"] [tool.setuptools] packages = ["assemblytics"] [tool.pytest.ini_options] testpaths = ["tests"] + +[tool.pylint.format] +max-line-length = 250 + +[tool.pylint."messages control"] +disable = [ + "missing-module-docstring", + "missing-function-docstring", + "missing-class-docstring", + "trailing-whitespace", + "wrong-import-order", + "wrong-import-position", + "import-outside-toplevel", + "too-many-locals", + "too-many-branches", + "too-many-statements", + "too-many-positional-arguments", + "too-many-arguments", + "consider-using-f-string", + "consider-using-with", + "consider-using-dict-items", + "unspecified-encoding", + "duplicate-code", + "bad-indentation", + "redefined-outer-name", + "chained-comparison", + "broad-exception-caught", +]