Skip to content

Add qiime map func #1109

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

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
22 changes: 22 additions & 0 deletions qiita_db/metadata_template/prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,25 @@ def status(self):
pd_statuses = conn_handler.execute_fetchall(sql, (self._id,))

return infer_status(pd_statuses)

@property
def qiime_map_fp(self):
"""The QIIME mapping file path of the prep template

Returns
-------
str
The filepath of the QIIME mapping file
"""
conn_handler = SQLConnectionHandler()

sql = """SELECT filepath_id, filepath
FROM qiita.filepath
JOIN qiita.{0} USING (filepath_id)
JOIN qiita.filepath_type USING (filepath_type_id)
WHERE {1} = %s AND filepath_type = 'qiime_map'
ORDER BY filepath_id DESC""".format(self._filepath_table,
self._id_column)
fn = conn_handler.execute_fetchall(sql, (self._id,))[0][1]
base_dir = get_mountpoint('templates')[0][1]
return join(base_dir, fn)
6 changes: 6 additions & 0 deletions qiita_db/metadata_template/test/test_prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,12 @@ def test_update_category(self):
self.assertEqual(self.tester['1.SKB8.640193']['center_name'], 'FOO')
self.assertEqual(self.tester['1.SKD8.640184']['center_name'], 'BAR')

def test_qiime_map_fp(self):
pt = PrepTemplate(1)
exp = join(get_mountpoint('templates')[0][1],
'1_prep_1_qiime_19700101-000000.txt')
self.assertEqual(pt.qiime_map_fp, exp)


EXP_PREP_TEMPLATE = (
'sample_name\tbarcode\tcenter_name\tcenter_project_name\t'
Expand Down
19 changes: 11 additions & 8 deletions qiita_ware/test/test_processing_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,20 @@ def test_get_preprocess_fasta_cmd_sff_run_prefix(self):
def test_get_preprocess_fasta_cmd_sff_run_prefix_match(self):
# Test that the run prefixes in the prep_template and the file names
# actually match and raise an error if not
new_fp_id = get_count('qiita.filepath') + 1
conn_handler = SQLConnectionHandler()
sql = ("""
INSERT INTO qiita.filepath (filepath_id, filepath,
filepath_type_id, checksum, checksum_algorithm_id,
data_directory_id) VALUES (19, '1_new.sff', 17, 852952723, 1,
data_directory_id) VALUES (%s, '1_new.sff', 17, 852952723, 1,
5);
INSERT INTO qiita.raw_filepath (raw_data_id , filepath_id) VALUES
(3, 19);
(3, %s);
UPDATE qiita.prep_1 SET run_prefix='preprocess_test';
UPDATE qiita.prep_1 SET run_prefix='new' WHERE
sample_id = '1.SKB8.640193';
""")
conn_handler.execute(sql)
conn_handler.execute(sql, (new_fp_id, new_fp_id))

raw_data = RawData(3)
params = Preprocessed454Params(1)
Expand Down Expand Up @@ -287,25 +288,27 @@ def test_get_preprocess_fasta_cmd_sff_run_prefix_match(self):
def test_get_preprocess_fasta_cmd_sff_run_prefix_match_error_1(self):
# Test that the run prefixes in the prep_template and the file names
# actually match and raise an error if not
fp_count = get_count('qiita.filepath')
conn_handler = SQLConnectionHandler()
sql = ("""
INSERT INTO qiita.filepath (filepath_id, filepath,
filepath_type_id, checksum, checksum_algorithm_id,
data_directory_id) VALUES (19, '1_new.sff', 17, 852952723, 1,
data_directory_id) VALUES (%s, '1_new.sff', 17, 852952723, 1,
5);
INSERT INTO qiita.raw_filepath (raw_data_id , filepath_id) VALUES
(3, 19);
(3, %s);
INSERT INTO qiita.filepath (filepath_id, filepath,
filepath_type_id, checksum, checksum_algorithm_id,
data_directory_id) VALUES (20, '1_error.sff', 17, 852952723,
data_directory_id) VALUES (%s, '1_error.sff', 17, 852952723,
1, 5);
INSERT INTO qiita.raw_filepath (raw_data_id , filepath_id) VALUES
(3, 20);
(3, %s);
UPDATE qiita.prep_1 SET run_prefix='preprocess_test';
UPDATE qiita.prep_1 SET run_prefix='new' WHERE
sample_id = '1.SKB8.640193';
""")
conn_handler.execute(sql)
conn_handler.execute(
sql, (fp_count + 1, fp_count + 1, fp_count + 2, fp_count + 2))

raw_data = RawData(3)
params = Preprocessed454Params(1)
Expand Down
6 changes: 3 additions & 3 deletions qiita_ware/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def test_hdf5IO_open(self):
('Diesel Rhizo', 3),
('Diesel Root', 3),
('Diesel bulk', 3)],
'dna_extracted': [('True', 27)],
'ebi_study_accession': [('None', 27)],
'ebi_submission_accession': [('None', 27)],
'elevation': [('114.0', 27)],
Expand All @@ -288,8 +289,6 @@ def test_hdf5IO_open(self):
'experiment_design_description': [('micro biome of soil and rhizosphere '
'of cannabis plants from CA', 27)],
'experiment_title': [('Cannabis Soil Microbiome', 27)],
'has_extracted_data': [('True', 27)],
'has_physical_specimen': [('True', 27)],
'host_subject_id': [('1001:B1', 1),
('1001:B2', 1),
('1001:B3', 1),
Expand Down Expand Up @@ -397,7 +396,8 @@ def test_hdf5IO_open(self):
('96.0693176066', 1)],
'pcr_primers': [('FWD:GTGCCAGCMGCCGCGGTAA; REV:GGACTACHVGGGTWTCTAAT', 27)],
'ph': [('6.8', 9), ('6.82', 10), ('6.94', 8)],
'physical_location': [('ANL', 27)],
'physical_specimen_location': [('ANL', 27)],
'physical_specimen_remaining': [('True', 27)],
'platform': [('Illumina', 27)],
'required_sample_info_status': [('completed', 27)],
'run_center': [('ANL', 27)],
Expand Down