Skip to content

Commit

Permalink
Fixed some build stuff and re-checked flowjo
Browse files Browse the repository at this point in the history
  • Loading branch information
keshav22 committed Sep 10, 2021
1 parent 22472ef commit 1def8eb
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 38 deletions.
75 changes: 38 additions & 37 deletions src/graph/dataManagement/workspaceAssembler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,44 @@ import { COMMON_CONSTANTS } from "assets/constants/commonConstants";

export default class WorkspaceAssembler {
exportWorkspace(workspace: WorkspaceData): string {
const files: string[] = [];
workspace.files.forEach((e) => {
files.push(e.src + "://" + e.id);
});
const gates: Gate[] = [];
workspace.gates.forEach((e) => {
e = lodash.cloneDeep(e);
e.parents = e.parents.map((p: any) => p.id);
e.children = e.children.map((c: any) => c.id);
const gateObj = JSON.parse(JSON.stringify(e));
delete gateObj.observers;
gates.push(gateObj);
});
const plots: object[] = [];
workspace.plots.forEach((plot: any) => {
let nplot = lodash.cloneDeep(plot);
nplot.histogramBarOverlays.forEach((x: any) => {
if (x.plot && Object.keys(x.plot).length > 0)
x.plot = this.parsePlot(x.plot);
});
nplot.histogramOverlays.forEach((x: any) => {
if (x.plot && Object.keys(x.plot).length > 0)
x.plot = this.parsePlot(x.plot);
});
let p = this.parsePlot(nplot);
plots.push(p);
});
const name =
workspace.workspaceName === undefined ? "" : workspace.workspaceName;

const workspaceJSON = JSON.stringify({
name,
files,
gates,
plots: plots === null || plots === undefined ? [] : plots,
});
return workspaceJSON;
// const files: string[] = [];
// workspace.files.forEach((e) => {
// files.push(e.src + "://" + e.id);
// });
// const gates: Gate[] = [];
// workspace.gates.forEach((e) => {
// e = lodash.cloneDeep(e);
// e.parents = e.parents.map((p: any) => p.id);
// e.children = e.children.map((c: any) => c.id);
// const gateObj = JSON.parse(JSON.stringify(e));
// delete gateObj.observers;
// gates.push(gateObj);
// });
// const plots: object[] = [];
// workspace.plots.forEach((plot: any) => {
// let nplot = lodash.cloneDeep(plot);
// nplot.histogramBarOverlays.forEach((x: any) => {
// if (x.plot && Object.keys(x.plot).length > 0)
// x.plot = this.parsePlot(x.plot);
// });
// nplot.histogramOverlays.forEach((x: any) => {
// if (x.plot && Object.keys(x.plot).length > 0)
// x.plot = this.parsePlot(x.plot);
// });
// let p = this.parsePlot(nplot);
// plots.push(p);
// });
// const name =
// workspace.workspaceName === undefined ? "" : workspace.workspaceName;
// const workspaceJSON = JSON.stringify({
// name,
// files,
// gates,
// plots: plots === null || plots === undefined ? [] : plots,
// });
// return workspaceJSON;

return "";
}
parsePlot(plot: any) {
plot = lodash.cloneDeep(plot);
Expand Down
83 changes: 83 additions & 0 deletions src/graph/utils/workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// import {
// File,
// FileID,
// Gate,
// GateID,
// Plot,
// PlotID,
// Population,
// PopulationID,
// Workspace,
// } from "graph/resources/types";
// import { store } from "redux/store";

// export const getWorkspace = (): Workspace => {
// return new ReduxCache().getWorkspace();
// };

// class ReduxCache {
// static instance: ReduxCache | null = null;
// private workspace: Workspace;

// constructor() {
// if (ReduxCache.instance) {
// return ReduxCache.instance;
// }
// ReduxCache.instance = this;
// this.workspace = store.getState().workspace as Workspace;
// store.subscribe((state: any) => {
// if (!state || !state?.workspace) return;
// this.workspace = state.workspace as Workspace;
// });
// }

// getWorkspace() {
// // TODO FIX CACHING SYNCHRONICITY BROKEN
// return store.getState().workspace;
// // return this.workspace;
// }
// }

// export const getFile = (fileID: FileID): File => {
// const workspace = getWorkspace();
// const files = workspace.files.filter((file) => file.id === fileID);
// if (files.length === 0) throw Error("File not found");
// if (files.length > 1) throw Error("Multiple files with ID = " + fileID);
// return files[0];
// };

// export const getPlot = (plotID: PlotID): Plot => {
// const workspace = getWorkspace();
// const plots = workspace.plots.filter((plot) => plot.id === plotID);
// if (plots.length === 0) throw Error("Plot not found");
// if (plots.length > 1) throw Error("Multiple plots with ID = " + plotID);
// return plots[0];
// };

// export const getPopulation = (populationID: PopulationID): Population => {
// const workspace = getWorkspace();
// const populations = workspace.populations.filter(
// (population) => population.id === populationID
// );
// if (populations.length === 0) throw Error("Population not found");
// if (populations.length > 1)
// throw Error("Multiple populations with ID = " + populationID);
// return populations[0];
// };

// export const getGate = (gateID: GateID): Gate => {
// const workspace = getWorkspace();
// const gates = workspace.gates.filter((gate) => gate.id === gateID);
// if (gates.length === 0) throw Error("Gate not found");
// if (gates.length > 1) throw Error("Multiple gates with ID = " + gateID);
// return gates[0];
// };

// export const getGate = (gateID: GateID): Gate => {
// const workspace = getWorkspace();
// const gates = workspace.gates.filter((gate) => gate.id === gateID);
// if (gates.length === 0) throw Error("Gate not found");
// if (gates.length > 1) throw Error("Multiple gates with ID = " + gateID);
// return gates[0];
// };
export {};
2 changes: 1 addition & 1 deletion src/services/FlowJoParser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const ParseFlowJoJson = async (flowJoJson: any) => {
let plot = new PlotData();
let sampleUri = samples[i]["DataSet"]["_attributes"]["uri"];
let sampleUrlArray = sampleUri.split("/");
let sampleName = sampleUri[sampleUrlArray.length - 1];
let sampleName = sampleUrlArray[sampleUrlArray.length - 1];
sampleName = sampleName.replace("%20", "");
let transformations = samples[i]["Transformations"];
let channelsInfo: any = [];
Expand Down

0 comments on commit 1def8eb

Please sign in to comment.