Skip to content

Commit

Permalink
Fix #260, #257
Browse files Browse the repository at this point in the history
  • Loading branch information
msalihaltun committed Jun 24, 2021
1 parent 8033784 commit a7a7de7
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/pathway-mapper/dist/index.es5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/pathway-mapper/dist/index.es5.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/pathway-mapper/dist/utils/PathwayActions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default class PathwayActions {
processFile(file: File, isMerge: boolean): void;
saveAs(type: string): void;
editorHandler(editor: any, eh: any, undoRedoManager: any, viewOperationsManager: ViewOperationsManager, gridOptionsManager: GridOptionsManager): void;
exists(profileId: string): boolean;
loadSampleData(): void;
performLayout(): void;
}
19 changes: 11 additions & 8 deletions packages/pathway-mapper/src/managers/EditorActionsManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ export default class EditorActionsManager{
{
args.ele.data('w', args.newWidth);
args.ele.data('h', args.newHeight);
args.ele.style('width', args.newWidth);
args.ele.style('height', args.newHeight);

return args;
};
Expand All @@ -226,9 +224,6 @@ export default class EditorActionsManager{
{
args.ele.data('w', args.oldWidth);
args.ele.data('h', args.oldHeight);
args.ele.style('width', args.oldWidth);
args.ele.style('height', args.oldHeight);

return args;
};

Expand Down Expand Up @@ -955,9 +950,6 @@ export default class EditorActionsManager{
//his.cy.add(newNode);
this.cy.nodes().updateCompoundBounds();
this.undoRedoManager.do("add", newNode);
//Width was not properly updated only by changing data property
var thatEle = this.cy.getElementById(nodeData.id);
thatEle.style('width', thatEle.data('w'));
};

shareDBNodeAddRemoveEventCallBack(op: any)
Expand Down Expand Up @@ -1767,6 +1759,17 @@ export default class EditorActionsManager{
this.shareDBManager.addGenomicData(parsedGenomicData.genomicDataMap);
this.shareDBManager.groupGenomicData(Object.keys(parsedGenomicData.visibilityMap),
groupID);

let currentVisibleGenomicDataCount = this.genomicDataOverlayManager.countVisibleGenomicDataByType();
Object.keys(parsedGenomicData.visibilityMap).forEach(study => {
if (parsedGenomicData.visibilityMap[study] && (currentVisibleGenomicDataCount >= 6)) {
parsedGenomicData.visibilityMap[study] = false;
}
else if(parsedGenomicData.visibilityMap[study]) {
currentVisibleGenomicDataCount++;
}
});

this.shareDBManager.addGenomicVisibilityData(parsedGenomicData.visibilityMap);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ export default class GenomicDataOverlayManager {
};

hideGenomicData = function() {

this.cy.nodes('[type="GENE"]').forEach(node => {
node.data('w', this.getRequiredWidthForGenomicData(0));
})

this.cy
.style()
.selector('node[type="GENE"]')
Expand Down Expand Up @@ -528,7 +533,7 @@ export default class GenomicDataOverlayManager {

this.cy.nodes('[type="GENE"]').forEach(node => {
node.data('w', this.getRequiredWidthForGenomicData(genomicDataBoxCount));
})
});

this.cy
.style()
Expand Down Expand Up @@ -568,8 +573,9 @@ export default class GenomicDataOverlayManager {
// Parse cancer types
for (let i = 1; i < metaLineColumns.length; i++) {
cancerTypes.push(metaLineColumns[i]);
const visibleGenomicDataCount = Object.keys(this.visibleGenomicDataMapByType).length;
// Update initially visible genomic data boxes !
if (i - 1 < this.DEFAULT_VISIBLE_GENOMIC_DATA_COUNT) {
if (visibleGenomicDataCount < this.DEFAULT_VISIBLE_GENOMIC_DATA_COUNT) {
this.visibleGenomicDataMapByType[cancerTypes[i - 1]] = true;
} else {
this.visibleGenomicDataMapByType[cancerTypes[i - 1]] = false;
Expand Down
3 changes: 2 additions & 1 deletion packages/pathway-mapper/src/managers/ShareDBManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class ShareDBManager {
var genomicDataGroupCount = this.doc.data[this.GENOMIC_DATA_GROUP_COUNT];
//Reset all genomic maps
for (const key of Object.keys(genomicMap)) {
ops.push({p: [this.GENOMIC_DATA_GROUP_NAME, key], od: genomicMap[key]});
ops.push({p: [this.GENOMIC_DATA_MAP_NAME, key], od: genomicMap[key]});
}
for (const key of Object.keys(visMap)) {
ops.push({p: [this.VISIBLE_GENOMIC_DATA_MAP_NAME, key], od: visMap[key]});
Expand Down Expand Up @@ -415,6 +415,7 @@ export default class ShareDBManager {

this.editor.genomicDataOverlayManager.showGenomicData();
this.editor.genomicDataOverlayManager.notifyObservers();
this.editor.cy.style().update();
this.editor.cy.fit(50);
};

Expand Down
13 changes: 2 additions & 11 deletions packages/pathway-mapper/src/ui/CytoscapeArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@ export default class CytoscapeArea extends React.Component<PathwayMapperType, {}
// so that a data field or something like that will be used to set node dimentions instead of directly calling node.css()
// is highly recommended (Of course this will require a proper setting in the stylesheet).
setWidth: function (node, width) {
node.style('width', width);
node.data('w', width)
},
setHeight: function (node, height) {
node.style('height', height);
node.data('h', height);
},
setCompoundMinWidth: function (node, minWidth) {
node.style('min-width', minWidth);
Expand Down Expand Up @@ -687,15 +687,6 @@ export default class CytoscapeArea extends React.Component<PathwayMapperType, {}
this.editor.postLayout();
});

// //TODO fix this when cytoscape is updated !!!
// //Due to cytoscape.js bug, only workaround that worked :(
// this.cy.on('add', 'node', function(event)
// {
// // event.target.select();
// this.cy.style().update();
// this.cy.forceRender();
// });

this.cy.on("nodeediting.resizeend", (_e: any, _type: any, node: any) => {

//Updates 'data' properties from 'style'
Expand Down
45 changes: 33 additions & 12 deletions packages/pathway-mapper/src/utils/PathwayActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,24 +418,45 @@ export default class PathwayActions {
this.gridOptionsManager = gridOptionsManager;
}

@autobind
exists(profileId: string){

let exists = false;
this.profiles.forEach((profile: IProfileMetaData) => {
if(profile.profileId === profileId){
exists = true;
}
});

return exists;
}

@autobind
loadSampleData() {
const data =
"gene\tlung\tovarian\tbreast\ty\n" +
"PTEN\t-7\t-20\t10\t20\n" +
"NF1\t-12\t-4\t30\t20\n" +
"PIK3CA\t18\t40\t-50\t20\n" +
"KRAS\t11\t-5\t0\t20\n" +
"ZIYA\t0\t-2\t0\t20\n" +
"AKT1\t3\t30\t-10\t20\n" +
"AKT2\t6\t-3\t20\t20\n" +
"AKT3\t6\t-3\t20\t20\n" +
"gene\tlung\tovarian\tbreast\n" +
"PTEN\t-7\t-20\t10\n" +
"NF1\t-12\t-4\t30\n" +
"PIK3CA\t18\t40\t-50\n" +
"KRAS\t11\t-5\t0\n" +
"ZIYA\t0\t-2\t0\n" +
"AKT1\t3\t30\t-10\n" +
"AKT2\t6\t-3\t20\n" +
"AKT3\t6\t-3\t20\n" +
"\n";

if (this.exists("lung") || this.exists("ovarian") || this.exists("breast")) {
return;
}

this.editor.addGenomicData(data);

this.addProfile({ profileId: "lung", enabled: true });
this.addProfile({ profileId: "ovarian", enabled: true });
this.addProfile({ profileId: "breast", enabled: true });
if (!this.isCollaborative) {
this.addProfile({ profileId: "lung", enabled: this.profiles.length < 6 ? true : false });
this.addProfile({ profileId: "ovarian", enabled: this.profiles.length < 6 ? true : false });
this.addProfile({ profileId: "breast", enabled: this.profiles.length < 6 ? true : false });
}

}

@autobind
Expand Down

0 comments on commit a7a7de7

Please sign in to comment.