IsoSpec  2.1.3
cwrapper.h
1 /*
2  * Copyright (C) 2015-2020 Mateusz Łącki and Michał Startek.
3  *
4  * This file is part of IsoSpec.
5  *
6  * IsoSpec is free software: you can redistribute it and/or modify
7  * it under the terms of the Simplified ("2-clause") BSD licence.
8  *
9  * IsoSpec is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * You should have received a copy of the Simplified BSD Licence
14  * along with IsoSpec. If not, see <https://opensource.org/licenses/BSD-2-Clause>.
15  */
16 
17 #pragma once
18 
19 #define ISOSPEC_ALGO_LAYERED 0
20 #define ISOSPEC_ALGO_ORDERED 1
21 #define ISOSPEC_ALGO_THRESHOLD_ABSOLUTE 2
22 #define ISOSPEC_ALGO_THRESHOLD_RELATIVE 3
23 #define ISOSPEC_ALGO_LAYERED_ESTIMATE 4
24 
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #else
29 #include <stdbool.h>
30 #endif
31 
32 void * setupIso(int dimNumber,
33  const int* isotopeNumbers,
34  const int* atomCounts,
35  const double* isotopeMasses,
36  const double* isotopeProbabilities);
37 
38 void * isoFromFasta(const char* fasta, bool use_nominal_masses, bool add_water);
39 
40 double getLightestPeakMassIso(void* iso);
41 double getHeaviestPeakMassIso(void* iso);
42 double getMonoisotopicPeakMassIso(void* iso);
43 double getModeLProbIso(void* iso);
44 double getModeMassIso(void* iso);
45 double getTheoreticalAverageMassIso(void* iso);
46 double getIsoVariance(void* iso);
47 double getIsoStddev(void* iso);
48 double* getMarginalLogSizeEstimates(void* iso, double target_total_prob);
49 
50 
51 void deleteIso(void* iso);
52 
53 #define ISOSPEC_C_FN_HEADER(generatorType, dataType, method)\
54 dataType method##generatorType(void* generator);
55 
56 #define ISOSPEC_C_FN_HEADER_GET_CONF_SIGNATURE(generatorType)\
57 void method##generatorType(void* generator);
58 
59 #define ISOSPEC_C_FN_HEADERS(generatorType)\
60 ISOSPEC_C_FN_HEADER(generatorType, double, mass) \
61 ISOSPEC_C_FN_HEADER(generatorType, double, lprob) \
62 ISOSPEC_C_FN_HEADER(generatorType, double, prob) \
63 ISOSPEC_C_FN_HEADER_GET_CONF_SIGNATURE(generatorType) \
64 ISOSPEC_C_FN_HEADER(generatorType, bool, advanceToNextConfiguration) \
65 ISOSPEC_C_FN_HEADER(generatorType, void, delete)
66 
67 
68 
69 
70 // ______________________________________________________THRESHOLD GENERATOR
71 void* setupIsoThresholdGenerator(void* iso,
72  double threshold,
73  bool _absolute,
74  int _tabSize,
75  int _hashSize,
76  bool reorder_marginals);
77 ISOSPEC_C_FN_HEADERS(IsoThresholdGenerator)
78 
79 
80 // ______________________________________________________LAYERED GENERATOR
81 void* setupIsoLayeredGenerator(void* iso,
82  int _tabSize,
83  int _hashSize,
84  bool reorder_marginals,
85  double t_prob_hint);
86 ISOSPEC_C_FN_HEADERS(IsoLayeredGenerator)
87 
88 // ______________________________________________________ORDERED GENERATOR
89 void* setupIsoOrderedGenerator(void* iso,
90  int _tabSize,
91  int _hashSize);
92 ISOSPEC_C_FN_HEADERS(IsoOrderedGenerator)
93 
94 void* setupIsoStochasticGenerator(void* iso,
95  size_t no_molecules,
96  double precision,
97  double beta_bias);
98 ISOSPEC_C_FN_HEADERS(IsoStochasticGenerator)
99 
100 
101 void* setupThresholdFixedEnvelope(void* iso,
102  double threshold,
103  bool absolute,
104  bool get_confs);
105 
106 void* setupTotalProbFixedEnvelope(void* iso,
107  double taget_coverage,
108  bool optimize,
109  bool get_confs);
110 
111 void* setupStochasticFixedEnvelope(void* iso,
112  size_t no_molecules,
113  double precision,
114  double beta_bias,
115  bool get_confs);
116 
117 void* setupBinnedFixedEnvelope(void* iso,
118  double target_total_prob,
119  double bin_width,
120  double bin_middle);
121 
122 void freeReleasedArray(void* array);
123 
124 void* setupFixedEnvelope(double* masses, double* probs, size_t size, bool mass_sorted, bool prob_sorted, double total_prob);
125 void deleteFixedEnvelope(void* tabulator, bool releaseEverything);
126 
127 const double* massesFixedEnvelope(void* tabulator);
128 const double* probsFixedEnvelope(void* tabulator);
129 const int* confsFixedEnvelope(void* tabulator);
130 size_t confs_noFixedEnvelope(void* tabulator);
131 
132 double empiricAverageMass(void* tabulator);
133 double empiricVariance(void* tabulator);
134 double empiricStddev(void* tabulator);
135 
136 double wassersteinDistance(void* tabulator1, void* tabulator2);
137 double orientedWassersteinDistance(void* tabulator1, void* tabulator2);
138 void* addEnvelopes(void* tabulator1, void* tabulator2);
139 void* convolveEnvelopes(void* tabulator1, void* tabulator2);
140 
141 double getTotalProbOfEnvelope(void* envelope);
142 void scaleEnvelope(void* envelope, double factor);
143 void normalizeEnvelope(void* envelope);
144 void* binnedEnvelope(void* envelope, double width, double middle);
145 void* linearCombination(void* const * const envelopes, const double* intensities, size_t count);
146 
147 void sortEnvelopeByMass(void* envelope);
148 void sortEnvelopeByProb(void* envelope);
149 
150 void parse_fasta_c(const char* fasta, int atomCounts[6]);
151 
152 
153 #ifdef __cplusplus
154 }
155 #endif