Skip to content

Commit

Permalink
Changes to the qiime plugin and qiime tests to handle changes in the …
Browse files Browse the repository at this point in the history
…tempdir creation methods.
  • Loading branch information
arivers committed Sep 23, 2024
1 parent dc27066 commit a313cbe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 7 additions & 5 deletions itsxpress/q2_itsxpress.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@

#default_cluster_id=0.995
default_cluster_id=1.0
try:
tempdir = tempfile.mkdtemp(prefix='itsxpress_')
print("tempdir location {}".format(tempdir))

except Exception as e:
raise ValueError("Could not create temporary directory")

def _set_fastqs_and_check(fastq: str,
fastq2: str,
tempdir: str,
sample_id: str,
single_end: bool,
reversed_primers: bool,
Expand Down Expand Up @@ -196,6 +192,11 @@ def main(per_sample_sequences,
# Setting the taxa
taxa = _taxa_prefix_to_taxa(taxa)
samples = per_sample_sequences.manifest.view(pd.DataFrame)
try:
tempdir = tempfile.mkdtemp(prefix='itsxpress_')
# print("tempdir location {}".format(tempdir))
except Exception as e:
raise ValueError("Could not create temporary directory")
# Creating result dir
results = CasavaOneEightSingleLanePerSampleDirFmt()
# Running the for loop for each sample
Expand All @@ -204,6 +205,7 @@ def main(per_sample_sequences,
sobj = _set_fastqs_and_check(
fastq=sample.forward,
fastq2=sample.reverse if paired_in else None,
tempdir=tempdir,
sample_id=sample.Index,
single_end=False if paired_in else True,
reversed_primers=reversed_primers,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_main_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ def test_create_paired_trimmed_seqs():
import pandas as pd
import itsxpress.q2_itsxpress as q2_itsxpress
import itsxpress.plugin_setup

tempdir = tempfile.mkdtemp()
# The test data dir
TEST_DIR = os.path.join(os.path.dirname(os.path.abspath(__name__)),"tests")
# Test info 1
Expand Down Expand Up @@ -341,6 +343,7 @@ def test_single(self):
for sample in samples.itertuples():
obs = q2_itsxpress._set_fastqs_and_check(fastq=sample.forward,
fastq2=None,
tempdir=tempdir,
sample_id=sample.Index,
single_end=True,
reversed_primers=False,
Expand All @@ -352,6 +355,7 @@ def test_paired(self):
for sample in samples.itertuples():
obs = q2_itsxpress._set_fastqs_and_check(fastq=sample.forward,
fastq2=sample.reverse,
tempdir=tempdir,
sample_id=sample.Index,
single_end=True,
reversed_primers=False,
Expand All @@ -366,6 +370,7 @@ def test_trim_single_no_cluster():
# Fix for missing argument
obs = q2_itsxpress._set_fastqs_and_check(fastq=sample.forward,
fastq2=None,
tempdir=tempdir,
sample_id=sample.Index,
single_end=True,
reversed_primers=False,
Expand Down

0 comments on commit a313cbe

Please sign in to comment.