Skip to content

Commit

Permalink
Merge pull request #893 from uclahs-cds/czhu-fix-call-variant
Browse files Browse the repository at this point in the history
Fix callVariant: variant bubble aligning issue
  • Loading branch information
zhuchcn authored Feb 13, 2025
2 parents 90e31ea + c2c033f commit bc73cfd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Fixed issue that `callVariant` fails on transcripts with SEC very close to the start codon.

- Fixed issue with extremely long run-time with complex alt splice events. #892

## [1.4.3] - 2025-01-18

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions docs/files/fuzz_test_history.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ v1.2.1 e7a4096 2023-11-28 comprehensive 522929 0 0 0:00:00.378236 15.50100807513
v1.4.2 c2da21c 2025-01-19 snv 270 0 0 0:00:00.170374 0.37595620821363007 0:00:56.681483 105.92716856631384
v1.4.2 c2da21c 2025-01-19 indel 275 0 0 0:00:00.170908 0.3764300020522951 0:00:40.836362 93.63957347416282
v1.4.2 c2da21c 2025-01-19 comprehensive 471 0 0 0:00:00.352437 0.6980351919379612 0:00:38.006367 140.52343056870941
v1.4.3 64a1cd7 2025-02-12 snv 3615 0 0 0:00:00.164877 0.5071353395324305 0:00:57.359060 118.20011598924994
v1.4.3 64a1cd7 2025-02-12 indel 3623 0 0 0:00:00.228542 1.0644126008878305 0:00:39.258896 93.83931730856402
v1.4.3 64a1cd7 2025-02-12 comprehensive 6985 0 0 0:00:00.372239 0.8090526920972508 0:00:35.994138 142.17524693622445
16 changes: 12 additions & 4 deletions moPepGen/svgraph/ThreeFrameTVG.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,17 +1418,19 @@ def is_candidate_out_node(x:TVGNode, y:TVGNode):
# the input node itself.
return node, set()

visited:Set[TVGNode] = {node}
visited:Dict[str, TVGNode] = {node.id: node}
# When a new farthest node is found, the downstream nodes of the old
# farthest node are put into this `exceptions` container, so they
# can be visited again.
exceptions:Set[TVGNode] = set()
non_members:Set[str] = set()
while queue:
cur:TVGNode = queue.popleft()
if cur is None:
continue

if cur.reading_frame_index != node.reading_frame_index:
non_members.add(cur.id)
continue

if subgraph_checker:
Expand All @@ -1437,7 +1439,7 @@ def is_candidate_out_node(x:TVGNode, y:TVGNode):
subgraph_checker = False

visited_len_before = len(visited)
visited.add(cur)
visited[cur.id] = cur
visited_len_after = len(visited)
if visited_len_before == visited_len_after:
if cur is farthest and cur is not node:
Expand Down Expand Up @@ -1497,7 +1499,8 @@ def is_candidate_out_node(x:TVGNode, y:TVGNode):
queue.append(farthest)
exceptions.add(cur)
continue
return farthest, visited
members = {v for k,v in visited.items() if k not in non_members}
return farthest, members

def first_node_is_smaller(self, first:TVGNode, second:TVGNode) -> bool:
""" Check if the first node is larger """
Expand Down Expand Up @@ -1628,6 +1631,11 @@ def align_variants(self, node:TVGNode) -> Tuple[TVGNode, TVGNode]:
new_bridge = bridge_in.copy()
for edge in bridge_in.out_edges:
self.add_edge(new_bridge, edge.out_node, edge.type)
# Here we want to limit the process within the variant bubble.
# In-bridge nodes should not be merged with their outgoing nodes
# that do not belong to the bubble.
if edge.out_node not in members:
end_nodes.add(edge.out_node)
bridge_map[new_bridge] = bridge_in
trash.add(bridge_in)

Expand Down Expand Up @@ -1670,7 +1678,7 @@ def align_variants(self, node:TVGNode) -> Tuple[TVGNode, TVGNode]:
for out_edge in copy.copy(cur.out_edges):
out_node:TVGNode = out_edge.out_node

# So this is the case that some of the end_nodes are in end_nodes
# So this is the case that some of the out_nodes are in end_nodes
# but not the others.
if out_node in end_nodes:
new_node = cur.copy()
Expand Down

0 comments on commit bc73cfd

Please sign in to comment.