int freesasa_shrake_rupley(double *sasa, const coord_t *xyz, const double *r, const freesasa_parameters *param) { assert(sasa); assert(xyz); assert(r); if (param == NULL) param = &freesasa_default_parameters; int n_atoms = freesasa_coord_n(xyz), n_threads = param->n_threads, resolution = param->shrake_rupley_n_points, return_value = FREESASA_SUCCESS; double probe_radius = param->probe_radius; sr_data sr; if (resolution <= 0) return freesasa_fail("in %s(): n_slices_per_atom = %f is invalid, must be > 0\n", __func__, resolution); if (n_atoms == 0) return freesasa_warn("%s(): empty coordinates", __func__); if (n_threads > n_atoms) { n_threads = n_atoms; freesasa_warn("No sense in having more threads than atoms, only using %d threads.", n_threads); } if (init_sr(&sr, sasa, xyz, r, probe_radius, resolution)) return FREESASA_FAIL; //calculate SASA if (n_threads > 1) { #if USE_THREADS return_value = sr_do_threads(n_threads, &sr); #else return_value = freesasa_warn("%s: program compiled for single-threaded use, " "but multiple threads were requested. Will " "proceed in single-threaded mode.\n", __func__); n_threads = 1; #endif } if (n_threads == 1) { // don't want the overhead of generating threads if only one is used for (int i = 0; i < n_atoms; ++i) { sasa[i] = sr_atom_area(i, &sr); } } release_sr(&sr); return return_value; }
int freesasa_shrake_rupley(double *sasa, const coord_t *xyz, const double *r, double probe_radius, int n_points, int n_threads) { assert(sasa); assert(xyz); assert(r); assert(n_threads > 0); int n_atoms = freesasa_coord_n(xyz); int return_value = FREESASA_SUCCESS; sr_data sr; if (n_atoms == 0) return freesasa_warn("%s(): empty coordinates", __func__); if (init_sr(&sr,sasa,xyz,r,probe_radius,n_points)) return mem_fail(); //calculate SASA if (n_threads > 1) { #if USE_THREADS sr_do_threads(n_threads, sr); #else return_value = freesasa_warn("%s: program compiled for single-threaded use, " "but multiple threads were requested. Will " "proceed in single-threaded mode.\n", __func__); n_threads = 1; #endif } if (n_threads == 1) { // don't want the overhead of generating threads if only one is used for (int i = 0; i < n_atoms; ++i) { sasa[i] = sr_atom_area(i,sr); } } release_sr(sr); return return_value; }