Skip to content

Commit

Permalink
fixed #48, implementing a rescale of the coverage and a form to input…
Browse files Browse the repository at this point in the history
… a value
  • Loading branch information
tiagofilipe12 committed Sep 11, 2017
1 parent 8a58825 commit f6fe576
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
14 changes: 12 additions & 2 deletions db_manager/db_app/static/css/visualization_functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
/* customizes taxa filters buttons*/

#modal-body-file{
height: 100px;
height: 150px;
overflow: auto;
}

Expand All @@ -140,6 +140,16 @@
margin-right: 1%;
}

#cutoffFileCheck{
float: left;
}

/*resize search box for gi*/
#cutoffValue{
width: 50px;
float: right;
}

#modal-body-scheme{
height: 100px;
}
Expand Down Expand Up @@ -492,4 +502,4 @@
border-color: grey;
border-width: 1px 0px 1px 0px;
outline: none;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// will cancel reader when defined... so during handleFileSelect
const abortRead = (reader) => {
console.log('canceled reading of file')
console.log("canceled reading of file")
// cancels the loading it self
document.getElementById('file_text').value = ''
read_json = ''
document.getElementById("file_text").value = ""
read_json = ""
}

// function to handle ONE file at a time (per button)
// infile_id refers to the button id and text_id referes to the text form that reads the file
const handleFileSelect = (infileId, textId, callback) => {
document.getElementById(infileId).addEventListener('change', function (e) {
document.getElementById(infileId).addEventListener("change", function (e) {
first_file = true // bollean to check the existance of a first file
var files = e.target.files // FileList object
// append fle name to text fomr displaying current selection

// checks if it is a json file extension
if (!files[0].name.includes('.json')) {
if (!files[0].name.includes(".json")) {
alert("File extension not supported. Only '.json' files are supported.")
} else {
// append the filename to the form
Expand Down
24 changes: 21 additions & 3 deletions db_manager/db_app/static/js/node_handling/reads_coloring.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const read_coloring = (g, list_gi, graphics, renderer) => {
scale = chroma.scale(['blue', '#eacc00', 'maroon'])
palette(scale, 20, readMode)
} else {
read_color = chroma.mix('lightsalmon', 'maroon', perc).hex().replace('#', '0x')
newPerc = rangeConverter(perc, cutoffParser(), 1, 0, 1)
read_color = chroma.mix('lightsalmon', 'maroon', newPerc).hex().replace('#', '0x')
scale = chroma.scale(['lightsalmon', 'maroon'])
palette(scale, 20, readMode)
}
Expand Down Expand Up @@ -145,9 +146,26 @@ const palette = (scale, x, readMode) => { // x is the number of colors to the
color_element = scale(i / x).hex()
$('#readLegend').append('<span class="grad-step" style="background-color:' + color_element + '; width:' + style_width + '%"></span>')
}
$('#readLegend').append('<div class="header_taxa" id="min">0</div>')
$('#readLegend').append('<div class="header_taxa" id="med">0.5</div>')
$('#readLegend').append('<div class="header_taxa" id="min">0.6</div>')
$('#readLegend').append('<div class="header_taxa" id="med">0.8</div>')
$('#readLegend').append('<div class="header_taxa" id="max">1</div>')
document.getElementById('read_label').style.display = 'block' // show label
}
}

// convertes a given range to valies between c and 1
// TODO default behavior should be between 0.6 and 1 in accordance with
// plasmidUNCover.py
const rangeConverter = (x, oldMin, oldMax, newMin, newMax) => {
// initial range is between 0 and 1
// newMax should be 1
// newMin should be the one that may change on user input and default
// behavior should be 0.6--> this is done by cutoffParser()
const y = (x - oldMin) * (newMax - newMin) / (oldMax - oldMin) + newMin
return y
}

// function to get value from cutoffValue
const cutoffParser = () => {
return ($("#cutoffValue").val() !== "") ? parseFloat($("#cutoffValue").val()) : 0.6
}
9 changes: 8 additions & 1 deletion db_manager/db_app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,16 @@ <h4 class="modal-title">Select input file</h4>
<div class="checkbox col-md-12">Check for pairwise comparison mode
<label>
<!--autocomplete prevents checkbox from being checkd after refresh-->
<input type="checkbox" id="check_file" autocomplete="off">
<input type="checkbox" id="check_file" autocomplete="off">
</label>
</div>
<div>
<div class="form-group" id="cutoffFileCheck">Provide a
value between 0 and 1. Tip: default is 0.6.
<input id="cutoffValue" type="text" class="form-control"
placeholder="0.6"/>
</div>
</div>
</div>
</div>

Expand Down

0 comments on commit f6fe576

Please sign in to comment.