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
c431628a
Commit
c431628a
authored
May 20, 2016
by
Severine Duvaud
Browse files
Handle max length
parent
2e2a7906
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/node-app/arraymap-beacon/v0.3/beacon-query.js
View file @
c431628a
...
...
@@ -70,6 +70,20 @@ function checkPreconditions(params) {
};
}
if
(
!
Number
(
params
.
length
))
{
return
{
hasError
:
true
,
msg
:
"
min. length not a number
"
};
}
if
(
!
Number
(
params
.
maxLength
))
{
return
{
hasError
:
true
,
msg
:
"
max length not a number
"
};
}
//TODO add additional checks
return
{
...
...
@@ -82,14 +96,21 @@ function buildMongoQuery(params) {
var
position
=
parseInt
(
params
.
start
);
var
length
=
0
;
var
maxLength
=
0
;
if
(
params
.
alternateBases
==
'
DEL
'
)
{
if
(
typeof
params
.
length
!=
undefined
&&
params
.
length
!=
null
&&
params
.
length
!=
''
)
if
(
typeof
params
.
length
!=
undefined
&&
params
.
length
!=
null
&&
params
.
length
!=
''
)
// min. length is provided
{
length
=
(
params
.
length
.
length
==
0
?
0
:
parseInt
(
params
.
length
));
}
}
console
.
log
(
"
*** LENGTH:
"
+
length
);
if
(
typeof
params
.
maxLength
!=
undefined
&&
params
.
maxLength
!=
null
&&
params
.
maxLength
!=
''
)
// max length is provided
{
maxLength
=
(
params
.
maxLength
.
length
==
0
?
0
:
parseInt
(
params
.
maxLength
));
if
(
length
==
0
)
{
length
++
;
// force min. length in case none is given
}
}
}
var
andConditions
=
[];
var
orConditions
=
[];
...
...
@@ -111,12 +132,29 @@ function buildMongoQuery(params) {
var
cond
=
{};
if
(
length
>
0
)
{
cond
[
convertedReference
]
=
{
'
$elemMatch
'
:
{
'
CHRO
'
:
params
.
referenceName
,
'
SEGTYPE
'
:
segType
,
'
SEGSIZE
'
:
length
,
// exact length
'
SEGSTART
'
:
position
// exact position
if
(
maxLength
>
0
)
{
cond
[
convertedReference
]
=
{
'
$elemMatch
'
:
{
'
CHRO
'
:
params
.
referenceName
,
'
SEGTYPE
'
:
segType
,
'
SEGSIZE
'
:
{
$gte
:
length
,
$lte
:
maxLength
},
// min. and max lengths
'
SEGSTART
'
:
position
// exact position
}
}
}
else
{
cond
[
convertedReference
]
=
{
'
$elemMatch
'
:
{
'
CHRO
'
:
params
.
referenceName
,
'
SEGTYPE
'
:
segType
,
'
SEGSIZE
'
:
{
$gte
:
length
},
// min. length
'
SEGSTART
'
:
position
// exact position
}
}
}
}
...
...
app/node-app/public/js/index.js
View file @
c431628a
...
...
@@ -23,7 +23,8 @@ arrayMap.controller('BeaconController', ['$scope', '$location', function ($scope
"
reference
"
:
"
GRCh38
"
,
"
dataset
"
:
"
all
"
,
"
alternateBases
"
:
"
DEL
"
,
"
length
"
:
'
1
'
"
length
"
:
'
1
'
,
"
maxLength
"
:
''
}
$scope
.
getNewApiUrl
=
function
()
{
...
...
@@ -36,7 +37,8 @@ arrayMap.controller('BeaconController', ['$scope', '$location', function ($scope
"
&assemblyId=
"
+
conf
.
reference
+
"
&datasetIds=
"
+
conf
.
dataset
+
((
conf
.
alternateBases
===
""
)
?
"
all
"
:
"
&alternateBases=
"
+
conf
.
alternateBases
)
+
"
&length=
"
+
conf
.
length
;
"
&length=
"
+
conf
.
length
+
((
conf
.
maxLength
===
''
)
?
""
:
"
&maxLength=
"
+
conf
.
maxLength
);
};
$scope
.
getInfoUrl
=
function
()
{
...
...
app/node-app/public/partials/beacon-home.html
View file @
c431628a
...
...
@@ -49,11 +49,19 @@
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"position"
class=
"col-sm-2 control-label"
>
Minimal
L
ength
</label>
<label
for=
"position"
class=
"col-sm-2 control-label"
>
Minimal
l
ength
</label>
<div
class=
"col-sm-4"
>
<input
type=
"text"
class=
"form-control"
id=
"length"
ng-model=
"config.length"
>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"position"
class=
"col-sm-2 control-label"
>
Maximal length
</label>
<div
class=
"col-sm-4"
>
<input
type=
"text"
class=
"form-control"
id=
"maxLength"
ng-model=
"config.maxLength"
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-sm-offset-2 col-sm-8"
>
<a
target=
"beacon"
ng-href=
"/v0.3/query?referenceName=11&start=34439881&assemblyId=GRCh38&datasetIds=8070/3&alternateBases=DEL"
>
Example query
</a>
...
...
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