Skip to content

Commit

Permalink
Merge 59188dd into 058ee0e
Browse files Browse the repository at this point in the history
  • Loading branch information
thermokarst committed May 27, 2020
2 parents 058ee0e + 59188dd commit 4b12b60
Show file tree
Hide file tree
Showing 5 changed files with 484 additions and 331 deletions.
29 changes: 29 additions & 0 deletions q2_types/per_sample_sequences/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import gzip
import itertools
import collections
import pathlib

import pandas as pd
import skbio
Expand All @@ -20,6 +21,10 @@
from qiime2.plugin import ValidationError

from ..plugin_setup import plugin
from ._util import (
_parse_casava_filename,
_manifest_to_df,
)


class FastqAbsolutePathManifestFormatV2(model.TextFileFormat):
Expand Down Expand Up @@ -296,6 +301,30 @@ def sequences_path_maker(self, sample_id, barcode_id, lane_number,
def _find_duplicates(self, ids):
return {x for x, c in collections.Counter(ids).items() if c > 1}

@property
def manifest(self):
tmp_manifest = FastqManifestFormat()
with tmp_manifest.open() as fh:
fh.write('sample-id,filename,direction\n')
for fp, _ in self.sequences.iter_views(FastqGzFormat):
sample_id, _, _, _, direction = _parse_casava_filename(fp)
fh.write('%s,%s,%s\n' % (sample_id, fp.name, direction))

df = _manifest_to_df(tmp_manifest, self.path.parent)

if 'reverse' not in df:
df['reverse'] = None

def munge_fn_closure(val):
if val is not None:
return str(self.path / pathlib.Path(val).name)
return val

for column in {'forward', 'reverse'}:
df[column] = df[column].apply(munge_fn_closure)

return df

def _validate_(self, level):
forwards = []
reverse = []
Expand Down
Loading

0 comments on commit 4b12b60

Please sign in to comment.