IsoSpec  2.1.2
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* setupIsoStrochasticGenerator(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 freeReleasedArray(void* array);
112 
113 void* setupFixedEnvelope(double* masses, double* probs, size_t size, bool mass_sorted, bool prob_sorted, double total_prob);
114 void deleteFixedEnvelope(void* tabulator, bool releaseEverything);
115 
116 const double* massesFixedEnvelope(void* tabulator);
117 const double* probsFixedEnvelope(void* tabulator);
118 const int* confsFixedEnvelope(void* tabulator);
119 int confs_noFixedEnvelope(void* tabulator);
120 
121 double empiricAverageMass(void* tabulator);
122 double empiricVariance(void* tabulator);
123 double empiricStddev(void* tabulator);
124 
125 double wassersteinDistance(void* tabulator1, void* tabulator2);
126 double orientedWassersteinDistance(void* tabulator1, void* tabulator2);
127 void* addEnvelopes(void* tabulator1, void* tabulator2);
128 void* convolveEnvelopes(void* tabulator1, void* tabulator2);
129 
130 double getTotalProbOfEnvelope(void* envelope);
131 void scaleEnvelope(void* envelope, double factor);
132 void normalizeEnvelope(void* envelope);
133 void* binnedEnvelope(void* envelope, double width, double middle);
134 void* linearCombination(void* const * const envelopes, const double* intensities, size_t count);
135 
136 void sortEnvelopeByMass(void* envelope);
137 void sortEnvelopeByProb(void* envelope);
138 
139 void parse_fasta_c(const char* fasta, int atomCounts[6]);
140 
141 
142 #ifdef __cplusplus
143 }
144 #endif