Skip to content

Commit

Permalink
Merge pull request #101 from squirrelo/data-data_type
Browse files Browse the repository at this point in the history
add datatype lookup for processed data
  • Loading branch information
josenavas committed Jun 18, 2014
2 parents ef03929 + d0e6704 commit 6759110
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions qiita_db/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,16 @@ def preprocessed_data(self):
"SELECT preprocessed_data_id FROM qiita.{0} WHERE "
"processed_data_id=%s".format(self._table),
[self._id])[0]

@property
def data_type(self):
r"""The data_type of the data used"""
conn_handler = SQLConnectionHandler()
sql = ("SELECT DISTINCT DT.data_type FROM qiita.processed_data PD "
"JOIN qiita.preprocessed_data PPD on PD.preprocessed_data_id "
"= PPD.preprocessed_data_id JOIN qiita.raw_data RD on "
"PPD.raw_data_id = RD.raw_data_id "
"JOIN qiita.common_prep_info CPI ON RD.raw_data_id = "
"CPI.raw_data_id JOIN qiita.data_type DT ON CPI.data_type_id = "
"DT.data_type_id WHERE PD.processed_data_id = %s")
return conn_handler.execute_fetchone(sql, [self._id])[0]
4 changes: 4 additions & 0 deletions qiita_db/test/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ def test_preprocessed_data(self):
pd = ProcessedData(1)
self.assertEqual(pd.preprocessed_data, 1)

def test_data_type(self):
pd = ProcessedData(1)
self.assertEqual(pd.data_type, "18S")


if __name__ == '__main__':
main()

0 comments on commit 6759110

Please sign in to comment.