Skip to content
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
Qiita 0.1.0-dev (changes since Qiita 0.1.0 go here)
---------------------------------------------------

* Creating an empty RawData is no longer needed in order to add a PrepTemplate.
Now, the PrepTemplate is required in order to add a RawData to a study. This is
the normal flow of a study, as the PrepTemplate information is usually
available before the RawData information is available.
* A user can upload a QIIME mapping file instead of a SampleTemplate. The
system will create a SampleTemplate and a PrepTemplate from the information
present in the QIIME mapping file. The QIIME required columns for this
functionality to work are 'BarcodeSequence', 'LinkerPrimerSequence' and
'Description'. For more information about QIIME mapping files, visit
http://qiime.org/documentation/file_formats.html#mapping-file-overview.

Version 0.1.0 (2015-04-30)
--------------------------

Expand Down
4 changes: 2 additions & 2 deletions qiita_pet/handlers/study_handlers/edit_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ def post(self, study=None):
if study:
# Check study and user access
the_study = self._check_study_exists_and_user_access(study)
# If the study is public, we use the short version of the form
if the_study.status == 'public':
# If the study is not sandbox, we use the short version
if the_study.status != 'sandbox':
form_factory = StudyEditorForm

# Get the form data from the request arguments
Expand Down
8 changes: 4 additions & 4 deletions qiita_ware/demux.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def to_ascii(demux, samples=None):
for samp, idx, seq, qual, bc_ori, bc_cor, bc_err in fetch(demux, samples):
seq_id = id_fmt % {'sample': samp, 'idx': idx, 'bc_ori': bc_ori,
'bc_cor': bc_cor, 'bc_diff': bc_err}
if qual is not None:
if qual != []:
qual = qual.astype(np.uint8)

yield formatter(seq_id, seq, qual)
Expand Down Expand Up @@ -516,7 +516,7 @@ def fetch(demux, samples=None, k=None):
seqs = demux[pjoin(dset_paths['sequence'])][indices]

# only yield qual if we have it
quals = repeat(None)
quals = repeat([])
if demux.attrs['has-qual']:
if len(indices) == 1:
if indices[0]:
Expand All @@ -531,8 +531,8 @@ def fetch(demux, samples=None, k=None):
iter_ = zip(repeat(sample), np.arange(indices.size)[indices], seqs,
quals, bc_original, bc_corrected, bc_error)

for item in iter_:
yield item
for samp, idx, seq, qual, bc_ori, bc_cor, bc_err in iter_:
yield (samp, idx, seq, qual[:len(seq)], bc_ori, bc_cor, bc_err)


def stats(demux):
Expand Down
33 changes: 33 additions & 0 deletions qiita_ware/test/test_demux.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,25 @@ def test_fetch(self):
# implicitly tested with test_to_ascii
pass

def test_fetch_qual_length_bug(self):
# fetch was not trimming qual to the length of the sequence resulting
# in qual scores for positions beyond the length of the sequence.
with tempfile.NamedTemporaryFile('r+', suffix='.fq',
delete=False) as f:
f.write(fqdata_variable_length)

self.to_remove.append(f.name)
to_hdf5(f.name, self.hdf5_file)

exp = [('a', [(b"@a_0 orig_bc=abc new_bc=abc bc_diffs=0\nxyz\n+\n"
"ABC\n")]),
('b', [(b"@b_0 orig_bc=abw new_bc=wbc bc_diffs=4\nqwe\n+\n"
"DFG\n"),
(b"@b_1 orig_bc=abw new_bc=wbc bc_diffs=4\nqwexx\n+\n"
"DEF#G\n")])]

obs = [(s[0], list(s[1])) for s in to_per_sample_ascii(self.hdf5_file)]
self.assertEqual(obs, exp)

seqdata = """>a_1 orig_bc=abc new_bc=abc bc_diffs=0
x
Expand Down Expand Up @@ -370,5 +389,19 @@ def test_fetch(self):
DEF
"""

fqdata_variable_length = """@a_1 orig_bc=abc new_bc=abc bc_diffs=0
xyz
+
ABC
@b_1 orig_bc=abw new_bc=wbc bc_diffs=4
qwe
+
DFG
@b_2 orig_bc=abw new_bc=wbc bc_diffs=4
qwexx
+
DEF#G
"""

if __name__ == '__main__':
main()