Skip to content

Commit 380057e

Browse files
committed
Merge branch 'master' of github.com:qiime/QiiTa into unify-sample-setitem
2 parents 8474ca4 + 12f48f9 commit 380057e

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
@@ -607,7 +607,7 @@ def _add_common_creation_steps_to_queue(cls, md_template, obj_id,
607607
headers = list(md_template.keys())
608608

609609
# Get the required columns from the DB
610-
db_cols = get_table_cols(cls._table, conn_handler)
610+
db_cols = sorted(get_table_cols(cls._table, conn_handler))
611611
# Remove the sample_id and _id_column columns
612612
db_cols.remove('sample_id')
613613
db_cols.remove(cls._id_column)
@@ -626,7 +626,7 @@ def _add_common_creation_steps_to_queue(cls, md_template, obj_id,
626626
values, many=True)
627627

628628
# Insert rows on *_columns table
629-
headers = list(set(headers).difference(db_cols))
629+
headers = sorted(set(headers).difference(db_cols))
630630
datatypes = get_datatypes(md_template.ix[:, headers])
631631
# psycopg2 requires a list of tuples, in which each tuple is a set
632632
# 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
@@ -407,32 +407,6 @@ def update(self, md_template):
407407
if '_qiime_' not in basename(fp):
408408
pt.create_qiime_mapping_file(fp)
409409

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

qiita_db/metadata_template/test/test_prep_template.py

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

590590
sql_create_table = (
591-
'CREATE TABLE qiita.prep_2 '
592-
'(sample_id varchar NOT NULL, str_column varchar, '
593-
'run_prefix varchar, barcodesequence varchar, platform varchar, '
594-
'linkerprimersequence varchar, '
595-
'experiment_design_description varchar, '
596-
'library_construction_protocol varchar)')
591+
'CREATE TABLE qiita.prep_2 (sample_id varchar NOT NULL, '
592+
'barcodesequence varchar, experiment_design_description varchar, '
593+
'library_construction_protocol varchar, '
594+
'linkerprimersequence varchar, platform varchar, '
595+
'run_prefix varchar, str_column varchar)')
597596

598597
sql_insert_dynamic = (
599598
'INSERT INTO qiita.prep_2 '
600-
'(sample_id, str_column, run_prefix, barcodesequence, platform, '
601-
'linkerprimersequence, experiment_design_description, '
602-
'library_construction_protocol) '
599+
'(sample_id, barcodesequence, experiment_design_description, '
600+
'library_construction_protocol, linkerprimersequence, platform, '
601+
'run_prefix, str_column) '
603602
'VALUES (%s, %s, %s, %s, %s, %s, %s, %s)')
604603

605604
sql_insert_dynamic_params_1 = (
606-
'2.SKB8.640193', 'Value for sample 1', 's_G1_L001_sequences',
607-
'GTCCGCAAGTTA', 'ILLUMINA', 'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA')
605+
'2.SKB8.640193', 'GTCCGCAAGTTA', 'BBBB', 'AAAA',
606+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
607+
'Value for sample 1')
608608
sql_insert_dynamic_params_2 = (
609-
'2.SKD8.640184', 'Value for sample 2', 's_G1_L001_sequences',
610-
'CGTAGAGCTCTC', 'ILLUMINA', 'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA')
609+
'2.SKD8.640184', 'CGTAGAGCTCTC', 'BBBB', 'AAAA',
610+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
611+
'Value for sample 2')
611612

