FreeSASA  1.1
Open source SASA calculations
View on GitHub
example.c
Go to the documentation of this file.
1 
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include "freesasa.h"
17 
19 int main(int argc, char **argv) {
20  freesasa_structure *structure = NULL;
21  freesasa_result *result = NULL;
22  freesasa_strvp *class_area = NULL;
23 
24  /* Read structure from stdin */
25  structure = freesasa_structure_from_pdb(stdin,NULL,0);
26 
27  /* Calculate SASA using structure */
28  if (structure) {
29  result = freesasa_calc_structure(structure,NULL);
30  }
31 
32  /* Calculate area of classes (Polar/Apolar/..) */
33  if (result) {
34  class_area = freesasa_result_classify(result,structure,NULL);
35  }
36 
37  /* Print results */
38  if (class_area) {
39  printf("Total area : %f A2\n",result->total);
40  for (int i = 0; i < class_area->n; ++i)
41  printf("%s : %f A2\n",class_area->string[i],
42  class_area->value[i]);
43  } else {
44  /* If there was an error at any step, we will end up here */
45  printf("Error calculating SASA\n");
46  }
47 
48  /* Free allocated resources */
49  freesasa_strvp_free(class_area);
50  freesasa_result_free(result);
51  freesasa_structure_free(structure);
52 
53  return EXIT_SUCCESS;
54 }
void freesasa_strvp_free(freesasa_strvp *strvp)
Frees a freesasa_strvp object.
Struct used to store n string-value-pairs (strvp) in arrays of doubles and strings.
Definition: freesasa.h:130
freesasa_strvp * freesasa_result_classify(const freesasa_result *result, const freesasa_structure *structure, const freesasa_classifier *classifier)
Sums up the SASA for groups of atoms defined by a classifier.
int n
Number of values and strings.
Definition: freesasa.h:133
freesasa_result * freesasa_calc_structure(const freesasa_structure *structure, const freesasa_parameters *parameters)
Calculates SASA based on a given structure.
double * value
Array of values.
Definition: freesasa.h:131
struct freesasa_structure freesasa_structure
Struct for structure object.
Definition: freesasa.h:123
Functions and datatypes for performing and analyzing SASA calculations.
char ** string
Array of strings.
Definition: freesasa.h:132
Struct to store results of SASA calculation.
Definition: freesasa.h:99
double total
Total SASA in Ångström^2.
Definition: freesasa.h:100
freesasa_structure * freesasa_structure_from_pdb(FILE *pdb, const freesasa_classifier *classifier, int options)
Init structure with coordinates from pdb-file.
void freesasa_structure_free(freesasa_structure *structure)
Free structure.
void freesasa_result_free(freesasa_result *result)
Frees a freesasa_result object.