def save_matrix(self, matrix_path): """ Writes matrix contents to disk. @param matrix_save_file: Complete path (with filename) where to save the matrix. """ pyRMSD_MatrixHandler.save_matrix(matrix_path, self.distance_matrix)
def save_statistics(self, matrix_base_path): """ Writes matrix statistics to disk in JSON format. @param matrix_base_path: The folder where to save the 'statistics.json' file. """ return pyRMSD_MatrixHandler.save_statistics(matrix_base_path, self.distance_matrix)
def calculate(cls, data_handler, matrix_params): """ :param matrix_params: The parameters to build the matrix. In this base case the only option is "load". Base parameters : { "method": STRING, "parameters":{ ... } } Options: - "load": Load an already created matrix from disk "parameters":{ "path": STRING } "path": The path from where the matrix is going to be loaded. :return: A CondensedMatrix. """ return pyRMSD_MatrixHandler.load_matrix(matrix_params["path"])
def test_write_and_load(self): mh = MatrixHandler(".") data = range(1000) matrix = CondensedMatrix(data) mh.distance_matrix = matrix mh.saveMatrix("matrix") mh2 = MatrixHandler(None) mh2.loadMatrix("matrix") recovered_data = mh2.distance_matrix.get_data() numpy.testing.assert_array_equal(mh.distance_matrix.get_data(), data) numpy.testing.assert_array_equal(recovered_data, data) # Clean it! os.system("rm matrix.npy")
def calcDistMatrix(coordsets): from pyRMSD.matrixHandler import MatrixHandler matrix = MatrixHandler().createMatrix(coordsets,'NOSUP_SERIAL_CALCULATOR') return matrix.get_data()
"chain":ligand_file_description[1], "atoms":ligand_file_description[2:] } ligand_description = "resname %s and name %s"%(ligand["resname"],"".join( a+" " for a in ligand["atoms"])) print "* Ligand parsed: ",ligand_description ####################################################################################################################### # Generate matrix with metrics (so now we are going to cluster based on Energy and spawning ####################################################################################################################### print "* Creating Spawning - totalE matrix" records = [] processFile(traj_pdb, records, True) all_metrics = genMetrics(plots["totale_spawning"], records) matrix_data = scipy.spatial.distance.pdist(normalize_metrics(all_metrics), 'euclidean') m_handler = MatrixHandler() m_handler.distance_matrix = CondensedMatrix(matrix_data) matrix_file = os.path.join(base_dir, TENERGY_SPAWN_MATRIX) m_handler.saveMatrix(matrix_file) ####################################################################################################################### # Cluster by metrics ####################################################################################################################### print "* Spawning - totalE clustering" be_rmsd_clustering_script_path = os.path.join(base_dir, 'scripts', CLUSTERING_SPAWN_TOTE_SCRIPT) working_directory = os.path.join(base_dir, TOTALE_SPAWN_WORKSPACE) params = load_dic_in_json(be_rmsd_clustering_script_path) params['global']['workspace']['base'] = working_directory params['data']['files'] = [os.path.join(os.getcwd(), traj_pdb)] params['data']['matrix']['parameters']['path'] = matrix_file save_dic_in_json(params, be_rmsd_clustering_script_path)