IsoSpec
Loading...
Searching...
No Matches
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#include "platform.h"
20
21#define ISOSPEC_ALGO_LAYERED 0
22#define ISOSPEC_ALGO_ORDERED 1
23#define ISOSPEC_ALGO_THRESHOLD_ABSOLUTE 2
24#define ISOSPEC_ALGO_THRESHOLD_RELATIVE 3
25#define ISOSPEC_ALGO_LAYERED_ESTIMATE 4
26
27
28#ifdef __cplusplus
29extern "C" {
30#else
31#include <stdbool.h>
32#endif
33
34ISOSPEC_C_API void * setupIso(int dimNumber,
35 const int* isotopeNumbers,
36 const int* atomCounts,
37 const double* isotopeMasses,
38 const double* isotopeProbabilities);
39
40ISOSPEC_C_API void * isoFromFasta(const char* fasta, bool use_nominal_masses, bool add_water);
41
42ISOSPEC_C_API double getLightestPeakMassIso(void* iso);
43ISOSPEC_C_API double getHeaviestPeakMassIso(void* iso);
44ISOSPEC_C_API double getMonoisotopicPeakMassIso(void* iso);
45ISOSPEC_C_API double getModeLProbIso(void* iso);
46ISOSPEC_C_API double getModeMassIso(void* iso);
47ISOSPEC_C_API double getTheoreticalAverageMassIso(void* iso);
48ISOSPEC_C_API double getIsoVariance(void* iso);
49ISOSPEC_C_API double getIsoStddev(void* iso);
50ISOSPEC_C_API double* getMarginalLogSizeEstimates(void* iso, double target_total_prob);
51
52
53ISOSPEC_C_API void deleteIso(void* iso);
54
55
56// ______________________________________________________THRESHOLD GENERATOR
57ISOSPEC_C_API void* setupIsoThresholdGenerator(void* iso,
58 double threshold,
59 bool _absolute,
60 int _tabSize,
61 int _hashSize,
62 bool reorder_marginals);
63ISOSPEC_C_API double massIsoThresholdGenerator(void* generator);
64ISOSPEC_C_API double lprobIsoThresholdGenerator(void* generator);
65ISOSPEC_C_API double probIsoThresholdGenerator(void* generator);
66ISOSPEC_C_API void get_conf_signatureIsoThresholdGenerator(void* generator, int* space);
67ISOSPEC_C_API bool advanceToNextConfigurationIsoThresholdGenerator(void* generator);
68ISOSPEC_C_API void deleteIsoThresholdGenerator(void* generator);
69
70
71// ______________________________________________________LAYERED GENERATOR
72ISOSPEC_C_API void* setupIsoLayeredGenerator(void* iso,
73 int _tabSize,
74 int _hashSize,
75 bool reorder_marginals,
76 double t_prob_hint);
77ISOSPEC_C_API double massIsoLayeredGenerator(void* generator);
78ISOSPEC_C_API double lprobIsoLayeredGenerator(void* generator);
79ISOSPEC_C_API double probIsoLayeredGenerator(void* generator);
80ISOSPEC_C_API void get_conf_signatureIsoLayeredGenerator(void* generator, int* space);
81ISOSPEC_C_API bool advanceToNextConfigurationIsoLayeredGenerator(void* generator);
82ISOSPEC_C_API void deleteIsoLayeredGenerator(void* generator);
83
84// ______________________________________________________ORDERED GENERATOR
85ISOSPEC_C_API void* setupIsoOrderedGenerator(void* iso,
86 int _tabSize,
87 int _hashSize);
88ISOSPEC_C_API double massIsoOrderedGenerator(void* generator);
89ISOSPEC_C_API double lprobIsoOrderedGenerator(void* generator);
90ISOSPEC_C_API double probIsoOrderedGenerator(void* generator);
91ISOSPEC_C_API void get_conf_signatureIsoOrderedGenerator(void* generator, int* space);
92ISOSPEC_C_API bool advanceToNextConfigurationIsoOrderedGenerator(void* generator);
93ISOSPEC_C_API void deleteIsoOrderedGenerator(void* generator);
94
95// ______________________________________________________STOCHASTIC GENERATOR
96ISOSPEC_C_API void* setupIsoStochasticGenerator(void* iso,
97 size_t no_molecules,
98 double precision,
99 double beta_bias);
100ISOSPEC_C_API double massIsoStochasticGenerator(void* generator);
101ISOSPEC_C_API double lprobIsoStochasticGenerator(void* generator);
102ISOSPEC_C_API double probIsoStochasticGenerator(void* generator);
103ISOSPEC_C_API void get_conf_signatureIsoStochasticGenerator(void* generator, int* space);
104ISOSPEC_C_API bool advanceToNextConfigurationIsoStochasticGenerator(void* generator);
105ISOSPEC_C_API void deleteIsoStochasticGenerator(void* generator);
106
107ISOSPEC_C_API void* setupThresholdFixedEnvelope(void* iso,
108 double threshold,
109 bool absolute,
110 bool get_confs);
111
112ISOSPEC_C_API void* setupTotalProbFixedEnvelope(void* iso,
113 double taget_coverage,
114 bool optimize,
115 bool get_confs);
116
117ISOSPEC_C_API void* setupStochasticFixedEnvelope(void* iso,
118 size_t no_molecules,
119 double precision,
120 double beta_bias,
121 bool get_confs);
122
123ISOSPEC_C_API void* setupBinnedFixedEnvelope(void* iso,
124 double target_total_prob,
125 double bin_width,
126 double bin_middle);
127
128ISOSPEC_C_API void freeReleasedArray(void* array);
129
130ISOSPEC_C_API void array_add(double* array, size_t N, double what);
131ISOSPEC_C_API void array_mul(double* array, size_t N, double what);
132ISOSPEC_C_API void array_fma(double* array, size_t N, double mul, double add);
133
134ISOSPEC_C_API void* setupFixedEnvelope(double* masses, double* probs, size_t size, bool mass_sorted, bool prob_sorted, double total_prob);
135ISOSPEC_C_API void* copyFixedEnvelope(void* other);
136ISOSPEC_C_API void deleteFixedEnvelope(void* tabulator, bool releaseEverything);
137
138ISOSPEC_C_API const double* massesFixedEnvelope(void* tabulator);
139ISOSPEC_C_API const double* probsFixedEnvelope(void* tabulator);
140ISOSPEC_C_API const int* confsFixedEnvelope(void* tabulator);
141ISOSPEC_C_API size_t confs_noFixedEnvelope(void* tabulator);
142
143ISOSPEC_C_API double empiricAverageMass(void* tabulator);
144ISOSPEC_C_API double empiricVariance(void* tabulator);
145ISOSPEC_C_API double empiricStddev(void* tabulator);
146
147ISOSPEC_C_API double wassersteinDistance(void* tabulator1, void* tabulator2);
148ISOSPEC_C_API double orientedWassersteinDistance(void* tabulator1, void* tabulator2);
149ISOSPEC_C_API double abyssalWassersteinDistance(void* tabulator1, void* tabulator2, double abyss_depth, double other_scale);
150//ISOSPEC_C_API double abyssalWassersteinDistanceGrad(void* const* envelopes, const double* scales, double* ret_gradient, size_t N, double abyss_depth_exp, double abyss_depth_the);
151
153double res1;
154double res2;
155double flow;
156};
157
158ISOSPEC_C_API struct ws_match_res wassersteinMatch(void* tabulator1, void* tabulator2, double flow_dist, double other_scale);
159
160ISOSPEC_C_API void* addEnvelopes(void* tabulator1, void* tabulator2);
161ISOSPEC_C_API void* convolveEnvelopes(void* tabulator1, void* tabulator2);
162
163ISOSPEC_C_API double getTotalProbOfEnvelope(void* envelope);
164ISOSPEC_C_API void scaleEnvelope(void* envelope, double factor);
165ISOSPEC_C_API void normalizeEnvelope(void* envelope);
166ISOSPEC_C_API void shiftMassEnvelope(void* envelope, double d_mass);
167ISOSPEC_C_API void resampleEnvelope(void* envelope, size_t ionic_current, double beta_bias);
168ISOSPEC_C_API void* binnedEnvelope(void* envelope, double width, double middle);
169ISOSPEC_C_API void* linearCombination(void* const * const envelopes, const double* intensities, size_t count);
170
171ISOSPEC_C_API void sortEnvelopeByMass(void* envelope);
172ISOSPEC_C_API void sortEnvelopeByProb(void* envelope);
173
174ISOSPEC_C_API void parse_fasta_c(const char* fasta, int atomCounts[6]);
175
176
177#ifdef __cplusplus
178}
179#endif