Skip to content

Commit

Permalink
Merge pull request #17 from kedhammar/ssjunnebo_aviti
Browse files Browse the repository at this point in the history
Unpack and apply setting inherited from LIMS manifest rows
  • Loading branch information
ssjunnebo authored Oct 9, 2024
2 parents 0dd6038 + 01dd52f commit d0c402a
Showing 1 changed file with 36 additions and 24 deletions.
60 changes: 36 additions & 24 deletions taca/element/Element_Runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,15 @@ def make_demux_manifests(

# Break down into groups by non-consolable properties
grouped_df = df_samples.groupby(
["I1Mask", "I2Mask", "I1UmiMask", "I2UmiMask", "R1Mask", "R2Mask", "Recipe"]
[
"I1Mask",
"I2Mask",
"I1UmiMask",
"I2UmiMask",
"R1Mask",
"R2Mask",
"settings",
]
)

# Sanity check
Expand All @@ -537,7 +545,7 @@ def make_demux_manifests(
I2UmiMask,
R1Mask,
R2Mask,
recipe,
settings,
), group in grouped_df:
file_name = f"{manifest_root_name}_{n}.csv"

Expand All @@ -547,39 +555,43 @@ def make_demux_manifests(
"KeyName, Value",
f"manifest_file, {file_name}",
f"manifest_group, {n+1}/{len(grouped_df)}",
f"built_from, {manifest_to_split}",
]
)

settings_section = "\n".join(
[
"[SETTINGS]",
"SettingName, Value",
f"R1FastqMask, {R1Mask}",
f"I1Mask, {I1Mask}",
f"I2Mask, {I2Mask}",
f"R2FastqMask, {R2Mask}",
]
)
# Instantiate settings
settings_kvs = {
"R1FastqMask": R1Mask,
"I1Mask": I1Mask,
"I2Mask": I2Mask,
"R2FastqMask": R2Mask,
}

# Add UMI settings
if "Y" in I1UmiMask and "Y" not in I2UmiMask:
settings_section += "\n" + "\n".join(
[
f"UmiMask, {I1UmiMask}",
"UmiFastQ, TRUE",
]
)
settings_kvs["UmiMask"] = I1UmiMask
settings_kvs["UmiFastQ"] = "TRUE"
elif "Y" in I2UmiMask and "Y" not in I1UmiMask:
settings_section += "\n" + "\n".join(
[
f"UmiMask, {I2UmiMask}",
"UmiFastQ, TRUE",
]
)
settings_kvs["UmiMask"] = I2UmiMask
settings_kvs["UmiFastQ"] = "TRUE"
elif "Y" not in I1UmiMask and "Y" not in I2UmiMask:
pass
else:
raise AssertionError("Both I1 and I2 appear to contain UMIs.")

# Unpack settings from LIMS manifest
for kv in settings.split(" "):
k, v = kv.split(":")
settings_kvs[k] = v

settings_section = "\n".join(
[
"[SETTINGS]",
"SettingName, Value",
]
+ [f"{k}, {v}" for k, v in settings_kvs.items()]
)

# Add PhiX stratified by index length
group_controls = df_controls[
df_controls["Lane"].isin(group["Lane"].unique())
Expand Down

0 comments on commit d0c402a

Please sign in to comment.