Skip to content

Commit

Permalink
Merge pull request biocore#305 from antgonza/issue_300
Browse files Browse the repository at this point in the history
Issue 300
  • Loading branch information
ElDeveloper committed Sep 22, 2014
2 parents db2bd50 + 6864cf3 commit 049e744
Show file tree
Hide file tree
Showing 42 changed files with 2,038 additions and 45,650 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Emperor 0.9.4-dev (changes since Emperor 0.9.4 go here)
* Add numpydoc generated documentation setup.
* Emperor's documentation requires `sphinx-boostrap-theme` and `sphinx`.
* Add documentation about file formats.
* Updated to three.js revision 68.


Emperor 0.9.4 (10 Sept 2014)
Expand Down
6 changes: 3 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Emperor makes usage of all of the following copyrighted packages; their licenses

--------------------------------------------------------------------------------

### THREE.js ([r58](https://github.com/mrdoob/three.js/tree/r58)) is released under the MIT License
### THREE.js ([r68](https://github.com/mrdoob/three.js/tree/r68)) is released under the MIT License

The MIT License

Expand Down Expand Up @@ -171,7 +171,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------------------

### THREEx.screenshot [v1](http://learningthreejs.com/data/THREEx/docs/THREEx.screenshot.html)
### THREEx.screenshot [v1](http://learningthreejs.com/data/THREEx/docs/THREEx.screenshot.html)
[repository](https://github.com/jeromeetienne/threex)

Copyright (c) 2011 Jerome Etienne, http://jetienne.com
Expand All @@ -197,7 +197,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--------------------------------------------------------------------------------

### FileSaver.js [283e78fd3c](https://github.com/eligrey/FileSaver.js/)
### FileSaver.js [283e78fd3c](https://github.com/eligrey/FileSaver.js/)

Copyright (c) 2011 [Eli Grey](http://eligrey.com).

Expand Down
28 changes: 15 additions & 13 deletions emperor/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EmperorLogicError(ValueError):
pass

def format_pcoa_to_js(header, coords, eigvals, pct_var, custom_axes=[],
coords_low=None, coords_high=None, number_of_axes=10,
coords_low=None, coords_high=None, number_of_axes=10,
number_of_segments=8):
"""Write the javascript necessary to represent a pcoa file in emperor
Expand All @@ -50,7 +50,7 @@ def format_pcoa_to_js(header, coords, eigvals, pct_var, custom_axes=[],
coords_low: coordinates representing the lower edges of an ellipse
coords_high: coordinates representing the highere edges of an ellipse
number_of_axes: number of axes to be returned
number_of_segments: number of segments and rings for each sphere
number_of_segments: number of segments and rings for each sphere
Output:
string: javascript representation of the PCoA data inputed, contains a list
Expand All @@ -61,7 +61,7 @@ def format_pcoa_to_js(header, coords, eigvals, pct_var, custom_axes=[],
declarations.
"""
js_pcoa_string = ''

# validating that the number of coords in coords
if number_of_axes>len(coords[0]):
number_of_axes = len(coords[0])
Expand All @@ -88,7 +88,7 @@ def format_pcoa_to_js(header, coords, eigvals, pct_var, custom_axes=[],
min_z = min(coords[:,2:3])
maximum = max(abs(coords[:,:number_of_axes]))
pcoalabels = pct_var[:number_of_axes]

radius = (max_x-min_x)*.012

# write the values for all the spheres
Expand All @@ -110,8 +110,8 @@ def format_pcoa_to_js(header, coords, eigvals, pct_var, custom_axes=[],
"'color': 0, 'width': %f, 'height': %f, 'length': %f , 'x': %f,"
" 'y': %f, 'z': %f, %s }\n" % (s_header, s_header,delta[0], delta[1],
delta[2], s_coord[0], s_coord[1], s_coord[2], all_coords))
js_pcoa_string += 'var g_segments = %d, g_rings = %d, g_radius = %f;\n' % (number_of_segments,

js_pcoa_string += 'var g_segments = %d, g_rings = %d, g_radius = %f;\n' % (number_of_segments,
number_of_segments, radius)
js_pcoa_string += 'var g_xAxisLength = %f;\n' % (abs(max_x)+abs(min_x))
js_pcoa_string += 'var g_yAxisLength = %f;\n' % (abs(max_y)+abs(min_y))
Expand Down Expand Up @@ -139,7 +139,7 @@ def format_pcoa_to_js(header, coords, eigvals, pct_var, custom_axes=[],
js_pcoa_string += 'var g_pc%dLabel = \"PC%d (%.2f %%)\";\n' %\
(i+1, i+1-offset, pcoalabels[i-offset])
js_pcoa_string += 'var g_number_of_custom_axes = %d;\n' % offset

js_pcts = []
js_pcts_round = []
if custom_axes == None: custom_axes = []
Expand All @@ -153,7 +153,7 @@ def format_pcoa_to_js(header, coords, eigvals, pct_var, custom_axes=[],
js_pcts_round.append('%.2f' % (pct_var[0]))
js_pcoa_string += 'var g_fractionExplained = [%s];\n' % ', '.join(js_pcts)
js_pcoa_string += 'var g_fractionExplainedRounded = [%s];\n' % ', '.join(js_pcts_round)

return js_pcoa_string

def format_mapping_file_to_js(mapping_file_data, mapping_file_headers, columns):
Expand Down Expand Up @@ -203,7 +203,7 @@ def format_mapping_file_to_js(mapping_file_data, mapping_file_headers, columns):
def format_taxa_to_js(otu_coords, lineages, prevalence, min_taxon_radius=0.5,
max_taxon_radius=5, radius=1.0):
"""Write a string representing the taxa in a PCoA plot as javascript
Inputs:
otu_coords: numpy array where the taxa is positioned
lineages: label for each of these lineages
Expand Down Expand Up @@ -503,9 +503,11 @@ def format_emperor_autograph(metadata_fp, coords_fp, language='HTML'):
<script type="text/javascript" src="emperor_required_resources/js/d3.parcoords.js"></script>
<!-- THREE.js and plugins for screenshots -->
<script type="text/javascript" src="emperor_required_resources/js/Three.js"></script>
<script type="text/javascript" src="emperor_required_resources/js/three.min.js"></script>
<script type="text/javascript" src="emperor_required_resources/js/js/Detector.js"></script>
<script type="text/javascript" src="emperor_required_resources/js/js/RequestAnimationFrame.js"></script>
<script type="text/javascript" src="emperor_required_resources/js/js/OrbitControls.js"></script>
<script type="text/javascript" src="emperor_required_resources/js/js/ColorConverter.js"></script>
<script type="text/javascript" src="emperor_required_resources/js/js/SVGRenderer.js"></script>
<script type="text/javascript" src="emperor_required_resources/js/THREEx.screenshot.js"></script>
<!-- General utilities (underscore.js and FileSaver.js) -->
Expand All @@ -521,7 +523,7 @@ def format_emperor_autograph(metadata_fp, coords_fp, language='HTML'):
<script type="text/javascript" src="emperor_required_resources/emperor/js/util.js"></script>
<script type="text/javascript">
"""

_ELLIPSE_OPACITY_SLIDER = """
Expand Down Expand Up @@ -808,7 +810,7 @@ def format_emperor_autograph(metadata_fp, coords_fp, language='HTML'):
</td></tr>
</table>
</div>
</div>
</div>
</div>
</body>
Expand Down
19 changes: 7 additions & 12 deletions emperor/support_files/emperor/js/emperor.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,18 +568,13 @@ function showByMenuChanged() {
// get all of the values for the selected category
vals.push(g_mappingFileData[sid][showByMenuIndex]);
// set everything to visible
try {
g_elementsGroup.add(g_plotEllipses[sid])
}
catch(TypeError){}
try {
g_elementsGroup.add(g_plotSpheres[sid])
}
catch(TypeError){}
try {
g_elementsGroup.add(g_plotVectors[sid])
}
catch(TypeError){}
if (typeof g_plotEllipses[sid] != 'undefined')
g_elementsGroup.add(g_plotEllipses[sid])
if (typeof g_plotSpheres[sid] != 'undefined')
g_elementsGroup.add(g_plotSpheres[sid])
if (typeof g_plotVectors[sid] != 'undefined')
g_elementsGroup.add(g_plotVectors[sid])

$('#'+divid+"_label").css('display','block');
}

Expand Down
Loading

0 comments on commit 049e744

Please sign in to comment.