diff --git a/src/components/workspace/uploadworkspace/settings.jsx b/src/components/workspace/uploadworkspace/settings.jsx index d7762c0..2e0375e 100644 --- a/src/components/workspace/uploadworkspace/settings.jsx +++ b/src/components/workspace/uploadworkspace/settings.jsx @@ -10,29 +10,33 @@ const SettingsPanel = ({ onLogoTypeChange, onScaleChange, onStartPosChange, onModeChange, mode, logodefault, scaledefault, startposdefault, alphabet, onAlphabetUpdate, onFrequencyChange, backgroundFrequencies, onApplyToFile, onApplyToAll, yAxisAuto, - onYAxisToggle, yAxisMax }) => ( + onYAxisToggle, yAxisMax, hasNegatives }) => (
); diff --git a/src/components/workspace/uploadworkspace/uploadworkspace.jsx b/src/components/workspace/uploadworkspace/uploadworkspace.jsx index 84eee6d..7f27554 100644 --- a/src/components/workspace/uploadworkspace/uploadworkspace.jsx +++ b/src/components/workspace/uploadworkspace/uploadworkspace.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { Grid, Menu, Dropdown, Button, Icon } from 'semantic-ui-react'; -import { embedLogo, Logo, INFORMATION_CONTENT } from 'logosj-react'; +import { embedLogo, Logo, INFORMATION_CONTENT, LogoWithNegatives } from 'logosj-react'; import { _svgdata } from '../../svgdownload/utils'; import SVGZip from '../../../utilities/zipfile'; @@ -42,12 +42,14 @@ class UploadWorkspace extends React.Component { }; } - _updateFile() { + _updateFile(hasNegatives, mode) { const nLogo = { startpos: this.state.selected.startpos, - alphabet: this.state.selected.alphabet, - backgroundFrequencies: this.state.selected.backgroundFrequencies + alphabet: this.state.selected.alphabet }; + if (!hasNegatives) nLogo.backgroundFrequencies = this.state.selected.backgroundFrequencies; + if (!hasNegatives) nLogo.mode = mode; + if (!hasNegatives && mode === INFORMATION_CONTENT) nLogo.yAxisMax = this.state.selected.yAxisAuto === false ? this.state.selected.yAxisMax : null; const nSets = [ ...this.state.logoSets ]; const nLogos = this.state.selectedFile.logos.map( logo => ({ ...logo, @@ -65,12 +67,14 @@ class UploadWorkspace extends React.Component { }); } - _updateAll() { + _updateAll(hasNegatives, mode) { const nLogo = { startpos: this.state.selected.startpos, - alphabet: this.state.selected.alphabet, - backgroundFrequencies: this.state.selected.backgroundFrequencies + alphabet: this.state.selected.alphabet }; + if (!hasNegatives) nLogo.backgroundFrequencies = this.state.selected.backgroundFrequencies; + if (!hasNegatives) nLogo.mode = mode; + if (!hasNegatives && mode === INFORMATION_CONTENT) nLogo.yAxisMax = this.state.selected.yAxisAuto === false ? this.state.selected.yAxisMax : null; const nSets = [ ...this.state.logoSets ]; nSets.forEach( (logoSet, i) => { const nLogos = logoSet.logos.map( logo => ({ @@ -292,12 +296,27 @@ class UploadWorkspace extends React.Component { yAxisMax }); } + + _hasNegatives(ppm) { + let r = false; + ppm.forEach( row => { row.forEach( x => { if (x < 0) r = true; } ); } ); + return r; + } render() { + let isdone = this.state.remaining === 0 && this.state.logoSets.length > 0; let selectedPPMs = this.state.selectedFile && this.state.selectedFile.logos; const selectedProps = this.state.selected ? { ...this.state.selected } : {}; if (selectedProps && selectedProps.yAxisAuto) selectedProps.yAxisMax = null; + + const defaultMax = this.state.selected && ( + this.state.selected.backgroundFrequencies + ? Math.max(...this.state.selected.backgroundFrequencies.map( x => Math.log2(1.0 / (x || 0.01)))) + : (this.state.selected.alphabet && Math.log2(this.state.selected.alphabet.length)) + ); + const hasNegatives = this.state.selected && this.state.selected.ppm && this._hasNegatives(this.state.selected.ppm); + return (