Skip to content

Commit c04e8cd

Browse files
committed
Added gmql language definition
1 parent a44cfe6 commit c04e8cd

File tree

6 files changed

+289
-0
lines changed

6 files changed

+289
-0
lines changed

demo/kitchen-sink/docs/gmql.gmql

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
AAA_RAW = SELECT(cell == '[Cell_Name]' AND antibody_target == 'AAA' AND dataType == 'ChipSeq') HG19_ENCODE_BED;
2+
AAA_Cover_2 = COVER(2,ANY) AAA_RAW;
3+
4+
BBB_RAW = SELECT(cell == '[Cell_Name]' AND antibody_target == 'BBB' AND dataType == 'ChipSeq') HG19_ENCODE_BED;
5+
BBB_Cover_2 = COVER(2,ANY) BBB_RAW;
6+
7+
TSS = SELECT(annotation_type == 'TSS' AND provider == "UCSC") HG19_BED_ANNOTATION;
8+
9+
TSS_AAA_2_L = JOIN(DLE(100000),UP; output: LEFT) TSS AAA_Cover_2;
10+
TSS_AAA_2_COUNT = MAP() TSS TSS_AAA_2_L;
11+
TSS_AAA_2_COUNT_0 = SELECT(region: count_TSS_TSS_AAA_2_L>0) TSS_AAA_2_COUNT;
12+
13+
TSS_BBB_2_L = JOIN(DLE(100000),UP;output: LEFT) TSS BBB_Cover_2;
14+
TSS_BBB_2_COUNT = MAP() TSS TSS_BBB_2_L;
15+
TSS_BBB_2_COUNT_0 = SELECT(region: count_TSS_TSS_BBB_2_L>0) TSS_BBB_2_COUNT;
16+
17+
COMMON_TSS = JOIN(DISTANCE<1;output: INT) TSS_AAA_2_COUNT_0 TSS_BBB_2_COUNT_0 ; # Under the hyphothesis (To Be Verified) that there are no partially overlapping TSSes
18+
# Doing this I skip the names. So I map again one of them of this to extract the names
19+
20+
COMMON_TSS_NAMES = MAP() TSS COMMON_TSS;
21+
TSS_0 = SELECT(region: count_TSS_COMMON_TSS>0) COMMON_TSS_NAMES; # These are the common TSSes. Old name: COMMON_TSS_NAMES
22+
23+
LONG_TSS_0 = PROJECT(region_modifier: left AS start - 100000) TSS_0; # Extend the TSSes
24+
TSS_0_AAA_2_CLOSE_0 = MAP(TSSname AS BAG($0)) AAA_Cover_2 LONG_TSS_0; # find the TFBS that are close on left to TSSes
25+
TSS_0_AAA_2_CLOSE = SELECT(region: count_AAA_Cover_2_LONG_TSS_0 > 0) TSS_0_AAA_2_CLOSE_0; # take out the irrelevant ones
26+
TSS_0_AAA_2_CLOSEST = JOIN(MD(1);output: LEFT) TSS_0_AAA_2_CLOSE TSS_0; # Find the closest TFBS
27+
28+
TSS_0_BBB_2_CLOSE_0 = MAP(TSSname AS BAG($0)) BBB_Cover_2 LONG_TSS_0; # find the TFBS that are close on left to TSSes
29+
TSS_0_BBB_2_CLOSE = SELECT(region: count_BBB_Cover_2_LONG_TSS_0 > 0) TSS_0_BBB_2_CLOSE_0; # take out the irrelevant ones
30+
TSS_0_BBB_2_CLOSEST = JOIN(MD(1);output: LEFT) TSS_0_BBB_2_CLOSE TSS_0; # Find the closest TFBS
31+
32+
MATERIALIZE TSS_0 into AAA_2_BBB_2_tss_0;
33+
MATERIALIZE TSS_0_AAA_2_CLOSEST into tss_0_AAA_2_closest;
34+
MATERIALIZE TSS_0_BBB_2_CLOSEST into tss_0_BBB_2_closest;

