Skip to content

Commit 6a8a755

Browse files
Merge pull request #3132 from antgonza/rm-pt-generate-files-from-sample-update
rm pt.generate_files from sample update
2 parents 3c24801 + 2daa4be commit 6a8a755

File tree

6 files changed

+44
-61
lines changed

6 files changed

+44
-61
lines changed

qiita_db/metadata_template/sample_template.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,6 @@ def generate_files(self, samples=None, columns=None):
268268
fp_id = qdb.util.convert_to_id("sample_template", "filepath_type")
269269
self.add_filepath(fp, fp_id=fp_id)
270270

271-
# generating all new QIIME mapping files
272-
for pt in qdb.study.Study(self._id).prep_templates():
273-
if samples is not None and samples and (
274-
columns is None or not columns):
275-
overlapping = set(samples) & set(pt.keys())
276-
# if the prep has no overlapping sample ids, we can skip
277-
# generationg the prep
278-
if not overlapping:
279-
continue
280-
pt.generate_files(samples, columns)
281-
282271
@property
283272
def ebi_sample_accessions(self):
284273
"""The EBI sample accessions for the samples in the sample template

qiita_db/metadata_template/test/test_sample_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,9 +1365,9 @@ def test_generate_files(self):
13651365
fp_count = qdb.util.get_count("qiita.filepath")
13661366
self.tester.generate_files()
13671367
obs = qdb.util.get_count("qiita.filepath")
1368-
# We just make sure that the count has been increased by 3, since
1368+
# We just make sure that the count has been increased by 1, since
13691369
# the contents of the files have been tested elsewhere.
1370-
self.assertEqual(obs, fp_count + 3)
1370+
self.assertEqual(obs, fp_count + 1)
13711371

13721372
def test_to_file(self):
13731373
"""to file writes a tab delimited file with all the metadata"""

qiita_db/test/test_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_investigation_study(self):
3333
self.assertEqual(get_count("qiita.investigation_study"), 1)
3434

3535
def test_filepath(self):
36-
self.assertEqual(get_count("qiita.filepath"), 25)
36+
self.assertEqual(get_count("qiita.filepath"), 23)
3737

3838
def test_filepath_type(self):
3939
self.assertEqual(get_count("qiita.filepath_type"), 24)

qiita_pet/handlers/api_proxy/tests/test_prep_template.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ def test_prep_template_ajax_get_req(self):
7575
'message': '',
7676
'name': "Prep information 1",
7777
'files': ["uploaded_file.txt"],
78-
'download_prep_id': 24,
79-
'other_filepaths': ['1_prep_1_qiime_19700101-000000.txt',
80-
'1_prep_1_19700101-000000.txt',
78+
'download_prep_id': 21,
79+
'other_filepaths': ['1_prep_1_19700101-000000.txt',
8180
'1_prep_1_qiime_19700101-000000.txt',
8281
'1_prep_1_19700101-000000.txt'],
8382
'num_samples': 27,
@@ -200,7 +199,7 @@ def test_prep_template_filepaths_get_req(self):
200199
self.assertEqual(obs['message'], '')
201200
# [0] the fp_id is the first element, that should change
202201
fp_ids = [fp[0] for fp in obs['filepaths']]
203-
self.assertCountEqual(fp_ids, [18, 19, 20, 21, 24])
202+
self.assertCountEqual(fp_ids, [18, 19, 20, 21])
204203

205204
def test_prep_template_filepaths_get_req_no_access(self):
206205
obs = prep_template_filepaths_get_req(1, '[email protected]')

qiita_pet/handlers/download.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ def _list_artifact_files_nginx(self, artifact):
124124
for pt in artifact.prep_templates:
125125
# the latest prep template file is always the first [0] tuple and
126126
# we need the filepath [1]
127-
pt_fp = pt.get_filepaths()[0][1]
128-
if pt_fp is not None:
127+
pt_fp = pt.get_filepaths()
128+
if pt_fp:
129+
pt_fp = pt_fp[0][1]
129130
spt_fp = pt_fp
130131
if pt_fp.startswith(basedir):
131132
spt_fp = pt_fp[basedir_len:]

qiita_pet/test/test_download.py

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -148,31 +148,27 @@ def test_download_study(self):
148148
response = self.get('/download_study_bioms/1')
149149
self.assertEqual(response.code, 200)
150150
exp = (
151-
'- 1256812 /protected/processed_data/'
152-
'1_study_1001_closed_reference_otu_table.biom processed_data/'
153-
'1_study_1001_closed_reference_otu_table.biom\n'
154-
'- [0-9]* /protected/templates/1_prep_1_[0-9]*-[0-9]*.txt '
151+
'- \\d+ /protected/processed_data/1_study_1001_closed_reference_'
152+
'otu_table.biom processed_data/1_study_1001_closed_reference_otu'
153+
'_table.biom\n'
154+
'- \\d+ /protected/templates/1_prep_1_qiime_19700101-000000.txt '
155155
'mapping_files/4_mapping_file.txt\n'
156-
'- 1256812 /protected/processed_data/'
157-
'1_study_1001_closed_reference_otu_table.biom processed_data/'
158-
'1_study_1001_closed_reference_otu_table.biom\n'
159-
'- [0-9]* /protected/templates/1_prep_1_[0-9]*-[0-9]*.txt '
156+
'- \\d+ /protected/processed_data/1_study_1001_closed_reference_'
157+
'otu_table.biom processed_data/1_study_1001_closed_reference_otu'
158+
'_table.biom\n'
159+
'- \\d+ /protected/templates/1_prep_1_qiime_19700101-000000.txt '
160160
'mapping_files/5_mapping_file.txt\n'
161-
'- 1256812 /protected/processed_data/1_study_1001_'
162-
'closed_reference_otu_table_Silva.biom processed_data/'
163-
'1_study_1001_closed_reference_otu_table_Silva.biom\n'
164-
'- [0-9]* /protected/templates/1_prep_1_[0-9]*-[0-9]*.txt '
161+
'- \\d+ /protected/processed_data/1_study_1001_closed_reference_'
162+
'otu_table_Silva.biom processed_data/1_study_1001_closed_'
163+
'reference_otu_table_Silva.biom\n'
164+
'- \\d+ /protected/templates/1_prep_1_qiime_19700101-000000.txt '
165165
'mapping_files/6_mapping_file.txt\n'
166-
'- 1093210 /protected/BIOM/7/biom_table.biom '
167-
'BIOM/7/biom_table.biom\n'
168-
'- [0-9]* /protected/templates/1_prep_2_[0-9]*-[0-9]*.txt '
169-
'mapping_files/7_mapping_file.txt\n'
170-
'- [0-9]* /protected/BIOM/{0}/otu_table.biom '
171-
'BIOM/{0}/otu_table.biom\n'
172-
'- 1 /protected/BIOM/10/sortmerna_picked_otus/seqs_otus.log '
173-
'BIOM/{0}/sortmerna_picked_otus/seqs_otus.log\n'
174-
'- [0-9]* /protected/templates/1_prep_1_[0-9]*-[0-9]*.txt '
175-
'mapping_files/{0}_mapping_file.txt\n'.format(a.id))
166+
'- \\d+ /protected/BIOM/7/biom_table.biom BIOM/7/biom_table.biom\n'
167+
'- \\d+ /protected/BIOM/10/otu_table.biom BIOM/10/otu_table.biom\n'
168+
'- \\d+ /protected/BIOM/10/sortmerna_picked_otus/seqs_otus.log '
169+
'BIOM/10/sortmerna_picked_otus/seqs_otus.log\n'
170+
'- \\d+ /protected/templates/1_prep_1_qiime_19700101-000000.txt '
171+
'mapping_files/10_mapping_file.txt\n')
176172
self.assertRegex(response.body.decode('ascii'), exp)
177173

178174
response = self.get('/download_study_bioms/200')
@@ -190,10 +186,9 @@ def test_download_study(self):
190186
a.visibility = 'private'
191187
self.assertEqual(response.code, 200)
192188
# we should have the same files than the previous test, except artifact
193-
# and mapping file 7: position 6 and 7; thus removing 6 twice
189+
# and mapping file 7: position 6; thus removing 6
194190
exp = exp.split('\n')
195191
exp.pop(6)
196-
exp.pop(6)
197192
exp = '\n'.join(exp)
198193
self.assertRegex(response.body.decode('ascii'), exp)
199194

@@ -244,7 +239,7 @@ def test_download_raw_data(self):
244239
'- 58 /protected/raw_data/'
245240
'1_s_G1_L001_sequences_barcodes.fastq.gz '
246241
'raw_data/1_s_G1_L001_sequences_barcodes.fastq.gz\n'
247-
'- [0-9]* /protected/templates/1_prep_1_[0-9]*-[0-9]*.txt '
242+
'- [0-9]* /protected/templates/1_prep_1_qiime_[0-9]*-[0-9]*.txt '
248243
'mapping_files/1_mapping_file.txt\n'
249244
'- 1093210 /protected/BIOM/7/biom_table.biom '
250245
'BIOM/7/biom_table.biom\n')
@@ -273,8 +268,8 @@ def test_download_raw_data(self):
273268
return_value=User("[email protected]"))
274269
response = self.get('/download_study_bioms/1')
275270
self.assertEqual(response.code, 200)
276-
exp = ('- [0-9]* /protected/templates/1_prep_2_[0-9]*-[0-9]*.txt '
277-
'mapping_files/7_mapping_file.txt\n')
271+
exp = ('- [0-9]* /protected/BIOM/7/biom_table.biom '
272+
'BIOM/7/biom_table.biom\n')
278273
self.assertRegex(response.body.decode('ascii'), exp)
279274

280275

@@ -405,17 +400,16 @@ def test_download(self):
405400
# check success
406401
response = self.get('/public_download/?data=biom&study_id=1')
407402
self.assertEqual(response.code, 200)
408-
exp = ('- [0-9]* /protected/templates/1_prep_2_[0-9]*-[0-9]*.txt '
409-
'mapping_files/7_mapping_file.txt\n')
403+
exp = ('- [0-9]* /protected/BIOM/7/biom_table.biom'
404+
' BIOM/7/biom_table.biom\n')
410405
self.assertRegex(response.body.decode('ascii'), exp)
411406

412407
Study(1).public_raw_download = True
413408
# check success
414409
response = self.get('/public_download/?data=raw&study_id=1')
415410
self.assertEqual(response.code, 200)
416-
exp = (
417-
'- [0-9]* /protected/templates/1_prep_2_[0-9]*-[0-9]*.txt '
418-
'mapping_files/7_mapping_file.txt\n')
411+
exp = ('- [0-9]* /protected/BIOM/7/biom_table.biom'
412+
' BIOM/7/biom_table.biom\n')
419413
self.assertRegex(response.body.decode('ascii'), exp)
420414

421415
# testing data_type
@@ -447,7 +441,7 @@ def test_download(self):
447441
exp = (
448442
'[0-9]* [0-9]* /protected/raw_data/1_s_G1_L001_sequences_barcodes'
449443
'.fastq.gz raw_data/1_s_G1_L001_sequences_barcodes.fastq.gz\n'
450-
'- [0-9]* /protected/templates/1_prep_1_[0-9]*-[0-9]*.txt '
444+
'- [0-9]* /protected/templates/1_prep_1_qiime_19700101-000000.txt '
451445
'mapping_files/1_mapping_file.txt')
452446
self.assertRegex(response.body.decode('ascii'), exp)
453447

@@ -458,11 +452,12 @@ def test_download(self):
458452
'- [0-9]* /protected/processed_data/1_study_1001_closed_'
459453
'reference_otu_table.biom processed_data/1_study_1001_closed_'
460454
'reference_otu_table.biom\n- [0-9]* /protected/templates/1_prep_'
461-
'1_[0-9]*-[0-9]*.txt mapping_files/4_mapping_file.txt\n'
455+
'1_qiime_19700101-000000.txt mapping_files/4_mapping_file.txt\n'
462456
'- [0-9]* /protected/processed_data/1_study_1001_closed_'
463457
'reference_otu_table.biom processed_data/1_study_1001_closed_'
464-
'reference_otu_table.biom\n- [0-9]* /protected/templates/1_prep_1'
465-
'_[0-9]*-[0-9]*.txt mapping_files/5_mapping_file.txt\n')
458+
'reference_otu_table.biom\n- [0-9]* /protected/templates/1_prep_'
459+
'1_qiime_19700101-000000.txt mapping_files/5_mapping_file.txt\n')
460+
466461
self.assertRegex(response.body.decode('ascii'), exp)
467462

468463
def test_download_sample_information(self):
@@ -506,8 +501,8 @@ def test_download_sample_information(self):
506501
response = self.get(
507502
'/public_download/?data=prep_information&prep_id=1')
508503
self.assertEqual(response.code, 200)
509-
exp = ('[0-9]* [0-9]* /protected/templates/1_prep_1_[0-9]*-[0-9]'
510-
'*.txt templates/1_prep_1_[0-9]*-[0-9]*.txt\n')
504+
exp = ('- [0-9]* /protected/templates/1_prep_1_qiime_[0-9]*-[0-9]'
505+
'*.txt templates/1_prep_1_qiime_[0-9]*-[0-9]*.txt\n')
511506
self.assertRegex(response.body.decode('ascii'), exp)
512507

513508

@@ -536,7 +531,7 @@ def test_download(self):
536531
'- [0-9]* /protected/processed_data/'
537532
'1_study_1001_closed_reference_otu_table.biom '
538533
'processed_data/1_study_1001_closed_reference_otu_table.biom\n'
539-
'- [0-9]* /protected/templates/1_prep_1_[0-9]*-[0-9]*.txt '
534+
'- [0-9]* /protected/templates/1_prep_1_qiime_19700101-000000.txt '
540535
'mapping_files/5_mapping_file.txt')
541536
self.assertRegex(response.body.decode('ascii'), exp)
542537

@@ -557,13 +552,12 @@ def test_download(self):
557552
o = urlparse(resp_dict["url"])
558553
response_file = self.get(o.path)
559554
self.assertEqual(response_file.code, 200)
560-
561555
exp = (
562556
'- 58 /protected/raw_data/1_s_G1_L001_sequences.fastq.gz '
563557
'raw_data/1_s_G1_L001_sequences.fastq.gz\n'
564558
'- 58 /protected/raw_data/1_s_G1_L001_sequences_barcodes.'
565559
'fastq.gz raw_data/1_s_G1_L001_sequences_barcodes.fastq.gz\n'
566-
'- [0-9]* /protected/templates/1_prep_1_[0-9]*-[0-9]*.txt '
560+
'- [0-9]* /protected/templates/1_prep_1_qiime_19700101-000000.txt '
567561
'mapping_files/1_mapping_file.txt\n'
568562
)
569563
self.assertRegex(response_file.body.decode('ascii'), exp)

0 commit comments

Comments
 (0)