END_TEST START_TEST (test_nb) { freesasa_set_verbosity(FREESASA_V_SILENT); ck_assert_ptr_eq(cell_list_new(1,&coord),NULL); ck_assert_int_eq(fill_cells(&a_cell_list,&coord),FREESASA_FAIL); ck_assert_ptr_eq(freesasa_nb_alloc(10),NULL); for (int i = 1; i < 50; ++i) { set_fail_freq(i); ck_assert_ptr_eq(freesasa_nb_alloc(2*i),NULL); set_fail_freq(i); ck_assert_ptr_eq(freesasa_nb_new(&coord,r),NULL); } set_fail_freq(1); freesasa_set_verbosity(FREESASA_V_NORMAL); }
int init_sr(sr_data* sr_p, double *sasa, const coord_t *xyz, const double *r, double probe_radius, int n_points) { int n_atoms = freesasa_coord_n(xyz); coord_t *srp = test_points(n_points); if (srp == NULL) return fail_msg("Failed to initialize test points."); //store parameters and reference arrays sr_data sr = {.n_atoms = n_atoms, .n_points = n_points, .probe_radius = probe_radius, .xyz = xyz, .srp = srp, .sasa = sasa}; sr.r = malloc(sizeof(double)*n_atoms); sr.r2 = malloc(sizeof(double)*n_atoms); if (sr.r == NULL || sr.r2 == NULL) { freesasa_coord_free(srp); free(sr.r); free(sr.r2); return mem_fail(); } for (int i = 0; i < n_atoms; ++i) { sr.r[i] = r[i] + probe_radius; sr.r2[i] = sr.r[i]*sr.r[i]; } //calculate distances sr.nb = freesasa_nb_new(xyz,sr.r); if (sr.nb == NULL) { freesasa_coord_free(srp); free(sr.r); free(sr.r2); return mem_fail(); } *sr_p = sr; return FREESASA_SUCCESS; }
int init_sr(sr_data *sr, double *sasa, const coord_t *xyz, const double *r, double probe_radius, int n_points) { int n_atoms = freesasa_coord_n(xyz); coord_t *srp = test_points(n_points); if (srp == NULL) return fail_msg("Failed to initialize test points."); //store parameters and reference arrays sr->n_atoms = n_atoms; sr->n_points = n_points; sr->probe_radius = probe_radius; sr->xyz = xyz; sr->srp = srp; sr->sasa = sasa; sr->nb = NULL; sr->r = malloc(sizeof(double)*n_atoms); sr->r2 = malloc(sizeof(double)*n_atoms); if (sr->r == NULL || sr->r2 == NULL) goto cleanup; for (int i = 0; i < n_atoms; ++i) { double ri = r[i] + probe_radius; sr->r[i] = ri; sr->r2[i] = ri * ri; } //calculate distances sr->nb = freesasa_nb_new(xyz, sr->r); if (sr->nb == NULL) goto cleanup; return FREESASA_SUCCESS; cleanup: release_sr(sr); return mem_fail(); }