nodes: 0, module; 1, function_definition; 2, function_name:iterative_overlap_assembly; 3, parameters; 4, block; 5, identifier:variant_sequences; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, comment:# reduce the number of inputs to the merge algorithm by first collapsing; 10, comment:# shorter sequences onto the longer sequences which contain them; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, identifier:min_overlap_size; 18, identifier:MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE; 19, comment:"""
      Assembles longer sequences from reads centered on a variant by
      between merging all pairs of overlapping sequences and collapsing
      shorter sequences onto every longer sequence which contains them.
  
      Returns a list of variant sequences, sorted by decreasing read support.
      """; 20, comparison_operator:len(variant_sequences) <= 1; 21, comment:# if we don't have at least two sequences to start with then; 22, comment:# skip the whole mess below; 23, block; 24, assignment; 25, assignment; 26, assignment; 27, call; 28, assignment; 29, call; 30, call; 31, integer:1; 32, return_statement; 33, identifier:n_before_collapse; 34, call; 35, identifier:variant_sequences; 36, call; 37, identifier:n_after_collapse; 38, call; 39, attribute; 40, argument_list; 41, identifier:merged_variant_sequences; 42, call; 43, identifier:list; 44, argument_list; 45, identifier:len; 46, argument_list; 47, identifier:variant_sequences; 48, identifier:len; 49, argument_list; 50, identifier:collapse_substrings; 51, argument_list; 52, identifier:len; 53, argument_list; 54, identifier:logger; 55, identifier:info; 56, string:"Collapsed %d -> %d sequences"; 57, identifier:n_before_collapse; 58, identifier:n_after_collapse; 59, identifier:greedy_merge; 60, argument_list; 61, call; 62, identifier:variant_sequences; 63, identifier:variant_sequences; 64, identifier:variant_sequences; 65, identifier:variant_sequences; 66, identifier:variant_sequences; 67, identifier:min_overlap_size; 68, identifier:sorted; 69, argument_list; 70, identifier:merged_variant_sequences; 71, keyword_argument; 72, identifier:key; 73, lambda; 74, lambda_parameters; 75, unary_operator; 76, identifier:seq; 77, call; 78, identifier:len; 79, argument_list; 80, attribute; 81, identifier:seq; 82, identifier:reads
code: def iterative_overlap_assembly(
          variant_sequences,
          min_overlap_size=MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE):
      """
      Assembles longer sequences from reads centered on a variant by
      between merging all pairs of overlapping sequences and collapsing
      shorter sequences onto every longer sequence which contains them.
  
      Returns a list of variant sequences, sorted by decreasing read support.
      """
      if len(variant_sequences) <= 1:
          # if we don't have at least two sequences to start with then
          # skip the whole mess below
          return variant_sequences
  
      # reduce the number of inputs to the merge algorithm by first collapsing
      # shorter sequences onto the longer sequences which contain them
      n_before_collapse = len(variant_sequences)
      variant_sequences = collapse_substrings(variant_sequences)
      n_after_collapse = len(variant_sequences)
      logger.info(
          "Collapsed %d -> %d sequences",
          n_before_collapse,
          n_after_collapse)
  
      merged_variant_sequences = greedy_merge(variant_sequences, min_overlap_size)
      return list(sorted(
          merged_variant_sequences,
          key=lambda seq: -len(seq.reads)))