Skip to content

Commit

Permalink
Switch to using a dictionary instead of a namedtuple.
Browse files Browse the repository at this point in the history
This was somehow losing its namedtupleness, so we're just
avoiding the issue by not using them.
  • Loading branch information
roryk committed Feb 7, 2020
1 parent a45b962 commit ec5a5d3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 0 additions & 5 deletions bcbio/pipeline/datadict.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
from collections import namedtuple
import sys

# be explicit about what fields can show up in the nested dictionaries and what they are

TxImport = namedtuple("TxImport", ['gene_tpm', 'gene_counts'])
TxImport.__new__.__defaults__ = (None,) * len(TxImport._fields)

LOOKUPS = {
"config": {"keys": ['config']},
"tmp_dir": {"keys": ['config', 'resources', 'tmp', 'dir']},
Expand Down
6 changes: 4 additions & 2 deletions bcbio/pipeline/rnaseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,8 @@ def load_tximport(data):
tpm_file = os.path.join(out_dir, "tximport-tpm.csv")
counts_file = os.path.join(out_dir, "tximport-counts.csv")
if file_exists(tpm_file) and file_exists(counts_file):
return dd.TxImport(gene_tpm = tpm_file, gene_counts=counts_file)
return {"gene_tpm": tpm_file,
"gene_counts": counts_file}
with file_transaction(tpm_file) as tx_tpm_file, file_transaction(counts_file) as tx_counts_file:
render_string = (
f'library(tidyverse);'
Expand All @@ -546,4 +547,5 @@ def load_tximport(data):
f'readr::write_csv(txi$abundance %>% as.data.frame() %>% tibble::rownames_to_column("gene"), "{tx_tpm_file}");'
)
do.run([rcmd, "--vanilla", "-e", render_string], f"Loading tximport.")
return dd.TxImport(gene_tpm = tpm_file, gene_counts=counts_file)
return {"gene_tpm": tpm_file,
"gene_counts": counts_file}
4 changes: 2 additions & 2 deletions bcbio/upload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@ def _get_files_project(sample, upload_config):
else:
out.append({"path": dd.get_combined_counts(sample)})
if dd.get_tximport(sample):
out.append({"path": dd.get_tximport(sample).gene_tpm, "dir": "tpm"})
out.append({"path": dd.get_tximport(sample).gene_counts, "dir": "counts"})
out.append({"path": dd.get_tximport(sample)["gene_tpm"], "dir": "tpm"})
out.append({"path": dd.get_tximport(sample)["gene_counts"], "dir": "counts"})
if dd.get_annotated_combined_counts(sample):
out.append({"path": dd.get_annotated_combined_counts(sample)})
if dd.get_combined_fpkm(sample):
Expand Down

0 comments on commit ec5a5d3

Please sign in to comment.