def save_cluster_elements(elements,
                          ids,
                          out_pdb_name,
                          data_handler,
                          options,
                          cluster_sizes = None):
    keep_remarks = options.get_value("keep_remarks", default_value = "NONE")
    add_source_details = options.get_value("add_source_details", default_value = False)

    file_handler_out = open(out_pdb_name, "w")
    
    data = data_handler.get_data()
    
    merged_structure = data.get_all_elements()
    
    file_handler_out.write("REMARK 000 File created using Prody and pyProCT\n")
    
    if not keep_remarks == "NONE" and not add_source_details:
        prody.writePDBStream(file_handler_out, merged_structure, csets =  elements)
    else:
        all_remarks = filter_remarks(data.get_all_remarks(), subset= keep_remarks)
        all_model_numbers = data.get_all_model_numbers()
        
        current_model = 0
        for i, element_id in enumerate(elements): 
            if keep_remarks:
                remarks = all_remarks[element_id]
                file_handler_out.write("".join(remarks))
            
            if add_source_details:
                model_number = all_model_numbers[element_id]
                conf_source = data_handler.get_source_of_element(element_id).get_path()
                file_handler_out.write("REMARK 000  source            : %s\n"%conf_source)
                file_handler_out.write("REMARK 000  original model nr : %d\n"%model_number)
                file_handler_out.write("REMARK 000  cluster id : %s\n"%ids[i])
                file_handler_out.write("REMARK 000  cluster element : %d\n"%element_id)
                if cluster_sizes is not None:
                    file_handler_out.write("REMARK 000  cluster population : %s\n"%(cluster_sizes[i]))
            
            file_handler_out.write("MODEL"+str(current_model).rjust(9)+"\n")
            pdb_handler = cStringIO.StringIO()
            prody.writePDBStream(pdb_handler, merged_structure, csets=  element_id)
            # skip the first remark if any
            lines = filter(lambda line: line[0:6]!="REMARK" and line[0:5]!="MODEL" and line[0:6]!="ENDMDL", 
                           pdb_handler.getvalue().splitlines(True))
            pdb_handler.close()
            file_handler_out.write("".join(lines))
            file_handler_out.write("ENDMDL\n")
            current_model+=1

    file_handler_out.close()
Saves a pdb file containing the most representative elements of the clustering.
dataset/ETHPy150Open victor-gil-sepulveda/pyProCT/pyproct/postprocess/actions/representatives.py/save_cluster_elements