-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotate_util.js
65 lines (61 loc) · 1.61 KB
/
annotate_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
53
54
55
56
57
58
59
60
61
62
63
64
65
function flatten_nested_arrays(array_of_arrays)
{
var flattened_array = []
for (var i in array_of_arrays)
{
var item = array_of_arrays[i]
if (item instanceof Array)
{
// console.log("found subarray")
// recursively flatten subarrays.
var flattened_sub_array = flatten_nested_arrays(item)
for (var k in flattened_sub_array)
{
flattened_array.push(flattened_sub_array[k])
}
}
else
{
flattened_array.push(item)
}
}
return flattened_array
}
function chooseVCFsForAnnotator(VCFs, associatedVcfs)
{
var vcfsToUse = [];
//this might be a nested array if it came from the OxoG output.
var flattened_array = flatten_nested_arrays(VCFs);
var associated_vcfs = associatedVcfs
for (var i in associated_vcfs)
{
for (var j in flattened_array)
{
if ( flattened_array[j].basename.indexOf(associated_vcfs[i].replace(".vcf.gz","")) !== -1 )
{
//console.log("OK "+flattened_array[j].basename + " was in "+associated_vcfs[i] +" so it will be annotated!")
vcfsToUse.push( flattened_array[j] );
}
else
{
//console.log("Not OK "+ flattened_array[j].basename + " was NOT in "+associated_vcfs[i] +" so it will NOT be annotated!")
}
}
}
return vcfsToUse;
}
function chooseBamForAnnotator(tumourBams, tumours_record)
{
// var BamToUse
for (var j in tumourBams )
{
// The Bam should be named the same as the regular bam, except for the "mini-" prefix.
// This condition should only ever be satisfied once.
if (tumourBams[j].basename.indexOf( tumours_record.bamFileName ) !== -1 )
{
return tumourBams[j]
}
}
//return BamToUse
return undefined
}