File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 12
12
- Add alias json if necessary
13
13
"""
14
14
15
- import typer
15
+ import numpy as np
16
16
import pandas as pd
17
+ import typer
17
18
from pango_aliasor .aliasor import Aliasor
18
- import numpy as np
19
19
20
20
LINEAGE_NOTES = "lineage_notes.txt"
21
21
LINEAGES_CSV = "lineages.csv"
@@ -110,16 +110,18 @@ def get_lineage_from_parent(parent_lineage: str):
110
110
unaliased_parent = aliasor .uncompress (parent_lineage )
111
111
112
112
# Filter to lineages descending from parent lineage
113
- children = unaliased [np .vectorize (lambda x : x .startswith (unaliased_parent ))(unaliased )]
113
+ children = unaliased [np .vectorize (lambda x : x .startswith (unaliased_parent + "." ))(unaliased )]
114
114
115
115
# Find number of levels of parent lineage
116
116
parent_levels = unaliased_parent .count ("." ) + 1
117
117
118
118
# Find numbers of level below parent lineage
119
- children_levels = np .vectorize (lambda x : extract_level (x , parent_levels ))(children )
120
-
121
- # Find last entry of 1 level below parent lineage
122
- max_child = max (children_levels )
119
+ if len (children ) == 0 :
120
+ max_child = 0
121
+ else :
122
+ children_levels = np .vectorize (lambda x : extract_level (x , parent_levels ))(children )
123
+ # Find last entry of 1 level below parent lineage
124
+ max_child = max (children_levels )
123
125
124
126
# Create compressd child
125
127
new_child_unaliased = f"{ unaliased_parent } .{ max_child + 1 } "
You can’t perform that action at this time.
0 commit comments