<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(gctoo_object, out_file_name, convert_back_to_neg_666=True, gzip_compression_level=6, max_chunk_kb=1024, matrix_dtype=numpy.float32):
 """ 	Writes a GCToo instance to specified file. 	Input: 		- gctoo_object (GCToo):
 A GCToo instance. 		- out_file_name (str):
 file name to write gctoo_object to. - convert_back_to_neg_666 (bool):
 whether to convert np.NAN in metadata back to "-666" - gzip_compression_level (int, default=6):
 Compression level to use for metadata. - max_chunk_kb (int, default=1024):
 The maximum number of KB a given chunk will occupy - matrix_dtype (numpy dtype, default=numpy.float32):
 Storage data type for data matrix. 	"""

    # make sure out file has a .gctx suffix
    gctx_out_name = add_gctx_to_out_name(out_file_name)

    # open an hdf5 file to write to
    hdf5_out = h5py.File(gctx_out_name, "w")

    # write version
    write_version(hdf5_out)

    # write src
    write_src(hdf5_out, gctoo_object, gctx_out_name)

    # set chunk size for data matrix
    elem_per_kb = calculate_elem_per_kb(max_chunk_kb, matrix_dtype)
    chunk_size = set_data_matrix_chunk_size(gctoo_object.data_df.shape, max_chunk_kb, elem_per_kb)

    # write data matrix
    hdf5_out.create_dataset(data_matrix_node, data=gctoo_object.data_df.transpose().values,
        dtype=matrix_dtype)

    # write col metadata
    write_metadata(hdf5_out, "col", gctoo_object.col_metadata_df, convert_back_to_neg_666,
        gzip_compression=gzip_compression_level)

    # write row metadata
    write_metadata(hdf5_out, "row", gctoo_object.row_metadata_df, convert_back_to_neg_666,
        gzip_compression=gzip_compression_level)

    # close gctx file
    hdf5_out.close()