@@ -2177,9 +2177,9 @@ def check_link_significance(ori_list):
21772177 Check if barcode link is strong enough
21782178 """
21792179 max_idx = ori_list .index (max (ori_list ))
2180- ori_list . sort ( )
2181- max_val = ori_list [- 1 ]
2182- sum_with_second_max = ori_list [- 1 ] + ori_list [- 2 ]
2180+ sorted_ori_list = sorted ( ori_list )
2181+ max_val = sorted_ori_list [- 1 ]
2182+ sum_with_second_max = sorted_ori_list [- 1 ] + sorted_ori_list [- 2 ]
21832183 normal_cdf = Physlr .normal_estimation (max_val , 0.5 , sum_with_second_max )
21842184 if 1 - normal_cdf < 0.05 :
21852185 return max_idx
@@ -2234,6 +2234,24 @@ def orient_part_of_path_forward(pairs, path, unoriented, curr_pos, name):
22342234
22352235 return path , unoriented
22362236
2237+ @staticmethod
2238+ def check_and_correct_pair (pairs , path , curr_pos , name ):
2239+ """
2240+ Orient small part of path based on ARCS scaffold pairing information going forwards
2241+ """
2242+ idxtojoin = {0 :"-+" , 1 :"--" , 2 :"++" , 3 :"+-" }
2243+ prev_pos = curr_pos - 1
2244+ prev_name = path [prev_pos ]
2245+ pair = (prev_name [:- 1 ], name [:- 1 ])
2246+ if pair in pairs :
2247+ join_orientation = pairs [pair ]
2248+ max_idx = Physlr .check_link_significance (join_orientation )
2249+ if max_idx != - 1 :
2250+ if idxtojoin [max_idx ][0 ] == prev_name [- 1 ]:
2251+ if idxtojoin [max_idx ][1 ] != name [- 1 ]:
2252+ path [curr_pos ] = name [:- 1 ] + idxtojoin [max_idx ][1 ]
2253+ return path
2254+
22372255 @staticmethod
22382256 def orient_path (path , pairs ):
22392257 """
@@ -2261,6 +2279,8 @@ def orient_path(path, pairs):
22612279
22622280 curr_pos = temp_curr_pos
22632281 name = temp_name
2282+ else :
2283+ path = Physlr .check_and_correct_pair (pairs , path , curr_pos , name )
22642284 else :
22652285 if not unoriented :
22662286 path , unoriented = Physlr .orient_part_of_path_forward (pairs , path ,
0 commit comments