Skip to content

Commit

Permalink
Explicitly set variable types (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
sminot authored Feb 9, 2023
1 parent 3406fc2 commit cf85e52
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
1 change: 1 addition & 0 deletions ._wb/tool/phip-flow/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/FredHutch/bash-workbench/main/docs/schema.json",
"name": "PhIP-Seq",
"description": "PhIP-Seq common analysis workflows",
"args": {
Expand Down
43 changes: 43 additions & 0 deletions templates/join_organisms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
import os
import pandas as pd

peptide_dtypes = dict(
peptide=str,
n_replicates=int,
EBS=float,
hit=str,
sample=str,
public=bool
)

org_dtypes = dict(
sample=str,
organism=str,
n_hits_all=int,
n_discordant_all=int,
max_ebs_all=float,
mean_ebs_all=float,
n_hits_public=int,
n_discordant_public=int,
max_ebs_public=float,
mean_ebs_public=float,

)

for suffix, dtype_dict in [
("peptide.ebs.csv.gz", peptide_dtypes),
("organism.summary.csv.gz", org_dtypes)
]:

pd.concat([
pd.read_csv(
os.path.join("input", fp),
dtype=dtype_dict
)
for fp in os.listdir("input")
if fp.endswith(suffix)
]).to_csv(
suffix,
index=None
)
16 changes: 1 addition & 15 deletions workflows/aggregate.nf
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,7 @@ process join_organisms {
output: path "*.csv.gz"
when: params.summarize_by_organism
shell:
"""#!/usr/bin/env python3
import os
import pandas as pd
for suffix in ["peptide.ebs.csv.gz", "organism.summary.csv.gz"]:
pd.concat([
pd.read_csv(
os.path.join("input", fp)
)
for fp in os.listdir("input")
if fp.endswith(suffix)
]).to_csv(suffix, index=None)
"""
template 'join_organisms.py'
}

workflow AGG {
Expand Down

0 comments on commit cf85e52

Please sign in to comment.