From 818e7d65bd1aedf5bf5a838f26bc8edab3c2d3df Mon Sep 17 00:00:00 2001 From: Jose Navas Date: Thu, 7 May 2015 11:54:37 -0700 Subject: [PATCH] Removing any instance of required_sample_info and common_prep_info. Also adding a test for metadata_headers --- qiita_db/metadata_template/prep_template.py | 2 +- qiita_db/metadata_template/sample_template.py | 2 - .../test/test_sample_template.py | 15 +++- qiita_db/metadata_template/util.py | 4 +- qiita_db/support_files/populate_test_db.sql | 82 +++++++++---------- qiita_db/test/test_setup.py | 2 +- 6 files changed, 59 insertions(+), 48 deletions(-) diff --git a/qiita_db/metadata_template/prep_template.py b/qiita_db/metadata_template/prep_template.py index 2d6bdceb6..eeee2e047 100644 --- a/qiita_db/metadata_template/prep_template.py +++ b/qiita_db/metadata_template/prep_template.py @@ -232,7 +232,7 @@ def delete(cls, id_): conn_handler.execute( "DROP TABLE qiita.{0}".format(table_name)) - # Remove the rows from common_prep_info + # Remove the rows from prep_template_samples conn_handler.execute( "DELETE FROM qiita.{0} where {1} = %s".format(cls._table, cls._id_column), diff --git a/qiita_db/metadata_template/sample_template.py b/qiita_db/metadata_template/sample_template.py index bb639f580..9ea16df42 100644 --- a/qiita_db/metadata_template/sample_template.py +++ b/qiita_db/metadata_template/sample_template.py @@ -84,8 +84,6 @@ def metadata_headers(): return [x[0] for x in conn_handler.execute_fetchall( "SELECT DISTINCT column_name FROM qiita.study_sample_columns " - "UNION SELECT column_name FROM information_schema.columns " - "WHERE table_name = 'required_sample_info' " "ORDER BY column_name")] @classmethod diff --git a/qiita_db/metadata_template/test/test_sample_template.py b/qiita_db/metadata_template/test/test_sample_template.py index 984758bab..b61164fb3 100644 --- a/qiita_db/metadata_template/test/test_sample_template.py +++ b/qiita_db/metadata_template/test/test_sample_template.py @@ -574,6 +574,19 @@ class TestSampleTemplateReadOnly(BaseTestSampleTemplate): def setUp(self): self._set_up() + def test_metadata_headers(self): + obs = SampleTemplate.metadata_headers() + exp = {'physical_specimen_location', 'physical_specimen_remaining', + 'dna_extracted', 'sample_type', 'collection_timestamp', + 'host_subject_id', 'description', 'season_environment', + 'assigned_from_geo', 'texture', 'taxon_id', 'depth', + 'host_taxid', 'common_name', 'water_content_soil', 'elevation', + 'temp', 'tot_nitro', 'samp_salinity', 'altitude', 'env_biome', + 'country', 'ph', 'anonymized_name', 'tot_org_carb', + 'description_duplicate', 'env_feature', 'latitude', 'longitude', + 'sample_id'} + self.assertEqual(set(obs), exp) + def test_study_id(self): """Ensure that the correct study ID is returned""" self.assertEqual(self.tester.study_id, 1) @@ -1111,7 +1124,7 @@ def test_create_int_prefix(self): # The returned object has the correct id self.assertEqual(st.id, new_id) - # The relevant rows to required_sample_info have been added. + # The relevant rows to study_sample have been added. obs = self.conn_handler.execute_fetchall( "SELECT * FROM qiita.study_sample WHERE study_id=%s", (new_id,)) exp = [["%s.12.Sample1" % new_id, new_id], diff --git a/qiita_db/metadata_template/util.py b/qiita_db/metadata_template/util.py index 7d0521046..1f7e5c9ac 100644 --- a/qiita_db/metadata_template/util.py +++ b/qiita_db/metadata_template/util.py @@ -221,13 +221,13 @@ def load_template_to_dataframe(fn, strip_whitespace=True): parse_dates=True, index_col=False, comment='\t', mangle_dupe_cols=False, converters={ 'sample_name': lambda x: str(x).strip(), - # required_sample_info + # required sample template information 'physical_location': str, 'sample_type': str, # collection_timestamp is not added here 'host_subject_id': str, 'description': str, - # common_prep_info + # common prep template information 'center_name': str, 'center_projct_name': str}) diff --git a/qiita_db/support_files/populate_test_db.sql b/qiita_db/support_files/populate_test_db.sql index 0d91a66d5..7099ccc29 100644 --- a/qiita_db/support_files/populate_test_db.sql +++ b/qiita_db/support_files/populate_test_db.sql @@ -107,26 +107,26 @@ INSERT INTO qiita.study_sample (study_id, sample_id) VALUES -- Add the study sample columns for study 1 INSERT INTO qiita.study_sample_columns (study_id, column_name, column_type) VALUES (1, 'sample_id', 'varchar'), - (1, 'SEASON_ENVIRONMENT', 'varchar'), - (1, 'ASSIGNED_FROM_GEO', 'varchar'), - (1, 'TEXTURE', 'varchar'), - (1, 'TAXON_ID', 'varchar'), - (1, 'DEPTH', 'float8'), - (1, 'HOST_TAXID', 'varchar'), - (1, 'COMMON_NAME', 'varchar'), - (1, 'WATER_CONTENT_SOIL', 'float8'), - (1, 'ELEVATION', 'float8'), - (1, 'TEMP', 'float8'), - (1, 'TOT_NITRO', 'float8'), - (1, 'SAMP_SALINITY', 'float8'), - (1, 'ALTITUDE', 'float8'), - (1, 'ENV_BIOME', 'varchar'), - (1, 'COUNTRY', 'varchar'), - (1, 'PH', 'float8'), - (1, 'ANONYMIZED_NAME', 'varchar'), - (1, 'TOT_ORG_CARB', 'float8'), - (1, 'Description_duplicate', 'varchar'), - (1, 'ENV_FEATURE', 'varchar'), + (1, 'season_environment', 'varchar'), + (1, 'assigned_from_geo', 'varchar'), + (1, 'texture', 'varchar'), + (1, 'taxon_id', 'varchar'), + (1, 'depth', 'float8'), + (1, 'host_taxid', 'varchar'), + (1, 'common_name', 'varchar'), + (1, 'water_content_soil', 'float8'), + (1, 'elevation', 'float8'), + (1, 'temp', 'float8'), + (1, 'tot_nitro', 'float8'), + (1, 'samp_salinity', 'float8'), + (1, 'altitude', 'float8'), + (1, 'env_biome', 'varchar'), + (1, 'country', 'varchar'), + (1, 'ph', 'float8'), + (1, 'anonymized_name', 'varchar'), + (1, 'tot_org_carb', 'float8'), + (1, 'description_duplicate', 'varchar'), + (1, 'env_feature', 'varchar'), (1, 'physical_specimen_location', 'varchar'), (1, 'physical_specimen_remaining', 'bool'), (1, 'dna_extracted', 'bool'), @@ -140,26 +140,26 @@ INSERT INTO qiita.study_sample_columns (study_id, column_name, column_type) VALU -- Crate the sample_1 dynamic table CREATE TABLE qiita.sample_1 ( sample_id varchar, - SEASON_ENVIRONMENT varchar, - ASSIGNED_FROM_GEO varchar, - TEXTURE varchar, - TAXON_ID varchar, - DEPTH float8, - HOST_TAXID varchar, - COMMON_NAME varchar, - WATER_CONTENT_SOIL float8, - ELEVATION float8, - TEMP float8, - TOT_NITRO float8, - SAMP_SALINITY float8, - ALTITUDE float8, - ENV_BIOME varchar, - COUNTRY varchar, - PH float8, - ANONYMIZED_NAME varchar, - TOT_ORG_CARB float8, - Description_duplicate varchar, - ENV_FEATURE varchar, + season_environment varchar, + assigned_from_geo varchar, + texture varchar, + taxon_id varchar, + depth float8, + host_taxid varchar, + common_name varchar, + water_content_soil float8, + elevation float8, + temp float8, + tot_nitro float8, + samp_salinity float8, + altitude float8, + env_biome varchar, + country varchar, + ph float8, + anonymized_name varchar, + tot_org_carb float8, + description_duplicate varchar, + env_feature varchar, physical_specimen_location varchar, physical_specimen_remaining bool, dna_extracted bool, @@ -173,7 +173,7 @@ CREATE TABLE qiita.sample_1 ( ); -- Populates the sample_1 dynamic table -INSERT INTO qiita.sample_1 (sample_id, SEASON_ENVIRONMENT, ASSIGNED_FROM_GEO, TEXTURE, TAXON_ID, DEPTH, HOST_TAXID, COMMON_NAME, WATER_CONTENT_SOIL, ELEVATION, TEMP, TOT_NITRO, SAMP_SALINITY, ALTITUDE, ENV_BIOME, COUNTRY, PH, ANONYMIZED_NAME, TOT_ORG_CARB, Description_duplicate, ENV_FEATURE, physical_specimen_location, physical_specimen_remaining, dna_extracted, sample_type, collection_timestamp, host_subject_id, description, latitude, longitude) VALUES +INSERT INTO qiita.sample_1 (sample_id, season_environment, assigned_from_geo, texture, taxon_id, depth, host_taxid, common_name, water_content_soil, elevation, temp, tot_nitro, samp_salinity, altitude, env_biome, country, ph, anonymized_name, tot_org_carb, description_duplicate, env_feature, physical_specimen_location, physical_specimen_remaining, dna_extracted, sample_type, collection_timestamp, host_subject_id, description, latitude, longitude) VALUES ('1.SKM7.640188', 'winter', 'n', '63.1 sand, 17.7 silt, 19.2 clay', '1118232', 0.15, '3483', 'root metagenome', 0.101, 114, 15, 1.3, 7.44, 0, 'ENVO:Temperate grasslands, savannas, and shrubland biome', 'GAZ:United States of America', 6.82, 'SKM7', 3.31, 'Bucu Roots', 'ENVO:plant-associated habitat', 'ANL', TRUE, TRUE, 'ENVO:soil', '2011-11-11 13:00', '1001:B6', 'Cannabis Soil Microbiome', 60.1102854322, 74.7123248382), ('1.SKD9.640182', 'winter', 'n', '66 sand, 16.3 silt, 17.7 clay', '1118232', 0.15, '3483', 'root metagenome', 0.178, 114, 15, 1.51, 7.1, 0, 'ENVO:Temperate grasslands, savannas, and shrubland biome', 'GAZ:United States of America', 6.82, 'SKD9', 4.32, 'Diesel Root', 'ENVO:plant-associated habitat', 'ANL', TRUE, TRUE, 'ENVO:soil', '2011-11-11 13:00', '1001:D3', 'Cannabis Soil Microbiome', 23.1218032799, 42.838497795), ('1.SKM8.640201', 'winter', 'n', '63.1 sand, 17.7 silt, 19.2 clay', '1118232', 0.15, '3483', 'root metagenome', 0.101, 114, 15, 1.3, 7.44, 0, 'ENVO:Temperate grasslands, savannas, and shrubland biome', 'GAZ:United States of America', 6.82, 'SKM8', 3.31, 'Bucu Roots', 'ENVO:plant-associated habitat', 'ANL', TRUE, TRUE, 'ENVO:soil', '2011-11-11 13:00', '1001:D8', 'Cannabis Soil Microbiome', 3.21190859967, 26.8138925876), diff --git a/qiita_db/test/test_setup.py b/qiita_db/test/test_setup.py index fa92ce236..247291cc9 100644 --- a/qiita_db/test/test_setup.py +++ b/qiita_db/test/test_setup.py @@ -65,7 +65,7 @@ def test_sample_1(self): def test_prep_template(self): self.assertEqual(get_count("qiita.prep_template"), 1) - def test_common_prep_info(self): + def test_prep_template_sample(self): self.assertEqual(get_count("qiita.prep_template_sample"), 27) def test_prep_columns(self):