Skip to content

Commit 3aa8f73

Browse files
committed
Merge pull request #1055 from josenavas/remove-add-category
Removing add_category function
2 parents 0d65c9d + 9c80092 commit 3aa8f73

File tree

2 files changed

+0
-76
lines changed

2 files changed

+0
-76
lines changed

qiita_db/metadata_template/sample_template.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -336,37 +336,3 @@ def update(self, md_template):
336336
# word qiime within the name of the file
337337
if '_qiime_' not in basename(fp):
338338
pt.create_qiime_mapping_file(fp)
339-
340-
def add_category(self, category, samples_and_values, dtype, default):
341-
"""Add a metadata category
342-
343-
Parameters
344-
----------
345-
category : str
346-
The category to add
347-
samples_and_values : dict
348-
A mapping of {sample_id: value}
349-
dtype : str
350-
The datatype of the column
351-
default : object
352-
The default value associated with the column. This must be
353-
specified as these columns are added "not null".
354-
355-
Raises
356-
------
357-
QiitaDBDuplicateError
358-
If the column already exists
359-
"""
360-
table_name = self._table_name(self.study_id)
361-
conn_handler = SQLConnectionHandler()
362-
363-
if category in self.categories():
364-
raise QiitaDBDuplicateError(category, "N/A")
365-
366-
conn_handler.execute("""
367-
ALTER TABLE qiita.{0}
368-
ADD COLUMN {1} {2}
369-
NOT NULL DEFAULT '{3}'""".format(table_name, category, dtype,
370-
default))
371-
372-
self.update_category(category, samples_and_values)

qiita_db/metadata_template/test/test_sample_template.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,48 +1286,6 @@ def test_update(self):
12861286
with self.assertRaises(QiitaDBError):
12871287
st.update(self.metadata_dict_updated_column_error)
12881288

1289-
def test_add_category(self):
1290-
column = "new_column"
1291-
dtype = "varchar"
1292-
default = "stuff"
1293-
mapping = {'1.SKB1.640202': "1",
1294-
'1.SKB5.640181': "2",
1295-
'1.SKD6.640190': "3"}
1296-
1297-
exp = {
1298-
'1.SKB1.640202': "1",
1299-
'1.SKB2.640194': "stuff",
1300-
'1.SKB3.640195': "stuff",
1301-
'1.SKB4.640189': "stuff",
1302-
'1.SKB5.640181': "2",
1303-
'1.SKB6.640176': "stuff",
1304-
'1.SKB7.640196': "stuff",
1305-
'1.SKB8.640193': "stuff",
1306-
'1.SKB9.640200': "stuff",
1307-
'1.SKD1.640179': "stuff",
1308-
'1.SKD2.640178': "stuff",
1309-
'1.SKD3.640198': "stuff",
1310-
'1.SKD4.640185': "stuff",
1311-
'1.SKD5.640186': "stuff",
1312-
'1.SKD6.640190': "3",
1313-
'1.SKD7.640191': "stuff",
1314-
'1.SKD8.640184': "stuff",
1315-
'1.SKD9.640182': "stuff",
1316-
'1.SKM1.640183': "stuff",
1317-
'1.SKM2.640199': "stuff",
1318-
'1.SKM3.640197': "stuff",
1319-
'1.SKM4.640180': "stuff",
1320-
'1.SKM5.640177': "stuff",
1321-
'1.SKM6.640187': "stuff",
1322-
'1.SKM7.640188': "stuff",
1323-
'1.SKM8.640201': "stuff",
1324-
'1.SKM9.640192': "stuff"}
1325-
1326-
self.tester.add_category(column, mapping, dtype, default)
1327-
1328-
obs = {k: v['new_column'] for k, v in self.tester.items()}
1329-
self.assertEqual(obs, exp)
1330-
13311289
def test_to_file(self):
13321290
"""to file writes a tab delimited file with all the metadata"""
13331291
fd, fp = mkstemp()

0 commit comments

Comments
 (0)