Skip to content

Commit 0842035

Browse files
committed
Upgrade index orientation checker to handle swapped indexes
1 parent 2117f41 commit 0842035

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

VERSIONLOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Scilifelab_epps Version Log
22

3+
## 20240523.1
4+
5+
Upgrade index orientation checker to handle swapped indexes
6+
37
## 20240521.2
48

59
Bugfix comparative assertion in Anglerfish parsing.

scripts/index_distance_checker.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@ def verify_orientation(data):
171171
index2
172172
):
173173
flag_first_sample = "Index1_and_Index2_RC"
174+
elif subset[0]["idx1"] == index2 and subset[0]["idx2"] == index1:
175+
flag_first_sample = "Index1_and_Index2_Swapped"
176+
elif subset[0]["idx1"] == rc(index2) and subset[0]["idx2"] == index1:
177+
flag_first_sample = "Index1_and_Index2_Swapped_plus_Index1_RC"
178+
elif subset[0]["idx1"] == index2 and subset[0]["idx2"] == rc(index1):
179+
flag_first_sample = "Index1_and_Index2_Swapped_plus_Index2_RC"
180+
elif subset[0]["idx1"] == rc(index2) and subset[0]["idx2"] == rc(
181+
index1
182+
):
183+
flag_first_sample = (
184+
"Index1_and_Index2_Swapped_plus_Index1_and_Index2_RC"
185+
)
174186
# Check the last sample
175187
if subset[-1]["idx1"] == index1 and subset[-1]["idx2"] == index2:
176188
flag_last_sample = "CORRECT"
@@ -182,6 +194,18 @@ def verify_orientation(data):
182194
index2
183195
):
184196
flag_last_sample = "Index1_and_Index2_RC"
197+
elif subset[0]["idx1"] == index2 and subset[0]["idx2"] == index1:
198+
flag_last_sample = "Index1_and_Index2_Swapped"
199+
elif subset[0]["idx1"] == rc(index2) and subset[0]["idx2"] == index1:
200+
flag_last_sample = "Index1_and_Index2_Swapped_plus_Index1_RC"
201+
elif subset[0]["idx1"] == index2 and subset[0]["idx2"] == rc(index1):
202+
flag_last_sample = "Index1_and_Index2_Swapped_plus_Index2_RC"
203+
elif subset[0]["idx1"] == rc(index2) and subset[0]["idx2"] == rc(
204+
index1
205+
):
206+
flag_last_sample = (
207+
"Index1_and_Index2_Swapped_plus_Index1_and_Index2_RC"
208+
)
185209
# Make a conclusion
186210
if flag_first_sample == flag_last_sample == "CORRECT":
187211
flag_idx_search = True
@@ -204,6 +228,42 @@ def verify_orientation(data):
204228
)
205229
flag_idx_search = True
206230
break
231+
elif flag_first_sample == flag_last_sample == "Index1_and_Index2_Swapped":
232+
message.append(
233+
f"Seems that Index 1 and Index 2 are swapped for pool {p}"
234+
)
235+
flag_idx_search = True
236+
break
237+
elif (
238+
flag_first_sample
239+
== flag_last_sample
240+
== "Index1_and_Index2_Swapped_plus_Index1_RC"
241+
):
242+
message.append(
243+
f"Seems that Index 1 and Index 2 are swapped, and Index 1 needs to be converted to RC for pool {p}"
244+
)
245+
flag_idx_search = True
246+
break
247+
elif (
248+
flag_first_sample
249+
== flag_last_sample
250+
== "Index1_and_Index2_Swapped_plus_Index2_RC"
251+
):
252+
message.append(
253+
f"Seems that Index 1 and Index 2 are swapped, and Index 2 needs to be converted to RC for pool {p}"
254+
)
255+
flag_idx_search = True
256+
break
257+
elif (
258+
flag_first_sample
259+
== flag_last_sample
260+
== "Index1_and_Index2_Swapped_plus_Index1_and_Index2_RC"
261+
):
262+
message.append(
263+
f"Seems that Index 1 and Index 2 are swapped, and both Index 1 and Index 2 need to be converted to RC for pool {p}"
264+
)
265+
flag_idx_search = True
266+
break
207267
elif flag_first_sample != flag_last_sample:
208268
message.append(f"Inconsistent Index pattern detected for pool {p}")
209269
flag_idx_search = True

0 commit comments

Comments
 (0)