Skip to content

Commit 9609361

Browse files
authored
Merge pull request qiita-spots#2199 from antgonza/fix-494
fix qiita-spots#494
2 parents aedfd3c + b123dcf commit 9609361

File tree

22 files changed

+2489
-2374
lines changed

22 files changed

+2489
-2374
lines changed

qiita_db/commands.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,14 @@ def get_optional(name):
4949
required_fields = ['timeseries_type_id', 'mixs_compliant',
5050
'reprocess', 'study_alias',
5151
'study_description', 'study_abstract',
52-
'metadata_complete', 'efo_ids',
53-
'principal_investigator']
52+
'metadata_complete', 'principal_investigator']
5453
optional_fields = ['funding', 'most_recent_contact', 'spatial_series',
5554
'number_samples_collected', 'number_samples_promised',
5655
'vamps_id', 'study_id']
5756
infodict = {}
5857
for value in required_fields:
5958
infodict[value] = get_required(value)
6059

61-
# this will eventually change to using the Experimental Factory Ontolgoy
62-
# names
63-
efo_ids = infodict.pop('efo_ids')
64-
efo_ids = [x.strip() for x in efo_ids.split(',')]
65-
6660
for value in optional_fields:
6761
optvalue = get_optional(value)
6862
if optvalue is not None:
@@ -86,8 +80,7 @@ def get_optional(name):
8680
infodict['principal_investigator_id'] = qdb.study.StudyPerson.create(
8781
pi_name.strip(), pi_email.strip(), pi_affiliation.strip())
8882

89-
return qdb.study.Study.create(
90-
qdb.user.User(owner), title, efo_ids, infodict)
83+
return qdb.study.Study.create(qdb.user.User(owner), title, infodict)
9184

9285

9386
def load_artifact_from_cmd(filepaths, filepath_types, artifact_type,

qiita_db/metadata_template/test/test_sample_template.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ def setUp(self):
253253
}
254254
self.new_study = qdb.study.Study.create(
255255
qdb.user.User('test@foo.bar'),
256-
"Fried Chicken Microbiome %s" % time(), [1],
257-
info)
256+
"Fried Chicken Microbiome %s" % time(), info)
258257

