Skip to content

Commit 84f303c

Browse files
committed
Fix bam mappings table pandas element access bug
1 parent 4b7175b commit 84f303c

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

workflow/rules/mapping.smk

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,18 +326,28 @@ if config["settings"]["recalibrate-base-qualities"]:
326326
# These might not exist when running with bam files from the outside, so we touch them here.
327327
def get_bam_from_mappings_table(sample):
328328
assert "mappings-table" in config["data"] and config["data"]["mappings-table"]
329-
bams = config["global"]["samples"].loc[sample, ["bam"]].dropna()
329+
330+
# Get the bam file(s) of the sample.
331+
# In a previous version, this was a series, with a loop over its elements below,
332+
# for reasons that I do not understand any more. It should only be a single bam file
333+
# per sample, so fixing this now, but keeping the old version for reference just in case.
334+
# bams = config["global"]["samples"].loc[sample, ["bam"]].dropna()
335+
bam = config["global"]["samples"].at[sample, "bam"]
330336

331337
# Touch all non-existing files. If they already exist,
332338
# we do nothing, to not mess with their time stamps.
333-
for f in bams:
334-
fp = Path(f + ".done")
335-
fp.parent.mkdir(parents=True, exist_ok=True)
336-
if not fp.exists():
337-
fp.touch(exist_ok=False)
339+
# for f in bams:
340+
# fp = Path(f + ".done")
341+
# fp.parent.mkdir(parents=True, exist_ok=True)
342+
# if not fp.exists():
343+
# fp.touch(exist_ok=False)
344+
bam_done = Path(bam + ".done")
345+
bam_done.parent.mkdir(parents=True, exist_ok=True)
346+
if not bam_done.exists():
347+
bam_done.touch(exist_ok=False)
338348

339349
# Now we can return the bam file list to the caller.
340-
return bams
350+
return bam
341351

342352

343353
# =================================================================================================

0 commit comments

Comments
 (0)