21 Sonde::Sonde(
const char* bezeichner,
int num_probes,
int allowed_mis,
double outside_mis) {
32 Allowed_Mismatch =
new long[num_probes];
33 Outside_Mismatch =
new double[num_probes];
34 for (
int i=0; i<num_probes; i++) {
35 Allowed_Mismatch[i]=0;
36 Outside_Mismatch[i]=0;
39 Allowed_Mismatch[0] = allowed_mis;
40 Outside_Mismatch[0] = outside_mis;
50 for (i=0; i<length_hitliste; i++) {
55 delete [] Allowed_Mismatch;
56 delete [] Outside_Mismatch;
61 printf(
"\nSonde %s\n------------------------------------------------\n", kennung);
63 printf(
"Laenge hitliste %ld mit minelem %ld und maxelem %ld\n", length_hitliste, minelem, maxelem);
64 printf(
"Far %ld, Mor %ld, AllMM %ld, OutMM %f\n\n", kombi_far, kombi_mor, *Allowed_Mismatch, *Outside_Mismatch);
75 char *match_name, *match_mismatches, *match_wmismatches;
76 T_PT_MATCHLIST match_list;
77 long match_list_cnt = -1;
84 mp_pd_gl.
locs.clear();
86 if (!error && !mp_pd_gl.
link) {
87 error =
"Cannot contact Probe bank server";
91 error =
"Cannot contact Probe bank server (2)";
96 LOCS_MATCH_ALSO_REVCOMP, (
long)match_also_revcompl,
97 LOCS_COMPLEMENT_FIRST, (
long)0,
98 LOCS_MATCH_SORT_BY, (
long)match_weight,
99 LOCS_MATCH_MAX_MISMATCHES, (
long)match_mis,
100 LOCS_SEARCHMATCH, match_seq,
103 error =
"Connection to PT_SERVER lost (4)";
108 char *locs_error =
NULp;
111 LOCS_MATCH_LIST, match_list.as_result_param(),
112 LOCS_MATCH_LIST_CNT, &match_list_cnt,
113 LOCS_MP_MATCH_STRING, &bs,
114 LOCS_ERROR, &locs_error,
130 match_name = strtok(bs.
data, toksep);
131 match_mismatches = strtok(
NULp, toksep);
132 match_wmismatches = strtok(
NULp, toksep);
136 while (match_name && match_mismatches && match_wmismatches) {
140 ret_list[i]->
mismatch = atof(match_mismatches);
142 ret_list[i]->
mismatch = atof(match_wmismatches);
145 match_name = strtok(
NULp, toksep);
146 match_mismatches = strtok(
NULp, toksep);
147 match_wmismatches = strtok(
NULp, toksep);
153 error =
"No matching species found.";
156 *number_of_species = match_list_cnt;
171 while ((i<laenge) && (probebacts[k]->nummer == probebacts[i]->nummer)) {
172 if (min > probebacts[i]->mismatch) {
190 double mm_to_search = 0;
191 int mm_int_to_search = 0;
196 if (mm_to_search > (
int) mm_to_search)
197 mm_int_to_search = (
int) mm_to_search + 1;
199 mm_int_to_search = (
int) mm_to_search;
212 if (!laenge || !probebacts) {
215 if (!laenge)
aw_message(
"This probe matches no species!");
235 for (k=0; k < laenge-1; k++) {
236 if (probebacts[k]->nummer == probebacts[k+1]->nummer) {
239 while ((k<laenge-1) && (probebacts[k]->nummer == probebacts[k+1]->nummer)) {
247 minelem = probebacts[0]->
nummer;
248 maxelem = probebacts[laenge-1]->
nummer;
251 hitliste =
new Hit*[laenge+1];
252 for (i=0; i<laenge+1; i++)
255 for (i=0; i<laenge; i++) {
256 hitliste[i] =
new Hit(probebacts[i]->nummer);
259 length_hitliste = laenge;
265 while (bl_elem[bl_index]) {
270 for (i=0; i<laenge; i++) {
271 delete probebacts[i];
273 delete [] probebacts;
281 if (hitliste && (index < length_hitliste))
282 return hitliste[index];
295 for (i=(feldlaenge-1)/2; i>-1; i--) {
296 sink(i, feldlaenge-1, Nr_Mm_Feld);
298 for (m=feldlaenge-1; m>0; m--) {
299 tmpmm = Nr_Mm_Feld[0];
300 Nr_Mm_Feld[0] = Nr_Mm_Feld[m];
301 Nr_Mm_Feld[m] = tmpmm;
303 sink(0, m-1, Nr_Mm_Feld);
315 if (A[i]->nummer >= A[j]->nummer) j = i;
316 if (k <= t && A[k]->nummer > A[j]->nummer) j = k;
319 tmpmm = A[i]; A[i] = A[j]; A[j] = tmpmm;
376 static char *create_list(
const MO_Liste& list) {
379 for (
int c = 0; c<=count+1; c++) {
382 buf.cat(name ? name :
"(null)");
384 return buf.release();
389 for (
int c = 0; c<count; c++) {
393 buf.nprintf(30,
"%s/%3.1f", name, mm->
mismatch);
395 return buf.release();
398 void TEST_get_matching_species() {
408 Sonde s(
"some-probe", 5, 3, 20);
416 for (
int pass = 0; pass<=1; ++pass) {
422 TEST_EXPECT_EQUAL_STRINGCOPY__NOERROREXPORTED(create_list(*Bakterienliste),
423 "(null),BcSSSS00,Bl0LLL00,ClnCorin,CltBotul,CPPParap,ClfPerfr,DlcTolu2,PbcAcet2,PbrPropi,Stsssola,DsssDesu,LgtLytic,DcdNodos,FrhhPhil,PsAAAA00,PslFlave,HllHalod,VbrFurni,VblVulni,VbhChole,AclPleur,PtVVVulg,(null)");
425 if (pass == 0) {
delete Bakterienliste; Bakterienliste =
new MO_Liste; }
428 for (
int pass = 0; pass<=1; ++pass) {
430 double mm_to_search = 0.0 + 1.0 + 0;
431 int mm_int_to_search =
int(mm_to_search-0.000001)+1;
433 MO_Mismatch** probebacts =
s.get_matching_species(TEST_SERVER_ID,
446 TEST_EXPECT_EQUAL_STRINGCOPY__NOERROREXPORTED(create_list(probebacts, laenge, *Bakterienliste),
447 "BcSSSS00/0.2,ClfPerfr/1.0,LgtLytic/1.0,FrhhPhil/1.0,ClfPerfr/1.1,VbrFurni/1.1,VblVulni/1.1,Bl0LLL00/1.1,AclPleur/1.2,VbrFurni/1.5,VblVulni/1.5");
450 for (
int i=0; i<laenge; i++) {
451 delete probebacts[i];
453 delete [] probebacts;
456 delete Bakterienliste;
Hit * get_hitdata_by_number(long index)
GBDATA * GB_open(const char *path, const char *opent)
void set_bitkennung(Bitvector *bv)
static void set_gb_main(GBDATA *gb_main_)
int aisc_close(aisc_com *link, AISC_Object &object)
#define TEST_SETUP_GLOBAL_ENVIRONMENT(modulename)
char * ARB_strdup(const char *str)
void convert(const FormattedFile &in, const FormattedFile &out)
void heapsort(long feldlaenge, MO_Mismatch **Nr_Mm_Feld)
int aisc_put(aisc_com *link, int o_type, const AISC_Object &object,...)
void sink(long i, long t, MO_Mismatch **A)
MO_Mismatch ** get_matching_species(int ptserver_id, bool match_also_revcompl, int match_weight, int match_mis, const char *match_seq, MO_Liste *convert, long *number_of_species, GB_ERROR &error)
GB_ERROR get_all_species(int ptserver_id)
void set_mismatch_at_pos(int pos, double mm)
double get_Allowed_Mismatch_no(int no)
#define TEST_REJECT_NULL(n)
int MP_init_local_com_struct(struct mp_gl_struct &mp_pd_gl)
static void error(const char *msg)
long get_index_by_entry(const char *key)
const char * get_entry_by_index(long index) const
int gen_Hitliste(MO_Liste *Bakterienliste)
const char * arb_look_and_start_ptserver(int magic_number, int ptserver_id, GB_ERROR &error)
float outside_mismatches_difference
double check_for_min(long k, MO_Mismatch **probebacts, long laenge)
#define AISC_MAGIC_NUMBER
aisc_com * aisc_open(const char *path, AISC_Object &main_obj, long magic, GB_ERROR *error)
Bakt_Info ** get_mo_liste()
const char * GBS_static_string(const char *str)
#define TEST_EXPECT_NO_ERROR(call)
void aw_message(const char *msg)
int aisc_get(aisc_com *link, int o_type, const AISC_Object &object,...)
Sonde(const char *bezeichner, int num_probes, int allowed_mis, double outside_mis)
#define TEST_EXPECT_EQUAL(expr, want)
void GB_close(GBDATA *gbd)
GB_write_int const char s