Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMP: Add transformer from slpssefdf to Casava #226

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion q2_types/per_sample_sequences/_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import gzip
import shutil
import warnings
import tempfile
thermokarst marked this conversation as resolved.
Show resolved Hide resolved
import collections

import skbio
Expand Down Expand Up @@ -94,6 +95,17 @@ def _11(dirfmt: CasavaOneEightLanelessPerSampleDirFmt) \
dirfmt, SingleLanePerSamplePairedEndFastqDirFmt, parse_lane=False)


@plugin.register_transformer
def _12(dirfmt: SingleLanePerSampleSingleEndFastqDirFmt) \
-> CasavaOneEightSingleLanePerSampleDirFmt:
casava = CasavaOneEightSingleLanePerSampleDirFmt(mode='w')
for file in dirfmt.path.iterdir():
thermokarst marked this conversation as resolved.
Show resolved Hide resolved
if 'MANIFEST' not in str(file) and 'metadata' not in str(file):
thermokarst marked this conversation as resolved.
Show resolved Hide resolved
shutil.copy(os.path.join(str(dirfmt), file), str(casava))
Oddant1 marked this conversation as resolved.
Show resolved Hide resolved
return casava



@plugin.register_transformer
def _5(dirfmt: SingleLanePerSamplePairedEndFastqDirFmt) \
-> SingleLanePerSampleSingleEndFastqDirFmt:
Expand Down Expand Up @@ -351,7 +363,7 @@ def _9(fmt: PairedEndFastqManifestPhred64) \


@plugin.register_transformer
def _12(dirfmt: SingleLanePerSampleSingleEndFastqDirFmt) \
def _27(dirfmt: SingleLanePerSampleSingleEndFastqDirFmt) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DBC: Why not keep this as _12, and name the new one _27? Just so you know, with transformers the names of the functions don't matter, we just took the strategy of naming them _number, but it can be anything

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, probably just because I saw _10, _11 and was bothered at the idea of the next thing being _27 but I guess the rest isn't in numerical order anyway 😆

-> QIIME1DemuxDirFmt:
with dirfmt.manifest.view(FastqManifestFormat).open() as fh:
input_manifest = _parse_and_validate_manifest(fh, single_end=True,
Expand Down
11 changes: 6 additions & 5 deletions q2_types/per_sample_sequences/tests/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ def test_casava_one_eight_single_lane_per_sample_dirfmt_to_slpssefdf(self):
for act, exp in zip(obs, input):
self.assertEqual(act, exp)

def test_casava_one_eight_single_lane_per_sample_dirfmt_to_slpspefdf(self):
filenames = ('Human-Kneecap_S1_L001_R1_001.fastq.gz',)
def test_slpssefdf_to_casava_one_eight_single_lane_per_sample_dirfmt(self):
filenames = ('single-end-two-sample-data2/MANIFEST',
'metadata.yml',
'Human-Kneecap_S1_L001_R1_001.fastq.gz')
input, obs = self.transform_format(
CasavaOneEightSingleLanePerSampleDirFmt,
SingleLanePerSamplePairedEndFastqDirFmt, filenames=filenames
)
SingleLanePerSampleSingleEndFastqDirFmt,
CasavaOneEightSingleLanePerSampleDirFmt, filenames=filenames)

input = skbio.io.read(
'%s/Human-Kneecap_S1_L001_R1_001.fastq.gz' % str(input),
Expand Down