Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ST
ga4gh-arraymap
Commits
6579bbf6
Commit
6579bbf6
authored
May 24, 2016
by
Severine Duvaud
Browse files
Implementing latest changes in the API spec
parent
7047dc4f
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/node-app/arraymap-beacon/v0.3/beacon-query.js
View file @
6579bbf6
...
...
@@ -176,12 +176,22 @@ function checkResultAndGetResponse(params, samples, countTotal) {
if
(
samples
&&
samples
.
length
>
0
)
{
// a value was found by mongodb
responseResource
.
observed
=
samples
.
length
;
// SD, May 2016: according to the specs, observed parameter was removed from BeaconDatasetAlleleResponse.
// We could divide the sample.length by the total number of samples in order to fill the frequency parameters
// for instance (and if of interest for arrayMap).
// responseResource.observed = samples.length;
responseResource
.
NOT_BEACON_numberMatchedSamples
=
samples
.
length
;
var
matchedSegments
=
samples
.
map
(
function
(
s
)
{
return
checkResult
(
params
,
s
)});
if
(
!
matchedSegments
||
!
matchedSegments
[
0
]
||
!
matchedSegments
[
0
].
matchedSegment
)
{
responseResource
.
exists
=
null
;
responseResource
.
error
=
"
Internal error, DB returned a value but post check is not valid.
"
// BeaconError instead of simple string
// (error is not null if and only of exists is null)
responseResource
.
error
=
{
errorCode
:
500
,
message
:
"
Internal error, DB returned a value but post check is not valid.
"
};
}
else
{
responseResource
.
exists
=
true
;
responseResource
.
NOT_BEACON_ARRAYMAP_DEBUG_INFO
=
{
"
matchedSegments
"
:
matchedSegments
};
...
...
app/node-app/routes/index.js
View file @
6579bbf6
...
...
@@ -54,8 +54,7 @@ router.get('/v0.2/query/', function (req, res) {
console
.
log
(
"
Building MongoDB query params:
"
+
JSON
.
stringify
(
mongoQuery
));
req
.
db
.
samples
.
count
({
'
ICDMORPHOLOGYCODE
'
:
req
.
query
.
dataset
},
function
(
err
,
count
){
req
.
db
.
samples
.
find
(
mongoQuery
,
{},
function
(
err
,
docs
){
req
.
db
.
samples
.
find
(
mongoQuery
,
{},
function
(
err
,
docs
){
var
response
=
beacon
.
checkResultAndGetResponse
(
req
.
query
,
docs
,
count
);
response
.
NOT_BEACON_totalInDataSet
=
count
;
res
.
json
(
response
);
...
...
@@ -77,8 +76,14 @@ router.get('/v0.3/query/', function (req, res) {
var
mongoQuery
=
beacon
.
buildMongoQuery
(
req
.
query
);
console
.
log
(
"
Building MongoDB query params:
"
+
JSON
.
stringify
(
mongoQuery
));
req
.
db
.
samples
.
count
({
'
ICDMORPHOLOGYCODE
'
:
req
.
query
.
dataset
},
function
(
err
,
count
){
// Count: list of datasets (and not 1 dataset)
var
orConditions
=
[];
var
identifiers
=
req
.
query
.
datasetIds
.
split
(
'
,
'
);
// comma separated list of datasets
identifiers
.
forEach
(
function
(
id
)
{
orConditions
.
push
({
ICDMORPHOLOGYCODE
:
id
});
});
req
.
db
.
samples
.
count
({
$or
:
orConditions
},
function
(
err
,
count
){
req
.
db
.
samples
.
find
(
mongoQuery
,
{},
function
(
err
,
docs
){
var
response
=
beacon
.
checkResultAndGetResponse
(
req
.
query
,
docs
,
count
);
response
.
NOT_BEACON_totalInDataSet
=
count
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment