Skip to content

Commit

Permalink
Linting and testing
Browse files Browse the repository at this point in the history
 - update version of python
  • Loading branch information
DrYak committed Mar 29, 2023
1 parent a6957ce commit 327a5e7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8.0'
python-version: '3.10.10'

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down
11 changes: 5 additions & 6 deletions cojac/cooc_curate.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def listmutations(lineage, extras={}):
if "variantQuery" in extras.keys():
# NOTE according to covspectrum: "Please specify the variant either by using the fields pangoLineage, nextstrainClade, gisaidClade, aaMutations and nucMutations, or by using variantQuery - don't use both at the same time."
return nucmutations(**extras)
return nucmutations(**{ lintype: (lineage + "*") }, **extras)
return nucmutations(**{lintype: (lineage + "*")}, **extras)


def aggregated(**kwargs):
Expand All @@ -122,8 +122,7 @@ def aggregated(**kwargs):
def listsublineages(lineage):
"""list all lineages which are known to be either the variant it self or one of its sub-variants"""
return set(
s[lintype]
for s in aggregated(**{ lintype: (lineage + "*") }, fields=lintype)
s[lintype] for s in aggregated(**{lintype: (lineage + "*")}, fields=lintype)
)


Expand Down Expand Up @@ -243,11 +242,11 @@ def curate_muts(
su = {combined}
else:
su = set(sublineages)
#print(muts)
# print(muts)
freqs = freqperlineage(muts, alllin)
#print(freqs)
# print(freqs)
(s, o, r) = rank(su, freqs, limit=low)
#print(s,o,r)
# print(s,o,r)

fi = [i for i in freqs.items()]
# print({p:fi[p-1] for p in [s,o,r]})
Expand Down
6 changes: 5 additions & 1 deletion cojac/cooc_pubmut.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@
def cooc_pubmut(
vocdir, amp, json_fname, yaml_fname, csv_fname, escape, semi, batchname, quiet
):
escape = ("\\n", csv.QUOTE_NONNUMERIC, "\\") if escape else ("\n", csv.QUOTE_MINIMAL, None)
escape = (
("\\n", csv.QUOTE_NONNUMERIC, "\\")
if escape
else ("\n", csv.QUOTE_MINIMAL, None)
)

# TODO make the "header prettification" code more generic and share with colourmut

Expand Down
1 change: 0 additions & 1 deletion cojac/cooc_tabmut.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def cooc_tabmut(
) # , inplace=True)
# rstudio_table_df.index.rename('sample', inplace=True)


if not quiet:
with pd.option_context(
"display.max_rows", None
Expand Down
4 changes: 2 additions & 2 deletions cojac/phe2cojac.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def phe2cojac(shortname, outname, fname):
)

for bl in yam["belongs-to-lineage"]:
for (s, l) in bl.items():
for s, l in bl.items():
if s == "PANGO":
outy["variant"]["pangolin"] = l
elif s == "nextstrain":
Expand Down Expand Up @@ -113,7 +113,7 @@ def phe2cojac(shortname, outname, fname):
# start writing
with open(outname, "wt") if outname is not None else sys.stdout as yf:
print(yaml.dump(outy, sort_keys=False), end="", file=yf)
for (t, s) in variants.items():
for t, s in variants.items():
if 0 == len(s):
continue
print(f"{t}:", file=yf)
Expand Down

0 comments on commit 327a5e7

Please sign in to comment.