Skip to content

Commit 157b60a

Browse files
committed
Adding qiime-map property to the prep template
1 parent 658a5b5 commit 157b60a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

qiita_db/metadata_template/prep_template.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,3 +505,25 @@ def status(self):
505505
pd_statuses = conn_handler.execute_fetchall(sql, (self._id,))
506506

507507
return infer_status(pd_statuses)
508+
509+
@property
510+
def qiime_map_fp(self):
511+
"""The QIIME mapping file path of the prep template
512+
513+
Returns
514+
-------
515+
str
516+
The filepath of the QIIME mapping file
517+
"""
518+
conn_handler = SQLConnectionHandler()
519+
520+
sql = """SELECT filepath_id, filepath
521+
FROM qiita.filepath
522+
JOIN qiita.{0} USING (filepath_id)
523+
JOIN qiita.filepath_type USING (filepath_type_id)
524+
WHERE {1} = %s AND filepath_type = 'qiime_map'
525+
ORDER BY filepath_id DESC""".format(self._filepath_table,
526+
self._id_column)
527+
fn = conn_handler.execute_fetchall(sql, (self._id,))[0][1]
528+
base_dir = get_mountpoint('templates')[0][1]
529+
return join(base_dir, fn)

qiita_db/metadata_template/test/test_prep_template.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,12 @@ def test_update_category(self):
12931293
self.assertEqual(self.tester['1.SKB8.640193']['center_name'], 'FOO')
12941294
self.assertEqual(self.tester['1.SKD8.640184']['center_name'], 'BAR')
12951295

1296+
def test_qiime_map_fp(self):
1297+
pt = PrepTemplate(1)
1298+
exp = join(get_mountpoint('templates')[0][1],
1299+
'1_prep_1_qiime_19700101-000000.txt')
1300+
self.assertEqual(pt.qiime_map_fp, exp)
1301+
12961302

12971303
EXP_PREP_TEMPLATE = (
12981304
'sample_name\tbarcodesequence\tcenter_name\tcenter_project_name\t'

0 commit comments

Comments
 (0)