Skip to content

Commit 1258155

Browse files
committed
Merge branch 'fix-1084' of https://github.com/biocore/qiita into 1084-qiita-pet
2 parents f65e9da + 23b12be commit 1258155

File tree

7 files changed

+22
-24
lines changed

7 files changed

+22
-24
lines changed

qiita_db/commands.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ def load_sample_template_from_cmd(sample_temp_path, study_id):
153153
return SampleTemplate.create(sample_temp, Study(study_id))
154154

155155

156-
def load_prep_template_from_cmd(prep_temp_path, study_id,
157-
data_type):
156+
def load_prep_template_from_cmd(prep_temp_path, study_id, data_type):
158157
r"""Adds a prep template to the database
159158
160159
Parameters

qiita_db/data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ def create(cls, filetype, prep_templates, filepaths):
307307
308308
Raises
309309
------
310-
IncompetentQiitaDeveloperError
310+
QiitaDBError
311311
If any of the passed prep templates already have a raw data id
312312
"""
313313
conn_handler = SQLConnectionHandler()
314-
# We first need to check if the passed prep templates doesn't have
314+
# We first need to check if the passed prep templates don't have
315315
# a raw data already attached to them
316316
sql = """SELECT EXISTS(
317317
SELECT *
@@ -322,7 +322,7 @@ def create(cls, filetype, prep_templates, filepaths):
322322
exists = conn_handler.execute_fetchone(
323323
sql, [pt.id for pt in prep_templates])[0]
324324
if exists:
325-
raise IncompetentQiitaDeveloperError(
325+
raise QiitaDBError(
326326
"Cannot create raw data because the passed prep templates "
327327
"already have a raw data associated with it. "
328328
"Prep templates: %s"

qiita_db/metadata_template/prep_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def create(cls, md_template, study, data_type, investigation_type=None):
108108

109109
# Get a connection handler
110110
conn_handler = SQLConnectionHandler()
111-
queue_name = "CREATE_PREP_TEMPLATE_%d" % study.id
111+
queue_name = "CREATE_PREP_TEMPLATE_%d_%d" % (study.id, id(md_template))
112112
conn_handler.create_queue(queue_name)
113113

114114
# Check if the data_type is the id or the string

qiita_db/metadata_template/test/test_prep_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ def test_raw_data_setter(self):
13411341
self.data_type_id)
13421342
self.assertEqual(pt.raw_data, None)
13431343
pt.raw_data = rd
1344-
self.assertEqual(pt.raw_data, 1)
1344+
self.assertEqual(pt.raw_data, rd.id)
13451345

13461346

13471347
EXP_PREP_TEMPLATE = (

qiita_db/support_files/patches/python_patches/25.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# May 19, 2015
22
# We attach the prep template directly to the study. The raw data is no longer
3-
# attached to the study directly, the prep template point to them. This will
3+
# attached to the study directly, the prep template points to them. This will
44
# make the RawData to be effectively just a container for the raw files,
55
# which is how it was acting previously.
66

@@ -47,7 +47,7 @@
4747

4848
conn_handler.add_to_queue(queue, sql_delete, (rd_id,))
4949

50-
# We can now perform all changes in the DB. Although this changes can be
50+
# We can now perform all changes in the DB. Although these changes can be
5151
# done in an SQL patch, they are done here because we need to execute the
5252
# previous clean up in the database before we can actually execute the SQL
5353
# patch.

qiita_db/test/test_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_create(self):
128128
self.assertEqual(obs, [[exp_id, top_id - 1], [exp_id, top_id]])
129129

130130
def test_create_error(self):
131-
with self.assertRaises(IncompetentQiitaDeveloperError):
131+
with self.assertRaises(QiitaDBError):
132132
RawData.create(self.filetype, [PrepTemplate(1)], self.filepaths)
133133

134134
def test_get_filepaths(self):

qiita_ware/test/test_processing_pipeline.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ def setUp(self):
7171
self.sff_prep_template = PrepTemplate.create(md, study, "16S")
7272

7373
tmp_dir = mkdtemp()
74-
path_builder = partial(join, tmp_dir)
75-
fp1 = path_builder('preprocess_test1.sff')
74+
self.path_builder = partial(join, tmp_dir)
75+
fp1 = self.path_builder('preprocess_test1.sff')
7676
with open(fp1, 'w') as f:
7777
f.write('\n')
78-
fp2 = path_builder('preprocess_test2.sff')
78+
fp2 = self.path_builder('preprocess_test2.sff')
7979
with open(fp2, 'w') as f:
8080
f.write('\n')
81-
fps = [(fp1, 17), (fp2, 17)]
81+
self.raw_sff_id = convert_to_id('raw_sff', 'filepath_type')
82+
fps = [(fp1, self.raw_sff_id), (fp2, self.raw_sff_id)]
8283

8384
# Magic number 1: is the filetype id
8485
self.raw_data = RawData.create(1, [self.sff_prep_template], fps)
@@ -89,14 +90,13 @@ def setUp(self):
8990
md_rp = pd.DataFrame.from_dict(md_dict, orient='index')
9091
self.sff_prep_template_rp = PrepTemplate.create(md_rp, study, "16S")
9192

92-
path_builder = partial(join, tmp_dir)
93-
rp_fp1 = path_builder('preprocess_test1.sff')
93+
rp_fp1 = self.path_builder('preprocess_test1.sff')
9494
with open(rp_fp1, 'w') as f:
9595
f.write('\n')
96-
rp_fp2 = path_builder('preprocess_test2.sff')
96+
rp_fp2 = self.path_builder('preprocess_test2.sff')
9797
with open(rp_fp2, 'w') as f:
9898
f.write('\n')
99-
fps = [(rp_fp1, 17), (rp_fp2, 17)]
99+
fps = [(rp_fp1, self.raw_sff_id), (rp_fp2, self.raw_sff_id)]
100100

101101
# Magic number 1: is the filetype id
102102
self.raw_data_rp = RawData.create(1, [self.sff_prep_template_rp], fps)
@@ -355,7 +355,7 @@ def test_get_preprocess_fasta_cmd_sff_run_prefix_match(self):
355355
f.write('\n')
356356
self.files_to_remove.append(fp)
357357
self.dirs_to_remove.append(tmp_dir)
358-
self.raw_data_rp.add_filepaths([(fp, 17)])
358+
self.raw_data_rp.add_filepaths([(fp, self.raw_sff_id)])
359359
params = Preprocessed454Params(1)
360360

361361
obs_cmd, obs_output_dir = _get_preprocess_fasta_cmd(
@@ -385,17 +385,16 @@ def test_get_preprocess_fasta_cmd_sff_run_prefix_match(self):
385385
def test_get_preprocess_fasta_cmd_sff_run_prefix_match_error_1(self):
386386
# Test that the run prefixes in the prep_template and the file names
387387
# actually match and raise an error if not
388-
tmp_dir = mkdtemp()
389-
fp = join(tmp_dir, 'new.sff')
388+
fp = self.path_builder('new.sff')
390389
with open(fp, 'w') as f:
391390
f.write('\n')
392391
self.files_to_remove.append(fp)
393-
fp_error = join(tmp_dir, 'error.sff')
392+
fp_error = self.path_builder('error.sff')
394393
with open(fp_error, 'w') as f:
395394
f.write('\n')
396395
self.files_to_remove.append(fp_error)
397-
self.dirs_to_remove.append(tmp_dir)
398-
self.raw_data_rp.add_filepaths([(fp, 17), (fp_error, 17)])
396+
self.raw_data_rp.add_filepaths(
397+
[(fp, self.raw_sff_id), (fp_error, self.raw_sff_id)])
399398
params = Preprocessed454Params(1)
400399
with self.assertRaises(ValueError):
401400
_get_preprocess_fasta_cmd(

0 commit comments

Comments
 (0)