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* setupFixedEnvelope(
double* masses,
double* probs,
size_t size,
bool mass_sorted,
bool prob_sorted,
double total_prob)
234 return reinterpret_cast<void*
>(ret);
237 void deleteFixedEnvelope(
void* t,
bool release_everything)
240 if(release_everything)
242 tt->release_masses();
249 const double* massesFixedEnvelope(
void* tabulator)
251 return reinterpret_cast<FixedEnvelope*
>(tabulator)->release_masses();
254 const double* probsFixedEnvelope(
void* tabulator)
256 return reinterpret_cast<FixedEnvelope*
>(tabulator)->release_probs();
259 const int* confsFixedEnvelope(
void* tabulator)
261 return reinterpret_cast<FixedEnvelope*
>(tabulator)->release_confs();
264 int confs_noFixedEnvelope(
void* tabulator)
266 return reinterpret_cast<FixedEnvelope*
>(tabulator)->confs_no();
269 double empiricAverageMass(
void* tabulator)
271 return reinterpret_cast<FixedEnvelope*
>(tabulator)->empiric_average_mass();
274 double empiricVariance(
void* tabulator)
276 return reinterpret_cast<FixedEnvelope*
>(tabulator)->empiric_variance();
279 double empiricStddev(
void* tabulator)
281 return reinterpret_cast<FixedEnvelope*
>(tabulator)->empiric_stddev();
284 double wassersteinDistance(
void* tabulator1,
void* tabulator2)
290 catch(std::logic_error&)
296 double orientedWassersteinDistance(
void* tabulator1,
void* tabulator2)
300 return reinterpret_cast<FixedEnvelope*
>(tabulator1)->OrientedWassersteinDistance(*
reinterpret_cast<FixedEnvelope*
>(tabulator2));
302 catch(std::logic_error&)
309 void* addEnvelopes(
void* tabulator1,
void* tabulator2)
315 void* convolveEnvelopes(
void* tabulator1,
void* tabulator2)
321 double getTotalProbOfEnvelope(
void* envelope)
323 return reinterpret_cast<FixedEnvelope*
>(envelope)->get_total_prob();
326 void scaleEnvelope(
void* envelope,
double factor)
331 void normalizeEnvelope(
void* envelope)
336 void* binnedEnvelope(
void* envelope,
double width,
double middle)
342 void* linearCombination(
void*
const *
const envelopes,
const double* intensities,
size_t count)
345 return reinterpret_cast<void*
>(
new FixedEnvelope(FixedEnvelope::LinearCombination(
reinterpret_cast<const FixedEnvelope*
const *
>(envelopes), intensities, count)));
348 void sortEnvelopeByMass(
void* envelope)
353 void sortEnvelopeByProb(
void* envelope)
358 void freeReleasedArray(
void* array)
363 void parse_fasta_c(
const char* fasta,
int atomCounts[6])
366 parse_fasta(fasta, atomCounts);