-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeneTools.js
27 lines (27 loc) · 961 Bytes
/
GeneTools.js
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
/* Module: GeneTools.js
Notes: Provides methods for handling gene data.
Dependencies: None
Author: Robin Dunn
*/
var GeneTools = {
parseHgvsQuery: function(query){
var parts = { symbol: '', type:'', positionChange:'' };
if(typeof query !== 'string' || query == '')
throw new Error('HGVS query must not be null or empty.');
var iDot = query.indexOf('.');
var iColon = query.indexOf(':');
if(iDot >= 1 && iColon >= 2){
parts.symbol = query.substring(0, iDot);
parts.type = query.substring(iDot+1, iColon);
parts.positionChange = query.substring(iColon+1);
}
return parts;
},
hasCharAt: function(sequence, index, character){
var isFound = false;
if(typeof sequence === 'string' && sequence.length >= index) {
isFound = sequence[index] == character;
}
return isFound;
}
}