Skip to content

Commit c4a3008

Browse files
Will-Tylerjeromekelleher
authored andcommitted
Simplify format field sorting
1 parent b0aaae5 commit c4a3008

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

bio2zarr/vcf2zarr/icf.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,24 +1247,16 @@ def process_partition(self, partition_index):
12471247
else:
12481248
format_fields.append(field)
12491249

1250-
# We need to determine LAA before LPL
1251-
try:
1252-
laa_index = next(
1253-
index
1254-
for index, format_field in enumerate(format_fields)
1255-
if format_field.name == "LAA"
1256-
)
1257-
lpl_index = next(
1258-
index
1259-
for index, format_field in enumerate(format_fields)
1260-
if format_field.name == "LPL"
1261-
)
1262-
1250+
format_field_names = [format_field.name for format_field in format_fields]
1251+
if "LAA" in format_field_names and "LPL" in format_field_names:
1252+
laa_index = format_field_names.index("LAA")
1253+
lpl_index = format_field_names.index("LPL")
1254+
# LAA needs to come before LPL
12631255
if lpl_index < laa_index:
1264-
format_fields.insert(laa_index + 1, format_fields[lpl_index])
1265-
format_fields.pop(lpl_index)
1266-
except StopIteration:
1267-
pass
1256+
format_fields[laa_index], format_fields[lpl_index] = (
1257+
format_fields[lpl_index],
1258+
format_fields[laa_index],
1259+
)
12681260

12691261
last_position = None
12701262
with IcfPartitionWriter(

0 commit comments

Comments
 (0)