parameters: (working_paths, opposite_paths_dict, shortest_opposite_path,
                    final_paths, flip_new_final_paths, sequence, scoring_scheme,
                    expected_scaled_score, graph, start_end_depth, total_max_length,
                    cull_score_fraction)
return_statement: return working_paths
docstring: This function takes the working paths for one direction and extends them until there are too
      many or there are no more.
docstring_summary: This function takes the working paths for one direction and extends them until there are too
      many or there are no more.
docstring_tokens: This function takes the working paths for one direction and extends them until there are too many or there are no more .
function: def advance_paths(working_paths, opposite_paths_dict, shortest_opposite_path,
                    final_paths, flip_new_final_paths, sequence, scoring_scheme,
                    expected_scaled_score, graph, start_end_depth, total_max_length,
                    cull_score_fraction):
      """
      This function takes the working paths for one direction and extends them until there are too
      many or there are no more.
      """
      # For this function, the longest we'll allow paths to get is the the max length minus how far
      # the other side has gotten.
      max_length = total_max_length - shortest_opposite_path
  
      while True:
          # If the working paths have run out or grown too large, then we're finished with this
          # round of advancing.
          if not 0 < len(working_paths) <= settings.PROGRESSIVE_PATH_SEARCH_MAX_WORKING_PATHS:
              break
  
          shortest_path_len = min(graph.get_path_length(x) for x in working_paths)
  
          # Extend the shortest working path(s) by adding downstream segments.
          new_working_paths = []
          for path in working_paths:
              path_len = graph.get_path_length(path)
  
              # If this path isn't the shortest path, we don't deal with it this time.
              if path_len > shortest_path_len:
                  new_working_paths.append(path)
  
              # If it is the shortest path and has downstream segments...
              elif path[-1] in graph.forward_links:
                  downstream_segments = graph.forward_links[path[-1]]
                  for next_seg in downstream_segments:
  
                      # Make sure we haven't already used this segment too many times in the path.
                      max_allowed_count = graph.max_path_segment_count(next_seg, start_end_depth)
                      count_so_far = path.count(next_seg) + path.count(-next_seg)
                      if count_so_far < max_allowed_count:
  
                          # If the next segment is in the dictionary of the opposite direction's
                          # paths, that means we've found a path through to the other side!
                          if next_seg in opposite_paths_dict:
                              for final_part in opposite_paths_dict[next_seg]:
                                  final_path = path + final_part
                                  if flip_new_final_paths:
                                      final_path = reverse_path(final_path)
                                  final_paths.add(tuple(final_path))
  
                          # Finally, extend the path if doing so won't make it too long.
                          if graph.get_path_length(path[1:] + [next_seg]) <= max_length:
                              new_working_paths.append(path + [next_seg])
  
          working_paths = new_working_paths
  
      # If we've exceeded the allowable working count, cull the paths down to size now.
      if len(working_paths) > settings.PROGRESSIVE_PATH_SEARCH_MAX_WORKING_PATHS:
          working_paths = cull_paths(graph, working_paths, sequence, scoring_scheme,
                                     expected_scaled_score, cull_score_fraction)
  
      return working_paths
function_tokens: def advance_paths ( working_paths , opposite_paths_dict , shortest_opposite_path , final_paths , flip_new_final_paths , sequence , scoring_scheme , expected_scaled_score , graph , start_end_depth , total_max_length , cull_score_fraction ) : # For this function, the longest we'll allow paths to get is the the max length minus how far # the other side has gotten. max_length = total_max_length - shortest_opposite_path while True : # If the working paths have run out or grown too large, then we're finished with this # round of advancing. if not 0 < len ( working_paths ) <= settings . PROGRESSIVE_PATH_SEARCH_MAX_WORKING_PATHS : break shortest_path_len = min ( graph . get_path_length ( x ) for x in working_paths ) # Extend the shortest working path(s) by adding downstream segments. new_working_paths = [ ] for path in working_paths : path_len = graph . get_path_length ( path ) # If this path isn't the shortest path, we don't deal with it this time. if path_len > shortest_path_len : new_working_paths . append ( path ) # If it is the shortest path and has downstream segments... elif path [ - 1 ] in graph . forward_links : downstream_segments = graph . forward_links [ path [ - 1 ] ] for next_seg in downstream_segments : # Make sure we haven't already used this segment too many times in the path. max_allowed_count = graph . max_path_segment_count ( next_seg , start_end_depth ) count_so_far = path . count ( next_seg ) + path . count ( - next_seg ) if count_so_far < max_allowed_count : # If the next segment is in the dictionary of the opposite direction's # paths, that means we've found a path through to the other side! if next_seg in opposite_paths_dict : for final_part in opposite_paths_dict [ next_seg ] : final_path = path + final_part if flip_new_final_paths : final_path = reverse_path ( final_path ) final_paths . add ( tuple ( final_path ) ) # Finally, extend the path if doing so won't make it too long. if graph . get_path_length ( path [ 1 : ] + [ next_seg ] ) <= max_length : new_working_paths . append ( path + [ next_seg ] ) working_paths = new_working_paths # If we've exceeded the allowable working count, cull the paths down to size now. if len ( working_paths ) > settings . PROGRESSIVE_PATH_SEARCH_MAX_WORKING_PATHS : working_paths = cull_paths ( graph , working_paths , sequence , scoring_scheme , expected_scaled_score , cull_score_fraction ) return working_paths