Skip to content

Commit

Permalink
Merge pull request #51 from biocore/ignore_missing_edges
Browse files Browse the repository at this point in the history
Only retain edges that exist in the tree
  • Loading branch information
wasade authored Dec 13, 2022
2 parents 2f92d78 + 6db1e03 commit 51de139
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bp/_io.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ def parse_jplace(object data):
Py_ssize_t placement_idx, placement_inner_idx, fragment_idx,
Py_ssize_t n_fragments
BP tree
object df
set edges

as_json = json.loads(data)
newick = as_json['tree']
Expand Down Expand Up @@ -389,4 +391,8 @@ def parse_jplace(object data):
placements.append(entry)

tree = parse_newick(newick)
return pd.DataFrame(placements, columns=fields), tree
edges = {tree.edge(i) for i, v in enumerate(tree.B) if v}
df = pd.DataFrame(placements, columns=fields)
df = df[df['edge_num'].isin(edges)]

return df, tree

0 comments on commit 51de139

Please sign in to comment.