Skip to content

Commit

Permalink
bug with complex number and,
Browse files Browse the repository at this point in the history
  • Loading branch information
tmushayahama committed Jan 23, 2025
1 parent 184cb40 commit cf39ec0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 217 deletions.
2 changes: 1 addition & 1 deletion src/components/gocam-viz/gocam-viz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export class GoCamViz {
});

const truncatedGps = gps.slice(0, 3)
let geneString = gps.join(', ')
let geneString = truncatedGps.join(', ')

if (gps.length > truncatedGps.length) {
geneString += ' and ' + (gps.length - truncatedGps.length).toString() + ' more'
Expand Down
214 changes: 1 addition & 213 deletions src/globals/@noctua.form/models/activity/cam.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { noctuaFormConfig } from './../../noctua-form-config';
import { Activity, ActivitySortField, ActivityType } from './activity'
import { ActivityNode, ActivityNodeType } from './activity-node';
import { Group } from '../group';
import { Contributor } from '../contributor';
import { Evidence } from './evidence';
import { Triple } from './triple';
import { Entity } from './entity';
import { each, find, orderBy, groupBy } from 'lodash';
import { each, find, groupBy } from 'lodash';
import { NoctuaFormUtils } from './../../utils/noctua-form-utils';
import { PendingChange } from './pending-change';

export enum ReloadType {
RESET = 'reset',
Expand Down Expand Up @@ -152,15 +149,6 @@ export class Cam {
this.displayId = NoctuaFormUtils.cleanID(id);
}

updateSortBy(field: ActivitySortField, label: string) {
this.sortBy.field = field
this.sortBy.label = label
}

toggleExpand() {
this.expanded = !this.expanded;
}

groupActivitiesByProcess() {
const groupedActivities = groupBy(this.activities, (activity: Activity) => {
if (activity.activityType === ActivityType.molecule) {
Expand All @@ -173,57 +161,6 @@ export class Cam {
return groupedActivities;
}


expandAllActivities(expand: boolean) {
const self = this;

each(self.activities, (activity: Activity) => {
activity.expanded = expand;
});
}

getCausalRelation(subjectId: string, objectId: string): Triple<Activity> {
const self = this;

return self.causalRelations.find((triple: Triple<Activity>) => {
if (triple.predicate?.isReverseLink) {
return triple.object?.id === subjectId && triple.object?.id === subjectId;
}
return triple.subject?.id === subjectId && triple.object?.id === objectId;
})
}

clearHighlight() {
const self = this;

each(self.activities, (activity: Activity) => {
each(activity.nodes, (node: ActivityNode) => {
node.term.highlight = false;
each(node.predicate.evidence, (evidence: Evidence) => {
evidence.evidence.highlight = false;
evidence.referenceEntity.highlight = false;
evidence.withEntity.highlight = false;
});
});
});
}

findNodeById(uuid, activities: Activity[]): ActivityNode {
const self = this;
let found
each(activities, (activity) => {
found = find(activity.nodes, (node: ActivityNode) => {
return node.uuid === uuid;
});

if (found) {
return false;
}
})

return found;
}

findActivityById(id) {
const self = this;

Expand All @@ -232,155 +169,6 @@ export class Cam {
});
}

findActivityByNodeUuid(nodeId): Activity[] {
const self = this;

const result: Activity[] = [];

each(self.activities, (activity: Activity) => {
each(activity.nodes, (node: ActivityNode) => {
if (node.uuid === nodeId) {
result.push(activity)
}
each(node.predicate.evidence, (evidence: Evidence) => {
if (evidence.uuid === nodeId) {
result.push(activity)
}
});
});
});
return result;
}



applyWeights(weight = 0) {
const self = this;

if (self.queryMatch && self.queryMatch.terms.length > 0) {

each(self.activities, (activity: Activity) => {
each(activity.nodes, (node: ActivityNode) => {
const matchNode = find(self.queryMatch.terms, { uuid: node.term.uuid }) as Entity;

if (matchNode) {
matchNode.weight = node.term.weight = weight;
weight++;
}

each(node.predicate.evidence, (evidence: Evidence) => {
const matchNode = find(self.queryMatch.terms, { uuid: evidence.referenceEntity.uuid }) as Entity;

if (matchNode) {
matchNode.weight = evidence.referenceEntity.weight = weight;
weight++;
}
});
});

});
}
}

addPendingChanges(findEntities: Entity[], replaceWith: string, category) {
const self = this;

each(self.activities, (activity: Activity) => {
each(activity.nodes, (node: ActivityNode) => {
each(findEntities, (entity: Entity) => {
if (category.name === noctuaFormConfig.findReplaceCategory.options.reference.name) {
each(node.predicate.evidence, (evidence: Evidence, key) => {
if (evidence.uuid === entity.uuid) {
const oldReference = new Entity(evidence.reference, evidence.reference);
const newReference = new Entity(replaceWith, replaceWith);

evidence.pendingReferenceChanges = new PendingChange(evidence.uuid, oldReference, newReference);
evidence.pendingReferenceChanges.uuid = evidence.uuid;
}
});
} else {
if (node.term.uuid === entity.uuid) {
const newValue = new Entity(replaceWith, replaceWith);
node.pendingEntityChanges = new PendingChange(node.uuid, node.term, newValue);
}
}
});
});
});
}

getNodesByType(type: ActivityNodeType): any[] {
const self = this;
const result = [];

each(self.activities, (activity: Activity) => {
result.push({
activity,
title: activity.title,
activityNodes: activity.getNodesByType(type)
});
});

return result;
}

getNodesByTypeFlat(type: ActivityNodeType): ActivityNode[] {
const self = this;
const result = [];

each(self.activities, (activity: Activity) => {
result.push(...activity.getNodesByType(type));
});

return result;
}

getTerms(formActivity: Activity) {
const self = this;
const result = [];

if (formActivity && formActivity.nodes) {
each(formActivity.nodes, (node: ActivityNode) => {
result.push(node);
});
}

each(self.activities, (activity: Activity) => {
each(activity.nodes, (node: ActivityNode) => {
result.push(node);
});
});

return result;
}

getEvidences(formActivity?: Activity) {
const self = this;
const result = [];

if (formActivity && formActivity.nodes) {
each(formActivity.nodes, (node: ActivityNode) => {
each(node.predicate.evidence, (evidence: Evidence) => {
if (evidence.hasValue()) {
result.push(evidence);
}
});
});
}

each(self.activities, (activity: Activity) => {
each(activity.edges, (triple: Triple<ActivityNode>) => {
each(triple.predicate.evidence, (evidence: Evidence) => {
if (evidence.hasValue()) {
result.push(evidence);
}
});
});
});

return result;
}

updateProperties() {
const self = this;

Expand Down
2 changes: 1 addition & 1 deletion src/globals/@noctua.form/services/graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class NoctuaGraphService {
cam.modified = responseData['modified-p'];

this.getMetadata(cam)
this.loadCam(cam)
this.loadCam(cam, true)

return cam;
}
Expand Down
4 changes: 2 additions & 2 deletions src/globals/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export enum Relations {
DIRECTLY_POSITIVELY_REGULATES = 'RO:0002629',
HAS_INPUT = 'RO:0002233',
HAS_OUTPUT = 'RO:0002234',
INDIRECTLY_NEGATIVELY_REGULATES = 'RO:0002407',
INDIRECTLY_POSITIVELY_REGULATES = 'RO:0002409',
INDIRECTLY_NEGATIVELY_REGULATES = 'RO:0002409',
INDIRECTLY_POSITIVELY_REGULATES = 'RO:0002407',
IS_SMALL_MOLECULE_INHIBITOR_OF = 'RO:0012006',
IS_SMALL_MOLECULE_ACTIVATOR_OF = 'RO:0012005',
NEGATIVELY_REGULATES = 'RO:0002212',
Expand Down

0 comments on commit cf39ec0

Please sign in to comment.