[973924]: / qiita_db / handlers / sample_information.py

Download this file

35 lines (28 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -----------------------------------------------------------------------------
# Copyright (c) 2014--, The Qiita Development Team.
#
# Distributed under the terms of the BSD 3-clause License.
#
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------
import qiita_db as qdb
from .oauth2 import OauthBaseHandler, authenticate_oauth
from .util import _get_instance
class SampleInfoDBHandler(OauthBaseHandler):
@authenticate_oauth
def get(self, study_id):
"""Retrieves the sample information content
Parameters
----------
study_id: str
The id of the study whose sample information is being retrieved
Returns
-------
dict
The contents of the sample information keyed by sample id
"""
with qdb.sql_connection.TRN:
ST = qdb.metadata_template.sample_template.SampleTemplate
st = _get_instance(ST, study_id, 'Error instantiating sample info')
response = {'data': st.to_dataframe().to_dict(orient='index')}
self.write(response)