lib/ace/ext/modelist.js

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ var supportedModes = {
8383
Gherkin: ["feature"],
8484
Gitignore: ["^.gitignore"],
8585
Glsl: ["glsl|frag|vert"],
86+
GMQL: ["gmql"],
8687
Gobstones: ["gbs"],
8788
golang: ["go"],
8889
Groovy: ["groovy"],

lib/ace/mode/gmql.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* ***** BEGIN LICENSE BLOCK *****
2+
* Distributed under the BSD license:
3+
*
4+
* Copyright (c) 2010, Ajax.org B.V.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* * Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
* * Neither the name of Ajax.org B.V. nor the
15+
* names of its contributors may be used to endorse or promote products
16+
* derived from this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* ***** END LICENSE BLOCK ***** */
30+
31+
define(function(require, exports, module) {
32+
"use strict";
33+
34+
var oop = require("../lib/oop");
35+
var TextMode = require("./text").Mode;
36+
var GmqlHighlightRules = require("./gmql_highlight_rules").GmqlHighlightRules;
37+
var Range = require("../range").Range;
38+
39+
var Mode = function() {
40+
this.HighlightRules = GmqlHighlightRules;
41+
};
42+
oop.inherits(Mode, TextMode);
43+
44+
(function() {
45+
46+
this.lineCommentStart = "--";
47+
48+
this.$id = "ace/mode/gmql";
49+
}).call(Mode.prototype);
50+
51+
exports.Mode = Mode;
52+
53+
});

lib/ace/mode/gmql_highlight_rules.js

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/* ***** BEGIN LICENSE BLOCK *****
2+
* Distributed under the BSD license:
3+
*
4+
* Copyright (c) 2010, Ajax.org B.V.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* * Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
* * Neither the name of Ajax.org B.V. nor the
15+
* names of its contributors may be used to endorse or promote products
16+
* derived from this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* ***** END LICENSE BLOCK ***** */
30+
31+
define(function(require, exports, module) {
32+
"use strict";
33+
34+
var oop = require("../lib/oop");
35+
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
36+
37+
var GmqlHighlightRules = function() {
38+
39+
var keywords = (
40+
"select|project|extend|group|merge|order" //relational unary operations
41+
+ "|sort" // ?do we have? //relational unary operations
42+
+ "|union|difference" //relational binary operations
43+
+ "|cover|flat|summit|histogram|map|join" //domain specific operations
44+
+ "|materialize" //utility operations
45+
);
46+
47+
var builtinConstants = (
48+
"true|false|distance|mindist|mindistance|dle|dge|md|any|all|start|stop|chr|strand|left|right|up|down|downstream|upstream"
49+
+ "|and|or|not|as|in|allbut"
50+
+ "|count|bag|sum|avg|min|max|median|std"
51+
+ "|cat|contig"
52+
);
53+
54+
var builtinFunctions = (
55+
"region|semijoin" // SELECT
56+
+ "|metadata|region_update|metadata_update" // PROJECT
57+
+ "|meta_aggregate|region_group|region_aggregate" //GROUP
58+
+ "|groupby" // MERGE
59+
+ "|desc|meta_top|meta_topg|region_order|region_top|region_topg|" // ORDER
60+
+ "|groupby" // MERGE
61+
+ "|joinby" //DIFFERENCE
62+
+ "|aggregate" //COVER(flat/summit/histogram
63+
+ "|output" //JOIN
64+
+ "|into" //MATERIALIZE
65+
//+ "|parser|region_modifier|meta_modifier|meta_project"
66+
);
67+
68+
var dataTypes = (
69+
"int|numeric|decimal|date|varchar|char|bigint|float|double|bit|binary|text|set|timestamp|" +
70+
"money|real|number|integer"
71+
);
72+
73+
var keywordMapper = this.createKeywordMapper({
74+
"support.function": builtinFunctions,
75+
"keyword": keywords,
76+
"constant.language": builtinConstants,
77+
"storage.type": dataTypes
78+
}, "identifier", true);
79+
80+
this.$rules = {
81+
"start" : [ {
82+
token : "comment",
83+
regex : "#.*$"
84+
}, {
85+
token : "string", // " string
86+
regex : '".*?"'
87+
}, {
88+
token : "string", // ' string
89+
regex : "'.*?'"
90+
}, {
91+
token : "constant.numeric", // float
92+
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
93+
}, {
94+
token : keywordMapper,
95+
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
96+
}, {
97+
token : "keyword.operator",
98+
regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=|,|;|:"
99+
}, {
100+
token : "paren.lparen",
101+
regex : "[\\(]"
102+
}, {
103+
token : "paren.rparen",
104+
regex : "[\\)]"
105+
}, {
106+
token : "text",
107+
regex : "\\s+"
108+
} ]
109+
};
110+
this.normalizeRules();
111+
};
112+
113+
oop.inherits(GmqlHighlightRules, TextHighlightRules);
114+
115+
exports.GmqlHighlightRules = GmqlHighlightRules;
116+
});
117+

lib/ace/snippets/gmql.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
define(function(require, exports, module) {
2+
"use strict";
3+
4+
exports.snippetText = require("../requirejs/text!./gmql.snippets");
5+
exports.scope = "gmql";
6+
7+
});

lib/ace/snippets/gmql.snippets

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
##
2+
## SELECT
3+
snippet SELECT
4+
SELECT(${1:pm}; region: ${2:pr}; semijoin: ${3:psj(DSext)}) ${4:DSin};
5+
6+
##
7+
8+
## MATERIALIZE
9+
snippet MATERIALIZE
10+
MATERIALIZE ${1:DS} INTO ​${2:fileName};
11+
##
12+
13+
## PROJECT
14+
snippet PROJECT
15+
PROJECT(region_update: ${1:new_right} AS ${2:right}) ${3:DS};
16+
##
17+
18+
## EXTEND
19+
snippet EXTEND
20+
EXTEND(${1:RegionCount} AS COUNT()) ${2:EXP};
21+
##
22+
23+
## GROUP
24+
snippet GROUP
25+
GROUP(${1:Tumor_type}; region_aggregate: ${2:Min AS MIN(score)}) ${3:EXP};
26+
##
27+
28+
## ORDER
29+
snippet ORDER
30+
ORDER(Region_count ${1:DESC}; meta_top: ${2:2};) ${3:INPUT_DS};
31+
##
32+
33+
## MERGE
34+
snippet MERGE
35+
MERGE(groupby: ${1:antibody_target}) ${2:EXPERIMENT};
36+
##
37+
38+
## UNION
39+
snippet UNION
40+
UNION() ${1:BROAD} ${2:NARROW};
41+
##
42+
43+
## DIFFERENCE
44+
snippet DIFFERENCE
45+
DIFFERENCE(joinby: ${1:antibody_target}) ${2:EXP1} ${3:EXP2};
46+
##
47+
48+
## MAP
49+
snippet MAP
50+
MAP (${1:minScore} AS ${2:MIN(score)}; joinby: ${3:cell_tissue}) ${4:REF} ${5:EXP};
51+
##
52+
53+
## JOIN
54+
snippet JOIN
55+
JOIN(${1:genometric_predicate}; output: ${2:CAT}; joinby: ${3:provider}) ${4:DS_ANCHOR} ${5:DS_EXP};
56+
##
57+
58+
## COVER
59+
snippet COVER
60+
COVER(${1:minAcc}, ${2:maxAcc};​ groupby: ${3:cell}; aggregate: ${4:min_pValue} AS ${5:MIN(pValue)}) ${6:DSin};
61+
##
62+
63+
## FLAT
64+
snippet FLAT
65+
FLAT(${1:minAcc}, ${2:maxAcc}; groupby: ${3:cell}) ${4:EXP};
66+
##
67+
68+
## SUMMIT
69+
snippet SUMMIT
70+
SUMMIT(${1:minAcc}, ${2:maxAcc}; groupby: ${3:cell}) ${4:EXP};
71+
##
72+
73+
## HISTOGRAM
74+
kerufherifuh
75+
snippet HISTOGRAM
76+
HISTOGRAM(${1:minAcc}, ${2:maxAcc}; groupby: ${3:cell}) ${4:EXP};
77+
##

0 commit comments

Comments
 (0)