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

Download this file

61 lines (48 with data), 2.1 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -----------------------------------------------------------------------------
# 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.
# -----------------------------------------------------------------------------
from .oauth2 import OauthBaseHandler, authenticate_oauth
from qiita_db.processing_job import ProcessingJob
from qiita_db.archive import Archive
from json import loads
class APIArchiveObservations(OauthBaseHandler):
@authenticate_oauth
def post(self):
"""Retrieves the archiving information
Returns
-------
dict
The contents of the analysis keyed by sample id
Notes
-----
Argument "path" must be the Qiita job_id which is used to infer
the merging scheme.
Argument "features" is a list of feature identifier,
e.g. Deblur sequences.
Feature identifiers not found in the archive won't be included in
the return dictionary.
"""
job_id = self.get_argument('job_id')
features = self.request.arguments['features']
ms = Archive.get_merging_scheme_from_job(ProcessingJob(job_id))
response = Archive.retrieve_feature_values(
archive_merging_scheme=ms, features=features)
self.write(response)
@authenticate_oauth
def patch(self):
"""Updates / stores feature information in the archive.
Notes
-----
Argument "path" must be the Qiita job_id which is used to infer
the merging scheme.
Argument "value" is a json string, i.e. result of a json.dump(obj)
of a dictionary, keyed with feature identifiers.
"""
req_path = self.get_argument('path')
req_value = self.get_argument('value')
ms = Archive.get_merging_scheme_from_job(ProcessingJob(req_path))
self.write(Archive.insert_features(ms, loads(req_value)))