Skip to content

Commit 77afb1c

Browse files
committed
Merge branch 'master' of github.com:qiime/QiiTa into unify-template-validation
2 parents 040d9fe + 12f48f9 commit 77afb1c

File tree

6 files changed

+73
-106
lines changed

6 files changed

+73
-106
lines changed

qiita_db/metadata_template/base_metadata_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ def _add_common_creation_steps_to_queue(cls, md_template, obj_id,
621621
headers = list(md_template.keys())
622622

623623
# Get the required columns from the DB
624-
db_cols = get_table_cols(cls._table, conn_handler)
624+
db_cols = sorted(get_table_cols(cls._table, conn_handler))
625625
# Remove the sample_id and _id_column columns
626626
db_cols.remove('sample_id')
627627
db_cols.remove(cls._id_column)
@@ -640,7 +640,7 @@ def _add_common_creation_steps_to_queue(cls, md_template, obj_id,
640640
values, many=True)
641641

642642
# Insert rows on *_columns table
643-
headers = list(set(headers).difference(db_cols))
643+
headers = sorted(set(headers).difference(db_cols))
644644
datatypes = get_datatypes(md_template.ix[:, headers])
645645
# psycopg2 requires a list of tuples, in which each tuple is a set
646646
# of values to use in the string formatting of the query. We have all

qiita_db/metadata_template/sample_template.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -413,32 +413,6 @@ def update(self, md_template):
413413
if '_qiime_' not in basename(fp):
414414
pt.create_qiime_mapping_file(fp)
415415

416-
def remove_category(self, category):
417-
"""Remove a category from the sample template
418-
419-
Parameters
420-
----------
421-
category : str
422-
The category to remove
423-
424-
Raises
425-
------
426-
QiitaDBColumnError
427-
If the column does not exist in the table
428-
"""
429-
table_name = self._table_name(self.study_id)
430-
conn_handler = SQLConnectionHandler()
431-
432-
if category not in self.categories():
433-
raise QiitaDBColumnError("Column %s does not exist in %s" %
434-
(category, table_name))
435-
436-
# This operation may invalidate another user's perspective on the
437-
# table
438-
conn_handler.execute("""
439-
ALTER TABLE qiita.{0} DROP COLUMN {1}""".format(table_name,
440-
category))
441-
442416
def update_category(self, category, samples_and_values):
443417
"""Update an existing column
444418

qiita_db/metadata_template/test/test_prep_template.py

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -582,39 +582,40 @@ def test_add_common_creation_steps_to_queue(self):
582582
'VALUES (%s, %s, %s)')
583583

584584
sql_create_table = (
585-
'CREATE TABLE qiita.prep_2 '
586-
'(sample_id varchar NOT NULL, str_column varchar, '
587-
'run_prefix varchar, barcodesequence varchar, platform varchar, '
588-
'linkerprimersequence varchar, '
589-
'experiment_design_description varchar, '
590-
'library_construction_protocol varchar)')
585+
'CREATE TABLE qiita.prep_2 (sample_id varchar NOT NULL, '
586+
'barcodesequence varchar, experiment_design_description varchar, '
587+
'library_construction_protocol varchar, '
588+
'linkerprimersequence varchar, platform varchar, '
589+
'run_prefix varchar, str_column varchar)')
591590

592591
sql_insert_dynamic = (
593592
'INSERT INTO qiita.prep_2 '
594-
'(sample_id, str_column, run_prefix, barcodesequence, platform, '
595-
'linkerprimersequence, experiment_design_description, '
596-
'library_construction_protocol) '
593+
'(sample_id, barcodesequence, experiment_design_description, '
594+
'library_construction_protocol, linkerprimersequence, platform, '
595+
'run_prefix, str_column) '
597596
'VALUES (%s, %s, %s, %s, %s, %s, %s, %s)')
598597

599598
sql_insert_dynamic_params_1 = (
600-
'2.SKB8.640193', 'Value for sample 1', 's_G1_L001_sequences',
601-
'GTCCGCAAGTTA', 'ILLUMINA', 'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA')
599+
'2.SKB8.640193', 'GTCCGCAAGTTA', 'BBBB', 'AAAA',
600+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
601+
'Value for sample 1')
602602
sql_insert_dynamic_params_2 = (
603-
'2.SKD8.640184', 'Value for sample 2', 's_G1_L001_sequences',
604-
'CGTAGAGCTCTC', 'ILLUMINA', 'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA')
603+
'2.SKD8.640184', 'CGTAGAGCTCTC', 'BBBB', 'AAAA',
604+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
605+
'Value for sample 2')
605606

606607
exp = [
607608
(sql_insert_common, sql_insert_common_params_1),
608609
(sql_insert_common, sql_insert_common_params_2),
609-
(sql_insert_prep_columns, (2, 'str_column', 'varchar')),
610-
(sql_insert_prep_columns, (2, 'run_prefix', 'varchar')),
611610
(sql_insert_prep_columns, (2, 'barcodesequence', 'varchar')),
612-
(sql_insert_prep_columns, (2, 'platform', 'varchar')),
613-
(sql_insert_prep_columns, (2, 'linkerprimersequence', 'varchar')),
614611
(sql_insert_prep_columns,
615612
(2, 'experiment_design_description', 'varchar')),
616613
(sql_insert_prep_columns,
617614
(2, 'library_construction_protocol', 'varchar')),
615+
(sql_insert_prep_columns, (2, 'linkerprimersequence', 'varchar')),
616+
(sql_insert_prep_columns, (2, 'platform', 'varchar')),
617+
(sql_insert_prep_columns, (2, 'run_prefix', 'varchar')),
618+
(sql_insert_prep_columns, (2, 'str_column', 'varchar')),
618619
(sql_create_table, None),
619620
(sql_insert_dynamic, sql_insert_dynamic_params_1),
620621
(sql_insert_dynamic, sql_insert_dynamic_params_2)]
@@ -877,17 +878,20 @@ def test_create(self):
877878
# The new table hosts the correct values
878879
obs = self.conn_handler.execute_fetchall(
879880
"SELECT * FROM qiita.prep_2")
880-
# sample_id, study_id, str_column, ebi_submission_accession,
881-
# run_prefix, barcodesequence, linkerprimersequence
882-
exp = [['1.SKB7.640196', 'Value for sample 3', 'ILLUMINA',
883-
's_G1_L002_sequences', 'CCTCTGAGAGCT', None,
884-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
885-
['1.SKB8.640193', 'Value for sample 1', 'ILLUMINA',
886-
's_G1_L001_sequences', 'GTCCGCAAGTTA', None,
887-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
888-
['1.SKD8.640184', 'Value for sample 2', 'ILLUMINA',
889-
's_G1_L001_sequences', 'CGTAGAGCTCTC', None,
890-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA']]
881+
882+
# barcodesequence, ebi_submission_accession,
883+
# experiment_design_description, library_construction_protocol,
884+
# linkerprimersequence, platform, run_prefix, str_column
885+
exp = [['1.SKB7.640196', 'CCTCTGAGAGCT', None, 'BBBB', 'AAAA',
886+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L002_sequences',
887+
'Value for sample 3'],
888+
['1.SKB8.640193', 'GTCCGCAAGTTA', None, 'BBBB', 'AAAA',
889+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
890+
'Value for sample 1'],
891+
['1.SKD8.640184', 'CGTAGAGCTCTC', None, 'BBBB', 'AAAA',
892+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
893+
'Value for sample 2']]
894+
891895
self.assertEqual(sorted(obs), sorted(exp))
892896

893897
# prep and qiime files have been created
@@ -941,17 +945,18 @@ def test_create_already_prefixed_samples(self):
941945
# The new table hosts the correct values
942946
obs = self.conn_handler.execute_fetchall(
943947
"SELECT * FROM qiita.prep_2")
944-
# sample_id, study_id, str_column, ebi_submission_accession,
945-
# run_prefix, barcodesequence, linkerprimersequence
946-
exp = [['1.SKB7.640196', 'Value for sample 3', 'ILLUMINA',
947-
's_G1_L002_sequences', 'CCTCTGAGAGCT', None,
948-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
949-
['1.SKB8.640193', 'Value for sample 1', 'ILLUMINA',
950-
's_G1_L001_sequences', 'GTCCGCAAGTTA', None,
951-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
952-
['1.SKD8.640184', 'Value for sample 2', 'ILLUMINA',
953-
's_G1_L001_sequences', 'CGTAGAGCTCTC', None,
954-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA']]
948+
# barcodesequence, ebi_submission_accession,
949+
# experiment_design_description, library_construction_protocol,
950+
# linkerprimersequence, platform, run_prefix, str_column
951+
exp = [['1.SKB7.640196', 'CCTCTGAGAGCT', None, 'BBBB', 'AAAA',
952+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L002_sequences',
953+
'Value for sample 3'],
954+
['1.SKB8.640193', 'GTCCGCAAGTTA', None, 'BBBB', 'AAAA',
955+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
956+
'Value for sample 1'],
957+
['1.SKD8.640184', 'CGTAGAGCTCTC', None, 'BBBB', 'AAAA',
958+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
959+
'Value for sample 2']]
955960
self.assertEqual(sorted(obs), sorted(exp))
956961

957962
# prep and qiime files have been created
@@ -1042,17 +1047,18 @@ def test_create_data_type_id(self):
10421047
# The new table hosts the correct values
10431048
obs = self.conn_handler.execute_fetchall(
10441049
"SELECT * FROM qiita.prep_2")
1045-
# sample_id, str_column, ebi_submission_accession,
1046-
# run_prefix, barcodesequence, linkerprimersequence
1047-
exp = [['1.SKB7.640196', 'Value for sample 3', 'ILLUMINA',
1048-
's_G1_L002_sequences', 'CCTCTGAGAGCT', None,
1049-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
1050-
['1.SKB8.640193', 'Value for sample 1', 'ILLUMINA',
1051-
's_G1_L001_sequences', 'GTCCGCAAGTTA', None,
1052-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
1053-
['1.SKD8.640184', 'Value for sample 2', 'ILLUMINA',
1054-
's_G1_L001_sequences', 'CGTAGAGCTCTC', None,
1055-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA']]
1050+
# barcodesequence, ebi_submission_accession,
1051+
# experiment_design_description, library_construction_protocol,
1052+
# linkerprimersequence, platform, run_prefix, str_column
1053+
exp = [['1.SKB7.640196', 'CCTCTGAGAGCT', None, 'BBBB', 'AAAA',
1054+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L002_sequences',
1055+
'Value for sample 3'],
1056+
['1.SKB8.640193', 'GTCCGCAAGTTA', None, 'BBBB', 'AAAA',
1057+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
1058+
'Value for sample 1'],
1059+
['1.SKD8.640184', 'CGTAGAGCTCTC', None, 'BBBB', 'AAAA',
1060+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
1061+
'Value for sample 2']]
10561062
self.assertEqual(sorted(obs), sorted(exp))
10571063

10581064
def test_create_error(self):

qiita_db/metadata_template/test/test_sample_template.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -803,23 +803,20 @@ def test_add_common_creation_steps_to_queue(self):
803803

804804
sql_insert_required = (
805805
'INSERT INTO qiita.required_sample_info '
806-
'(study_id, sample_id, physical_location, has_physical_specimen, '
807-
'has_extracted_data, sample_type, required_sample_info_status_id, '
808-
'collection_timestamp, host_subject_id, description, latitude, '
809-
'longitude) '
806+
'(study_id, sample_id, collection_timestamp, description, '
807+
'has_extracted_data, has_physical_specimen, host_subject_id, '
808+
'latitude, longitude, physical_location, '
809+
'required_sample_info_status_id, sample_type) '
810810
'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)')
811811
sql_insert_required_params_1 = (
812-
2, '2.Sample1', 'location1', True, True, 'type1', 1,
813-
datetime(2014, 5, 29, 12, 24, 51), 'NotIdentified',
814-
'Test Sample 1', 42.42, 41.41)
812+
2, '2.Sample1', datetime(2014, 5, 29, 12, 24, 51), 'Test Sample 1',
813+
True, True, 'NotIdentified', 42.42, 41.41, 'location1', 1, 'type1')
815814
sql_insert_required_params_2 = (
816-
2, '2.Sample2', 'location1', True, True, 'type1', 1,
817-
datetime(2014, 5, 29, 12, 24, 51), 'NotIdentified',
818-
'Test Sample 2', 4.2, 1.1)
815+
2, '2.Sample2', datetime(2014, 5, 29, 12, 24, 51), 'Test Sample 2',
816+
True, True, 'NotIdentified', 4.2, 1.1, 'location1', 1, 'type1')
819817
sql_insert_required_params_3 = (
820-
2, '2.Sample3', 'location1', True, True, 'type1', 1,
821-
datetime(2014, 5, 29, 12, 24, 51), 'NotIdentified',
822-
'Test Sample 3', 4.8, 4.41)
818+
2, '2.Sample3', datetime(2014, 5, 29, 12, 24, 51), 'Test Sample 3',
819+
True, True, 'NotIdentified', 4.8, 4.41, 'location1', 1, 'type1')
823820

824821
sql_insert_sample_cols = (
825822
'INSERT INTO qiita.study_sample_columns '
@@ -1327,18 +1324,6 @@ def test_add_category(self):
13271324
obs = {k: v['new_column'] for k, v in self.tester.items()}
13281325
self.assertEqual(obs, exp)
13291326

1330-
def test_remove_category(self):
1331-
with self.assertRaises(QiitaDBColumnError):
1332-
self.tester.remove_category('does not exist')
1333-
1334-
for v in self.tester.values():
1335-
self.assertIn('elevation', v)
1336-
1337-
self.tester.remove_category('elevation')
1338-
1339-
for v in self.tester.values():
1340-
self.assertNotIn('elevation', v)
1341-
13421327
def test_to_file(self):
13431328
"""to file writes a tab delimited file with all the metadata"""
13441329
fd, fp = mkstemp()

qiita_pet/templates/analysis_waiting.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
<script src="/static/vendor/js/moi.js"></script>
55
<script src="/static/vendor/js/moi_list.js"></script>
66
<script type="text/javascript">
7-
window.onload = function() {moi_list.init("{{group_id}}");};
7+
$(document).ready(function() {
8+
moi_list.init("{{group_id}}");
9+
});
810
</script>
911
{% end %}
1012

qiita_pet/templates/compute_wait.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{%block head%}
44
<script type="text/javascript">
5-
window.onload = function() {
5+
$(document).ready(function() {
66

77
var host = 'ws://' + window.location.host + '/consumer/';
88
var websocket = new WebSocket(host);
@@ -34,7 +34,7 @@
3434
}
3535
};
3636
websocket.onerror = function(evt) { };
37-
};
37+
});
3838
</script>
3939
{% end %}
4040

0 commit comments

Comments
 (0)