def compress(self, clustering, workspace_handler, trajectory_handler, matrix_handler): representatives = [] compression_type = self.parameters.get_value("type", default_value="KMEDOIDS") pdb_name = self.parameters.get_value("file", default_value="compressed") if compression_type == "RANDOM": representatives = self.__naive_compression(clustering, matrix_handler) elif compression_type == "KMEDOIDS": representatives = self.__kmedoids_compression( clustering, matrix_handler) else: print "[ERROR Compressor::compress] The compression type does not exist (%s)" % ( self.type) return save_representatives( representatives, pdb_name, workspace_handler, trajectory_handler, do_merged_files_have_correlative_models=True, write_frame_number_instead_of_correlative_model_number=False, keep_remarks=(lambda params: params['keep_remarks'] if 'keep_remarks' in params else False)( self.parameters))
def test_save_representatives(self): representatives = [1,5] pdbs = ["data/pdb1.pdb", "data/pdb2.pdb", "data/pdb3.pdb"] file_path = save_representatives(representatives, "representatives.pdb", {"results":"data/","tmp":"data/"}, pdbs, do_merged_files_have_correlative_models = False, write_frame_number_instead_of_correlative_model_number = False) self.assertEqual("".join(open(file_path,"r").readlines()), merged_1_5_correlative) file_path = save_representatives(representatives, "representatives.pdb", {"results":"data/","tmp":"data/"}, pdbs, do_merged_files_have_correlative_models = False, write_frame_number_instead_of_correlative_model_number = True) self.assertEqual("".join(open(file_path,"r").readlines()), merged_1_5)
def test_extract_prototypes(self): self.fail("TODO: Update Test") prototypes = [2,26,48,56,100] open("data/prototypes.pdb","w").write(proto_pdb) file_path = save_representatives([prototypes[3]], "prototype.pdb", {"results":"data/","tmp":"data/"}, ["data/prototypes.pdb"], do_merged_files_have_correlative_models = False, write_frame_number_instead_of_correlative_model_number = True) print "".join(open(file_path,"r").readlines())