-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphdrListWildtypeEqual.js
57 lines (52 loc) · 1.82 KB
/
phdrListWildtypeEqual.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var almtRasObjs = glue.tableToObjects(glue.command(["list", "custom-table-row", "phdr_alignment_ras",
"display_structure", "phdr_ras.gene", "phdr_ras.structure", "alignment.displayName"]));
var wildtypeRasObjs = [];
_.each(almtRasObjs, function(almtRasObj) {
var wildtypeRas = false;
var mixedWildtypeRas = false;
var structure = almtRasObj.display_structure;
var structureBits = structure.split("+");
_.each(structureBits, function(structureBit) {
if(structureBit.indexOf("del") < 0) {
var wildtypeAndMutationBits = structureBit.split(/[0-9]+/);
var wildtypeBit = wildtypeAndMutationBits[0];
var mutationBit = wildtypeAndMutationBits[1];
var wildtypeAas = wildtypeBit.split("/");
var mutationAas = mutationBit.split("/");
var intersection = _.intersection(wildtypeAas, mutationAas);
if(intersection.length > 0) {
if(wildtypeAas.length > 1) {
mixedWildtypeRas = true;
} else {
wildtypeRas = true;
}
}
}
});
if(wildtypeRas || mixedWildtypeRas) {
wildtypeRasObjs.push({
clade: almtRasObj["alignment.displayName"].replace("HCV ", ""),
virusProtein: almtRasObj["phdr_ras.gene"],
polymorphism: almtRasObj["display_structure"],
combination: structureBits.length > 1 ? "Yes" : "No",
mixedWildtype: mixedWildtypeRas ? "Yes" : "No",
hcvGlueLink: "=HYPERLINK(\"http://hcv-glue.cvr.gla.ac.uk/#/project/rap/"+almtRasObj["phdr_ras.gene"]+":"+almtRasObj["phdr_ras.structure"]+"\")",
});
}
});
var documentResult = {
"documentResult":{
"column":_.keys(wildtypeRasObjs[0]),
"row":_.map(wildtypeRasObjs, function(obj) {
return {
"value":_.values(obj)
};
})
}
};
glue.inMode("module/phdrTabularUtility", function() {
glue.command({"save-tabular": {
"tabularData": documentResult,
"fileName": "wildtypeRasList.txt"
}});
});