Skip to content

Commit

Permalink
Merge f31446c into f505bf0
Browse files Browse the repository at this point in the history
  • Loading branch information
ElDeveloper committed Jun 18, 2014
2 parents f505bf0 + f31446c commit a6cc375
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
15 changes: 15 additions & 0 deletions qiita_db/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,21 @@ def sample_template(self):
"""
return self._id

@property
def data_types(self):
"""Returns list of the data types for this study
Returns
-------
list of str
"""
conn_handler = SQLConnectionHandler()
sql = ("SELECT DISTINCT DT.data_type FROM qiita.study_raw_data SRD "
"JOIN qiita.common_prep_info CPI ON SRD.raw_data_id = "
"CPI.raw_data_id JOIN qiita.data_type DT ON CPI.data_type_id = "
"DT.data_type_id WHERE SRD.study_id = %s")
return [x[0] for x in conn_handler.execute_fetchall(sql, (self._id,))]

@property
def raw_data(self):
""" Returns list of data ids for raw data info
Expand Down
8 changes: 8 additions & 0 deletions qiita_db/test/test_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ def test_retrieve_investigation_empty(self):
def test_retrieve_sample_template(self):
self.assertEqual(self.study.sample_template, 1)

def test_retrieve_data_types(self):
self.assertEqual(self.study.data_types, ['18S'])

def test_retrieve_data_types_none(self):
new = Study.create(User('test@foo.bar'), 'Identification of the '
'Microbiomes for Cannabis Soils', [1], self.info)
self.assertEqual(new.data_types, [])

def test_retrieve_raw_data(self):
self.assertEqual(self.study.raw_data, [1, 2])

Expand Down

0 comments on commit a6cc375

Please sign in to comment.