612613
exp = [
613614
(sql_insert_common, sql_insert_common_params_1),
614615
(sql_insert_common, sql_insert_common_params_2),
615-
(sql_insert_prep_columns, (2, 'str_column', 'varchar')),
616-
(sql_insert_prep_columns, (2, 'run_prefix', 'varchar')),
617616
(sql_insert_prep_columns, (2, 'barcodesequence', 'varchar')),
618-
(sql_insert_prep_columns, (2, 'platform', 'varchar')),
619-
(sql_insert_prep_columns, (2, 'linkerprimersequence', 'varchar')),
620617
(sql_insert_prep_columns,
621618
(2, 'experiment_design_description', 'varchar')),
622619
(sql_insert_prep_columns,
623620
(2, 'library_construction_protocol', 'varchar')),
621+
(sql_insert_prep_columns, (2, 'linkerprimersequence', 'varchar')),
622+
(sql_insert_prep_columns, (2, 'platform', 'varchar')),
623+
(sql_insert_prep_columns, (2, 'run_prefix', 'varchar')),
624+
(sql_insert_prep_columns, (2, 'str_column', 'varchar')),
624625
(sql_create_table, None),
625626
(sql_insert_dynamic, sql_insert_dynamic_params_1),
626627
(sql_insert_dynamic, sql_insert_dynamic_params_2)]
@@ -800,17 +801,20 @@ def test_create(self):
800801
# The new table hosts the correct values
801802
obs = self.conn_handler.execute_fetchall(
802803
"SELECT * FROM qiita.prep_2")
803-
# sample_id, study_id, str_column, ebi_submission_accession,
804-
# run_prefix, barcodesequence, linkerprimersequence
805-
exp = [['1.SKB7.640196', 'Value for sample 3', 'ILLUMINA',
806-
's_G1_L002_sequences', 'CCTCTGAGAGCT', None,
807-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
808-
['1.SKB8.640193', 'Value for sample 1', 'ILLUMINA',
809-
's_G1_L001_sequences', 'GTCCGCAAGTTA', None,
810-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
811-
['1.SKD8.640184', 'Value for sample 2', 'ILLUMINA',
812-
's_G1_L001_sequences', 'CGTAGAGCTCTC', None,
813-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA']]
804+
805+
# barcodesequence, ebi_submission_accession,
806+
# experiment_design_description, library_construction_protocol,
807+
# linkerprimersequence, platform, run_prefix, str_column
808+
exp = [['1.SKB7.640196', 'CCTCTGAGAGCT', None, 'BBBB', 'AAAA',
809+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L002_sequences',
810+
'Value for sample 3'],
811+
['1.SKB8.640193', 'GTCCGCAAGTTA', None, 'BBBB', 'AAAA',
812+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
813+
'Value for sample 1'],
814+
['1.SKD8.640184', 'CGTAGAGCTCTC', None, 'BBBB', 'AAAA',
815+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
816+
'Value for sample 2']]
817+
814818
self.assertEqual(sorted(obs), sorted(exp))
815819

816820
# prep and qiime files have been created
@@ -864,17 +868,18 @@ def test_create_already_prefixed_samples(self):
864868
# The new table hosts the correct values
865869
obs = self.conn_handler.execute_fetchall(
866870
"SELECT * FROM qiita.prep_2")
867-
# sample_id, study_id, str_column, ebi_submission_accession,
868-
# run_prefix, barcodesequence, linkerprimersequence
869-
exp = [['1.SKB7.640196', 'Value for sample 3', 'ILLUMINA',
870-
's_G1_L002_sequences', 'CCTCTGAGAGCT', None,
871-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
872-
['1.SKB8.640193', 'Value for sample 1', 'ILLUMINA',
873-
's_G1_L001_sequences', 'GTCCGCAAGTTA', None,
874-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
875-
['1.SKD8.640184', 'Value for sample 2', 'ILLUMINA',
876-
's_G1_L001_sequences', 'CGTAGAGCTCTC', None,
877-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA']]
871+
# barcodesequence, ebi_submission_accession,
872+
# experiment_design_description, library_construction_protocol,
873+
# linkerprimersequence, platform, run_prefix, str_column
874+
exp = [['1.SKB7.640196', 'CCTCTGAGAGCT', None, 'BBBB', 'AAAA',
875+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L002_sequences',
876+
'Value for sample 3'],
877+
['1.SKB8.640193', 'GTCCGCAAGTTA', None, 'BBBB', 'AAAA',
878+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
879+
'Value for sample 1'],
880+
['1.SKD8.640184', 'CGTAGAGCTCTC', None, 'BBBB', 'AAAA',
881+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
882+
'Value for sample 2']]
878883
self.assertEqual(sorted(obs), sorted(exp))
879884

880885
# prep and qiime files have been created
@@ -965,17 +970,18 @@ def test_create_data_type_id(self):
965970
# The new table hosts the correct values
966971
obs = self.conn_handler.execute_fetchall(
967972
"SELECT * FROM qiita.prep_2")
968-
# sample_id, str_column, ebi_submission_accession,
969-
# run_prefix, barcodesequence, linkerprimersequence
970-
exp = [['1.SKB7.640196', 'Value for sample 3', 'ILLUMINA',
971-
's_G1_L002_sequences', 'CCTCTGAGAGCT', None,
972-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
973-
['1.SKB8.640193', 'Value for sample 1', 'ILLUMINA',
974-
's_G1_L001_sequences', 'GTCCGCAAGTTA', None,
975-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA'],
976-
['1.SKD8.640184', 'Value for sample 2', 'ILLUMINA',
977-
's_G1_L001_sequences', 'CGTAGAGCTCTC', None,
978-
'GTGCCAGCMGCCGCGGTAA', 'BBBB', 'AAAA']]
973+
# barcodesequence, ebi_submission_accession,
974+
# experiment_design_description, library_construction_protocol,
975+
# linkerprimersequence, platform, run_prefix, str_column
976+
exp = [['1.SKB7.640196', 'CCTCTGAGAGCT', None, 'BBBB', 'AAAA',
977+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L002_sequences',
978+
'Value for sample 3'],
979+
['1.SKB8.640193', 'GTCCGCAAGTTA', None, 'BBBB', 'AAAA',
980+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
981+
'Value for sample 1'],
982+
['1.SKD8.640184', 'CGTAGAGCTCTC', None, 'BBBB', 'AAAA',
983+
'GTGCCAGCMGCCGCGGTAA', 'ILLUMINA', 's_G1_L001_sequences',
984+
'Value for sample 2']]
979985
self.assertEqual(sorted(obs), sorted(exp))
980986

981987
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
@@ -806,23 +806,20 @@ def test_add_common_creation_steps_to_queue(self):
806806

807807
sql_insert_required = (
808808
'INSERT INTO qiita.required_sample_info '
809-
'(study_id, sample_id, physical_location, has_physical_specimen, '
810-
'has_extracted_data, sample_type, required_sample_info_status_id, '
811-
'collection_timestamp, host_subject_id, description, latitude, '
812-
'longitude) '
809+
'(study_id, sample_id, collection_timestamp, description, '
810+
'has_extracted_data, has_physical_specimen, host_subject_id, '
811+
'latitude, longitude, physical_location, '
812+
'required_sample_info_status_id, sample_type) '
813813
'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)')
814814
sql_insert_required_params_1 = (
815-
2, '2.Sample1', 'location1', True, True, 'type1', 1,
816-
datetime(2014, 5, 29, 12, 24, 51), 'NotIdentified',
817-
'Test Sample 1', 42.42, 41.41)
815+
2, '2.Sample1', datetime(2014, 5, 29, 12, 24, 51), 'Test Sample 1',
816+
True, True, 'NotIdentified', 42.42, 41.41, 'location1', 1, 'type1')
818817
sql_insert_required_params_2 = (
819-
2, '2.Sample2', 'location1', True, True, 'type1', 1,
820-
datetime(2014, 5, 29, 12, 24, 51), 'NotIdentified',
821-
'Test Sample 2', 4.2, 1.1)
818+
2, '2.Sample2', datetime(2014, 5, 29, 12, 24, 51), 'Test Sample 2',
819+
True, True, 'NotIdentified', 4.2, 1.1, 'location1', 1, 'type1')
822820
sql_insert_required_params_3 = (
823-
2, '2.Sample3', 'location1', True, True, 'type1', 1,
824-
datetime(2014, 5, 29, 12, 24, 51), 'NotIdentified',
825-
'Test Sample 3', 4.8, 4.41)
821+
2, '2.Sample3', datetime(2014, 5, 29, 12, 24, 51), 'Test Sample 3',
822+
True, True, 'NotIdentified', 4.8, 4.41, 'location1', 1, 'type1')
826823

827824
sql_insert_sample_cols = (
828825
'INSERT INTO qiita.study_sample_columns '
@@ -1241,18 +1238,6 @@ def test_add_category(self):
12411238
obs = {k: v['new_column'] for k, v in self.tester.items()}
12421239
self.assertEqual(obs, exp)
12431240

1244-
def test_remove_category(self):
1245-
with self.assertRaises(QiitaDBColumnError):
1246-
self.tester.remove_category('does not exist')
1247-
1248-
for v in self.tester.values():
1249-
self.assertIn('elevation', v)
1250-
1251-
self.tester.remove_category('elevation')
1252-
1253-
for v in self.tester.values():
1254-
self.assertNotIn('elevation', v)
1255-
12561241
def test_to_file(self):
12571242
"""to file writes a tab delimited file with all the metadata"""
12581243
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)