Skip to content

Commit

Permalink
fixes #430 and adds corresponding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Dec 14, 2023
1 parent 37591f1 commit 77b3115
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 5 deletions.
2 changes: 1 addition & 1 deletion looper/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def make_set(items):
try:
# Check if user input single integer value for inclusion/exclusion criteria
if len(items) == 1:
items = list(map(int, items)) # list(int(items[0]))
items = list(map(str, items)) # list(int(items[0]))
except:
if isinstance(items, str):
items = [items]
Expand Down
8 changes: 4 additions & 4 deletions tests/data/annotation_sheet.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sample_name,protocol,data_source,SRR,Sample_geo_accession,read1,read2
sample1,PROTO1,SRA,SRR5210416,GSM2471255,SRA_1,SRA_2
sample2,PROTO1,SRA,SRR5210450,GSM2471300,SRA_1,SRA_2
sample3,PROTO2,SRA,SRR5210398,GSM2471249,SRA_1,SRA_2
sample_name,protocol,data_source,SRR,Sample_geo_accession,read1,read2,toggle
sample1,PROTO1,SRA,SRR5210416,GSM2471255,SRA_1,SRA_2,1
sample2,PROTO1,SRA,SRR5210450,GSM2471300,SRA_1,SRA_2,1
sample3,PROTO2,SRA,SRR5210398,GSM2471249,SRA_1,SRA_2,1
92 changes: 92 additions & 0 deletions tests/smoketests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,95 @@ def test_excluding_attr_and_flags_works(
subs_list = [os.path.join(sd, f) for f in os.listdir(sd) if f.endswith(".sub")]

assert len(subs_list) == 2

@pytest.mark.parametrize("flag_id", ["completed"])
@pytest.mark.parametrize(
"pipeline_name", ["PIPELINE1"]
) # This is given in the pipestat_output_schema.yaml
def test_excluding_toggle_attr(
self, prep_temp_pep_pipestat, flag_id, pipeline_name
):
"""Verify that checking works"""
tp = prep_temp_pep_pipestat

p = Project(tp)
out_dir = p[CONFIG_KEY][LOOPER_KEY][OUTDIR_KEY]
count = 0
for s in p.samples:
sf = os.path.join(out_dir, "results_pipeline")
if not os.path.exists(sf):
os.makedirs(sf)
flag_path = os.path.join(
sf, pipeline_name + "_" + s.sample_name + "_" + FLAGS[count] + ".flag"
)
with open(flag_path, "w") as f:
f.write(FLAGS[count])
count += 1

x = [
"run",
"-d",
"--looper-config",
tp,
"--sel-attr",
"toggle",
"--sel-excl",
"1",
]

try:
results = main(test_args=x)
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

with pytest.raises(FileNotFoundError):
# No samples submitted, thus no sub dir
sd = os.path.join(get_outdir(tp), "submission")
subs_list = [
os.path.join(sd, f) for f in os.listdir(sd) if f.endswith(".sub")
]

@pytest.mark.parametrize("flag_id", ["completed"])
@pytest.mark.parametrize(
"pipeline_name", ["PIPELINE1"]
) # This is given in the pipestat_output_schema.yaml
def test_including_toggle_attr(
self, prep_temp_pep_pipestat, flag_id, pipeline_name
):
"""Verify that checking works"""
tp = prep_temp_pep_pipestat

p = Project(tp)
out_dir = p[CONFIG_KEY][LOOPER_KEY][OUTDIR_KEY]
count = 0
for s in p.samples:
sf = os.path.join(out_dir, "results_pipeline")
if not os.path.exists(sf):
os.makedirs(sf)
flag_path = os.path.join(
sf, pipeline_name + "_" + s.sample_name + "_" + FLAGS[count] + ".flag"
)
with open(flag_path, "w") as f:
f.write(FLAGS[count])
count += 1

x = [
"run",
"-d",
"--looper-config",
tp,
"--sel-attr",
"toggle",
"--sel-incl",
"1",
]

try:
results = main(test_args=x)
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))

sd = os.path.join(get_outdir(tp), "submission")
subs_list = [os.path.join(sd, f) for f in os.listdir(sd) if f.endswith(".sub")]

assert len(subs_list) == 3

0 comments on commit 77b3115

Please sign in to comment.