Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueg committed Feb 4, 2024
1 parent e7c353d commit 5011930
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions workflow/rules/sra_download.smk
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ checkpoint get_layout:
),
shell:
"""
(mkdir -p {output.outdir}; \
(mkdir -p {output.outdir} && \
layout=$(efetch -db sra \
-id {wildcards.sample} \
-format runinfo | \
awk -F, 'x=1 NR>1 && $1 == {wildcards.sample} {print $16; x=0} END {exit x}'); \
touch {output.outdir}/$layout.info ; \
awk -F, 'BEGIN {{ exitval = 1 }} NR>1 && $1 == "{wildcards.sample}" {{ print $16; exitval=0 }} END {{ exit exitval }}') && \
touch {output.outdir}/$layout.info; \
) 1> {log.stdout} 2> {log.stderr}
"""

Expand Down Expand Up @@ -87,12 +87,17 @@ def get_layouts(wildcards):
for sample in samples[
samples.index.str.contains("^.RR", regex=True, case=True)
].index.tolist():
layouts[sample] = []
checkpoint_output = checkpoints.get_layout.get(
sample=sample, **wildcards
).output.outdir
layouts[sample] = glob_wildcards(
os.path.join(checkpoint_output, "{layout}.info")
).layout
_files = [
os.path.join(checkpoint_output, _file)
for _file in os.listdir(checkpoint_output)
if _file.endswith(".info")
]
assert len(_files) == 1
layouts[sample] = os.path.splitext(os.path.basename(_files[0]))[0]

# convert layouts to short form
layouts_short = {}
Expand All @@ -102,16 +107,16 @@ def get_layouts(wildcards):
elif val == "SINGLE":
layouts_short[key] = "se"
else:
raise ValueError("Layout not recognized.")
raise ValueError(f"Layout {val} for sample {key} not recognized.")

# return layouts
layouts = expand(
os.path.join(
config["outdir"], "compress", "{sample}", "{sample}.{seqmode}.tsv"
),
zip,
sample=ivals2.keys(),
seqmode=ivals2.values(),
sample=layouts_short.keys(),
seqmode=layouts_short.values(),
)
return layouts

Expand Down

0 comments on commit 5011930

Please sign in to comment.