FreeSASA  2.0
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;
23  freesasa_nodearea area;
24 
25  /* Read structure from stdin */
26  structure = freesasa_structure_from_pdb(stdin, classifier, 0);
27 
28  /* Calculate SASA using structure */
29  if (structure) {
30  result = freesasa_calc_structure(structure, NULL);
31  }
32 
33  /* Calculate area of classes (Polar/Apolar/..) */
34  if (result) {
35  area = freesasa_result_classes(structure, result);
36  } else {
37  /* If there was an error at any step, we will end up here */
38  printf("Error calculating SASA\n");
39  }
40 
41  /* Print results */
42  printf("Total : %f A2\n", area.total);
43  printf("Apolar : %f A2\n", area.apolar);
44  printf("Polar : %f A2\n", area.polar);
45 
46  /* Free allocated resources */
47  freesasa_result_free(result);
48  freesasa_structure_free(structure);
49 
50  return EXIT_SUCCESS;
51 }
double polar
Polar SASA.
Definition: freesasa.h:225
freesasa_result * freesasa_calc_structure(const freesasa_structure *structure, const freesasa_parameters *parameters)
Calculates SASA based on a given structure.
freesasa_structure * freesasa_structure_from_pdb(FILE *pdb, const freesasa_classifier *classifier, int options)
Init structure with coordinates from pdb-file.
double total
Total SASA.
Definition: freesasa.h:222
void freesasa_result_free(freesasa_result *result)
Frees a freesasa_result object.
freesasa_nodearea freesasa_result_classes(const freesasa_structure *structure, const freesasa_result *result)
Results by classes.
void freesasa_structure_free(freesasa_structure *structure)
Free structure.
#define freesasa_default_classifier
Default freesasa_classifier.
Definition: freesasa.h:109
struct freesasa_classifier freesasa_classifier
Struct that can be used to determine classes (polar/apolar) and radii of atoms.
Definition: freesasa.h:266
double apolar
Apolar SASA.
Definition: freesasa.h:226
Struct to store integrated SASA values for either a full structure or a subset thereof.
Definition: freesasa.h:220
Functions and datatypes for performing and analyzing SASA calculations.
Struct to store results of SASA calculation.
Definition: freesasa.h:202
struct freesasa_structure freesasa_structure
Struct for structure object.
Definition: freesasa.h:199