nodes: 0, module; 1, function_definition; 2, function_name:combine; 3, parameters; 4, block; 5, identifier:beds; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, comment:# For some reason, doing the merging in the reduce statement doesn't work. I; 12, comment:# think this might be a pybedtools bug. In any fashion, I can merge; 13, comment:# afterward although I think it makes a performance hit because the combined; 14, comment:# bed file grows larger than it needs to.; 15, expression_statement; 16, expression_statement; 17, if_statement; 18, return_statement; 19, identifier:beds_sorted; 20, False; 21, identifier:postmerge; 22, True; 23, comment:"""
      Combine a list of bed files or BedTool objects into a single BedTool object.
  
      Parameters
      ----------
      beds : list
          List of paths to bed files or BedTool objects.
  
      beds_sorted : boolean
          Whether the bed files in beds are already sorted. If False, all bed
          files in beds will be sorted.
  
      postmerge : boolean
          Whether to merge intervals after combining beds together. 
  
      Returns
      -------
      out : pybedtools.BedTool
          New sorted BedTool with intervals from all input beds.
  
      """; 24, assignment; 25, pattern_list; 26, call; 27, block; 28, assignment; 29, assignment; 30, identifier:postmerge; 31, block; 32, identifier:out; 33, identifier:beds; 34, call; 35, identifier:i; 36, identifier:v; 37, identifier:enumerate; 38, argument_list; 39, if_statement; 40, if_statement; 41, identifier:out; 42, call; 43, identifier:out; 44, call; 45, expression_statement; 46, attribute; 47, argument_list; 48, identifier:beds; 49, comparison_operator:type(v) == str; 50, block; 51, not_operator; 52, block; 53, identifier:reduce; 54, argument_list; 55, attribute; 56, argument_list; 57, assignment; 58, identifier:copy; 59, identifier:deepcopy; 60, identifier:beds; 61, call; 62, identifier:str; 63, expression_statement; 64, identifier:beds_sorted; 65, expression_statement; 66, lambda; 67, identifier:beds; 68, identifier:out; 69, identifier:sort; 70, identifier:out; 71, call; 72, identifier:type; 73, argument_list; 74, assignment; 75, assignment; 76, lambda_parameters; 77, call; 78, attribute; 79, argument_list; 80, identifier:v; 81, subscript; 82, call; 83, subscript; 84, call; 85, identifier:x; 86, identifier:y; 87, attribute; 88, argument_list; 89, identifier:out; 90, identifier:merge; 91, identifier:beds; 92, identifier:i; 93, attribute; 94, argument_list; 95, identifier:beds; 96, identifier:i; 97, attribute; 98, argument_list; 99, identifier:x; 100, identifier:cat; 101, identifier:y; 102, keyword_argument; 103, identifier:pbt; 104, identifier:BedTool; 105, identifier:v; 106, subscript; 107, identifier:sort; 108, identifier:postmerge; 109, False; 110, identifier:beds; 111, identifier:i
code: def combine(beds, beds_sorted=False, postmerge=True):
      """
      Combine a list of bed files or BedTool objects into a single BedTool object.
  
      Parameters
      ----------
      beds : list
          List of paths to bed files or BedTool objects.
  
      beds_sorted : boolean
          Whether the bed files in beds are already sorted. If False, all bed
          files in beds will be sorted.
  
      postmerge : boolean
          Whether to merge intervals after combining beds together. 
  
      Returns
      -------
      out : pybedtools.BedTool
          New sorted BedTool with intervals from all input beds.
  
      """
      beds = copy.deepcopy(beds)
      for i,v in enumerate(beds):
          if type(v) == str:
              beds[i] = pbt.BedTool(v)
          if not beds_sorted:
              beds[i] = beds[i].sort()
  
      # For some reason, doing the merging in the reduce statement doesn't work. I
      # think this might be a pybedtools bug. In any fashion, I can merge
      # afterward although I think it makes a performance hit because the combined
      # bed file grows larger than it needs to.
      out = reduce(lambda x,y : x.cat(y, postmerge=False), beds)
      out = out.sort()
      if postmerge:
          out = out.merge()
      return out