259258
self.metadata_dict = {
260259
'Sample1': {'physical_specimen_location': 'location1',

qiita_db/study.py

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ class Study(qdb.base.QiitaObject):
113113
Attributes
114114
----------
115115
data_types
116-
efo
117116
info
118117
investigation
119118
name
@@ -302,7 +301,7 @@ def exists(cls, study_title):
302301
return qdb.sql_connection.TRN.execute_fetchlast()
303302

304303
@classmethod
305-
def create(cls, owner, title, efo, info, investigation=None):
304+
def create(cls, owner, title, info, investigation=None):
306305
"""Creates a new study on the database
307306
308307
Parameters
@@ -311,8 +310,6 @@ def create(cls, owner, title, efo, info, investigation=None):
311310
the study's owner
312311
title : str
313312
Title of the study
314-
efo : list
315-
Experimental Factor Ontology id(s) for the study
316313
info : dict
317314
the information attached to the study. All "*_id" keys must pass
318315
the objects associated with them.
@@ -326,24 +323,19 @@ def create(cls, owner, title, efo, info, investigation=None):
326323
All required keys not passed
327324
IncompetentQiitaDeveloperError
328325
email, study_id, study_status_id, or study_title passed as a key
329-
empty efo list passed
330326
QiitaDBDuplicateError
331327
If a study with the given title already exists
332328
333329
Notes
334330
-----
335-
All keys in info, except the efo, must be equal to columns in
336-
qiita.study table in the database.
331+
All keys in info, must be equal to columns in qiita.study table in the
332+
database.
337333
"""
338334
# make sure not passing non-info columns in the info dict
339335
if cls._non_info.intersection(info):
340336
raise qdb.exceptions.QiitaDBColumnError(
341337
"non info keys passed: %s" % cls._non_info.intersection(info))
342338

343-
# make sure efo info passed
344-
if not efo:
345-
raise IncompetentQiitaDeveloperError("Need EFO information!")
346-
347339
with qdb.sql_connection.TRN:
348340
if cls.exists(title):
349341
raise qdb.exceptions.QiitaDBDuplicateError(
@@ -383,13 +375,6 @@ def create(cls, owner, title, efo, info, investigation=None):
383375
qdb.sql_connection.TRN.add(sql, data)
384376
study_id = qdb.sql_connection.TRN.execute_fetchlast()
385377

386-
# insert efo information into database
387-
sql = """INSERT INTO qiita.{0}_experimental_factor
388-
(study_id, efo_id)
389-
VALUES (%s, %s)""".format(cls._table)
390-
qdb.sql_connection.TRN.add(
391-
sql, [[study_id, e] for e in efo], many=True)
392-
393378
# Add to both QIITA and given portal (if not QIITA)
394379
portal_id = qdb.util.convert_to_id(
395380
qiita_config.portal, 'portal_type', 'portal')
@@ -442,10 +427,6 @@ def delete(cls, id_):
442427
sql = "DELETE FROM qiita.study_portal WHERE study_id = %s"
443428
qdb.sql_connection.TRN.add(sql, args)
444429

445-
sql = """DELETE FROM qiita.study_experimental_factor
446-
WHERE study_id = %s"""
447-
qdb.sql_connection.TRN.add(sql, args)
448-
449430
sql = "DELETE FROM qiita.study_publication WHERE study_id = %s"
450431
qdb.sql_connection.TRN.add(sql, args)
451432

@@ -631,44 +612,6 @@ def info(self, info):
631612
qdb.sql_connection.TRN.add(sql, data)
632613
qdb.sql_connection.TRN.execute()
633614

634-
@property
635-
def efo(self):
636-
with qdb.sql_connection.TRN:
637-
sql = """SELECT efo_id FROM qiita.{0}_experimental_factor
638-
WHERE study_id = %s""".format(self._table)
639-
qdb.sql_connection.TRN.add(sql, [self._id])
640-
return qdb.sql_connection.TRN.execute_fetchflatten()
641-
642-
@efo.setter
643-
def efo(self, efo_vals):
644-
"""Sets the efo for the study
645-
646-
Parameters
647-
----------
648-
efo_vals : list
649-
Id(s) for the new efo values
650-
651-
Raises
652-
------
653-
IncompetentQiitaDeveloperError
654-
Empty efo list passed
655-
"""
656-
if not efo_vals:
657-
raise IncompetentQiitaDeveloperError("Need EFO information!")
658-
with qdb.sql_connection.TRN:
659-
self._lock_non_sandbox()
660-
# wipe out any EFOs currently attached to study
661-
sql = """DELETE FROM qiita.{0}_experimental_factor
662-
WHERE study_id = %s""".format(self._table)
663-
qdb.sql_connection.TRN.add(sql, [self._id])
664-
# insert new EFO information into database
665-
sql = """INSERT INTO qiita.{0}_experimental_factor
666-
(study_id, efo_id)
667-
VALUES (%s, %s)""".format(self._table)
668-
qdb.sql_connection.TRN.add(
669-
sql, [[self._id, efo] for efo in efo_vals], many=True)
670-
qdb.sql_connection.TRN.execute()
671-
672615
@property
673616
def shared_with(self):
674617
"""list of users the study is shared with

qiita_db/support_files/patches/56.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Aug 4, 2017
2+
-- DROP qiita.study_experimental_factor
3+
4+
DROP TABLE IF EXISTS qiita.study_experimental_factor;

qiita_db/support_files/populate_test_db.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ INSERT INTO qiita.investigation (investigation_name, investigation_description,
6262
-- Insert investigation_study (link study 1 with investigation 1)
6363
INSERT INTO qiita.investigation_study (investigation_id, study_id) VALUES (1, 1);
6464

65-
-- Insert the study experimental factor for study 1
66-
INSERT INTO qiita.study_experimental_factor (study_id, efo_id) VALUES (1, 1);
67-
6865
-- Add the study_sample for study 1
6966
INSERT INTO qiita.study_sample (study_id, sample_id, ebi_sample_accession, biosample_accession) VALUES
7067
(1, '1.SKB8.640193', 'ERS000000', 'SAMEA0000000'),

0 commit comments

Comments
 (0)