Skip to content

Commit

Permalink
total number of abundance observations #98
Browse files Browse the repository at this point in the history
  • Loading branch information
lzy7071 committed May 26, 2020
1 parent 8dfd546 commit e66140e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions datanator_rest_api/routes/proteins.py
Expand Up @@ -9,6 +9,7 @@


from datanator_query_python.config import query_manager
from datanator_query_python.aggregate import pipelines
from datanator_rest_api.util import taxon_distance


Expand Down Expand Up @@ -96,6 +97,13 @@ def get():
return p_manager.collection.count_documents({'abundances': {"$exists": True}})


class num_obs_abundances():
def get():
pipeline = pipelines.Pipeline().aggregate_total_array_length("observation")
for doc in p_manager.db_obj['pax'].aggregate(pipeline):
return doc['total']


class num_publications():

def get():
Expand Down
13 changes: 13 additions & 0 deletions datanator_rest_api/spec/DatanatorAPI.yaml
Expand Up @@ -961,6 +961,19 @@ paths:
summary: Get number of proteins with abundance values
tags:
- Proteins
/proteins/summary/num_obs_abundances/:
get:
description: For about page
responses:
'200':
content:
application/json:
schema:
type: integer
description: OK
summary: Get number of observed abundance values
tags:
- Proteins
/proteins/summary/num_organism/:
get:
description: For about page
Expand Down
14 changes: 14 additions & 0 deletions datanator_rest_api/spec/paths/proteins.yaml
Expand Up @@ -216,6 +216,20 @@ summary:
application/json:
schema:
type: integer

num_obs_abundances:
get:
tags:
- Proteins
summary: Get number of observed abundance values
description: For about page
responses:
"200":
description: OK
content:
application/json:
schema:
type: integer

num_publications:
get:
Expand Down
2 changes: 2 additions & 0 deletions datanator_rest_api/spec/root.yaml
Expand Up @@ -79,6 +79,8 @@ paths:
$ref: paths/proteins.yaml#/summary/num_abundances
/proteins/summary/num_publications/:
$ref: paths/proteins.yaml#/summary/num_publications
/proteins/summary/num_obs_abundances/:
$ref: paths/proteins.yaml#/summary/num_obs_abundances
/proteins/similar_protein/refseq/:
$ref: paths/proteins.yaml#/similar_protein/refseq
/proteins/related/related_reactions_by_kegg/:
Expand Down
4 changes: 4 additions & 0 deletions tests/routes/test_proteins.py
Expand Up @@ -74,6 +74,10 @@ def test_summary_num_publications(self):
result = self.client.get('/proteins/summary/num_publications/')
self.assertEqual(result.status_code, 200)

def test_summary_num_obs_abundances(self):
result = self.client.get('/proteins/summary/num_obs_abundances/')
self.assertEqual(result.status_code, 200)

def test_similar_protein_refseq(self):
result = self.client.get('/proteins/similar_protein/refseq/?uniprot_id=q9vb24&identity=90')
self.assertEqual(result.status_code, 200)
Expand Down

0 comments on commit e66140e

Please sign in to comment.