Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/filter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,17 @@ class filter

generateColumns: () ->

if !biom.columns[0].metadata?
for i in [0..attr_length]
if !biom.columns[i].metadata?
biom.columns[i].metadata = {}

for key of biom.columns[0].metadata
if key.toLowerCase().indexOf("date") != -1
date_array.push(key)

else if key == 'phinchID'
console.log 'PhinchID does exsit!'
console.log 'PhinchID does exist!'

else if (key.toLowerCase().indexOf("barcode") != -1) || (key.toLowerCase().indexOf("sequence") != -1) || (key.toLowerCase().indexOf("reverse") != -1) || (key.toLowerCase() == "internalcode") || (key.toLowerCase() == "description") || (key.toLowerCase().indexOf("adapter") !=-1)
no_data_attributes_array.push(key)
Expand Down Expand Up @@ -362,7 +367,7 @@ class filter
toprocess = []

content = ""
content += "<span class = 'biom_valid_attr'>" + groupable_array[_i] + "</span><br/>"
content += "<span class = 'biom_valid_attr'>" + groupable_array[i] + "</span><br/>"

if groupable_array_content.length > 0
for j in [pointer_left..groupable_array_content.length-1]
Expand All @@ -379,7 +384,7 @@ class filter

if toprocess.length > 0
for k in [0..toprocess.length-1]
content += "<input type='checkbox' name='groupable_check_group' id='groupable_check_" + check_count + "' checked='checked' /><label for='groupable_check_" + check_count + "'></label><span class = 'biom_valid_attr_grp'>" + toprocess[_k] + "</span><br/>"
content += "<input type='checkbox' name='groupable_check_group' id='groupable_check_" + check_count + "' checked='checked' /><label for='groupable_check_" + check_count + "'></label><span class = 'biom_valid_attr_grp'>" + toprocess[k] + "</span><br/>"
check_count++

$('#groupable_att').append("<div class='overflowControl'>" + content + "</div>")
Expand Down Expand Up @@ -601,16 +606,18 @@ class filter
for i in [0..biom.shape[1]-1]

# If this is a not selected descriptive attribute, delete it
for j in [0..no_data_attributes_array.length-1]
if @selected_no_data_attributes_array.indexOf(no_data_attributes_array[j]) == -1
@removeFromObjectByKey(phinch.columns[i].metadata, no_data_attributes_array[j])

if no_data_attributes_array.length > 0
for j in [0..no_data_attributes_array.length-1]
if @selected_no_data_attributes_array.indexOf(no_data_attributes_array[j]) == -1
@removeFromObjectByKey(phinch.columns[i].metadata, no_data_attributes_array[j])
# If this is not a selected attributes, delete it
for k in [0..attributes_array.length-1]
if @selected_attributes_array.indexOf(attributes_array[k]) == -1
@removeFromObjectByKey(phinch.columns[i].metadata, attributes_array[k])

if attributes_array.length > 0
for k in [0..attributes_array.length-1]
if @selected_attributes_array.indexOf(attributes_array[k]) == -1
@removeFromObjectByKey(phinch.columns[i].metadata, attributes_array[k])
# Add the new phinch Id column back in the file
if !phinch.columns[i].metadata?
phinch.columns[i].metadata = {}
phinch.columns[i].metadata['phinchID'] = phinchID_array[i]


Expand Down
31 changes: 30 additions & 1 deletion src/readFile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,44 @@ class readFile
@checkFile(files)
false)

# Load by URL, requires CORS at remote server
query = window.location.search.substring(1)
raw_vars = query.split("&")
params = {}
for v in raw_vars
[key, val] = v.split("=")
params[key] = decodeURIComponent(val)
if params['biomURL']?
$('#loadTestFile').hide()
$('#fileDrag').hide()
$('#progress_bar').hide()
$('#frmUpload').hide()
$('#parse').html('loading URL...&nbsp;&nbsp;<i class="icon-spinner icon-spin icon-large"></i>');
$.get(params['biomURL'], (urlData) =>
if urlData.constructor != String
urlData = JSON.stringify( urlData )
biomToStore = {}
biomToStore.name = params['biomURL']
biomToStore.size = urlData.length
biomToStore.data = urlData
d = new Date();
biomToStore.date = d.getUTCFullYear() + "-" + (d.getUTCMonth() + 1) + "-" + d.getUTCDate() + "T" + d.getUTCHours() + ":" + d.getUTCMinutes() + ":" + d.getUTCSeconds() + " UTC"
@server.biom.add(biomToStore).done () ->
setTimeout( "window.location.href = 'preview.html'", 1)
)


# load test file
document.getElementById('loadTestFile').addEventListener('click', (evt) =>
$('#loadTestFile').html('loading...&nbsp;&nbsp;<i class="icon-spinner icon-spin icon-large"></i>');
hostURL = 'http://' + window.location.host + window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/'))
testfile = hostURL + '/data/testdata.biom' ## Dev TODO http://phinch.org/data/testdata.biom
$.get(testfile, (testdata) =>
if testdata.constructor != String
testdata = JSON.stringify( testdata )
biomToStore = {}
biomToStore.name = 'testdata.biom'
biomToStore.size = 15427024
biomToStore.size = testdata.length
biomToStore.data = testdata
d = new Date();
biomToStore.date = d.getUTCFullYear() + "-" + (d.getUTCMonth() + 1) + "-" + d.getUTCDate() + "T" + d.getUTCHours() + ":" + d.getUTCMinutes() + ":" + d.getUTCSeconds() + " UTC"
Expand Down
3 changes: 3 additions & 0 deletions src/taxonomyViz.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ class taxonomyViz
comp_i = new Array(7)
comb_len = unique_taxonomy_comb.length

if !biom.rows[i].metadata? or !biom.rows[i].metadata.taxonomy?
alert '"taxonomy" metadata needs to be provided in BIOM file'

if biom.rows[i].metadata.taxonomy.indexOf(';') != -1
comp_i = biom.rows[i].metadata.taxonomy.replace(/\s+/g, '').replace(/;/g,',').split(',')
else
Expand Down