original_docstring: Aggregate a given list of aliquot-level MAF files.
  
      The aliquot-level MAF files will be combined into a single MAF file and written to
      the given output file-like object.
  
      The input files are assumed to be gzipped MAF files.  The output will be written
      as a gzipped MAF file.
  
      Args:
          mafs: A list of aliquot-level MAF files with metadata.
          output: A file-like object to write the aggregated MAF file.
      
docstring: Aggregate a given list of aliquot-level MAF files.
  The aliquot-level MAF files will be combined into a single MAF file and written to
  the given output file-like object.
  
  The input files are assumed to be gzipped MAF files.  The output will be written
  as a gzipped MAF file.
docstring_tokens: Aggregate a given list of aliquot - level MAF files . The aliquot - level MAF files will be combined into a single MAF file and written to the given output file - like object . The input files are assumed to be gzipped MAF files . The output will be written as a gzipped MAF file .
code: def aggregate_mafs(mafs: List[AliquotLevelMaf], output: BinaryIO) -> None:
      """Aggregate a given list of aliquot-level MAF files.
  
      The aliquot-level MAF files will be combined into a single MAF file and written to
      the given output file-like object.
  
      The input files are assumed to be gzipped MAF files.  The output will be written
      as a gzipped MAF file.
  
      Args:
          mafs: A list of aliquot-level MAF files with metadata.
          output: A file-like object to write the aggregated MAF file.
      """
      if not mafs:
          return
  
      with gzip.open(output, "wt") as gzip_output:
          is_first_pass = True
          for maf in mafs:
              with io.BufferedReader(gzip.open(maf.file, "r")) as reader:
                  # Case where the file content is empty or the user does not have access to a file.
                  file_headers = _read_and_parse_file_headers(reader)
                  if not file_headers:
                      continue
                  if is_first_pass:
                      expected_file_headers = file_headers
                  _validate_file_headers(
                      headers=file_headers, expected_headers=expected_file_headers
                  )
  
                  column_headers = _read_and_parse_column_headers(reader)
                  if is_first_pass:
                      expected_column_headers = column_headers.copy()
                  _validate_column_headers(
                      headers=column_headers, expected_headers=expected_column_headers
                  )
  
                  if is_first_pass:
                      _write_file_headers(
                          output=gzip_output,
                          version=file_headers.version,
                          file_date=datetime.datetime.now(),
                          annotation_spec=file_headers.annotation_spec,
                          submitter_ids=[m.tumor_aliquot_submitter_id for m in mafs],
                      )
                      _write_column_headers(gzip_output, column_headers)
  
                  for line in reader:
                      gzip_output.write(line.decode())
  
              is_first_pass = False
code_tokens: def aggregate_mafs ( mafs : List [ AliquotLevelMaf ] , output : BinaryIO ) -> None : if not mafs : return with gzip . open ( output , "wt" ) as gzip_output : is_first_pass = True for maf in mafs : with io . BufferedReader ( gzip . open ( maf . file , "r" ) ) as reader : file_headers = _read_and_parse_file_headers ( reader ) if not file_headers : continue if is_first_pass : expected_file_headers = file_headers _validate_file_headers ( headers = file_headers , expected_headers = expected_file_headers ) column_headers = _read_and_parse_column_headers ( reader ) if is_first_pass : expected_column_headers = column_headers . copy ( ) _validate_column_headers ( headers = column_headers , expected_headers = expected_column_headers ) if is_first_pass : _write_file_headers ( output = gzip_output , version = file_headers . version , file_date = datetime . datetime . now ( ) , annotation_spec = file_headers . annotation_spec , submitter_ids = [ m . tumor_aliquot_submitter_id for m in mafs ] , ) _write_column_headers ( gzip_output , column_headers ) for line in reader : gzip_output . write ( line . decode ( ) ) is_first_pass = False
short_docstring: Aggregate a given list of aliquot-level MAF files.
short_docstring_tokens: Aggregate a given list of aliquot - level MAF files .
comment: """Aggregate a given list of aliquot-level MAF files.
  
      The aliquot-level MAF files will be combined into a single MAF file and written to
      the given output file-like object.
  
      The input files are assumed to be gzipped MAF files.  The output will be written
      as a gzipped MAF file.
  
      Args:
          mafs: A list of aliquot-level MAF files with metadata.
          output: A file-like object to write the aggregated MAF file.
      """$SEP$# Case where the file content is empty or the user does not have access to a file.