24 #include "marginalTrek++.h"
25 #include "isoSpec++.h"
26 #include "fixedEnvelopes.h"
34 void * setupIso(
int dimNumber,
35 const int* isotopeNumbers,
36 const int* atomCounts,
37 const double* isotopeMasses,
38 const double* isotopeProbabilities)
40 Iso* iso =
new Iso(dimNumber, isotopeNumbers, atomCounts, isotopeMasses, isotopeProbabilities);
42 return reinterpret_cast<void*
>(iso);
45 void * isoFromFasta(
const char* fasta,
bool use_nominal_masses,
bool add_water)
49 return reinterpret_cast<void*
>(iso);
52 void deleteIso(
void* iso)
54 delete reinterpret_cast<Iso*
>(iso);
57 double getLightestPeakMassIso(
void* iso)
59 return reinterpret_cast<Iso*
>(iso)->getLightestPeakMass();
62 double getHeaviestPeakMassIso(
void* iso)
64 return reinterpret_cast<Iso*
>(iso)->getHeaviestPeakMass();
67 double getMonoisotopicPeakMassIso(
void* iso)
69 return reinterpret_cast<Iso*
>(iso)->getMonoisotopicPeakMass();
72 double getModeLProbIso(
void* iso)
74 return reinterpret_cast<Iso*
>(iso)->getModeLProb();
77 double getModeMassIso(
void* iso)
79 return reinterpret_cast<Iso*
>(iso)->getModeMass();
82 double getTheoreticalAverageMassIso(
void* iso)
84 return reinterpret_cast<Iso*
>(iso)->getTheoreticalAverageMass();
87 double getIsoVariance(
void* iso)
89 return reinterpret_cast<Iso*
>(iso)->variance();
92 double getIsoStddev(
void* iso)
94 return reinterpret_cast<Iso*
>(iso)->stddev();
98 double* getMarginalLogSizeEstimates(
void* iso,
double target_total_prob)
100 Iso* i =
reinterpret_cast<Iso*
>(iso);
101 double* ret =
reinterpret_cast<double*
>(malloc(
sizeof(
double)*i->
getDimNumber()));
109 #define ISOSPEC_C_FN_CODE(generatorType, dataType, method)\
110 dataType method##generatorType(void* generator){ return reinterpret_cast<generatorType*>(generator)->method(); }
112 #define ISOSPEC_C_FN_CODE_GET_CONF_SIGNATURE(generatorType)\
113 void get_conf_signature##generatorType(void* generator, int* space)\
114 { reinterpret_cast<generatorType*>(generator)->get_conf_signature(space); }
117 #define ISOSPEC_C_FN_DELETE(generatorType) void delete##generatorType(void* generator){ delete reinterpret_cast<generatorType*>(generator); }
119 #define ISOSPEC_C_FN_CODES(generatorType)\
120 ISOSPEC_C_FN_CODE(generatorType, double, mass) \
121 ISOSPEC_C_FN_CODE(generatorType, double, lprob) \
122 ISOSPEC_C_FN_CODE(generatorType, double, prob) \
123 ISOSPEC_C_FN_CODE_GET_CONF_SIGNATURE(generatorType) \
124 ISOSPEC_C_FN_CODE(generatorType, bool, advanceToNextConfiguration) \
125 ISOSPEC_C_FN_DELETE(generatorType)
130 void* setupIsoThresholdGenerator(
void* iso,
135 bool reorder_marginals)
138 std::move(*
reinterpret_cast<Iso*
>(iso)),
145 return reinterpret_cast<void*
>(iso_tmp);
151 void* setupIsoLayeredGenerator(
void* iso,
154 bool reorder_marginals,
159 std::move(*
reinterpret_cast<Iso*
>(iso)),
166 return reinterpret_cast<void*
>(iso_tmp);
172 void* setupIsoOrderedGenerator(
void* iso,
177 std::move(*
reinterpret_cast<Iso*
>(iso)),
181 return reinterpret_cast<void*
>(iso_tmp);
186 void* setupIsoStochasticGenerator(
void* iso,
192 std::move(*
reinterpret_cast<Iso*
>(iso)),
197 return reinterpret_cast<void*
>(iso_tmp);
203 void* setupThresholdFixedEnvelope(
void* iso,
209 FixedEnvelope::FromThreshold(
Iso(*
reinterpret_cast<const Iso*
>(iso),
true),
214 return reinterpret_cast<void*
>(ret);
217 void* setupTotalProbFixedEnvelope(
void* iso,
218 double target_coverage,
223 FixedEnvelope::FromTotalProb(
Iso(*
reinterpret_cast<const Iso*
>(iso),
true),
228 return reinterpret_cast<void*
>(ret);
231 void* setupStochasticFixedEnvelope(
void* iso,
238 FixedEnvelope::FromStochastic(
Iso(*
reinterpret_cast<const Iso*
>(iso),
true),
244 return reinterpret_cast<void*
>(ret);
248 void* setupBinnedFixedEnvelope(
void* iso,
249 double target_total_prob,
254 FixedEnvelope::Binned(
Iso(*
reinterpret_cast<const Iso*
>(iso),
true),
259 return reinterpret_cast<void*
>(ret);
262 void* setupFixedEnvelope(
double* masses,
double* probs,
size_t size,
bool mass_sorted,
bool prob_sorted,
double total_prob)
265 return reinterpret_cast<void*
>(ret);
268 void deleteFixedEnvelope(
void* t,
bool release_everything)
271 if(release_everything)
273 tt->release_masses();
280 const double* massesFixedEnvelope(
void* tabulator)
282 return reinterpret_cast<FixedEnvelope*
>(tabulator)->release_masses();
285 const double* probsFixedEnvelope(
void* tabulator)
287 return reinterpret_cast<FixedEnvelope*
>(tabulator)->release_probs();
290 const int* confsFixedEnvelope(
void* tabulator)
292 return reinterpret_cast<FixedEnvelope*
>(tabulator)->release_confs();
295 size_t confs_noFixedEnvelope(
void* tabulator)
297 return reinterpret_cast<FixedEnvelope*
>(tabulator)->confs_no();
300 double empiricAverageMass(
void* tabulator)
302 return reinterpret_cast<FixedEnvelope*
>(tabulator)->empiric_average_mass();
305 double empiricVariance(
void* tabulator)
307 return reinterpret_cast<FixedEnvelope*
>(tabulator)->empiric_variance();
310 double empiricStddev(
void* tabulator)
312 return reinterpret_cast<FixedEnvelope*
>(tabulator)->empiric_stddev();
315 double wassersteinDistance(
void* tabulator1,
void* tabulator2)
321 catch(std::logic_error&)
327 double orientedWassersteinDistance(
void* tabulator1,
void* tabulator2)
331 return reinterpret_cast<FixedEnvelope*
>(tabulator1)->OrientedWassersteinDistance(*
reinterpret_cast<FixedEnvelope*
>(tabulator2));
333 catch(std::logic_error&)
340 void* addEnvelopes(
void* tabulator1,
void* tabulator2)
346 void* convolveEnvelopes(
void* tabulator1,
void* tabulator2)
352 double getTotalProbOfEnvelope(
void* envelope)
354 return reinterpret_cast<FixedEnvelope*
>(envelope)->get_total_prob();
357 void scaleEnvelope(
void* envelope,
double factor)
362 void normalizeEnvelope(
void* envelope)
367 void* binnedEnvelope(
void* envelope,
double width,
double middle)
373 void* linearCombination(
void*
const *
const envelopes,
const double* intensities,
size_t count)
376 return reinterpret_cast<void*
>(
new FixedEnvelope(FixedEnvelope::LinearCombination(
reinterpret_cast<const FixedEnvelope*
const *
>(envelopes), intensities, count)));
379 void sortEnvelopeByMass(
void* envelope)
384 void sortEnvelopeByProb(
void* envelope)
389 void freeReleasedArray(
void* array)
394 void parse_fasta_c(
const char* fasta,
int atomCounts[6])
397 parse_fasta(fasta, atomCounts);