Commit 0fe23f04 authored by MatusT's avatar MatusT
Browse files
parents 641f35df 09f9795d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -206,6 +206,7 @@ function App(): JSX.Element {
    {
      type: "bin-coordinates-single",
      dataId: undefined,
      mappingIds: [],
      visible: false,
      from: 0,
      to: 0
+43 −0
Original line number Diff line number Diff line
@@ -47,6 +47,18 @@ export function ChromatinViewportConfigurationPanel(props: {
            } as IComboBoxOption;
        });

    const otherData1DOptions = data.data
        .filter(d => d.type == "sparse-1d-data-text" || d.type == "sparse-1d-data-numerical")
        .map(d => {
            return {
                key: isoDataID.unwrap(d.id),
                id: isoDataID.unwrap(d.id).toString(),
                text: d.name,
            }
        })



    const [isCalloutVisible, setIsCalloutVisible] = useState<boolean>(false);

    const selections = useSelections(0, [configuration, updateConfiguration], props.dataReducer, props.selectionsReducer);
@@ -129,6 +141,19 @@ export function ChromatinViewportConfigurationPanel(props: {
        }
    };

    const setOtherData1D = (event: React.FormEvent<IComboBox>, option?: IComboBoxOption) => {

        const selected = option?.selected;
        if (option) {
            updateConfiguration({
                ...configuration,
                otherMapValues: selected
                    ? [...configuration.otherMapValues, isoDataID.wrap(Number(option!.key))]
                    : configuration.otherMapValues.filter(id => id != isoDataID.wrap(Number(option!.key)))
            });
        }
    }

    const setRadius = (radius: number) => {
        if (!configuration.data) return;

@@ -309,6 +334,24 @@ export function ChromatinViewportConfigurationPanel(props: {
                }
            />)
        }
        <Text nowrap block variant='large'>The other map 1D data</Text>
        {otherData1DOptions.length <= 0 && ("No more data available.")}
        {
            otherData1DOptions.length > 0 && (<ComboBox
                label=""
                allowFreeform={false}
                autoComplete={'on'}
                multiSelect
                options={otherData1DOptions}
                onChange={setOtherData1D}
                // onItemClick={setData1D}
                style={{ marginTop: '8px', padding: '4px' }}
                shouldRestoreFocus={false}
                selectedKey={
                    configuration.otherMapValues.map(k => isoDataID.unwrap(k))
                }
            />)
        }

        {/* SELECTIONS */}
        <div style={{ display: 'block', width: '100%', marginTop: '16px' }}></div>
+30 −3
Original line number Diff line number Diff line
import { Dispatch } from "react";
import { binToGenomicCoordinate } from "../../modules/coordniatesUtils";
import { CoordinatePreviewAction, CoordinatePreviewState } from "../../modules/storage/models/coordinatePreview";
import { BinPositionsData, DataAction, DataState } from "../../modules/storage/models/data";
import { BinPositionsData, DataAction, DataState, Sparse1DTextData, Sparse1DNumericData } from "../../modules/storage/models/data";
import { ConfigurationAction, ConfigurationState } from "../../modules/storage/models/viewports";
import { useConfigurationTypeless } from "../hooks";

@@ -13,7 +13,7 @@ export function CoordinatePreview(props: {
}) {
    const [coordinatePreview, dispatchCoordinatePreview] = props.coordinatePreviewReducer;
    const [data, dispatchData] = props.dataReducer;
    if (!coordinatePreview.visible) {
    if (!coordinatePreview.visible || coordinatePreview.dataId == null) {
        return <></>
    }

@@ -22,10 +22,37 @@ export function CoordinatePreview(props: {
        return <></>
    }

    const renderMapped = (genomicFrom: number, genomicTo: number) => {
        const mappedPairs = [];
        for (const mappedId of coordinatePreview.mappingIds) {
            const mappedData = data.data.find(d => d.id == mappedId);
            if (!mappedData) {
                continue
            }
            if (mappedData.type != 'sparse-1d-data-text' && mappedData.type != 'sparse-1d-data-numerical') {
                throw `No representation for data type ${mappedData.type}`
            }


            if (mappedData.type == 'sparse-1d-data-text') {
                const data1d = mappedData.values as Sparse1DTextData
                for (const txtValue of data1d.filter(v => v.from <= genomicTo && v.to >= genomicFrom)) {
                    mappedPairs.push(<><span>{mappedData.name}:  {txtValue.name} </span> | </>)
                }
            }
            if (mappedData.type == 'sparse-1d-data-numerical') {
                const data1d = mappedData.values as Sparse1DNumericData
                for (const txtValue of data1d.filter(v => v.from <= genomicTo && v.to >= genomicFrom)) {
                    mappedPairs.push(<><span>{mappedData.name}:  {txtValue.value} </span> | </>)
                }
            }
        }
        return mappedPairs;
    }
    if (dataModel.type == '3d-positions') {
        const dataModel3d = dataModel as BinPositionsData;
        const [genomicFrom, genomicTo] = binToGenomicCoordinate(coordinatePreview.from, dataModel3d.basePairsResolution)
        return <div style={props.style}>Bin: {coordinatePreview.from} (Genomic: {genomicFrom} - {genomicTo})</div>
        return <div style={props.style}>Bin: {coordinatePreview.from} (Genomic: {genomicFrom} - {genomicTo}) | {renderMapped(genomicFrom, genomicTo)}</div>

    }

+0 −1
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ export function NewGenomicDataDialog(props: {


    if (file != null) {
        debugger;
        parsedFile = parseBED(file.content, delimiter)
        if (parsedFile.length == 0) {
            parsedFileColumns = [];
+1 −1
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ export function ChromatinViewport(props: {
            visible: true,
            type: "bin-coordinates-single",
            dataId: iso<DataID>().wrap(closestIntersection.chromatinPart.dataId),
            mappingIds: configuration.otherMapValues,
            from: closestIntersection.binIndex
        })
    }, [viewport, closestIntersection])
@@ -544,7 +545,6 @@ export function ChromatinViewport(props: {
            const sphereRadius = tool.radius;
            const value = isAltPressed ? 0 : 1;


            for (let chromosomeIndex = 0; chromosomeIndex < configuration.chromosomes.length; chromosomeIndex++) {
                const chromatinPart = viewport.getChromatinPartByChromosomeIndex(chromosomeIndex);
                if (!chromatinPart || !configuration.chromosomes[chromosomeIndex]) return;
Loading