Skip to content

Commit

Permalink
fix: highlight nodes on another tree correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Jan 17, 2023
1 parent d25bdf7 commit b70d8cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/Tree/PhyloGraph/convertPhyloTreeToGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ export function convertPhyloTreeToGraph(tree: TreeNodeOld, meta: TreeMetadataOld
/** Index tree nodes with unique IDs */
function flattenPhyloTreeNodesRecursive(node: TreeNodeOld, nodes: GraphNodeRaw[]): TreeNodeOldWithIds {
const id = nodes.length.toString()
nodes.push({ id, ...omit(node, 'children') })

// HACK: override gene tree name to be the same as accession
// TODO: figure out whatever the mess is `name` vs `accession` and clarify the rules on how they need to be matched on the 2 trees. All that needs to be computed offline.
const name = node.accession ?? node.name

nodes.push({ id, ...omit(node, 'children'), name })

const children = node.children ?? []
const childrenWithIds = children.map((child) => flattenPhyloTreeNodesRecursive(child, nodes))
return { ...node, id, children: childrenWithIds }

return { ...node, name, id, children: childrenWithIds }
}

/** Convert tree node hierarchy into flat lists of nodes and edges */
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useDataIndexQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface TreeNodeOld {
name: string
branch_length?: number
clade?: string
accession?: string
attr?: {
strain?: string
collection_date?: string
Expand Down

0 comments on commit b70d8cc

Please sign in to comment.