From bc3a9ebcd6599cca4d30ca5ee0c1876f3952fb5f Mon Sep 17 00:00:00 2001 From: tmushayahama Date: Mon, 7 May 2018 12:54:59 -0700 Subject: [PATCH] bp only mapping correctly to the first 4 options https://github.com/geneontology/simple-annoton-editor/issues/61 --- app/annoton/annoton-node.js | 23 +++++++++++++++++++++++ app/annoton/sae-graph.js | 7 +++++++ app/graph.service.js | 26 +++++++++++++++++--------- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/app/annoton/annoton-node.js b/app/annoton/annoton-node.js index 001d2d7..897cf4e 100644 --- a/app/annoton/annoton-node.js +++ b/app/annoton/annoton-node.js @@ -147,11 +147,34 @@ export default class AnnotonNode { self.addEvidence(); } + deepCopyValues(node) { + const self = this; + + self.term.control.value = node.term.control.value; + self.evidence = node.evidence; + + self.modelId = node.modelId; + self.annoton = node.annoton; + self.ontologyClass = node.ontologyClass; + self.assignedBy = node.assignedBy; + self.termRequiredList = node.termRequiredList; + self.evidenceRequiredLis = node.evidenceRequiredList + self.evidenceNotRequiredList = node.evidenceNotRequiredList; + self.errors = node.errors; + self.warnings = node.warnings; + self.status = node.status; + + self.edgeOption = node.edgeOption; + self.isComplement = node.isComplement; + } + copyValues(node) { const self = this; self.term.control.value = node.term.control.value; self.evidence = node.evidence; + self.assignedBy = node.assignedBy; + self.isComplement = node.isComplement; } addEvidences(evidences, except) { diff --git a/app/annoton/sae-graph.js b/app/annoton/sae-graph.js index 119043d..275da36 100644 --- a/app/annoton/sae-graph.js +++ b/app/annoton/sae-graph.js @@ -46,6 +46,13 @@ export default class SaeGraph { this.addEdge(source, object, edge) }; + editEdge(subjectId, objectId, srcEdge) { + const self = this; + let destEdge = self.getEdge(subjectId, objectId); + + destEdge.edge = srcEdge; + } + getEdge(subjectId, objectId) { const self = this; let edge = self.edges[subjectId]; diff --git a/app/graph.service.js b/app/graph.service.js index 9caa070..76f8a38 100644 --- a/app/graph.service.js +++ b/app/graph.service.js @@ -547,7 +547,6 @@ export default class GraphService { } } else { annoton.parser.setCardinalityError(annotonNode, gpObjectNode.term, self.saeConstants.edge.enabledBy.id); - // self.graphToAnnatonDFS(graph, annoton, mfEdgesIn, annotonNode, true); } if (isDoomed) { @@ -638,9 +637,6 @@ export default class GraphService { if (annoton.parser.parseCardinality(graph, annotonNode, mfEdgesIn, edge.nodes)) { each(mfEdgesIn, function (toMFEdge) { - if (!toMFEdge) { - return; - } let predicateId = toMFEdge.predicate_id(); let evidence = self.edgeToEvidence(graph, toMFEdge); let toMFObject = toMFEdge.object_id(); @@ -649,6 +645,16 @@ export default class GraphService { self.config.addGPAnnotonData(annoton, toMFObject); } + if (annoton.annotonModelType === self.saeConstants.annotonModelType.options.bpOnly.name) { + let causalEdge = _.find(self.saeConstants.causalEdges, { + id: predicateId + }) + + if (causalEdge) { + self.adjustBPOnly(annoton, causalEdge); + } + } + each(edge.nodes, function (node) { if (predicateId === node.edge.id) { if (predicateId === self.saeConstants.edge.hasPart.id && toMFObject !== node.object.id) { @@ -861,8 +867,6 @@ export default class GraphService { let gpNode = annoton.getGPNode(); - self.adjustBPOnly(annoton); - let row = { gp: gpNode.term.control.value.label, original: JSON.parse(JSON.stringify(annoton)), @@ -1028,14 +1032,17 @@ export default class GraphService { } - adjustBPOnly(annoton) { + adjustBPOnly(annoton, srcEdge) { const self = this; let mfNode = annoton.getNode('mf'); let bpNode = annoton.getNode('bp'); + + if (mfNode && bpNode && annoton.annotonModelType === self.saeConstants.annotonModelType.options.bpOnly.name) { mfNode.displaySection = self.saeConstants.displaySection.fd; mfNode.displayGroup = self.saeConstants.displayGroup.mf; + annoton.editEdge('mf', 'bp', srcEdge); bpNode.relationship = annoton.getEdge('mf', 'bp').edge; } } @@ -1169,9 +1176,10 @@ export default class GraphService { each(srcAnnoton.nodes, function (srcNode) { if (srcNode.hasValue()) { - let destNode = self.config.generateNode(srcNode.id); + // let destNode = self.config.generateNode(srcNode.id); - destNode.copyValues(srcNode); + // destNode.copyValues(srcNode); + let destNode = srcNode; destAnnoton.addNode(destNode); } });