-
Notifications
You must be signed in to change notification settings - Fork 0
/
preprocess_util.js
52 lines (50 loc) · 1.3 KB
/
preprocess_util.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
/**
* Filters an array of files. Returns an array that only contains files that contain "indel" in their name.
* @param inArr - the array.
* @return a filtered array - it will only contain files whose names contain the string "indel".
*/
function filterForIndels(inArr)
{
var arr = [];
for (var i = 0; i < inArr.length ; i++)
{
if (inArr[i].basename.indexOf("indel") >= 0)
{
arr.push(inArr[i]);
}
}
return arr;
}
/**
* This function will filter an array of files and select only files that match
* workflowName and vcfType.
* @param workflowName - the name of the workflow to filter for.
* @param vcfType - the type of VCF (snv, indel, etc...)
* @param inArr - an array of files (File[]) to search through.
* @return an array that has been filtered.
*/
function filterFor(workflowName, vcfType, inArr)
{
var arr = [];
for (var i = 0; i < inArr.length; i++)
{
if (typeof(inArr[i]) == "string") //("class" in inArr[i] && inArr[i].class == "File")
{
if (inArr[i].indexOf(workflowName) >= 0 && inArr[i].indexOf(vcfType) >= 0)
{
arr.push(inArr[i])
}
}
else
{
if ("class" in inArr[i] && inArr[i].class == "File")
{
if (inArr[i].basename.indexOf(workflowName) >= 0 && inArr[i].basename.indexOf(vcfType) >= 0)
{
arr.push(inArr[i])
}
}
}
}
return arr;
}