Changeset 8041 for trunk

Show
Ignore:
Timestamp:
07/10/11 14:39:27 (8 months ago)
Author:
westram
Message:

merge from dev [7990] [7991] [7992] [7993] [7994] [7995] [7996] [7998] [8001] [8003] [8005] [8006] [8007] [8008] [8009] [8011] [8012] [8019]

  • added a faked ecoli to ptserver test-db
  • added unit-tests for gene-ptserver
  • rename ptserver testdb
  • ptserver db-cleanup
    • size of mapfile for SSUREF108 is reduced by 85% (3,4Gb -> 519Mb)
  • ptserver
    • refactored
      • prefix tree builders
      • probe_input_data
    • removed ptnd_new_match (dead code)
Location:
trunk
Files:
3 removed
38 modified
7 copied

Legend:

Unmodified
Added
Removed
  • trunk/ARBDB/ad_prot.h

    r8040 r8041  
    184184#ifdef UNIT_TESTS 
    185185#define TEST_SERVER_ID (-666) 
     186#define TEST_GENESERVER_ID (-667) 
    186187#endif 
    187188 
     
    393394GB_ERROR GB_set_undo_mem(GBDATA *gbd, long memsize); 
    394395 
     396/* admap.cxx */ 
     397bool GB_supports_mapfile(void); 
     398 
    395399/* adquery.cxx */ 
    396400const char *GB_get_GBDATA_path(GBDATA *gbd); 
  • trunk/ARBDB/ad_save_load.cxx

    r8037 r8041  
    12971297 
    12981298// #define TEST_AUTO_UPDATE // uncomment to auto-update binary and quicksave testfiles (needed once after changing ascii testfile or modify_db()) 
    1299 #define TEST_copy(src, dst) TEST_ASSERT(system(GBS_global_string("cp '%s' '%s'", src, dst)) == 0) 
    13001299 
    13011300#define TEST_loadsave_CLEANUP() TEST_ASSERT(system("rm -f [ab]2[ab]*.* master.* slave.* renamed.* fast.* fast2b.* TEST_loadsave.ARF") == 0) 
     
    13731372 
    13741373#if defined(TEST_AUTO_UPDATE) 
    1375         TEST_copy("a2b.a00", "TEST_loadsave_quick.a00"); 
     1374        TEST_COPY_FILE("a2b.a00", "TEST_loadsave_quick.a00"); 
    13761375#endif // TEST_AUTO_UPDATE 
    13771376 
  • trunk/ARBDB/admap.cxx

    r7667 r8041  
    674674} 
    675675 
     676bool GB_supports_mapfile() { 
     677#if (MEMORY_TEST == 1) 
     678    return false; 
     679#else 
     680    return true; 
     681#endif 
     682} 
     683 
    676684int gb_is_valid_mapfile(const char *path, gb_map_header *mheader, int verbose) { 
    677685    /* Test whether mapfile is valid 
  • trunk/ARBDB/adsocket.cxx

    r8036 r8041  
    11941194    GB_ULONG usedmemsize = (MIN(net_memsize, max_malloc)*95)/100; // arb uses max. 95 % of available memory (was 70% in the past) 
    11951195 
    1196 #if defined(DEBUG) 
     1196#if defined(DEBUG) && 0 
    11971197    printf("- memsize(real)        = %20lu k\n", memsize); 
    11981198    printf("- memsize(net)         = %20lu k\n", net_memsize); 
    11991199    printf("- memsize(max_malloc)  = %20lu k\n", max_malloc); 
     1200    printf("- memsize(used by ARB) = %20lu k\n", usedmemsize); 
    12001201#endif // DEBUG 
    1201     printf("- memsize(used by ARB) = %20lu k\n", usedmemsize); 
    12021202 
    12031203    arb_assert(usedmemsize != 0); 
  • trunk/ARBDB/adtcp.cxx

    r8036 r8041  
    304304// AISC_MKPT_PROMOTE:#ifdef UNIT_TESTS 
    305305// AISC_MKPT_PROMOTE:#define TEST_SERVER_ID (-666) 
     306// AISC_MKPT_PROMOTE:#define TEST_GENESERVER_ID (-667) 
    306307// AISC_MKPT_PROMOTE:#endif 
    307308 
     
    317318const char *GBS_ptserver_tag(int id) { 
    318319#ifdef UNIT_TESTS 
    319     if (id == TEST_SERVER_ID) { 
    320         return "ARB_TEST_PT_SERVER"; 
    321     } 
     320    if (id == TEST_SERVER_ID) return "ARB_TEST_PT_SERVER"; 
     321    if (id == TEST_GENESERVER_ID) return "ARB_TEST_PT_SERVER_GENE"; 
    322322#endif // UNIT_TESTS 
    323323    gb_assert(id >= 0); 
  • trunk/ARBDB/gb_memory.h

    r7201 r8041  
    2727#if defined(UNIT_TESTS) 
    2828#undef MEMORY_TEST 
    29 #define MEMORY_TEST 0 // test mmapped-DB version in unittests 
     29#define MEMORY_TEST 0 // test mmapped-DB version in unittests (recommended setting) 
    3030// #define MEMORY_TEST 1 // test DEBUG DB version in unittests 
    3131#endif 
  • trunk/Makefile

    r8039 r8041  
    10391039                SERVERCNTRL/SERVERCNTRL.a \ 
    10401040                SL/HELIX/HELIX.a \ 
     1041                SL/PTCLEAN/PTCLEAN.a \ 
    10411042 
    10421043ARCHS_PROBE_LINK = \ 
     
    18431844        PHYLO/PHYLO.test \ 
    18441845        PRIMER_DESIGN/PRIMER_DESIGN.test \ 
    1845         PROBE/PROBE.test \ 
    18461846        PROBE_DESIGN/PROBE_DESIGN.test \ 
    18471847        ptpan/PROBE.test \ 
     
    19111911        CONVERTALN/CONVERTALN.test \ 
    19121912        SL/SEQIO/SEQIO.test \ 
     1913        SL/PTCLEAN/PTCLEAN.test \ 
     1914        PROBE/PROBE.test \ 
    19131915 
    19141916TESTED_UNITS_MANUAL = \ 
  • trunk/PROBE/Makefile

    r7937 r8041  
    2727 
    2828proto: 
    29         ../AISC_MKPTPS/aisc_mkpt -G -E -z -A -w pt_prototypes.h $(OBJECTS:.o=.cxx) probe_tree.h >pt_prototypes.h.tmp 
     29        ../AISC_MKPTPS/aisc_mkpt -P -G -E -z -A -w pt_prototypes.h $(OBJECTS:.o=.cxx) probe_tree.h >pt_prototypes.h.tmp 
    3030        ../SOURCE_TOOLS/mv_if_diff pt_prototypes.h.tmp pt_prototypes.h 
    3131 
     
    5757PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_assert.h 
    5858PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_core.h 
     59PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_defs.h 
    5960PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_error.h 
    6061PT_buildtree.o: $(ARBHOME)/INCLUDE/arb_msg.h 
     
    7374PT_buildtree.o: $(ARBHOME)/INCLUDE/static_assert.h 
    7475PT_buildtree.o: $(ARBHOME)/INCLUDE/test_global.h 
     76PT_buildtree.o: $(ARBHOME)/INCLUDE/test_unit.h 
    7577 
    7678PT_debug.o: probe.h 
     
    202204PT_main.o: $(ARBHOME)/INCLUDE/arb_assert.h 
    203205PT_main.o: $(ARBHOME)/INCLUDE/arb_core.h 
     206PT_main.o: $(ARBHOME)/INCLUDE/arb_defs.h 
    204207PT_main.o: $(ARBHOME)/INCLUDE/arb_error.h 
    205208PT_main.o: $(ARBHOME)/INCLUDE/arb_msg.h 
     
    218221PT_main.o: $(ARBHOME)/INCLUDE/PT_server.h 
    219222PT_main.o: $(ARBHOME)/INCLUDE/PT_server_prototypes.h 
     223PT_main.o: $(ARBHOME)/INCLUDE/ptclean.h 
    220224PT_main.o: $(ARBHOME)/INCLUDE/server.h 
    221225PT_main.o: $(ARBHOME)/INCLUDE/servercntrl.h 
  • trunk/PROBE/PT_buildtree.cxx

    r7937 r8041  
    1313#include "probe_tree.h" 
    1414#include "pt_prototypes.h" 
     15#include "arb_defs.h" 
    1516 
    1617#include <arb_progress.h> 
     
    1819#include <unistd.h> 
    1920 
    20 POS_TREE *build_pos_tree (POS_TREE *pt, int anfangs_pos, int apos, int RNS_nr, unsigned int end) 
    21 { 
    22     static POS_TREE       *pthelp, *pt_next; 
    23     unsigned int i, j; 
    24     int          height = 0, anfangs_apos_ref, anfangs_rpos_ref, RNS_nr_ref; 
    25     pthelp = pt; 
    26     i = anfangs_pos; 
    27     while (PT_read_type(pthelp) == PT_NT_NODE) {    // now we got an inner node 
    28         if ((pt_next = PT_read_son_stage_1(psg.ptmain, pthelp, (PT_BASES)psg.data[RNS_nr].data[i])) == NULL) { 
    29                             // there is no son of that type -> simply add the new son to that path // 
    30             if (pthelp == pt) { // now we create a new root structure (size will change) 
    31                 PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_pos, apos, RNS_nr); 
    32                 return pthelp;  // return the new root 
    33             } 
    34             else { 
    35                 PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_pos, apos, RNS_nr); 
    36                 return pt;  // return the old root 
    37             } 
     21// AISC_MKPT_PROMOTE: class DataLoc; 
     22 
     23static POS_TREE *build_pos_tree(POS_TREE *const root, const DataLoc& loc) { 
     24    POS_TREE *at = root; 
     25    int       height = 0; 
     26 
     27    while (PT_read_type(at) == PT_NT_NODE) {    // now we got an inner node 
     28        POS_TREE *pt_next = PT_read_son_stage_1(at, loc[height]); 
     29        if (!pt_next) { // there is no son of that type -> simply add the new son to that path // 
     30            bool atRoot = (at == root); 
     31            PT_create_leaf(&at, loc[height], loc); 
     32            return atRoot ? at : root; // inside tree return old root, otherwise new root has been created 
    3833        } 
    3934        else {            // go down the tree 
    40             pthelp = pt_next; 
     35            at = pt_next; 
    4136            height++; 
    42             i++; 
    43             if (i >= end) {     // end of sequence reached -> change node to chain and add 
    44                         // should never be reached, because of the terminal symbol 
    45                         // of each sequence 
    46                 if (PT_read_type(pthelp) == PT_NT_CHAIN) 
    47                     pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 
     37 
     38            if (loc.is_shorther_than(height)) { 
     39                // end of sequence reached -> change node to chain and add 
     40                // should never be reached, because of the terminal symbol of each sequence (@@@ this IS reached - even with unittestdb) 
     41                if (PT_read_type(at) == PT_NT_CHAIN) { 
     42                    PT_add_to_chain(at, loc); 
     43                } 
    4844                // if type == node then forget it 
    49                 return pt; 
    50             } 
    51         } 
    52     } 
    53             // type == leaf or chain 
    54     if (PT_read_type(pthelp) == PT_NT_CHAIN) {      // old chain reached 
    55         pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 
    56         return pt; 
    57     } 
    58     anfangs_rpos_ref = PT_read_rpos(psg.ptmain, pthelp); // change leave to node and create two sons 
    59     anfangs_apos_ref = PT_read_apos(psg.ptmain, pthelp); 
    60     RNS_nr_ref = PT_read_name(psg.ptmain, pthelp); 
    61     j = anfangs_rpos_ref + height; 
    62  
    63     while (psg.data[RNS_nr].data[i] == psg.data[RNS_nr_ref].data[j]) {  // creates nodes until sequences are different 
    64                                         // type != nt_node 
    65         if (PT_read_type(pthelp) == PT_NT_CHAIN) {          // break 
    66             pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 
    67             return pt; 
     45                return root; 
     46            } 
     47        } 
     48    } 
     49 
     50    // type == leaf or chain 
     51    if (PT_read_type(at) == PT_NT_CHAIN) {      // old chain reached 
     52        PT_add_to_chain(at, loc); 
     53        return root; 
     54    } 
     55 
     56    // change leave to node and create two sons 
     57 
     58    const DataLoc loc_ref(at); 
     59 
     60    while (loc[height] == loc_ref[height]) {  // creates nodes until sequences are different 
     61        // type != nt_node 
     62        if (PT_read_type(at) == PT_NT_CHAIN) {  
     63            PT_add_to_chain(at, loc); 
     64            return root; 
    6865        } 
    6966        if (height >= PT_POS_TREE_HEIGHT) { 
    70             if (PT_read_type(pthelp) == PT_NT_LEAF) { 
    71                 pthelp = PT_leaf_to_chain(psg.ptmain, pthelp); 
    72             } 
    73             pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 
    74             return pt; 
    75         } 
    76         if (((i + 1) >= end) && (j + 1 >= (unsigned)(psg.data[RNS_nr_ref].size))) { // end of both sequences 
    77             return pt; 
    78         } 
    79         pthelp = PT_change_leaf_to_node(psg.ptmain, pthelp); // change tip to node and append two new leafs 
    80         if (i + 1 >= end) {                 // end of source sequence reached 
    81             pthelp = PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr_ref].data[j], 
    82                     anfangs_rpos_ref, anfangs_apos_ref, RNS_nr_ref); 
    83             return pt; 
    84         } 
    85         if (j + 1 >= (unsigned)(psg.data[RNS_nr_ref].size)) {       // end of reference sequence 
    86             pthelp = PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_pos, apos, RNS_nr); 
    87             return pt; 
    88         } 
    89         pthelp = PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_rpos_ref, anfangs_apos_ref, RNS_nr_ref); 
    90                     // dummy leaf just to create a new node; may become a chain 
    91         i++; 
    92         j++; 
     67            if (PT_read_type(at) == PT_NT_LEAF) { 
     68                at = PT_leaf_to_chain(at); 
     69            } 
     70            PT_add_to_chain(at, loc); 
     71            return root; 
     72        } 
     73 
     74        bool loc_done = loc.is_shorther_than(height+1); 
     75        bool ref_done = loc_ref.is_shorther_than(height+1); 
     76 
     77        if (ref_done && loc_done) return root; // end of both sequences 
     78 
     79        at = PT_change_leaf_to_node(at); // change tip to node and append two new leafs 
     80        if (loc_done) { // end of source sequence reached 
     81            PT_create_leaf(&at, loc_ref[height], loc_ref); 
     82            return root; 
     83        } 
     84        if (ref_done) { // end of reference sequence 
     85            PT_create_leaf(&at, loc[height], loc); 
     86            return root; 
     87        } 
     88        at = PT_create_leaf(&at, loc[height], loc_ref); // dummy leaf just to create a new node; may become a chain 
    9389        height++; 
    9490    } 
     91 
     92     
     93     
    9594    if (height >= PT_POS_TREE_HEIGHT) { 
    96         if (PT_read_type(pthelp) == PT_NT_LEAF) 
    97             pthelp = PT_leaf_to_chain(psg.ptmain, pthelp); 
    98         pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 
    99         return pt; 
    100     } 
    101     if (PT_read_type(pthelp) == PT_NT_CHAIN) { 
    102         pthelp = PT_add_to_chain(psg.ptmain, pthelp, RNS_nr, apos, anfangs_pos); 
     95        if (PT_read_type(at) == PT_NT_LEAF) at = PT_leaf_to_chain(at); 
     96        PT_add_to_chain(at, loc); 
     97        return root; 
     98    } 
     99    if (PT_read_type(at) == PT_NT_CHAIN) { 
     100        // not covered by test - but looks similar to case in top-loop 
     101        PT_add_to_chain(at, loc); 
    103102    } 
    104103    else { 
    105         pthelp = PT_change_leaf_to_node(psg.ptmain, pthelp); // Blatt loeschen 
    106         PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr].data[i], anfangs_pos, apos, RNS_nr); // zwei neue Blaetter 
    107         PT_create_leaf(psg.ptmain, &pthelp, (PT_BASES)psg.data[RNS_nr_ref].data[j], anfangs_rpos_ref, anfangs_apos_ref, RNS_nr_ref); 
    108     } 
    109     return pt; 
    110 } 
     104        at = PT_change_leaf_to_node(at);             // delete leaf 
     105        PT_create_leaf(&at, loc[height], loc); // two new leafs 
     106        PT_create_leaf(&at, loc_ref[height], loc_ref); 
     107    } 
     108    return root; 
     109} 
     110 
    111111 
    112112inline void get_abs_align_pos(char *seq, int &pos) 
     
    147147} 
    148148 
    149 long PTD_save_partial_tree(FILE *out, PTM2 *ptmain, POS_TREE * node, char *partstring, int partsize, long pos, long *ppos, ARB_ERROR& error) { 
     149long PTD_save_partial_tree(FILE *out, POS_TREE * node, char *partstring, int partsize, long pos, long *ppos, ARB_ERROR& error) { 
    150150    if (partsize) { 
    151         POS_TREE *son = PT_read_son(ptmain, node, (PT_BASES)partstring[0]); 
     151        POS_TREE *son = PT_read_son(node, (PT_BASES)partstring[0]); 
    152152        if (son) { 
    153             pos = PTD_save_partial_tree(out, ptmain, son, partstring+1, partsize-1, pos, ppos, error); 
     153            pos = PTD_save_partial_tree(out, son, partstring+1, partsize-1, pos, ppos, error); 
    154154        } 
    155155    } 
    156156    else { 
    157         PTD_clear_fathers(ptmain, node); 
     157        PTD_clear_fathers(node); 
    158158        long r_pos; 
    159159        int blocked; 
     
    165165            fflush(stdout); 
    166166#endif 
    167             r_pos = PTD_write_leafs_to_disk(out, ptmain, node, pos, ppos, &blocked, error); 
     167            r_pos = PTD_write_leafs_to_disk(out, node, pos, ppos, &blocked, error); 
    168168            if (r_pos > pos) pos = r_pos; 
    169169        } 
     
    221221            psg.ptmain->stage1 = 1;             // enter stage 1 
    222222 
    223             pt = PT_create_leaf(psg.ptmain, NULL, PT_N, 0, 0, 0);  // create main node 
    224             pt = PT_change_leaf_to_node(psg.ptmain, pt); 
     223            pt = PT_create_leaf(NULL, PT_N, DataLoc(0, 0, 0));  // create main node 
     224            pt = PT_change_leaf_to_node(pt); 
    225225            psg.stat.cut_offs = 0;                  // statistic information 
    226226            GB_begin_transaction(psg.gb_main); 
     
    267267 
    268268                    int abs_align_pos = psize-1; 
    269                     for (int j = psg.data[i].size - 1; j >= 0; j--, abs_align_pos--) { 
     269                    for (int j = psg.data[i].get_size() - 1; j >= 0; j--, abs_align_pos--) { 
    270270                        get_abs_align_pos(align_abs, abs_align_pos); // may result in neg. abs_align_pos (seems to happen if sequences are short < 214bp ) 
    271271                        if (abs_align_pos < 0) break; // -> in this case abort 
    272272 
    273                         if (partsize && (*partstring != psg.data[i].data[j] || strncmp(partstring, psg.data[i].data+j, partsize))) continue; 
    274                         if (ptd_string_shorter_than(psg.data[i].data+j, 9)) continue; 
    275  
    276                         pt = build_pos_tree(pt, j, abs_align_pos, i, psg.data[i].size); 
     273                        if (partsize && (*partstring != psg.data[i].get_data()[j] || strncmp(partstring, psg.data[i].get_data()+j, partsize))) continue; 
     274                        if (ptd_string_shorter_than(psg.data[i].get_data()+j, 9)) continue; 
     275 
     276                        pt = build_pos_tree(pt, DataLoc(i, abs_align_pos, j)); 
    277277                    } 
    278278                    free(align_abs); 
     
    280280                    ++data_progress; 
    281281                } 
    282                 pos = PTD_save_partial_tree(out, psg.ptmain, pt, partstring, partsize, pos, &last_obj, error); 
     282                pos = PTD_save_partial_tree(out, pt, partstring, partsize, pos, &last_obj, error); 
    283283                if (error) break; 
    284284 
     
    292292            if (!error) { 
    293293                if (partsize) { 
    294                     pos = PTD_save_partial_tree(out, psg.ptmain, pt, NULL, 0, pos, &last_obj, error); 
     294                    pos = PTD_save_partial_tree(out, pt, NULL, 0, pos, &last_obj, error); 
    295295#ifdef PTM_DEBUG 
    296296                    PTM_debug_mem(); 
     
    377377        } 
    378378        else { 
    379             error = PTD_read_leafs_from_disk(tname, psg.ptmain, &psg.pt); 
     379            error = PTD_read_leafs_from_disk(tname, &psg.pt); 
    380380            fclose(in); 
    381381        } 
     
    385385} 
    386386 
     387// -------------------------------------------------------------------------------- 
     388 
     389#ifdef UNIT_TESTS 
     390#ifndef TEST_UNIT_H 
     391#include <test_unit.h> 
     392#endif 
     393 
     394int main(int argc, const char*argv[]); 
     395void NOTEST_SLOW_maybe_build_tree() { 
     396    // does only test sth if DB is present. 
     397 
     398    const char *dbarg      = "-D" "extra_pt_src.arb"; 
     399    const char *testDB     = dbarg+2; 
     400    const char *resultPT   = "extra_pt_src.arb.pt"; 
     401    const char *expectedPT = "extra_pt_src.arb_expected.pt"; 
     402    bool        exists     = GB_is_regularfile(testDB); 
     403 
     404    if (exists) { 
     405        const char *argv[] = { 
     406            "fake_pt_server", 
     407            "-build", 
     408            dbarg, 
     409        }; 
     410 
     411#if 1 
     412        // build 
     413        int res = main(ARRAY_ELEMS(argv), argv); 
     414        TEST_ASSERT_EQUAL(res, EXIT_SUCCESS); 
     415#endif 
     416 
     417// #define TEST_AUTO_UPDATE 
     418#if defined(TEST_AUTO_UPDATE) 
     419        TEST_COPY_FILE(resultPT, expectedPT); 
     420#else // !defined(TEST_AUTO_UPDATE) 
     421        TEST_ASSERT_FILES_EQUAL(resultPT, expectedPT); 
     422#endif 
     423    } 
     424} 
     425 
     426#endif // UNIT_TESTS 
     427 
     428// -------------------------------------------------------------------------------- 
  • trunk/PROBE/PT_debug.cxx

    r7812 r8041  
    4747            basecnt = 0; 
    4848            for (i=PT_QU; i<PT_B_MAX; i++) { 
    49                 if ((pt_help = PT_read_son(psg.ptmain, pt, (PT_BASES)i))) 
     49                if ((pt_help = PT_read_son(pt, (PT_BASES)i))) 
    5050                { 
    5151                    basecnt++; 
     
    6161            ptds->chains[height]++; 
    6262            psg.height = 0; 
    63             PT_forwhole_chain(psg.ptmain, pt, PT_chain_count()); 
     63            PT_forwhole_chain(pt, PT_chain_count()); 
    6464            if (psg.height >= DEBUG_MAX_CHAIN_SIZE) psg.height = DEBUG_MAX_CHAIN_SIZE; 
    6565            ptds->chainsizes[psg.height][height]++; 
     
    6868            if (ptds->chaincount<20) { 
    6969                printf("\n\n\n\n"); 
    70                 PT_forwhole_chain(psg.ptmain, pt, PTD_chain_print()); 
     70                PT_forwhole_chain(pt, PTD_chain_print()); 
    7171            } 
    7272            break; 
     
    140140        struct probe_input_data& data = psg.data[leaf.name]; 
    141141 
    142         PT_BASES b = (PT_BASES)data.data[leaf.rpos]; 
    143  
    144         printf("%s[%c] %s apos=%i rpos=%i\n", prefix, PT_BASES_2_char(b), data.name, leaf.apos, leaf.rpos); 
     142        PT_BASES b = (PT_BASES)data.get_data()[leaf.rpos]; 
     143 
     144        printf("%s[%c] %s apos=%i rpos=%i\n", prefix, PT_BASES_2_char(b), data.get_name(), leaf.apos, leaf.rpos); 
    145145        return 0; 
    146146    } 
     
    152152    switch (PT_read_type(pt)) { 
    153153        case PT_NT_NODE: 
    154             for (int i = PT_N; i<PT_B_MAX; i++) { 
     154            for (int i = PT_QU; i<PT_B_MAX; i++) { 
    155155                PT_BASES  b   = PT_BASES(i); 
    156                 POS_TREE *son = PT_read_son(psg.ptmain, pt, b); 
     156                POS_TREE *son = PT_read_son(pt, b); 
    157157                if (son) { 
    158                     char *subPrefix = GBS_global_string_copy("%s%c", prefix, PT_BASES_2_char(b)); 
     158                    char *subPrefix = GBS_global_string_copy("%s%c", prefix, b == PT_QU ? '.' : PT_BASES_2_char(b)); 
    159159                    PT_dump_POS_TREE_recursive(son, subPrefix); 
    160160                    free(subPrefix); 
     
    163163            break; 
    164164        case PT_NT_LEAF: { 
    165             PT_dump_leaf dump_leaf(prefix); 
    166             dump_leaf(DataLoc(psg.ptmain, pt)); 
    167             break; 
    168         } 
    169         case PT_NT_CHAIN: 
    170             PT_forwhole_chain(psg.ptmain, pt, PT_dump_leaf(prefix)); 
    171             break; 
     165            char         *subPrefix = GBS_global_string_copy("{l} %s", prefix); 
     166            PT_dump_leaf  dump_leaf(subPrefix); 
     167            dump_leaf(DataLoc(pt)); 
     168            free(subPrefix); 
     169            break; 
     170        } 
     171        case PT_NT_CHAIN: { 
     172            char *subPrefix = GBS_global_string_copy("{c} %s", prefix); 
     173            PT_forwhole_chain(pt, PT_dump_leaf(subPrefix)); 
     174            free(subPrefix); 
     175            break; 
     176        } 
    172177        default: 
    173178            printf("%s [unhandled]\n", prefix); 
     
    183188    // Debug function for all stages 
    184189#if defined(DEBUG) 
    185     long             i; 
    186     PTM2        *ptmain = psg.ptmain; 
    187190    if (!node) printf("Zero node\n"); 
    188     PT_READ_PNTR(&node->data, i); 
    189     printf("node father 0x%lx\n", i); 
     191 
     192    { 
     193        long i; 
     194        PT_READ_PNTR(&node->data, i); 
     195        printf("node father 0x%lx\n", i); 
     196    } 
     197 
    190198    switch (PT_read_type(node)) { 
    191         case PT_NT_LEAF: 
    192             printf("leaf %i:%i,%i\n", PT_read_name(ptmain, node), 
    193                    PT_read_rpos(ptmain, node), PT_read_apos(ptmain, node)); 
    194             break; 
     199        case PT_NT_LEAF: { 
     200            DataLoc loc(node); 
     201            printf("leaf %i:%i,%i\n", loc.name, loc.rpos, loc.apos); 
     202            break; 
     203        } 
    195204        case PT_NT_NODE: 
    196             for (i = 0; i < PT_B_MAX; i++) { 
    197                 printf("%6li:0x%p\n", i, PT_read_son(ptmain, node, (PT_BASES)i)); 
     205            for (long i = 0; i < PT_B_MAX; i++) { 
     206                printf("%6li:0x%p\n", i, PT_read_son(node, (PT_BASES)i)); 
    198207            } 
    199208            break; 
    200209        case PT_NT_CHAIN: 
    201210            printf("chain:\n"); 
    202             PT_forwhole_chain(ptmain, node, PTD_chain_print()); 
     211            PT_forwhole_chain(node, PTD_chain_print()); 
    203212            break; 
    204213        case PT_NT_SAVED: 
  • trunk/PROBE/PT_etc.cxx

    r7986 r8041  
    7272} 
    7373 
    74 const char *virt_name(PT_probematch *ml) 
     74const char *virt_name(PT_probematch *ml)  
    7575{ 
    7676    // get the name with a virtual function 
    7777    if (gene_flag) { 
    78         const gene_struct *gs = get_gene_struct_by_internal_gene_name(psg.data[ml->name].name); 
     78        const gene_struct *gs = get_gene_struct_by_internal_gene_name(psg.data[ml->name].get_name()); 
    7979        return gs ? gs->get_arb_species_name() : "<cantResolveName>"; 
    8080    } 
    8181    else { 
    82         pt_assert(psg.data[ml->name].name); 
    83         return psg.data[ml->name].name; 
    84     } 
    85 } 
    86  
    87 const char *virt_fullname(PT_probematch * ml) 
     82        pt_assert(psg.data[ml->name].get_name()); 
     83        return psg.data[ml->name].get_name(); 
     84    } 
     85} 
     86 
     87const char *virt_fullname(PT_probematch * ml)  
    8888{ 
    8989    if (gene_flag) { 
    90         const gene_struct *gs = get_gene_struct_by_internal_gene_name(psg.data[ml->name].name); 
     90        const gene_struct *gs = get_gene_struct_by_internal_gene_name(psg.data[ml->name].get_name()); 
    9191        return gs ? gs->get_arb_gene_name() : "<cantResolveGeneFullname>"; 
    9292    } 
    9393    else { 
    94         return psg.data[ml->name].fullname ?  psg.data[ml->name].fullname : "<undefinedFullname>"; 
     94        return psg.data[ml->name].get_fullname() ?  psg.data[ml->name].get_fullname() : "<undefinedFullname>"; 
    9595    } 
    9696} 
     
    163163    // clear 'is_group' 
    164164    for (int i = 0; i < psg.data_count; i++) { 
    165         psg.data[i].is_group = 0; // Note: probes are designed for species with is_group == 1 
     165        psg.data[i].set_group_state(0); // Note: probes are designed for species with is_group == 1 
    166166    } 
    167167    locs->group_count = 0; 
     
    212212                const char *checksum = get_list_part(checksums, coff); 
    213213                // if sequence checksum changed since pt server was updated -> not found 
    214                 found                = atol(checksum) == psg.data[idx].checksum; 
     214                found                = atol(checksum) == psg.data[idx].get_checksum(); 
    215215            } 
    216216            else { 
     
    219219 
    220220            if (found) { 
    221                 psg.data[idx].is_group = 1; // mark 
     221                psg.data[idx].set_group_state(1); // mark 
    222222                locs->group_count++; 
    223223            } 
  • trunk/PROBE/PT_family.cxx

    r7933 r8041  
    2222inline void aisc_link(dll_public *dll, PT_family_list *family)   { aisc_link(reinterpret_cast<dllpublic_ext*>(dll), reinterpret_cast<dllheader_ext*>(family)); } 
    2323 
     24 
     25class HitCounter { 
     26    int    count;     // Counter for matches 
     27    double rel_count; // match_count / (seq_len - probe_len + 1) 
     28 
     29public: 
     30    HitCounter() : count(0), rel_count(0.0) {} 
     31 
     32    void inc() { count++; } 
     33    void calc_rel_match(int max_poss_matches) { 
     34        rel_count = max_poss_matches>0 ? double(count)/max_poss_matches : 0; 
     35    } 
     36 
     37    bool less_abs(const HitCounter& other) const { return count < other.count; } 
     38    bool less_rel(const HitCounter& other) const { return rel_count < other.rel_count; } 
     39 
     40    int get_match_count() const { return count; } 
     41    const double& get_rel_match_count() const { return rel_count; } 
     42}; 
     43 
     44class FamilyStat : virtual Noncopyable { 
     45    size_t      size; 
     46    HitCounter *famstat; 
     47 
     48public: 
     49    FamilyStat(size_t size_) : size(size_), famstat(new HitCounter[size]) { } 
     50    ~FamilyStat() { delete [] famstat; } 
     51 
     52    void calc_rel_matches(int probe_len, int sequence_length)  { 
     53        for (size_t i = 0; i < size; i++) { 
     54            int max_poss_matches = std::min(psg.data[i].get_size(), sequence_length) - probe_len + 1; 
     55            famstat[i].calc_rel_match(max_poss_matches); 
     56        } 
     57    } 
     58 
     59    const HitCounter& hits(size_t idx) const { pt_assert(idx<size); return famstat[idx]; } 
     60 
     61    void count_match(size_t idx) { famstat[idx].inc(); } 
     62 
     63    bool less_abs(int a, int b) const { return famstat[a].less_abs(famstat[b]); } 
     64    bool less_rel(int a, int b) const { return famstat[a].less_rel(famstat[b]); } 
     65}; 
     66 
    2467class ProbeTraversal { 
    2568    static Range range; 
    2669 
    27     static void count_match(const DataLoc& match) { 
    28         if (range.contains(match)) { 
    29             ++psg.data[match.name].stat.match_count; 
    30         } 
    31     } 
    32  
    33     // ---------------------------------------- 
    34      
    3570    const char *probe; 
    3671    int         height; 
    3772    int         needed_positions; 
    3873    int         accept_mismatches; 
     74     
     75    FamilyStat& fam_stat; 
     76 
     77    void count_match(const DataLoc& match) const { 
     78        if (range.contains(match)) { 
     79            fam_stat.count_match(match.name); 
     80        } 
     81    } 
    3982 
    4083    bool at_end() const { return *probe == PT_QU; } 
     
    5598 
    5699    void match_rest_and_mark(const DataLoc& loc) { 
    57         do match_one_char(psg.data[loc.name].data[loc.rpos+height]); while (match_possible()); 
     100        do match_one_char(psg.data[loc.name].get_data()[loc.rpos+height]); while (match_possible()); 
    58101        if (did_match()) count_match(loc); 
    59102    } 
     
    69112        range  = Range(-1, -1, -1); 
    70113    } 
    71      
    72     ProbeTraversal(const char *probe_, int needed_positions_, int accept_mismatches_) 
     114 
     115    ProbeTraversal(const char *probe_, int needed_positions_, int accept_mismatches_, FamilyStat& fam_stat_) 
    73116        : probe(probe_), 
    74117          height(0), 
    75118          needed_positions(needed_positions_), 
    76           accept_mismatches(accept_mismatches_) 
     119          accept_mismatches(accept_mismatches_), 
     120          fam_stat(fam_stat_) 
    77121    { } 
    78122 
     
    100144    if (PT_read_type(pt) == PT_NT_NODE) { 
    101145        for (int base = PT_N; base < PT_B_MAX; base++) { 
    102             POS_TREE *pt_son = PT_read_son(psg.ptmain, pt, (PT_BASES)base); 
     146            POS_TREE *pt_son = PT_read_son(pt, (PT_BASES)base); 
    103147            if (pt_son && !at_end()) { 
    104148                ProbeTraversal sub(*this); 
     
    112156    } 
    113157    else { 
    114         PT_withall_tips(psg.ptmain, pt, *this); // calls operator()  
     158        PT_withall_tips(pt, *this); // calls operator()  
    115159    } 
    116160} 
     
    123167    if (PT_read_type(pt) == PT_NT_NODE) { 
    124168        for (int base = PT_N; base < PT_B_MAX; base++) { 
    125             POS_TREE *pt_son = PT_read_son(psg.ptmain, pt, (PT_BASES)base); 
     169            POS_TREE *pt_son = PT_read_son(pt, (PT_BASES)base); 
    126170            if (pt_son) mark_all(pt_son); 
    127171        } 
    128172    } 
    129173    else { 
    130         PT_withall_tips(psg.ptmain, pt, *this); // calls operator()  
    131     } 
    132 } 
    133  
    134  
    135 static void clear_statistic() { 
    136     //! Clear all information in psg.data[i].stat 
    137  
    138     for (int i = 0; i < psg.data_count; i++) { 
    139         memset((char *) &psg.data[i].stat, 0, sizeof(probe_statistic)); 
    140     } 
    141 } 
    142  
    143  
    144  
    145 static void make_match_statistic(int probe_len, int sequence_length) { 
    146     //! Calculate the statistic information for the family 
    147  
    148     // compute statistic for all species in family 
    149     for (int i = 0; i < psg.data_count; i++) { 
    150         int all_len = std::min(psg.data[i].size, sequence_length) - probe_len + 1; 
    151         if (all_len <= 0) { 
    152             psg.data[i].stat.rel_match_count = 0; 
    153         } 
    154         else { 
    155             psg.data[i].stat.rel_match_count = psg.data[i].stat.match_count / (double) (all_len); 
    156         } 
     174        PT_withall_tips(pt, *this); // calls operator()  
    157175    } 
    158176} 
    159177 
    160178struct cmp_probe_abs { 
    161     bool operator()(const struct probe_input_data* a, const struct probe_input_data* b) { 
    162         return b->stat.match_count < a->stat.match_count; 
    163     } 
     179    const FamilyStat& fam_stat; 
     180    cmp_probe_abs(const FamilyStat& fam_stat_) : fam_stat(fam_stat_) {} 
     181    bool operator()(int a, int b) { return fam_stat.less_abs(b, a); } 
    164182}; 
    165183 
    166184struct cmp_probe_rel { 
    167     bool operator()(const struct probe_input_data* a, const struct probe_input_data* b) { 
    168         return b->stat.rel_match_count < a->stat.rel_match_count; 
    169     } 
    170 }; 
    171  
    172 static int make_PT_family_list(PT_family *ffinder) { 
     185    const FamilyStat& fam_stat; 
     186    cmp_probe_rel(const FamilyStat& fam_stat_) : fam_stat(fam_stat_) {} 
     187    bool operator()(int a, int b) { return fam_stat.less_rel(b, a); } 
     188}; 
     189 
     190static int make_PT_family_list(PT_family *ffinder, const FamilyStat& famStat) { 
    173191    //!  Make sorted list of family members 
    174192 
     193    // destroy old list 
     194    while (ffinder->fl) destroy_PT_family_list(ffinder->fl); 
     195 
    175196    // Sort the data 
    176     std::vector<struct probe_input_data*> my_list; 
    177     my_list.resize(psg.data_count); 
    178  
    179     for (int i = 0; i < psg.data_count; i++) { 
    180         my_list[i] = &psg.data[i]; 
    181     } 
     197    std::vector<int> sorted; 
     198    sorted.resize(psg.data_count); 
     199 
     200    for (int i = 0; i < psg.data_count; i++) sorted[i] = i; 
    182201 
    183202    bool sort_all = ffinder->sort_max == 0 || ffinder->sort_max >= psg.data_count; 
     
    185204    if (ffinder->sort_type == 0) { 
    186205        if (sort_all) { 
    187             std::sort(my_list.begin(), my_list.end(), cmp_probe_abs()); 
     206            std::sort(sorted.begin(), sorted.end(), cmp_probe_abs(famStat)); 
    188207        } 
    189208        else { 
    190             std::partial_sort(my_list.begin(), my_list.begin() + ffinder->sort_max, my_list.begin() + psg.data_count, cmp_probe_abs()); 
     209            std::partial_sort(sorted.begin(), sorted.begin() + ffinder->sort_max, sorted.begin() + psg.data_count, cmp_probe_abs(famStat)); 
    191210        } 
    192211    } 
    193212    else { 
    194213        if (sort_all) { 
    195             std::sort(my_list.begin(), my_list.begin() + psg.data_count, cmp_probe_rel()); 
     214            std::sort(sorted.begin(), sorted.begin() + psg.data_count, cmp_probe_rel(famStat)); 
    196215        } 
    197216        else { 
    198             std::partial_sort(my_list.begin(), my_list.begin() + ffinder->sort_max, my_list.begin() + psg.data_count, cmp_probe_rel()); 
    199         } 
    200     } 
    201  
    202     // destroy old list 
    203     while (ffinder->fl) destroy_PT_family_list(ffinder->fl); 
     217            std::partial_sort(sorted.begin(), sorted.begin() + ffinder->sort_max, sorted.begin() + psg.data_count, cmp_probe_rel(famStat)); 
     218        } 
     219    } 
    204220 
    205221    // build new list 
     
    208224    int end = (sort_all) ? psg.data_count : ffinder->sort_max; 
    209225    for (int i = 0; i < end; i++) { 
    210         if (my_list[i]->stat.match_count != 0) { 
     226        probe_input_data& pid = psg.data[sorted[i]]; 
     227        const HitCounter& ps  = famStat.hits(sorted[i]); 
     228 
     229        if (ps.get_match_count() != 0) { 
    211230            PT_family_list *fl = create_PT_family_list(); 
    212231 
    213             fl->name        = strdup(my_list[i]->name); 
    214             fl->matches     = my_list[i]->stat.match_count; 
    215             fl->rel_matches = my_list[i]->stat.rel_match_count; 
     232            fl->name        = strdup(pid.get_name()); 
     233            fl->matches     = ps.get_match_count(); 
     234            fl->rel_matches = ps.get_rel_match_count(); 
    216235 
    217236            aisc_link(&ffinder->pfl, fl); 
     
    263282    int   sequence_len = probe_compress_sequence(sequence, species->size); 
    264283 
    265     clear_statistic(); 
    266  
    267284    // if find_type > 0 -> search only probes starting with 'A' (quick but less accurate) 
    268285    char last_first_c = ffinder->find_type ? PT_A : PT_T; 
     
    270287    ProbeTraversal::restrictMatchesToRegion(ffinder->range_start, ffinder->range_end, probe_len); 
    271288 
     289    FamilyStat famStat(psg.data_count); 
     290     
    272291    // Note: code depends on order of ../AWTC/awtc_next_neighbours.hxx@FF_complement_dep 
    273292    for (int cmode = 1; cmode <= 8; cmode *= 2) { 
     
    290309                    for (char *probe = sequence; probe < last_probe; ++probe) { 
    291310                        if (probe_is_ok(probe, probe_len, first_c, second_c)) { 
    292                             ProbeTraversal(probe, probe_len, mismatch_nr).mark_matching(psg.pt); 
     311                            ProbeTraversal(probe, probe_len, mismatch_nr, famStat).mark_matching(psg.pt); 
    293312                        } 
    294313                    } 
     
    298317    } 
    299318 
    300     make_match_statistic(ffinder->pr_len, sequence_len); 
    301     make_PT_family_list(ffinder); 
     319    famStat.calc_rel_matches(ffinder->pr_len, sequence_len); 
     320    make_PT_family_list(ffinder, famStat); 
    302321 
    303322    ProbeTraversal::unrestrictMatchesToRegion(); 
  • trunk/PROBE/PT_findEx.cxx

    r7415 r8041  
    2121        case PT_NT_NODE: { 
    2222            for (int i=PT_A; i<PT_B_MAX; ++i) { 
    23                 POS_TREE *son = PT_read_son(psg.ptmain, node, PT_BASES(i)); 
     23                POS_TREE *son = PT_read_son(node, PT_BASES(i)); 
    2424                if (son) { 
    2525                    probe[0] = PT_BASES(i); // write leftmost probe into result 
     
    3737        case PT_NT_LEAF: { 
    3838            // here the probe-tree is cut off, because only one species matches 
    39             int pos  = PT_read_rpos(psg.ptmain, node) + height; 
    40             int name = PT_read_name(psg.ptmain, node); 
    41             if (pos + restlen >= psg.data[name].size) 
     39            DataLoc loc(node); 
     40            int     pos  = loc.rpos + height; 
     41            int     name = loc.name; 
     42 
     43            if (pos + restlen >= psg.data[name].get_size()) 
    4244                break;          // at end-of-sequence -> no probe with wanted length here 
    4345 
    4446            pt_assert(probe[restlen] == 0); 
    45             const char *seq_data = psg.data[name].data; 
     47            const char *seq_data = psg.data[name].get_data(); 
    4648            for (int r = 0; r<restlen; ++r) { 
    4749                int data = seq_data[pos+r]; 
     
    7072    switch (PT_read_type(node)) { 
    7173        case PT_NT_NODE: { 
    72             POS_TREE *son   = PT_read_son(psg.ptmain, node, PT_BASES(probe[0])); 
     74            POS_TREE *son   = PT_read_son(node, PT_BASES(probe[0])); 
    7375            bool      found = (son != 0) && findNextProbe(son, probe+1, restlen-1, height+1); 
    7476 
     
    7779            if (!found) { 
    7880                for (int i=probe[0]+1; !found && i<PT_B_MAX; ++i) { 
    79                     son = PT_read_son(psg.ptmain, node, PT_BASES(i)); 
     81                    son = PT_read_son(node, PT_BASES(i)); 
    8082                    if (son) { 
    8183                        probe[0] = PT_BASES(i); // change probe 
  • trunk/PROBE/PT_io.cxx

    r7933 r8041  
    7171} 
    7272 
    73 ARB_ERROR probe_read_data_base(const char *name) { // goes to header: __ATTR__USERESULT 
     73ARB_ERROR probe_read_data_base(const char *name, bool readOnly) { // goes to header: __ATTR__USERESULT 
    7474    ARB_ERROR error; 
    7575    GB_set_verbose(); 
     
    7777    psg.gb_shell = new GB_shell; 
    7878 
    79     GBDATA *gb_main     = GB_open(name, "r"); 
     79    GBDATA *gb_main     = GB_open(name, readOnly ? "r" : "rw"); 
    8080    if (!gb_main) error = GB_await_error(); 
    8181    else { 
     
    195195} 
    196196 
    197 char *probe_read_alignment(int j, int *psize) { 
     197char *probe_input_data::read_alignment(int *psize) const { 
    198198    char           *buffer     = 0; 
    199     GBDATA         *gb_species = psg.data[j].gbd; 
     199    GBDATA         *gb_species = get_gbdata(); 
    200200    GB_transaction  ta(gb_species); 
    201201    GBDATA         *gb_ali     = GB_entry(gb_species, psg.alignment_name); 
     
    206206    } 
    207207    return buffer; 
     208} 
     209 
     210char *probe_read_alignment(int j, int *psize) {  
     211    return psg.data[j].read_alignment(psize); 
     212} 
     213 
     214GB_ERROR probe_input_data::init(GBDATA *gb_species) { 
     215    GB_ERROR  error   = NULL; 
     216    GBDATA   *gb_ali  = GB_entry(gb_species, psg.alignment_name); 
     217    GBDATA   *gb_data = gb_ali ? GB_entry(gb_ali, "data") : NULL; 
     218 
     219    if (!gb_data) { 
     220        error = GBS_global_string("Species '%s' has no data in '%s'\n", GBT_read_name(gb_species), psg.alignment_name); 
     221    } 
     222    else { 
     223        int   hsize; 
     224        char *sdata = probe_read_string_append_point(gb_data, &hsize); 
     225 
     226        if (!sdata) { 
     227            error = GBS_global_string("Could not read data in '%s' for species '%s'\n(Reason: %s)\n", 
     228                                      psg.alignment_name, GBT_read_name(gb_species), GB_await_error()); 
     229        } 
     230        else { 
     231            name = strdup(GBT_read_name(gb_species)); 
     232 
     233            fullname                = GBT_read_string(gb_species, "full_name"); 
     234            if (!fullname) fullname = strdup(""); 
     235 
     236            gbd   = gb_species; 
     237 
     238            set_checksum(GB_checksum(sdata, hsize, 1, ".-")); 
     239            int csize = probe_compress_sequence(sdata, hsize); 
     240 
     241            set_data(GB_memdup(sdata, csize), csize); 
     242            free(sdata); 
     243        } 
     244    } 
     245 
     246    return error; 
    208247} 
    209248 
     
    230269    int icount = GB_number_of_subentries(psg.gb_species_data); 
    231270     
    232     psg.data       = (probe_input_data *)calloc(sizeof(probe_input_data), icount); 
     271    psg.data       = new probe_input_data[icount]; 
    233272    psg.data_count = 0; 
    234273 
     
    246285            probe_input_data& pid = psg.data[count]; 
    247286 
    248             pid.name     = strdup(GBT_read_name(gb_species)); 
    249             pid.fullname = GBT_read_string(gb_species, "full_name"); 
    250  
    251             if (!pid.fullname) pid.fullname = strdup(""); 
    252  
    253             pid.is_group = 1; 
    254             pid.gbd      = gb_species; 
    255  
    256             GBDATA *gb_ali  = GB_entry(gb_species, psg.alignment_name); 
    257             GBDATA *gb_data = gb_ali ? GB_entry(gb_ali, "data") : NULL; 
    258             if (!gb_data) { 
    259                 fprintf(stderr, "Species '%s' has no data in '%s'\n", pid.name, psg.alignment_name); 
     287            GB_ERROR error = pid.init(gb_species); 
     288            if (error) { 
     289                fputs(error, stderr); 
     290                fputc('\n', stderr); 
    260291                data_missing++; 
    261292            } 
    262293            else { 
    263                 int   hsize; 
    264                 char *data = probe_read_string_append_point(gb_data, &hsize); 
    265  
    266                 if (!data) { 
    267                     GB_ERROR error = GB_await_error(); 
    268                     fprintf(stderr, "Could not read data in '%s' for species '%s'\n(Reason: %s)\n", 
    269                             psg.alignment_name, pid.name, error); 
    270                     data_missing++; 
    271                 } 
    272                 else { 
    273                     pid.checksum = GB_checksum(data, hsize, 1, ".-"); 
    274                     int   size = probe_compress_sequence(data, hsize); 
    275  
    276                     pid.data = GB_memdup(data, size); 
    277                     pid.size = size; 
    278  
    279                     free(data); 
    280                     count++; 
    281                 } 
    282                      
     294                count++; 
    283295            } 
    284296            progress.inc(); 
     
    306318    psg.namehash = GBS_create_hash(psg.data_count, GB_MIND_CASE); 
    307319    for (i=0; i<psg.data_count; i++) { 
    308         GBS_write_hash(psg.namehash, psg.data[i].name, i+1); 
     320        GBS_write_hash(psg.namehash, psg.data[i].get_name(), i+1); 
    309321    } 
    310322    unsigned int    max_size; 
    311323    max_size = 0; 
    312324    for (i = 0; i < psg.data_count; i++) {  // get max sequence len 
    313         max_size = std::max(max_size, (unsigned)(psg.data[i].size)); 
    314         psg.char_count += psg.data[i].size; 
     325        max_size = std::max(max_size, (unsigned)(psg.data[i].get_size())); 
     326        psg.char_count += psg.data[i].get_size(); 
    315327    } 
    316328    psg.max_size = max_size; 
  • trunk/PROBE/PT_main.cxx

    r7415 r8041  
    1616 
    1717#include <arbdbt.h> 
     18#include <arb_defs.h> 
    1819#include <servercntrl.h> 
    1920#include <server.h> 
     
    2122#include <struct_man.h> 
    2223#include <ut_valgrinded.h> 
     24#include <ptclean.h> 
    2325 
    2426#include <unistd.h> 
     
    4244 
    4345ARB_ERROR pt_init_main_struct(PT_main *, const char *filename) { // __ATTR__USERESULT 
    44     ARB_ERROR error = probe_read_data_base(filename); 
     46    ARB_ERROR error = probe_read_data_base(filename, true); 
    4547    if (!error) { 
    4648        GB_begin_transaction(psg.gb_main); 
     
    6769    // shutdown server 
    6870    aisc_server_shutdown(psg.com_so); 
    69     PT_exit(EXIT_SUCCESS); // never returns 
    70     return 0; 
     71    PT_exit(); 
     72    exit(EXIT_SUCCESS); 
    7173} 
    7274 
     
    98100    if (psg_initialized) { 
    99101        if (psg.gb_main) { 
    100             int count = GB_number_of_subentries(psg.gb_species_data); 
    101             for (int i = 0; i < count; ++i) { 
    102                 free(psg.data[i].data); 
    103                 free(psg.data[i].name); 
    104                 free(psg.data[i].fullname); 
    105             } 
    106             free(psg.data); 
     102            delete [] psg.data; 
    107103 
    108104            GB_close(psg.gb_main); 
     
    131127} 
    132128 
    133 void PT_exit(int exitcode) { // goes to header: __ATTR__NORETURN 
     129void PT_exit() {  
    134130    // unique exit point to ensure cleanup 
    135131    if (aisc_main) destroy_PT_main(aisc_main); 
    136132    if (psg_initialized) PT_exit_psg(); 
    137133    PTM_finally_free_all_mem(); 
    138     exit(exitcode); 
    139134} 
    140135 
     
    220215            const char *map_str     = GB_read_char_pntr(map_ptr_str); 
    221216 
    222             parse_names_into_gene_struct(map_str, all_gene_structs); 
     217            error = parse_names_into_gene_struct(map_str, all_gene_structs).deliver(); 
    223218 
    224219            // build indices : 
     
    309304            if (update_reason) { 
    310305                printf("- updating postree (Reason: %s)", update_reason); 
    311                 char *build_cmd  = GBS_global_string_copy("%s -build -D%s", exename, arbdb_name); 
    312                 make_valgrinded_call(build_cmd); 
    313                 error            = GB_system(build_cmd); 
    314                 free(build_cmd); 
     306 
     307                const char *build_step[] = { 
     308                    "build_clean", 
     309                    "build_map", 
     310                    "build", 
     311                }; 
     312 
     313                for (size_t s = 0; !error && s<ARRAY_ELEMS(build_step); s++) { 
     314                    if (s == 1 && !GB_supports_mapfile()) continue; // skip useless step  
     315                     
     316                    char *build_cmd = GBS_global_string_copy("%s -%s -D%s", exename, build_step[s], arbdb_name); 
     317                    make_valgrinded_call(build_cmd); 
     318                    error           = GB_system(build_cmd); 
     319                    free(build_cmd); 
     320                } 
     321 
    315322                if (error) error = GBS_global_string("Failed to update postree (Reason: %s)", error.deliver()); 
    316323            } 
     
    364371        char *pt_name = GBS_global_string_copy("%s.pt", params->db_server); 
    365372 
    366         if (strcmp(command, "-build") == 0) {  // build command 
     373        if (strcmp(command, "-build_clean") == 0) {  // cleanup source DB 
     374            error = probe_read_data_base(params->db_server, false); 
     375            if (!error) { 
     376                pt_assert(psg.gb_main); 
     377                error = prepare_ptserver_database(psg.gb_main, PTSERVER); 
     378                if (!error) { 
     379                    const char *mode = "bf"; // save PT-server database withOUT! Fastload file 
     380                    error            = GB_save_as(psg.gb_main, params->db_server, mode); 
     381                } 
     382            } 
     383        } 
     384        else if (strcmp(command, "-build_map") == 0) {  // create a clean mapfile for source DB 
     385            if (GB_supports_mapfile()) { 
     386                error = probe_read_data_base(params->db_server, false); 
     387                if (!error) { 
     388                    pt_assert(psg.gb_main); 
     389                    const char *mode = "bfm"; // save PT-server database with Fastload file 
     390                    error            = GB_save_as(psg.gb_main, params->db_server, mode); 
     391                } 
     392            } 
     393            else { 
     394                error = "Invalid invocation of -build_map (your ARB version does not support mapfiles)"; 
     395            } 
     396        } 
     397        else if (strcmp(command, "-build") == 0) {  // build command 
    367398            error = pt_init_main_struct(aisc_main, params->db_server); 
    368399            if (error) error = GBS_global_string("Gave up (Reason: %s)", error.deliver()); 
     
    477508 
    478509    free_arb_params(params); 
    479     PT_exit(exitcode); 
    480 } 
     510    PT_exit(); 
     511    return exitcode; 
     512} 
  • trunk/PROBE/PT_match.cxx

    r7986 r8041  
    6767            pos = matchLoc.rpos+psg.height; 
    6868            height = psg.height; 
    69             while ((base=probe[height]) && (ref = psg.data[matchLoc.name].data[pos])) { 
     69            while ((base=probe[height]) && (ref = psg.data[matchLoc.name].get_data()[pos])) { 
    7070                if (ref == PT_N || base == PT_N) { 
    7171                    // @@@ Warning: dupped code also counts PT_QU as mismatch! 
     
    124124    int            base; 
    125125    int            error; 
    126     int            name, pos, rpos; 
    127126    PT_probematch *ml; 
    128127 
     
    135134    } 
    136135    if (PT_read_type(pt) == PT_NT_LEAF) { 
    137         name = PT_read_name(psg.ptmain, pt); 
    138         pos  = PT_read_apos(psg.ptmain, pt); 
    139         rpos = PT_read_rpos(psg.ptmain, pt); 
     136        DataLoc loc(pt); 
    140137 
    141138        // @@@ dupped code from PT_store_match_in::operator() 
    142139        ml = create_PT_probematch(); 
    143140 
    144         ml->name         = name; 
    145         ml->b_pos        = pos; 
     141        ml->name         = loc.name; 
     142        ml->b_pos        = loc.apos; 
    146143        ml->g_pos        = -1; 
    147         ml->rpos         = rpos; 
     144        ml->rpos         = loc.rpos; 
    148145        ml->mismatches   = psg.mismatches; 
    149146        ml->wmismatches  = psg.wmismatches; 
     
    158155        if (PT_read_type(pt) == PT_NT_CHAIN) { 
    159156            psg.probe = 0; 
    160             if (PT_forwhole_chain(psg.ptmain, pt, PT_store_match_in(locs))) { 
     157            if (PT_forwhole_chain(pt, PT_store_match_in(locs))) { 
    161158                error = 1; 
    162159                return 1; 
     
    165162        else { 
    166163            for (base = PT_QU; base< PT_B_MAX; base++) { 
    167                 error = read_names_and_pos(locs, PT_read_son(psg.ptmain, pt, (PT_BASES)base)); 
     164                error = read_names_and_pos(locs, PT_read_son(pt, (PT_BASES)base)); 
    168165                if (error) return error; 
    169166            } 
     
    197194    if (PT_read_type(pt) == PT_NT_NODE && probe[height]) { 
    198195        for (i=PT_N; i<PT_B_MAX; i++) { 
    199             if ((pthelp = PT_read_son(psg.ptmain, pt, (PT_BASES)i))) { 
     196            if ((pthelp = PT_read_son(pt, (PT_BASES)i))) { 
    200197                new_N_mis = N_mismatches; 
    201198                base = probe[height]; 
     
    232229            // @@@ code here is duplicate of code in PT_store_match_in::operator() 
    233230 
    234             pos  = PT_read_rpos(psg.ptmain, pt) + height; 
    235             name = PT_read_name(psg.ptmain, pt); 
     231            DataLoc loc(pt); 
     232            pos  = loc.rpos + height; 
     233            name = loc.name; 
    236234 
    237235            // @@@ recursive use of strlen with constant result (argh!) 
    238             if (pos + (int)(strlen(probe+height)) >= psg.data[name].size)       // end of sequence 
     236            if (pos + (int)(strlen(probe+height)) >= psg.data[name].get_size())       // end of sequence 
    239237                return 0; 
    240238 
    241239            while ((base = probe[height])) { 
    242                 i = psg.data[name].data[pos]; 
     240                i = psg.data[name].get_data()[pos]; 
    243241                if (i == PT_N || base == PT_N || i == PT_QU || base == PT_QU) { 
    244242                    psg.N_mismatches = psg.N_mismatches + 1; 
     
    260258            psg.probe = probe; 
    261259            psg.height = height; 
    262             PT_forwhole_chain(psg.ptmain, pt, PT_store_match_in(locs)); // @@@ why ignore result 
     260            PT_forwhole_chain(pt, PT_store_match_in(locs)); // @@@ why ignore result 
    263261            return 0; 
    264262        } 
     
    444442    pt_build_pos_to_weight((PT_MATCH_TYPE)locs->sort_by, probestring); 
    445443 
    446     if (psg.deep >= 0) { 
    447         get_info_about_probe(locs, probestring, psg.pt, 0, 0.0, 0, 0); 
    448     } 
    449     else { 
    450         ptnd_new_match(locs,    probestring); 
    451     } 
     444    pt_assert(psg.deep >= 0); // deep < 0 was used till [8011] to trigger "new match" (feature unused) 
     445    get_info_about_probe(locs, probestring, psg.pt, 0, 0.0, 0, 0); 
     446 
    452447    if (locs->pm_reversed) { 
    453448        psg.reversed = 1; 
    454         rev_pro = reverse_probe(probestring, 0); 
     449        rev_pro      = reverse_probe(probestring, 0); 
    455450        complement_probe(rev_pro, 0); 
    456451        freeset(locs->pm_csequence, psg.main_probe = strdup(rev_pro)); 
    457         if (psg.deep >= 0) { 
    458             get_info_about_probe(locs, rev_pro, psg.pt, 0, 0.0, 0, 0); 
    459         } 
    460         else { 
    461             ptnd_new_match(locs,        rev_pro); 
    462         } 
     452         
     453        get_info_about_probe(locs, rev_pro, psg.pt, 0, 0.0, 0, 0); 
    463454        free(rev_pro); 
    464455    } 
     
    564555         pr_pos--, al_pos--) 
    565556    { 
    566         if (!psg.data[ml->name].data[al_pos]) break; 
    567         ref[pr_pos] = psg.data[ml->name].data[al_pos]; 
     557        if (!psg.data[ml->name].get_data()[al_pos]) break; 
     558        ref[pr_pos] = psg.data[ml->name].get_data()[al_pos]; 
    568559    } 
    569560    ref[9] = '-'; 
     
    572563 
    573564    for (int pr_pos = 0, al_pos = ml->rpos; 
    574          pr_pos < pr_len && al_pos < psg.data[ml->name].size; 
     565         pr_pos < pr_len && al_pos < psg.data[ml->name].get_size(); 
    575566         pr_pos++, al_pos++) 
    576567    { 
    577568        int a = ml->sequence[pr_pos]; 
    578         int b = psg.data[ml->name].data[al_pos]; 
     569        int b = psg.data[ml->name].get_data()[al_pos]; 
    579570        if (a == b) { 
    580571            ref[pr_pos+10] = '='; 
     
    593584 
    594585    for (int pr_pos = 0, al_pos = ml->rpos+pr_len; 
    595          pr_pos < 9 && al_pos < psg.data[ml->name].size; 
     586         pr_pos < 9 && al_pos < psg.data[ml->name].get_size(); 
    596587         pr_pos++, al_pos++) 
    597588    { 
    598         ref[pr_pos+11+pr_len] = psg.data[ml->name].data[al_pos]; 
     589        ref[pr_pos+11+pr_len] = psg.data[ml->name].get_data()[al_pos]; 
    599590    } 
    600591    ref[10+pr_len] = '-'; 
     
    684675 
    685676    for (; ml; ml = ml->next) { 
    686         probe_input_data&  pid    = psg.data[ml->name]; 
    687         GBDATA            *gb_pos = GB_entry(pid.gbd, "abspos"); 
    688  
    689         if (gb_pos) { 
    690             long gene_pos  = GB_read_int(gb_pos); 
    691             ml->g_pos      = ml->b_pos; 
    692             ml->b_pos     += gene_pos; 
     677        long gene_pos = psg.data[ml->name].get_abspos(); 
     678        if (gene_pos >= 0) { 
     679            ml->g_pos  = ml->b_pos; 
     680            ml->b_pos += gene_pos; 
    693681        } 
    694682        else { 
    695683            fprintf(stderr, "Error in gene-pt-server: gene w/o position info\n"); 
    696             pt_assert(gb_pos); 
     684            pt_assert(0); 
    697685        } 
    698686    } 
     
    796784    for (i = 0; i < psg.data_count; i++) 
    797785    { 
    798         GBS_strcat(memfile, psg.data[i].name); 
     786        GBS_strcat(memfile, psg.data[i].get_name()); 
    799787        GBS_chrcat(memfile, (char)1); 
    800788    } 
  • trunk/PROBE/PT_new_design.cxx

    r7811 r8041  
    5454    } 
    5555} 
    56 struct ptnd_loop_com { 
     56 
     57static struct ptnd_loop_com { 
    5758    PT_pdc        *pdc; 
    5859    PT_local      *locs; 
    5960    PT_probeparts *parts; 
    6061    int            mishits; 
    61     int            new_match; // match or design the probe: 1 match   0 design 
    6262    double         sum_bonds; // sum of bond of longest non mismatch string 
    6363    double         dt;     // sum of mismatches 
     
    193193        // count all mishits for a probe 
    194194 
    195         // @@@ dupped code is in ptnd_count_mishits and ptnd_count_mishits2 
    196195        char *probe = psg.probe; 
    197196        psg.abs_pos.announce(probeLoc.apos); 
     
    199198        const probe_input_data& pid = psg.data[probeLoc.name]; 
    200199 
    201         if (pid.is_group) return 0;              // don't count group or neverminds 
    202         if (probe) { 
    203             int rpos = probeLoc.rpos + psg.height; 
    204             while (*probe && pid.data[rpos]) { 
    205                 if (pid.data[rpos] != *(probe)) return 0; 
    206                 probe++; 
    207                 rpos++; 
    208             } 
    209         } 
    210         ptnd.mishits++; 
     200        if (pid.outside_group()) { 
     201            if (probe) { 
     202                int rpos = probeLoc.rpos + psg.height; 
     203                while (*probe && pid.get_data()[rpos]) { 
     204                    if (pid.get_data()[rpos] != *(probe)) return 0; 
     205                    probe++; 
     206                    rpos++; 
     207                } 
     208            } 
     209            ptnd.mishits++; 
     210        } 
    211211        return 0; 
    212212    } 
     
    215215static int ptnd_count_mishits2(POS_TREE *pt) { 
    216216    //! go down the tree to chains and leafs; count the species that are in the non member group 
    217     int base; 
    218     int name; 
    219     int mishits = 0; 
    220  
    221217    if (pt == NULL) 
    222218        return 0; 
     219     
    223220    if (PT_read_type(pt) == PT_NT_LEAF) { 
    224         name     = PT_read_name(psg.ptmain, pt); 
    225         int apos = PT_read_apos(psg.ptmain, pt); 
    226  
    227         // @@@ dupped code from ptnd_chain_count_mishits::operator(): 
    228         psg.abs_pos.announce(apos); 
    229         if (!psg.data[name].is_group)   return 1; 
    230         return 0; 
    231     } 
    232     else if (PT_read_type(pt) == PT_NT_CHAIN) { 
     221        DataLoc loc(pt); 
     222        psg.abs_pos.announce(loc.apos); 
     223        return psg.data[loc.name].outside_group(); 
     224    } 
     225     
     226    if (PT_read_type(pt) == PT_NT_CHAIN) { 
    233227        psg.probe = 0; 
    234228        ptnd.mishits = 0; 
    235         PT_forwhole_chain(psg.ptmain, pt, ptnd_chain_count_mishits()); 
     229        PT_forwhole_chain(pt, ptnd_chain_count_mishits()); 
    236230        return ptnd.mishits; 
    237231    } 
    238     else { 
    239         for (base = PT_QU; base< PT_B_MAX; base++) { 
    240             mishits += ptnd_count_mishits2(PT_read_son(psg.ptmain, pt, (PT_BASES)base)); 
    241         } 
    242         return mishits; 
    243     } 
     232     
     233    int mishits = 0; 
     234    for (int base = PT_QU; base< PT_B_MAX; base++) { 
     235        mishits += ptnd_count_mishits2(PT_read_son(pt, (PT_BASES)base)); 
     236    } 
     237    return mishits; 
    244238} 
    245239 
     
    409403static int ptnd_count_mishits(char *probe, POS_TREE *pt, int height) { 
    410404    //! search down the tree to find matching species for the given probe 
    411     int       name; 
    412405    int       i; 
    413406    POS_TREE *pthelp; 
    414     int       pos; 
    415407    int       mishits; 
    416408 
     
    420412        for (i=PT_A; i<PT_B_MAX; i++) { 
    421413            if (i != *probe) continue; 
    422             if ((pthelp = PT_read_son(psg.ptmain, pt, (PT_BASES)i))) 
     414            if ((pthelp = PT_read_son(pt, (PT_BASES)i))) 
    423415                mishits += ptnd_count_mishits(probe+1, pthelp, height+1); 
    424416        } 
     
    427419    if (*probe) { 
    428420        if (PT_read_type(pt) == PT_NT_LEAF) { 
    429             pos  = PT_read_rpos(psg.ptmain, pt) + height; 
    430             name = PT_read_name(psg.ptmain, pt); 
    431  
    432             // @@@ dupped code from ptnd_chain_count_mishits::operator() 
    433             if (pos + (int)(strlen(probe)) >= psg.data[name].size)              // after end 
     421            const DataLoc loc(pt); 
     422            int           pos = loc.rpos+height; 
     423 
     424            if (pos + (int)(strlen(probe)) >= psg.data[loc.name].get_size())              // after end 
    434425                return 0; 
    435426 
    436427            while (*probe) { 
    437                 if (psg.data[name].data[pos++] != *(probe++)) 
     428                if (psg.data[loc.name].get_data()[pos++] != *(probe++)) 
    438429                    return 0; 
    439430            } 
     
    443434            psg.height = height; 
    444435            ptnd.mishits = 0; 
    445             PT_forwhole_chain(psg.ptmain, pt, ptnd_chain_count_mishits()); 
     436            PT_forwhole_chain(pt, ptnd_chain_count_mishits()); 
    446437            return ptnd.mishits; 
    447438        } 
     
    482473} 
    483474 
    484 static void ptnd_check_bonds(PT_pdc *pdc, int match) { 
     475static void ptnd_check_bonds(PT_pdc *pdc) { 
    485476    /*! check the average bond size. 
    486477     * 
     
    501492        tprobe->sum_bonds = sbond; 
    502493    } 
    503     match = match; 
    504494} 
    505495 
     
    628618} 
    629619 
    630 static void ptnd_check_part_inc_dt(PT_pdc *pdc, PT_probeparts *parts, 
    631                                    const DataLoc& matchLoc, 
    632                                    double dt, double sum_bonds) 
    633 { 
     620static void ptnd_check_part_inc_dt(PT_pdc *pdc, PT_probeparts *parts, const DataLoc& matchLoc, double dt, double sum_bonds) { 
    634621    //! test the probe parts, search the longest non mismatch string 
    635622 
     
    649636        while (start>=0) { 
    650637            if (pos<0) break;   // out of sight 
    651             h = ptnd_check_split(ptnd.pdc, probe, start, psg.data[matchLoc.name].data[pos]); 
     638            h = ptnd_check_split(ptnd.pdc, probe, start, psg.data[matchLoc.name].get_data()[pos]); 
    652639            if (h>0.0 && !split)        return; // there is a longer part matching this 
    653640            dt -= h; 
     
    664651    if (pos >= PERC_SIZE) return; // out of observation 
    665652    tprobe->perc[pos] ++; 
    666     if (ptnd.new_match) {                       // save the result in probematch 
    667         PT_probematch *match; 
    668         if (psg.data[matchLoc.name].match) { 
    669             if (psg.data[matchLoc.name].match->dt < ndt) return; 
    670             // there is a better hit for that sequence 
    671             match = psg.data[matchLoc.name].match; 
    672         } 
    673         else { 
    674             match = create_PT_probematch(); 
    675             aisc_link(&ptnd.locs->ppm, match); 
    676             psg.data[matchLoc.name].match = match; 
    677         } 
    678         match->name = matchLoc.name; 
    679         match->b_pos = matchLoc.apos - parts->start;     // that's not correct !!! 
    680         match->rpos = matchLoc.rpos-parts->start; 
    681         match->N_mismatches = -1;       // there are no mismatches in this mode 
    682         match->mismatches = -1; 
    683         match->wmismatches = dt;        // only weighted mismatches (maybe) 
    684         match->dt = ndt; 
    685         match->sequence = psg.main_probe; 
    686         match->reversed = psg.reversed; 
    687     } 
    688653} 
    689654static int ptnd_check_inc_mode(PT_pdc *pdc, PT_probeparts *parts, double dt, double sum_bonds) 
     
    705670     
    706671    int operator() (const DataLoc& partLoc) { 
    707         char   *probe  = psg.probe; 
    708         int     height = psg.height; 
    709         double  sbond  = ptnd.sum_bonds; 
    710         double  dt     = ptnd.dt; 
    711         double  h      = 1.0; 
    712         int     pos; 
    713         int     base; 
    714  
    715         if (!ptnd.new_match && psg.data[partLoc.name].is_group) return 0;           // don't count group or neverminds 
    716         if (probe) { 
    717             pos = partLoc.rpos+psg.height; 
    718             while (probe[height] && (base = psg.data[partLoc.name].data[pos])) { 
    719                 if (!split && (h = ptnd_check_split(ptnd.pdc, probe, height, base) < 0.0)) { 
    720                     dt -= h; 
    721                     split = 1; 
     672        if (psg.data[partLoc.name].outside_group()) { 
     673            char   *probe  = psg.probe; 
     674            int     height = psg.height; 
     675            double  sbond  = ptnd.sum_bonds; 
     676            double  dt     = ptnd.dt; 
     677            double  h      = 1.0; 
     678            int     pos; 
     679            int     base; 
     680 
     681            if (probe) { 
     682                pos = partLoc.rpos+psg.height; 
     683                while (probe[height] && (base = psg.data[partLoc.name].get_data()[pos])) { 
     684                    if (!split && (h = ptnd_check_split(ptnd.pdc, probe, height, base) < 0.0)) { 
     685                        dt -= h; 
     686                        split = 1; 
     687                    } 
     688                    else { 
     689                        dt += h; 
     690                        sbond += ptnd_check_max_bond(ptnd.pdc, probe[height]) - h; 
     691                    } 
     692                    height++; pos++; 
    722693                } 
    723                 else { 
    724                     dt += h; 
    725                     sbond += ptnd_check_max_bond(ptnd.pdc, probe[height]) - h; 
    726                 } 
    727                 height++; pos++; 
    728             } 
    729         } 
    730         ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, partLoc, dt, sbond); 
     694            } 
     695            ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, partLoc, dt, sbond); 
     696        } 
    731697        return 0; 
    732698    } 
     
    739705 
    740706    int base; 
    741     int name, apos, rpos; 
    742  
    743707    if (pt == NULL) 
    744708        return; 
    745709    if (PT_read_type(pt) == PT_NT_LEAF) { 
    746710        // @@@ dupped code is in ptnd_chain_check_part::operator() 
    747         name = PT_read_name(psg.ptmain, pt); 
    748         if (!ptnd.new_match && psg.data[name].is_group) return; 
    749         rpos = PT_read_rpos(psg.ptmain, pt); 
    750         apos = PT_read_apos(psg.ptmain, pt); 
    751         ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, DataLoc(name, apos, rpos), dt, sum_bonds); 
     711        DataLoc loc(pt); 
     712        if (psg.data[loc.name].outside_group()) { 
     713            ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, loc, dt, sum_bonds); 
     714        } 
    752715    } 
    753716    else if (PT_read_type(pt) == PT_NT_CHAIN) { 
     
    755718        ptnd.dt = dt; 
    756719        ptnd.sum_bonds = sum_bonds; 
    757         PT_forwhole_chain(psg.ptmain, pt, ptnd_chain_check_part(0)); 
     720        PT_forwhole_chain(pt, ptnd_chain_check_part(0)); 
    758721    } 
    759722    else { 
    760723        for (base = PT_QU; base< PT_B_MAX; base++) { 
    761             ptnd_check_part_all(PT_read_son(psg.ptmain, pt, (PT_BASES)base), dt, sum_bonds); 
     724            ptnd_check_part_all(PT_read_son(pt, (PT_BASES)base), dt, sum_bonds); 
    762725        } 
    763726    } 
     
    765728static void ptnd_check_part(char *probe, POS_TREE *pt, int  height, double dt, double sum_bonds, int split) { 
    766729    //! search down the tree to find matching species for the given probe 
    767     int       name; 
     730    int       pos; 
    768731    int       i; 
    769732    POS_TREE *pthelp; 
    770     int       rpos, apos, pos; 
    771733    double    ndt, nsum_bonds, h; 
    772734    int       nsplit; 
     
    778740        if (split && ptnd_check_inc_mode(ptnd.pdc, ptnd.parts, dt, sum_bonds)) return; 
    779741        for (i=PT_A; i<PT_B_MAX; i++) { 
    780             if ((pthelp = PT_read_son(psg.ptmain, pt, (PT_BASES)i))) 
     742            if ((pthelp = PT_read_son(pt, (PT_BASES)i))) 
    781743            { 
    782744                nsplit = split; 
     
    810772        if (PT_read_type(pt) == PT_NT_LEAF) { 
    811773            // @@@ dupped code is in ptnd_chain_check_part::operator() 
    812             name = PT_read_name(psg.ptmain, pt); 
    813             if (!ptnd.new_match && psg.data[name].is_group)     return; 
    814             rpos = PT_read_rpos(psg.ptmain, pt); 
    815             apos = PT_read_apos(psg.ptmain, pt); 
    816             pos = rpos + height; 
    817             if (pos + (int)(strlen(probe+height)) >= psg.data[name].size)               // after end 
    818                 return; 
    819             while (probe[height] && (ref = psg.data[name].data[pos])) { 
    820                 if (split) { 
    821                     h = ptnd_check_split(ptnd.pdc, probe, height, ref); 
    822                     if (h<0.0) dt -= h; else dt += h; 
    823                 } else if ((h = ptnd_check_split(ptnd.pdc, probe, height, 
    824                                                  ref)) < 0.0) { 
    825                     dt -= h; 
    826                     split = 1; 
     774            const DataLoc loc(pt); 
     775            if (psg.data[loc.name].outside_group()) { 
     776                pos = loc.rpos + height; 
     777                if (pos + (int)(strlen(probe+height)) >= psg.data[loc.name].get_size())               // after end 
     778                    return; 
     779                while (probe[height] && (ref = psg.data[loc.name].get_data()[pos])) { 
     780                    if (split) { 
     781                        h = ptnd_check_split(ptnd.pdc, probe, height, ref); 
     782                        if (h<0.0) dt -= h; else dt += h; 
     783                    } 
     784                    else if ((h = ptnd_check_split(ptnd.pdc, probe, height, ref)) < 0.0) { 
     785                        dt -= h; 
     786                        split = 1; 
     787                    } 
     788                    else { 
     789                        dt += h; 
     790                        sum_bonds += ptnd_check_max_bond(ptnd.pdc, probe[height]) - h; 
     791                    } 
     792                    height++; pos++; 
    827793                } 
    828                 else { 
    829                     dt += h; 
    830                     sum_bonds += ptnd_check_max_bond(ptnd.pdc, probe[height]) - h; 
    831                 } 
    832                 height++; pos++; 
    833             } 
    834             ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, DataLoc(name, apos, rpos), dt, sum_bonds); 
     794                ptnd_check_part_inc_dt(ptnd.pdc, ptnd.parts, loc, dt, sum_bonds); 
     795            } 
    835796            return; 
    836797        } 
     
    840801            ptnd.dt = dt; 
    841802            ptnd.sum_bonds = sum_bonds; 
    842             PT_forwhole_chain(psg.ptmain, pt, ptnd_chain_check_part(split)); 
     803            PT_forwhole_chain(pt, ptnd_chain_check_part(split)); 
    843804            return; 
    844805        } 
     
    895856} 
    896857 
    897 inline void PT_incr_hash(GB_HASH *hash, char *sequence, int len) { 
     858inline void PT_incr_hash(GB_HASH *hash, const char *sequence, int len) { 
    898859    char c        = sequence[len]; 
    899     sequence[len] = 0; 
     860    const_cast<char*>(sequence)[len] = 0; 
    900861 
    901862    pt_assert(strlen(sequence) == (size_t)len); 
     
    903864    GBS_incr_hash(hash, sequence); 
    904865 
    905     sequence[len] = c; 
    906 } 
    907  
    908 static void ptnd_add_sequence_to_hash(PT_pdc *pdc, GB_HASH *hash, char *sequence, int seq_len, int probe_len, char *prefix, int prefix_len) { 
     866    const_cast<char*>(sequence)[len] = c; 
     867} 
     868 
     869static void ptnd_add_sequence_to_hash(PT_pdc *pdc, GB_HASH *hash, const char *sequence, int seq_len, int probe_len, char *prefix, int prefix_len) { 
    909870    int pos; 
    910871    if (*prefix) { // partition search, else very large hash tables (>60 mbytes) 
     
    946907        int used_idx = 0; 
    947908        for (int name = 0; name < psg.data_count; name++) { 
    948             if (psg.data[name].is_group == 1) { 
     909            if (psg.data[name].inside_group()) { 
    949910                group_idx[used_idx++]                  = name; // store marked group indices 
    950                 unsigned long size                     = psg.data[name].size; 
     911                unsigned long size                     = psg.data[name].get_size(); 
    951912                datasize                              += size; 
    952913                if (datasize<size) datasize            = ULONG_MAX; // avoid overflow! 
     
    1002963        for (int g = 0; g<group_count; ++g) { 
    1003964            int      name             = group_idx[g]; 
    1004             long     possible_tprobes = psg.data[name].size-pdc->probelen+1; 
     965            long     possible_tprobes = psg.data[name].get_size()-pdc->probelen+1; 
    1005966            GB_HASH *hash_one         = GBS_create_hash(possible_tprobes*hash_multiply, GB_MIND_CASE); // count tprobe occurrences for one group/sequence 
    1006             ptnd_add_sequence_to_hash(pdc, hash_one, psg.data[name].data, psg.data[name].size, pdc->probelen, partstring, partsize); 
     967            ptnd_add_sequence_to_hash(pdc, hash_one, psg.data[name].get_data(), psg.data[name].get_size(), pdc->probelen, partstring, partsize); 
    1007968            GBS_hash_do_loop(hash_one, ptnd_collect_hash, hash_outer); // merge hash_one into hash 
    1008969#if defined(DEBUG) 
     
    10491010    //  IDP probe design 
    10501011 
    1051     PT_local *locs   = (PT_local*)pdc->mh.parent->parent; 
    1052     ptnd.new_match   = 0; 
    1053     ptnd.locs        = locs; 
    1054     ptnd.pdc         = pdc; 
     1012    PT_local *locs = (PT_local*)pdc->mh.parent->parent; 
     1013 
     1014    ptnd.locs = locs; 
     1015    ptnd.pdc  = pdc; 
    10551016 
    10561017    const char *error; 
     
    10831044    ptnd_first_check(pdc); 
    10841045    ptnd_check_position(pdc); 
    1085     ptnd_check_bonds(pdc, ptnd.new_match); 
     1046    ptnd_check_bonds(pdc); 
    10861047    ptnd_cp_tprobe_2_probepart(pdc); 
    10871048    ptnd_duplicate_probepart(pdc); 
     
    10971058} 
    10981059 
    1099 void ptnd_new_match(PT_local * locs, char *probestring) 
    1100 { 
    1101     PT_pdc     *pdc = locs->pdc; 
    1102     PT_tprobes *tprobe; 
    1103  
    1104     ptnd.locs      = locs; 
    1105     ptnd.pdc       = pdc; 
    1106     ptnd.new_match = 1; 
    1107  
    1108     if (!pdc) return; // no config 
    1109  
    1110     tprobe           = create_PT_tprobes(); 
    1111     tprobe->sequence = strdup(probestring); 
    1112  
    1113     aisc_link(&pdc->ptprobes, tprobe); 
    1114     ptnd_check_bonds(pdc, ptnd.new_match); 
    1115     ptnd_cp_tprobe_2_probepart(pdc); 
    1116     ptnd_duplicate_probepart(pdc); 
    1117     ptnd_sort_parts(pdc); 
    1118     ptnd_remove_duplicated_probepart(pdc); 
    1119     ptnd_check_probepart(pdc); 
    1120  
    1121     while (pdc->parts)                  destroy_PT_probeparts(pdc->parts); 
    1122     while ((tprobe = pdc->tprobes))     destroy_PT_tprobes(tprobe); 
    1123 } 
  • trunk/PROBE/PT_prefixtree.cxx

    r7812 r8041  
    204204} 
    205205 
    206 POS_TREE *PT_add_to_chain(PTM2 *ptmain, POS_TREE *node, int name, int apos, int rpos)   // stage1 
    207 {                                           // insert at the beginning of list 
    208     static char buffer[100]; 
     206POS_TREE *PT_add_to_chain(POS_TREE *node, const DataLoc& loc) { // stage1 
     207    // insert at the beginning of list 
     208 
     209    char *data  = (&node->data) + psg.ptmain->mode; 
     210    data       += (node->flags&1) ? 4 : 2; 
     211 
    209212    unsigned long old_first; 
    210     char *data; 
    211     int mainapos;                           // TODO: mainapos isn't used 
    212     data = (&node->data) + ptmain->mode; 
    213     if (node->flags&1) { 
    214         PT_READ_INT(data, mainapos); 
    215         data += 4; 
    216     } 
    217     else { 
    218         PT_READ_SHORT(data, mainapos); 
    219         data += 2; 
    220     } 
    221213    PT_READ_PNTR(data, old_first);  // create a new list element 
    222     char *p; 
    223     p = buffer; 
     214 
     215    static char  buffer[100]; 
     216    char        *p = buffer; 
     217 
    224218    PT_WRITE_PNTR(p, old_first); 
    225219    p += sizeof(PT_PNTR); 
    226     PT_WRITE_NAT(p, name); 
    227     PT_WRITE_NAT(p, rpos); 
    228     PT_WRITE_NAT(p, apos); 
     220 
     221    PT_WRITE_NAT(p, loc.name); 
     222    PT_WRITE_NAT(p, loc.rpos); 
     223    PT_WRITE_NAT(p, loc.apos); 
     224     
    229225    int size = p - buffer; 
    230     p = (char *)PTM_get_mem(size); 
     226    p        = (char *)PTM_get_mem(size); 
    231227    memcpy(p, buffer, size); 
    232228    PT_WRITE_PNTR(data, p); 
     
    235231} 
    236232 
    237  
    238 POS_TREE *PT_change_leaf_to_node(PTM2 * /* ptmain */, POS_TREE *node) // stage 1 
    239 { 
     233POS_TREE *PT_change_leaf_to_node(POS_TREE *node) { // stage 1 
     234    if (PT_GET_TYPE(node) != PT_NT_LEAF) PT_CORE; 
     235     
    240236    long i; 
    241     POS_TREE *father, *new_elem; 
    242     if (PT_GET_TYPE(node) != PT_NT_LEAF) PT_CORE; 
    243237    PT_READ_PNTR((&node->data), i); 
    244     father=(POS_TREE *)i; 
    245     new_elem = (POS_TREE *)PTM_get_mem(PT_EMPTY_NODE_SIZE); 
     238 
     239    POS_TREE *father   = (POS_TREE *)i; 
     240    POS_TREE *new_elem = (POS_TREE *)PTM_get_mem(PT_EMPTY_NODE_SIZE); 
    246241    if (father) PT_change_father(father, node, new_elem); 
    247242    PTM_free_mem((char *)node, PT_LEAF_SIZE(node)); 
    248243    PT_SET_TYPE(new_elem, PT_NT_NODE, 0); 
    249244    PT_WRITE_PNTR((&(new_elem->data)), (long)father); 
     245 
    250246    return new_elem; 
    251247} 
    252248 
    253 POS_TREE *PT_leaf_to_chain(PTM2 *ptmain, POS_TREE *node)        // stage 1 
    254 { 
     249POS_TREE *PT_leaf_to_chain(POS_TREE *node) { // stage 1 
     250    if (PT_GET_TYPE(node) != PT_NT_LEAF) PT_CORE; 
     251 
    255252    long i; 
    256     int apos, rpos, name; 
    257     POS_TREE *father, *new_elem; 
    258     int chain_size; 
    259     char    *data; 
    260     if (PT_GET_TYPE(node) != PT_NT_LEAF) PT_CORE; 
    261253    PT_READ_PNTR((&node->data), i); 
    262     father=(POS_TREE *)i; 
    263     name = PT_read_name(ptmain, node);                          // backup name, 
    264     apos = PT_read_apos(ptmain, node);                          //        apos, 
    265     rpos = PT_read_rpos(ptmain, node);                          //        rpos 
    266     chain_size = PT_EMPTY_CHAIN_SIZE; 
    267     if (apos>PT_SHORT_SIZE) chain_size+=2; 
    268  
    269     new_elem = (POS_TREE *)PTM_get_mem(chain_size); 
     254 
     255    POS_TREE      *father = (POS_TREE *)i; 
     256    const DataLoc  loc(node); 
     257 
     258    int chain_size                          = PT_EMPTY_CHAIN_SIZE; 
     259    if (loc.apos>PT_SHORT_SIZE) chain_size += 2; 
     260 
     261    POS_TREE *new_elem = (POS_TREE *)PTM_get_mem(chain_size); 
    270262    PT_change_father(father, node, new_elem); 
    271263    PTM_free_mem((char *)node, PT_LEAF_SIZE(node)); 
    272264    PT_SET_TYPE(new_elem, PT_NT_CHAIN, 0); 
    273     PT_WRITE_PNTR((&new_elem->data), (long)father);             // father 
    274     data = (&new_elem->data)+sizeof(PT_PNTR); 
    275     if (apos>PT_SHORT_SIZE) {                                   // mainapos 
    276         PT_WRITE_INT(data, apos);                               // . 
    277         data+=4; new_elem->flags|=1;                            // . 
    278     } 
    279     else {                                                      // . 
    280         PT_WRITE_SHORT(data, apos);                             // . 
    281         data+=2;                                                // . 
    282     } 
    283     PT_WRITE_PNTR(data, NULL);                                  // first element 
    284     PT_add_to_chain(ptmain, new_elem, name, apos, rpos); 
     265    PT_WRITE_PNTR((&new_elem->data), (long)father); 
     266     
     267    char *data = (&new_elem->data)+sizeof(PT_PNTR); 
     268    if (loc.apos>PT_SHORT_SIZE) {                                    
     269        PT_WRITE_INT(data, loc.apos);                                
     270        data+=4; 
     271        new_elem->flags|=1; 
     272    } 
     273    else {                                                       
     274        PT_WRITE_SHORT(data, loc.apos); 
     275        data+=2; 
     276    } 
     277    PT_WRITE_PNTR(data, NULL); 
     278    PT_add_to_chain(new_elem, loc); 
     279 
    285280    return new_elem; 
    286281} 
    287282 
    288 POS_TREE       * 
    289 PT_create_leaf(PTM2 *ptmain, POS_TREE ** pfather, PT_BASES base, int rpos, int apos, int name)  // stage 1 
    290 { 
    291     POS_TREE       *father, *node, *new_elemfather; 
    292     int             base2; 
    293     int     leafsize; 
    294     char        *dest; 
     283POS_TREE *PT_create_leaf(POS_TREE ** pfather, PT_BASES base, const DataLoc& loc) { // stage 1 
     284    POS_TREE *father, *node, *new_elemfather; 
     285    int       base2; 
     286    int       leafsize; 
     287    char     *dest; 
    295288    leafsize = PT_EMPTY_LEAF_SIZE; 
    296     if (rpos>PT_SHORT_SIZE) leafsize+=2; 
    297     if (apos>PT_SHORT_SIZE) leafsize+=2; 
    298     if (name>PT_SHORT_SIZE) leafsize+=2; 
    299     node = (POS_TREE *) PTM_get_mem(leafsize); 
     289 
     290    if (loc.rpos>PT_SHORT_SIZE) leafsize += 2; 
     291    if (loc.apos>PT_SHORT_SIZE) leafsize += 2; 
     292    if (loc.name>PT_SHORT_SIZE) leafsize += 2; 
     293    node                              = (POS_TREE *) PTM_get_mem(leafsize); 
    300294    if (base >= PT_B_MAX) 
    301         *(int *) 0 = 0; 
     295        *(int *) 0                    = 0; 
    302296    if (pfather) { 
    303297        int             oldfathersize; 
     
    341335    PT_SET_TYPE(node, PT_NT_LEAF, 0); 
    342336    dest = (&node->data) + sizeof(PT_PNTR); 
    343     if (name>PT_SHORT_SIZE) { 
    344         PT_WRITE_INT(dest, name); 
     337    if (loc.name>PT_SHORT_SIZE) { 
     338        PT_WRITE_INT(dest, loc.name); 
    345339        node->flags |= 1; 
    346340        dest += 4; 
    347341    } 
    348342    else { 
    349         PT_WRITE_SHORT(dest, name); 
     343        PT_WRITE_SHORT(dest, loc.name); 
    350344        dest += 2; 
    351345    } 
    352     if (rpos>PT_SHORT_SIZE) { 
    353         PT_WRITE_INT(dest, rpos); 
     346    if (loc.rpos>PT_SHORT_SIZE) { 
     347        PT_WRITE_INT(dest, loc.rpos); 
    354348        node->flags |= 2; 
    355349        dest += 4; 
    356350    } 
    357351    else { 
    358         PT_WRITE_SHORT(dest, rpos); 
     352        PT_WRITE_SHORT(dest, loc.rpos); 
    359353        dest += 2; 
    360354    } 
    361     if (apos>PT_SHORT_SIZE) { 
    362         PT_WRITE_INT(dest, apos); 
     355    if (loc.apos>PT_SHORT_SIZE) { 
     356        PT_WRITE_INT(dest, loc.apos); 
    363357        node->flags |= 4; 
    364358        dest += 4; 
    365359    } 
    366360    else { 
    367         PT_WRITE_SHORT(dest, apos); 
     361        PT_WRITE_SHORT(dest, loc.apos); 
    368362        dest += 2; 
    369363    } 
    370364    if (base == PT_QU) 
    371         return PT_leaf_to_chain(ptmain, node); 
     365        return PT_leaf_to_chain(node); 
    372366    return node; 
    373367} 
    374  
    375368 
    376369// ------------------------------------ 
    377370//      functions for stage 1: save 
    378371 
    379 void PTD_clear_fathers(PTM2 *ptmain, POS_TREE * node)       // stage 1 
    380 { 
    381     POS_TREE       *sons; 
    382     int i; 
    383     PT_NODE_TYPE    type = PT_read_type(node); 
    384     if (type == PT_NT_SAVED) return; 
    385     PT_WRITE_PNTR((&node->data), NULL); 
    386     if (type == PT_NT_NODE) { 
    387         for (i = PT_QU; i < PT_B_MAX; i++) { 
    388             sons = PT_read_son(ptmain, node, (PT_BASES)i); 
    389             if (sons) 
    390                 PTD_clear_fathers(ptmain, sons); 
     372void PTD_clear_fathers(POS_TREE * node) { // stage 1 
     373    PT_NODE_TYPE type = PT_read_type(node); 
     374    if (type != PT_NT_SAVED) { 
     375        PT_WRITE_PNTR((&node->data), NULL); 
     376        if (type == PT_NT_NODE) { 
     377            for (int i = PT_QU; i < PT_B_MAX; i++) { 
     378                POS_TREE *sons = PT_read_son(node, (PT_BASES)i); 
     379                if (sons) PTD_clear_fathers(sons); 
     380            } 
    391381        } 
    392382    } 
     
    445435} 
    446436 
    447 long PTD_write_tip_to_disk(FILE * out, PTM2 * /* ptmain */, POS_TREE * node, long pos) 
     437long PTD_write_tip_to_disk(FILE * out, POS_TREE * node, long pos) 
    448438{ 
    449439    int size, cnt; 
     
    490480} 
    491481 
    492 ARB_ERROR ptd_write_chain_entries(FILE * out, long *ppos, PTM2 * /* ptmain */, char ** entry_tab,  int n_entries, int mainapos) { // __ATTR__USERESULT 
     482ARB_ERROR ptd_write_chain_entries(FILE * out, long *ppos, char ** entry_tab,  int n_entries, int mainapos) { // __ATTR__USERESULT 
    493483    ARB_ERROR   error; 
    494484    int         lastname = 0; 
     
    530520 
    531521 
    532 long PTD_write_chain_to_disk(FILE * out, PTM2 *ptmain, POS_TREE * node, long pos, ARB_ERROR& error) { 
     522long PTD_write_chain_to_disk(FILE * out, POS_TREE * node, long pos, ARB_ERROR& error) { 
    533523    char *data; 
    534524    long oldpos = pos; 
     
    536526    pos++; 
    537527    int mainapos; 
    538     data = (&node->data) + ptmain->mode; 
     528    data = (&node->data) + psg.ptmain->mode; 
    539529 
    540530    if (node->flags&1) { 
     
    556546        char **entry_tab = (char **)GB_calloc(sizeof(char *), n_entries); 
    557547        ptd_set_chain_references((char *)first_entry, entry_tab); 
    558         error = ptd_write_chain_entries(out, &pos, ptmain, entry_tab, n_entries, mainapos); 
     548        error = ptd_write_chain_entries(out, &pos, entry_tab, n_entries, mainapos); 
    559549        free(entry_tab); 
    560550    } 
     
    593583} 
    594584 
    595 long PTD_write_node_to_disk(FILE * out, PTM2 *ptmain, POS_TREE * node, long *r_poss, long pos) { 
     585long PTD_write_node_to_disk(FILE * out, POS_TREE * node, long *r_poss, long pos) { 
    596586    int i, size;   // Save node after all descendends are already saved 
    597587    POS_TREE *sons; 
     
    606596 
    607597    for (i = PT_QU; i < PT_B_MAX; i++) {    // free all sons 
    608         sons = PT_read_son(ptmain, node, (PT_BASES)i); 
     598        sons = PT_read_son(node, (PT_BASES)i); 
    609599        if (sons) { 
    610600            int memsize; 
     
    759749} 
    760750 
    761 long PTD_write_leafs_to_disk(FILE * out, PTM2 *ptmain, POS_TREE * node, long pos, long *pnodepos, int *pblock, ARB_ERROR& error) { 
     751long PTD_write_leafs_to_disk(FILE * out, POS_TREE * node, long pos, long *pnodepos, int *pblock, ARB_ERROR& error) { 
    762752    // returns new pos when son is written 0 otherwise 
    763753    // pnodepos is set to last object 
     
    778768    else if (type == PT_NT_LEAF) { 
    779769        *pnodepos = pos; 
    780         pos = PTD_write_tip_to_disk(out, ptmain, node, pos); 
     770        pos = PTD_write_tip_to_disk(out, node, pos); 
    781771    } 
    782772    else if (type == PT_NT_CHAIN) { 
    783773        *pnodepos = pos; 
    784         pos = PTD_write_chain_to_disk(out, ptmain, node, pos, error); 
     774        pos = PTD_write_chain_to_disk(out, node, pos, error); 
    785775    } 
    786776    else if (type == PT_NT_NODE) { 
     
    788778        o_pos = pos; 
    789779        for (i = PT_QU; i < PT_B_MAX && !error; i++) {    // save all sons 
    790             sons = PT_read_son(ptmain, node, (PT_BASES)i); 
     780            sons = PT_read_son(node, (PT_BASES)i); 
    791781            r_poss[i] = 0; 
    792782            if (sons) { 
    793                 r_pos = PTD_write_leafs_to_disk(out, ptmain, sons, pos, &(r_poss[i]), &(block[0]), error); 
     783                r_pos = PTD_write_leafs_to_disk(out, sons, pos, &(r_poss[i]), &(block[0]), error); 
    794784                if (r_pos>pos) {        // really saved ???? 
    795785                    son_size[i] = r_pos-pos; 
     
    813803        else {          // now i can write my data 
    814804            *pnodepos = pos; 
    815             if (!error) pos = PTD_write_node_to_disk(out, ptmain, node, r_poss, pos); 
     805            if (!error) pos = PTD_write_node_to_disk(out, node, r_poss, pos); 
    816806        } 
    817807    } 
     
    824814 
    825815 
    826 ARB_ERROR PTD_read_leafs_from_disk(const char *fname, PTM2 *ptmain, POS_TREE **pnode) { // __ATTR__USERESULT 
     816ARB_ERROR PTD_read_leafs_from_disk(const char *fname, POS_TREE **pnode) { // __ATTR__USERESULT 
    827817    GB_ERROR  error  = NULL; 
    828818    char     *buffer = GB_map_file(fname, 0); 
     
    892882            pt_assert(i >= 0); 
    893883 
    894             *pnode             = (POS_TREE *)(i+buffer); 
    895             ptmain->mode       = 0; 
    896             ptmain->data_start = buffer; 
     884            *pnode = (POS_TREE *)(i+buffer); 
     885 
     886            psg.ptmain->mode       = 0; 
     887            psg.ptmain->data_start = buffer; 
    897888        } 
    898889    } 
  • trunk/PROBE/needs_libs

    r6865 r8041  
    44SERVERCNTRL/SERVERCNTRL.a 
    55SL/HELIX/HELIX.a 
     6SL/PTCLEAN/PTCLEAN.a 
    67 
  • trunk/PROBE/probe.h

    r7986 r8041  
    5050#define FINDANSWER   52                             // private msg type: find result answer 
    5151 
     52extern int gene_flag;           // if 'gene_flag' == 1 -> we are a gene pt server 
    5253extern ULONG physical_memory; 
    5354struct Hs_struct; 
     
    100101//      Probe search 
    101102 
    102 struct probe_statistic { 
    103     int    match_count;                             // Counter for matches 
    104     double rel_match_count;                         // match_count / (seq_len - probe_len + 1) 
    105 }; 
    106  
    107 struct probe_input_data {                           // every taxa's own data 
    108     char   *data;                                   // sequence 
    109     long    checksum; 
    110     int     size; 
     103class probe_input_data : virtual Noncopyable {      // every taxa's own data 
     104 
     105    char *data;       // sequence 
     106    long  checksum;   // checksum of sequence 
     107    int   size; 
     108 
    111109    char   *name; 
    112110    char   *fullname; 
    113111    GBDATA *gbd; 
    114112 
    115     // probe design 
    116     int is_group;                                   // -1: nevermind, 0: no group, 1: group 
    117  
    118     // probe design (match) 
    119     PT_probematch *match;                           // best hit for PT_new_design 
    120  
    121     // find family 
    122     probe_statistic stat; 
    123  
    124     int next; 
     113    bool group;           // probe_design: whether species is in group 
     114 
     115    // obsolete methods below @@@ remove them 
     116    GBDATA *get_gbdata() const { return gbd; } 
     117    void set_data(char *assign, int size_) { pt_assert(!data); data = assign; size = size_; } 
     118    void set_checksum(long cs) { checksum = cs; } 
     119     
     120public: 
     121 
     122    probe_input_data() 
     123        : data(0), 
     124          checksum(0),  
     125          size(0),  
     126          name(0),  
     127          fullname(0),  
     128          gbd(0),  
     129          group(false)  
     130    {} 
     131    ~probe_input_data() { 
     132        free(data); 
     133        free(name); 
     134        free(fullname); 
     135    } 
     136 
     137    GB_ERROR init(GBDATA *gbd_); 
     138 
     139    const char *get_data() const { return data; } 
     140    char *read_alignment(int *psize) const; 
     141 
     142    const char *get_name() const { return name; } 
     143    const char *get_fullname() const { return fullname; } 
     144    long get_checksum() const { return checksum; } 
     145    int get_size() const { return size; } 
     146 
     147    bool inside_group() const { return group; } 
     148    bool outside_group() const { return !group; } 
     149 
     150    void set_group_state(bool isGroupMember) { group = isGroupMember; } 
     151 
     152    long get_abspos() const { 
     153        pt_assert(gene_flag); // only legal in gene-ptserver 
     154        GBDATA *gb_pos = GB_entry(get_gbdata(), "abspos"); 
     155        if (gb_pos) return GB_read_int(gb_pos); 
     156        return -1; 
     157    } 
     158 
     159private: 
    125160}; 
    126161 
     
    198233    GB_HASH  *namehash;                             // name to int 
    199234 
     235    int                      data_count; 
    200236    struct probe_input_data *data;                  // the internal database 
    201237 
     
    203239    BI_ecoli_ref *bi_ecoli; 
    204240 
    205     int  data_count; 
    206241    int  max_size;                                  // maximum sequence len 
    207242    long char_count;                                // number of all 'acgtuACGTU' 
     
    284319}; 
    285320 
    286 extern int gene_flag;           // if 'gene_flag' == 1 -> we are a gene pt server 
    287  
    288321struct ltByArbName { 
    289322    bool operator()(const gene_struct *gs1, const gene_struct *gs2) const { 
     
    313346#error probe.h included twice 
    314347#endif 
     348 
     349 
  • trunk/PROBE/probe_tree.h

    r7933 r8041  
    411411// calculate the index of the pointer in a node 
    412412 
    413 inline POS_TREE *PT_read_son(PTM2 *ptmain, POS_TREE *node, PT_BASES base) 
     413inline POS_TREE *PT_read_son(POS_TREE *node, PT_BASES base) 
    414414{ 
    415     long i; 
    416     UINT sec; 
    417     UINT offset; 
     415    long  i; 
     416    UINT  sec; 
     417    UINT  offset; 
     418    PTM2 *ptmain = psg.ptmain; 
    418419    if (ptmain->stage3) {       // stage 3  no father 
    419420        if (node->flags & IS_SINGLE_BRANCH_NODE) { 
     
    503504} 
    504505 
    505 inline POS_TREE *PT_read_son_stage_1(PTM2 *ptmain, POS_TREE *node, PT_BASES base) 
    506 { 
    507     long i; 
     506inline POS_TREE *PT_read_son_stage_1(POS_TREE *node, PT_BASES base) { 
    508507    if (!((1<<base) & node->flags)) return NULL;   // bit not set 
    509508    base = (PT_BASES)PT_count_bits[base][node->flags]; 
    510     PT_READ_PNTR((&node->data)+sizeof(PT_PNTR)*base+ptmain->mode, i); 
    511     return (POS_TREE *)(i+ptmain->data_start); // ptmain->data_start == 0x00 in stage 1 
     509    long i; 
     510    PT_READ_PNTR((&node->data)+sizeof(PT_PNTR)*base+psg.ptmain->mode, i); 
     511    return (POS_TREE *)(i+psg.ptmain->data_start); // psg.ptmain->data_start == 0x00 in stage 1 
    512512} 
    513513 
     
    517517} 
    518518 
    519 inline int PT_read_name(PTM2 *ptmain, POS_TREE *node) 
    520 { 
    521     int i; 
    522     if (node->flags&1) { 
    523         PT_READ_INT((&node->data)+ptmain->mode, i); 
    524     } 
    525     else { 
    526         PT_READ_SHORT((&node->data)+ptmain->mode, i); 
    527     } 
    528     pt_assert(i >= 0); 
    529     return i; 
    530 } 
    531  
    532 inline int PT_read_rpos(PTM2 *ptmain, POS_TREE *node) 
    533 { 
    534     int i; 
    535     char *data = (&node->data)+2+ptmain->mode; 
    536     if (node->flags&1) data+=2; 
    537     if (node->flags&2) { 
    538         PT_READ_INT(data, i); 
    539     } 
    540     else { 
    541         PT_READ_SHORT(data, i); 
    542     } 
    543     pt_assert(i >= 0); 
    544     return i; 
    545 } 
    546  
    547 inline int PT_read_apos(PTM2 *ptmain, POS_TREE *node) 
    548 { 
    549     int i; 
    550     char *data = (&node->data)+ptmain->mode+4;  // father 4 name 2 rpos 2 
    551     if (node->flags&1) data+=2; 
    552     if (node->flags&2) data+=2; 
    553     if (node->flags&4) { 
    554         PT_READ_INT(data, i); 
    555     } 
    556     else { 
    557         PT_READ_SHORT(data, i); 
    558     } 
    559     pt_assert(i >= 0); 
    560     return i; 
    561 } 
    562  
    563519struct DataLoc { 
    564     int name; 
     520    int name; // index into psg.data[], aka as species id 
    565521    int apos; 
    566     int rpos; 
     522    int rpos; // position in data 
    567523 
    568524    void init(const char ** data, int pos) { 
    569525        *data = PT_READ_CHAIN_ENTRY(*data, pos, &name, &apos, &rpos); 
    570526    } 
    571     void init(PTM2 *ptmain, POS_TREE *pt) { 
    572         pt_assert(PT_read_type(pt) == PT_NT_LEAF); 
    573  
    574         name = PT_read_name(ptmain, pt); 
    575         apos = PT_read_apos(ptmain, pt); 
    576         rpos = PT_read_rpos(ptmain, pt); 
     527    void init(POS_TREE *node) { 
     528        pt_assert(PT_read_type(node) == PT_NT_LEAF); 
     529        char *data = (&node->data)+psg.ptmain->mode; 
     530        if (node->flags&1) { PT_READ_INT(data, name); data += 4; } else { PT_READ_SHORT(data, name); data += 2; } 
     531        if (node->flags&2) { PT_READ_INT(data, rpos); data += 4; } else { PT_READ_SHORT(data, rpos); data += 2; } 
     532        if (node->flags&4) { PT_READ_INT(data, apos); data += 4; } else { PT_READ_SHORT(data, apos); data += 2; } 
     533 
     534        pt_assert(name >= 0); 
     535        pt_assert(apos >= 0); 
     536        pt_assert(rpos >= 0); 
    577537    } 
    578538 
    579539    DataLoc(int name_, int apos_, int rpos_) : name(name_), apos(apos_), rpos(rpos_) {} 
    580     DataLoc(const char ** data, int pos) { 
    581         name = 0; 
    582         init(data, pos); 
    583     } 
    584     DataLoc(PTM2 *ptmain, POS_TREE *pt) { 
    585         init(ptmain, pt); 
    586     } 
     540    DataLoc(POS_TREE *pt) { init(pt); } 
     541    DataLoc(const char ** data, int pos) { name = 0; init(data, pos); } 
     542 
     543    const probe_input_data& get_pid() const { pt_assert(name >= 0 && name<psg.data_count); return psg.data[name]; } 
     544    const char *get_data() const { return get_pid().get_data(); } 
     545    PT_BASES operator[](int offset) const { return PT_BASES(get_data()[rpos+offset]); } 
     546 
     547    int restlength() const { return get_pid().get_size()-rpos; } 
     548    bool is_shorther_than(int offset) const { return offset >= restlength(); } 
    587549 
    588550#if defined(DEBUG) 
    589551    void dump(FILE *fp) const { 
    590         fprintf(fp, "          apos=%6i  rpos=%6i  name=%6i='%s'\n", apos, rpos, name, psg.data[name].name); 
     552        fprintf(fp, "          apos=%6i  rpos=%6i  name=%6i='%s'\n", apos, rpos, name, psg.data[name].get_name()); 
    591553        fflush(fp); 
    592554    } 
     
    595557 
    596558template<typename T> 
    597 int PT_forwhole_chain(PTM2 *ptmain, POS_TREE *node, T func) { 
     559int PT_forwhole_chain(POS_TREE *node, T func) { 
    598560    pt_assert(PT_read_type(node) == PT_NT_CHAIN); 
    599561 
    600     const char *data = (&node->data) + ptmain->mode; 
     562    const char *data = (&node->data) + psg.ptmain->mode; 
    601563    int         pos; 
    602564 
     
    621583 
    622584template<typename T> 
    623 int PT_withall_tips(PTM2 *ptmain, POS_TREE *node, T func) { 
     585int PT_withall_tips(POS_TREE *node, T func) { 
    624586    // like PT_forwhole_chain, but also can handle leafs 
    625587    PT_NODE_TYPE type = PT_read_type(node); 
    626588    if (type == PT_NT_LEAF) { 
    627         return func(DataLoc(ptmain, node)); 
     589        return func(DataLoc(node)); 
    628590    } 
    629591 
    630592    pt_assert(type == PT_NT_CHAIN); 
    631     return PT_forwhole_chain(ptmain, node, func); 
     593    return PT_forwhole_chain(node, func); 
    632594} 
    633595 
  • trunk/PROBE/pt_prototypes.h

    r7986 r8041  
    1313 
    1414/* PT_buildtree.cxx */ 
    15 POS_TREE *build_pos_tree(POS_TREE *pt, int anfangs_pos, int apos, int RNS_nr, unsigned int end); 
    16 long PTD_save_partial_tree(FILE *out, PTM2 *ptmain, POS_TREE *node, char *partstring, int partsize, long pos, long *ppos, ARB_ERROR &error); 
     15 
     16 class DataLoc; 
     17 
     18long PTD_save_partial_tree(FILE *out, POS_TREE *node, char *partstring, int partsize, long pos, long *ppos, ARB_ERROR &error); 
    1719ARB_ERROR enter_stage_1_build_tree(PT_main *, char *tname) __ATTR__USERESULT; 
    1820ARB_ERROR enter_stage_3_load_tree(PT_main *, const char *tname) __ATTR__USERESULT; 
     
    4042int compress_data(char *probestring); 
    4143void PT_base_2_string(char *id_string, long len); 
    42 ARB_ERROR probe_read_data_base(const char *name) __ATTR__USERESULT; 
     44ARB_ERROR probe_read_data_base(const char *name, bool readOnly) __ATTR__USERESULT; 
    4345int probe_compress_sequence(char *seq, int seqsize); 
    4446char *probe_read_alignment(int j, int *psize); 
     
    5355void PT_init_psg(void); 
    5456void PT_exit_psg(void); 
    55 void PT_exit(int exitcode) __ATTR__NORETURN; 
     57void PT_exit(void); 
    5658GB_ERROR PT_init_map(void) __ATTR__USERESULT; 
    5759 
     
    7678char *get_design_hinfo(PT_tprobes *tprobe); 
    7779int PT_start_design(PT_pdc *pdc, int dummy_1x); 
    78 void ptnd_new_match(PT_local *locs, char *probestring); 
    7980 
    8081/* PT_prefixtree.cxx */ 
     
    8889PTM2 *PT_init(void); 
    8990void PT_change_father(POS_TREE *father, POS_TREE *source, POS_TREE *dest); 
    90 POS_TREE *PT_add_to_chain(PTM2 *ptmain, POS_TREE *node, int name, int apos, int rpos); 
    91 POS_TREE *PT_change_leaf_to_node(PTM2 *, POS_TREE *node); 
    92 POS_TREE *PT_leaf_to_chain(PTM2 *ptmain, POS_TREE *node); 
    93 POS_TREE *PT_create_leaf(PTM2 *ptmain, POS_TREE **pfather, PT_BASES base, int rpos, int apos, int name); 
    94 void PTD_clear_fathers(PTM2 *ptmain, POS_TREE *node); 
     91POS_TREE *PT_add_to_chain(POS_TREE *node, const DataLoc &loc); 
     92POS_TREE *PT_change_leaf_to_node(POS_TREE *node); 
     93POS_TREE *PT_leaf_to_chain(POS_TREE *node); 
     94POS_TREE *PT_create_leaf(POS_TREE **pfather, PT_BASES base, const DataLoc &loc); 
     95void PTD_clear_fathers(POS_TREE *node); 
    9596void PTD_put_longlong(FILE *out, ULONG i); 
    9697void PTD_put_int(FILE *out, ULONG i); 
    9798void PTD_put_short(FILE *out, ULONG i); 
    9899void PTD_set_object_to_saved_status(POS_TREE *node, long pos, int size); 
    99 long PTD_write_tip_to_disk(FILE *out, PTM2 *, POS_TREE *node, long pos); 
     100long PTD_write_tip_to_disk(FILE *out, POS_TREE *node, long pos); 
    100101int ptd_count_chain_entries(char *entry); 
    101102void ptd_set_chain_references(char *entry, char **entry_tab); 
    102 ARB_ERROR ptd_write_chain_entries(FILE *out, long *ppos, PTM2 *, char **entry_tab, int n_entries, int mainapos) __ATTR__USERESULT; 
    103 long PTD_write_chain_to_disk(FILE *out, PTM2 *ptmain, POS_TREE *node, long pos, ARB_ERROR &error); 
     103ARB_ERROR ptd_write_chain_entries(FILE *out, long *ppos, char **entry_tab, int n_entries, int mainapos) __ATTR__USERESULT; 
     104long PTD_write_chain_to_disk(FILE *out, POS_TREE *node, long pos, ARB_ERROR &error); 
    104105void PTD_debug_nodes(void); 
    105 long PTD_write_node_to_disk(FILE *out, PTM2 *ptmain, POS_TREE *node, long *r_poss, long pos); 
    106 long PTD_write_leafs_to_disk(FILE *out, PTM2 *ptmain, POS_TREE *node, long pos, long *pnodepos, int *pblock, ARB_ERROR &error); 
    107 ARB_ERROR PTD_read_leafs_from_disk(const char *fname, PTM2 *ptmain, POS_TREE **pnode) __ATTR__USERESULT; 
     106long PTD_write_node_to_disk(FILE *out, POS_TREE *node, long *r_poss, long pos); 
     107long PTD_write_leafs_to_disk(FILE *out, POS_TREE *node, long pos, long *pnodepos, int *pblock, ARB_ERROR &error); 
     108ARB_ERROR PTD_read_leafs_from_disk(const char *fname, POS_TREE **pnode) __ATTR__USERESULT; 
    108109 
    109110/* PT_debug.cxx */ 
     
    113114 
    114115/* probe_tree.h */ 
    115 template <typename T >int PT_forwhole_chain(PTM2 *ptmain, POS_TREE *node, T func); 
    116 template <typename T >int PT_withall_tips(PTM2 *ptmain, POS_TREE *node, T func); 
     116template <typename T >int PT_forwhole_chain(POS_TREE *node, T func); 
     117template <typename T >int PT_withall_tips(POS_TREE *node, T func); 
    117118 
    118119#else 
  • trunk/SERVERCNTRL/servercntrl.cxx

    r7811 r8041  
    153153 
    154154            if (!error) { 
    155 #if defined(DEBUG) 
    156                 printf("Starting server (cmd='%s')\n", command); 
    157 #endif // DEBUG 
     155                printf("[Starting server (cmd='%s')]\n", command); 
    158156                if (!gbmain || GBCMC_system(gbmain, command)) system(command); 
    159157                if (do_sleep) sleep(delay); 
  • trunk/SL/Makefile

    r7801 r8041  
    11 
    22ARCHS_ALL = \ 
     3        PTCLEAN/PTCLEAN.dummy  \ 
    34        ALIVIEW/ALIVIEW.dummy  \ 
    45        AP_TREE/AP_TREE.dummy  \ 
  • trunk/SL/PTCLEAN

    • Property svn:ignore set to
      *.bak
      *.gcno
  • trunk/SL/PTCLEAN/Makefile

    r7993 r8041  
    3333ptclean.o: ptclean.h 
    3434ptclean.o: $(ARBHOME)/INCLUDE/ad_prot.h 
     35ptclean.o: $(ARBHOME)/INCLUDE/ad_t_prot.h 
    3536ptclean.o: $(ARBHOME)/INCLUDE/arb_assert.h 
    3637ptclean.o: $(ARBHOME)/INCLUDE/arb_core.h 
     
    4041ptclean.o: $(ARBHOME)/INCLUDE/arbdb.h 
    4142ptclean.o: $(ARBHOME)/INCLUDE/arbdb_base.h 
     43ptclean.o: $(ARBHOME)/INCLUDE/arbdbt.h 
    4244ptclean.o: $(ARBHOME)/INCLUDE/arbtools.h 
    4345ptclean.o: $(ARBHOME)/INCLUDE/attributes.h 
  • trunk/SL/PTCLEAN/ptclean.cxx

    r7993 r8041  
    1111 
    1212#include "ptclean.h" 
    13 #include <arbdb.h> 
     13#include <arbdbt.h> 
     14 
     15#define pt_assert(cond) arb_assert(cond) 
    1416 
    1517// using namespace std; 
    1618 
    17 GB_ERROR clean_ptserver_database(GBDATA *gb_main, Servertype type) { 
    18     fprintf(stderr, "********* clean_ptserver_database does not delete anything yet\n"); 
    19     // return "test-error"; 
    20     return NULL; 
     19class EntryTempMarker : virtual Noncopyable { 
     20    // marks all entries of DB as 'temp', that are of no use for PTSERVER 
     21    // (Note: 'temp' entries will not be saved) 
     22 
     23    GBDATA         *gb_main; 
     24    GB_transaction  ta; 
     25    Servertype      type; 
     26    char           *ali_name; 
     27 
     28    enum Need { 
     29        NONE, 
     30        ALL, 
     31        SOME_OF_ROOT, 
     32        SOME_OF_PRESETS, 
     33        SOME_OF_SPECIES_DATA, 
     34        SOME_OF_EXTENDED_DATA, 
     35        SOME_OF_SPECIES, 
     36        SOME_OF_EXTENDED, 
     37        SOME_OF_ALI_CONTAINER, // below species or SAI 
     38    }; 
     39 
     40    Need data_needed(GBDATA *gbd, const char *keyname, Need from) const { 
     41        switch (from) { 
     42            case SOME_OF_ROOT: 
     43                if (strcmp(keyname, "__SYSTEM__")    == 0) return ALL; 
     44                if (strcmp(keyname, "genom_db")      == 0) return ALL; 
     45                if (strcmp(keyname, "gene_map")      == 0) return ALL; 
     46                if (strcmp(keyname, "species_data")  == 0) return SOME_OF_SPECIES_DATA; 
     47                if (strcmp(keyname, "extended_data") == 0) return SOME_OF_EXTENDED_DATA; 
     48                if (strcmp(keyname, "presets")       == 0) return SOME_OF_PRESETS; 
     49                break; 
     50 
     51            case SOME_OF_SPECIES_DATA: 
     52                if (strcmp(keyname, "species") == 0) return SOME_OF_SPECIES; 
     53                break; 
     54 
     55            case SOME_OF_EXTENDED_DATA: 
     56                if (strcmp(keyname, "extended") == 0) { 
     57                    const char *sainame = GBT_read_name(gbd); 
     58                    if (strcmp(sainame, "ECOLI") == 0) return SOME_OF_EXTENDED; // only "need" ECOLI  
     59                } 
     60                break; 
     61 
     62            case SOME_OF_SPECIES: 
     63            case SOME_OF_EXTENDED: 
     64                if (from == SOME_OF_SPECIES) { 
     65                    if (strcmp(keyname, "abspos") == 0) return ALL; 
     66                } 
     67                if (strcmp(keyname, "name")      == 0) return ALL; 
     68                if (strcmp(keyname, "acc")       == 0) return ALL; 
     69                if (strcmp(keyname, "full_name") == 0) return ALL; 
     70                if (strcmp(keyname, ali_name)    == 0) return SOME_OF_ALI_CONTAINER; 
     71                break; 
     72 
     73            case SOME_OF_PRESETS: 
     74                if (strcmp(keyname, "use") == 0) return ALL; 
     75                break; 
     76 
     77            case SOME_OF_ALI_CONTAINER: 
     78                if (strcmp(keyname, "data") == 0) return ALL; 
     79                break; 
     80 
     81            case NONE: pt_assert(0); break; 
     82            case ALL:  pt_assert(0); break; 
     83        } 
     84 
     85        return NONE; 
     86    } 
     87 
     88    GB_ERROR mark_child(GBDATA *gb_entry, const char *keyname, Need from) { 
     89        GB_ERROR error = 0; 
     90        Need     need  = data_needed(gb_entry, keyname, from); 
     91        switch (need) { 
     92            case NONE: error = GB_set_temporary(gb_entry); break; 
     93            case ALL:  pt_assert(!GB_is_temporary(gb_entry)); break; 
     94            default:   error = mark_subentries(gb_entry, need); break; 
     95        } 
     96        return error; 
     97    } 
     98    GB_ERROR mark_subentries(GBDATA *gb_father, Need from) { 
     99        GB_ERROR error = 0; 
     100        if (!GB_is_temporary(gb_father)) { 
     101            for (GBDATA *gb_child = GB_child(gb_father); gb_child && !error; gb_child = GB_nextChild(gb_child)) { 
     102                const char *key = GB_read_key_pntr(gb_child); 
     103                error           = mark_child(gb_child, key, from); 
     104            } 
     105        } 
     106        return error; 
     107    } 
     108 
     109public: 
     110    EntryTempMarker(Servertype type_, GBDATA *gb_main_) 
     111        : gb_main(gb_main_), 
     112          ta(gb_main), 
     113          type(type_), 
     114          ali_name(GBT_get_default_alignment(gb_main)) 
     115    {} 
     116    ~EntryTempMarker() { free(ali_name); } 
     117 
     118    GB_ERROR mark_unwanted_entries() { return mark_subentries(gb_main, SOME_OF_ROOT); } 
     119}; 
     120 
     121inline GB_ERROR clean_ptserver_database(GBDATA *gb_main, Servertype type) { 
     122    return EntryTempMarker(type, gb_main).mark_unwanted_entries(); 
    21123} 
    22124 
     125GB_ERROR prepare_ptserver_database(GBDATA *gb_main, Servertype type) { 
     126    GB_ERROR error = GB_request_undo_type(gb_main, GB_UNDO_NONE); 
     127    if (!error) { 
     128        GB_push_my_security(gb_main); 
     129        error = clean_ptserver_database(gb_main, type); 
     130        if (!error) { 
     131            // @@@ calculate bp and checksums 
     132        } 
     133        GB_pop_my_security(gb_main); 
     134    } 
     135    return error; 
     136} 
    23137// -------------------------------------------------------------------------------- 
    24138 
     
    29143 
    30144void TEST_ptclean() { 
    31     GB_shell  shell; 
    32     GBDATA   *gb_main = GB_open("TEST_pt_src.arb", "rw"); 
     145    GB_shell    shell; 
     146    GBDATA     *gb_main = GB_open("TEST_pt_src.arb", "rw"); 
     147    const char *saveas  = "TEST_pt_cleaned.arb"; 
    33148 
    34149    TEST_ASSERT(gb_main); 
    35     TEST_ASSERT_NO_ERROR(clean_ptserver_database(gb_main, PTSERVER)); 
    36     TEST_ASSERT_NO_ERROR(GB_save_as(gb_main, "TEST_pt_cleaned.arb", "a")); 
     150    TEST_ASSERT_NO_ERROR(prepare_ptserver_database(gb_main, PTSERVER)); 
     151    TEST_ASSERT_NO_ERROR(GB_save_as(gb_main, saveas, "a")); 
    37152    GB_close(gb_main); 
    38153 
    39 #define TEST_AUTO_UPDATE 
     154// #define TEST_AUTO_UPDATE 
    40155#if defined(TEST_AUTO_UPDATE) 
    41156    TEST_COPY_FILE("TEST_pt_cleaned.arb", "TEST_pt_cleaned_expected.arb"); 
    42157#else 
    43     TEST_ASSERT_FILES_EQUAL("TEST_pt_cleaned.arb", "TEST_pt_cleaned_expected.arb"); 
     158    TEST_ASSERT_TEXTFILES_EQUAL("TEST_pt_cleaned.arb", "TEST_pt_cleaned_expected.arb"); 
    44159#endif 
     160    TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink(saveas)); 
    45161} 
    46162 
  • trunk/SL/PTCLEAN/ptclean.h

    r7993 r8041  
    2222}; 
    2323 
    24 GB_ERROR clean_ptserver_database(GBDATA *gb_main, Servertype type); 
     24GB_ERROR prepare_ptserver_database(GBDATA *gb_main, Servertype type); 
    2525 
    2626#else 
  • trunk/SOURCE_TOOLS/dep.4dummy

    r7935 r8041  
    2424PHYLO/PHYLO.dummy: AWT/AWT.dummy SL/MATRIX/MATRIX.dummy 
    2525PRIMER_DESIGN/PRIMER_DESIGN.dummy: AWT/AWT.dummy 
    26 PROBE/PROBE.dummy: PROBE_COM/PROBE_COM.dummy SERVERCNTRL/SERVERCNTRL.dummy SL/HELIX/HELIX.dummy 
     26PROBE/PROBE.dummy: PROBE_COM/PROBE_COM.dummy SERVERCNTRL/SERVERCNTRL.dummy SL/HELIX/HELIX.dummy SL/PTCLEAN/PTCLEAN.dummy 
    2727PROBE_DESIGN/PROBE_DESIGN.dummy: SERVERCNTRL/SERVERCNTRL.dummy SL/TREEDISP/TREEDISP.dummy 
    2828RNA3D/RNA3D.dummy: AWT/AWT.dummy GL/glAW/glAW.dummy GL/glpng/glpng.dummy SL/HELIX/HELIX.dummy 
     
    4848SL/NEIGHBOURJOIN/NEIGHBOURJOIN.dummy: ARBDB/ARBDB.dummy 
    4949SL/PRONUC/PRONUC.dummy: ARBDB/ARBDB.dummy 
     50SL/PTCLEAN/PTCLEAN.dummy: ARBDB/ARBDB.dummy 
    5051SL/REFENTRIES/REFENTRIES.dummy: WINDOW/WINDOW.dummy 
    5152SL/REGEXPR/REGEXPR.dummy: ARBDB/ARBDB.dummy 
  • trunk/SOURCE_TOOLS/dep.alltargets

    r7935 r8041  
    4848SL/NEIGHBOURJOIN/NEIGHBOURJOIN.a 
    4949SL/PRONUC/PRONUC.a 
     50SL/PTCLEAN/PTCLEAN.a 
    5051SL/REFENTRIES/REFENTRIES.a 
    5152SL/REGEXPR/REGEXPR.a 
  • trunk/SOURCE_TOOLS/dep.libtargets

    r7935 r8041  
    4848SL/NEIGHBOURJOIN/NEIGHBOURJOIN.a 
    4949SL/PRONUC/PRONUC.a 
     50SL/PTCLEAN/PTCLEAN.a 
    5051SL/REFENTRIES/REFENTRIES.a 
    5152SL/REGEXPR/REGEXPR.a 
  • trunk/SOURCE_TOOLS/generate_all_links.sh

    r7916 r8041  
    278278symlink_file ../SL/PRONUC/AP_pro_a_nucs.hxx INCLUDE/AP_pro_a_nucs.hxx && 
    279279symlink_file ../SL/PRONUC/iupac.h INCLUDE/iupac.h && 
     280symlink_file ../SL/PTCLEAN/ptclean.h INCLUDE/ptclean.h && 
    280281symlink_file ../SL/REFENTRIES/refentries.h INCLUDE/refentries.h && 
    281282symlink_file ../SL/REGEXPR/RegExpr.hxx INCLUDE/RegExpr.hxx && 
  • trunk/TOOLS/arb_probe.cxx

    r7986 r8041  
    319319 
    320320#ifdef UNIT_TESTS 
    321     const int minServerID   = TEST_SERVER_ID; 
     321    const int minServerID   = TEST_GENESERVER_ID; 
    322322#else // !UNIT_TESTS 
    323323    const int minServerID   = 0; 
     
    326326    P.SERVERID = getInt("serverid", 0, minServerID, 100, "Server Id, look into $ARBHOME/lib/arb_tcp.dat"); 
    327327#ifdef UNIT_TESTS 
    328     if (P.SERVERID<0) { arb_assert(P.SERVERID == TEST_SERVER_ID); } 
     328    if (P.SERVERID<0) { arb_assert(P.SERVERID == TEST_SERVER_ID || P.SERVERID == TEST_GENESERVER_ID); } 
    329329#endif 
    330330 
     
    455455#endif 
    456456 
    457 static void test_setup() { 
    458     static bool setup = false; 
    459     if (!setup) { 
    460         TEST_SETUP_GLOBAL_ENVIRONMENT("ptserver"); // first call will recreate the test pt-server 
    461         setup = true; 
    462     } 
     457static int test_setup(bool use_gene_ptserver) { 
     458    static bool setup[2] = { false, false }; 
     459    if (!setup[use_gene_ptserver]) { 
     460        TEST_SETUP_GLOBAL_ENVIRONMENT(use_gene_ptserver ? "ptserver_gene" : "ptserver"); // first call will recreate the test pt-server 
     461        setup[use_gene_ptserver] = true; 
     462    } 
     463    return use_gene_ptserver ? TEST_GENESERVER_ID : TEST_SERVER_ID; 
    463464} 
    464465 
    465466void TEST_SLOW_variable_defaults_in_server() { 
    466     test_setup(); 
     467    test_setup(false); 
    467468 
    468469    const char *server_tag = GBS_ptserver_tag(TEST_SERVER_ID); 
     
    524525//      test probe design / match 
    525526 
    526 #define TEST_PART1(fake_argc,fake_argv)                                 \ 
    527     test_setup();                                                       \ 
    528     TEST_ASSERT_EQUAL(true, parseCommandLine(fake_argc, fake_argv));    \ 
    529     P.SERVERID = TEST_SERVER_ID;                                        \ 
    530     ARB_ERROR  error;                                                   \ 
    531     char      *answer = execute(error);                                 \ 
    532     TEST_ASSERT_NO_ERROR(error.deliver());                              \ 
     527#define TEST_PART1(fake_argc,fake_argv)                                                 \ 
     528    int       serverid = test_setup(use_gene_ptserver);                                 \ 
     529    TEST_ASSERT_EQUAL(true, parseCommandLine(fake_argc, fake_argv));                    \ 
     530    TEST_ASSERT((serverid == TEST_SERVER_ID)||(serverid == TEST_GENESERVER_ID));        \ 
     531    P.SERVERID         = serverid;                                                      \ 
     532    ARB_ERROR error;                                                                    \ 
     533    char      *answer   = execute(error);                                               \ 
     534    TEST_ASSERT_NO_ERROR(error.deliver()) 
    533535 
    534536 
     
    553555    } while(0) 
    554556 
     557typedef const char *CCP; 
    555558void TEST_SLOW_match_probe() { 
    556     typedef const char *CCP; 
    557     { 
    558         const char *arguments[] = { 
    559             "fake", // "program"-name 
     559    bool use_gene_ptserver = false; 
     560    { 
     561        const char *arguments[] = { 
     562            "prgnamefake", 
    560563            "matchsequence=UAUCGGAGAGUUUGA", 
    561564        }; 
    562         CCP expected = "    name---- fullname mis N_mis wmis pos rev          'UAUCGGAGAGUUUGA'\1" 
    563             "BcSSSS00\1" "  BcSSSS00            0     0  0.0   3 0   .......UU-===============-UCAAGUCGA\1"; 
     565        CCP expected = "    name---- fullname mis N_mis wmis pos ecoli rev          'UAUCGGAGAGUUUGA'\1" 
     566            "BcSSSS00\1" "  BcSSSS00            0     0  0.0   3     2 0   .......UU-===============-UCAAGUCGA\1"; 
    564567 
    565568        TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expected); 
     
    571574    { 
    572575        const char *arguments[] = { 
    573             "fake", // "program"-name 
     576            "prgnamefake", 
    574577            "matchsequence=CANCUCCUUUC", // contains 1 N 
    575578            NULL // matchmismatches 
    576579        }; 
    577580 
    578         CCP expectd0 = "    name---- fullname mis N_mis wmis pos rev          'CANCUCCUUUC'\1" 
    579             "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176 0   CGGCUGGAU-==C========-U\1"; // only N-mismatch accepted 
    580  
    581         CCP expectd1 = "    name---- fullname mis N_mis wmis pos rev          'CANCUCCUUUC'\1" 
    582             "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176 0   CGGCUGGAU-==C========-U\1"  
    583             "PbcAcet2\1" "  PbcAcet2            0     2  0.0 176 0   CGGCUGGAU-==C=======N-N\1"  
    584             "ClfPerfr\1" "  ClfPerfr            1     1  0.0 176 0   AGAUUAAUA-=CC========-U\1"; 
    585  
    586         CCP expectd2 = "    name---- fullname mis N_mis wmis pos rev          'CANCUCCUUUC'\1" 
    587             "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176 0   CGGCUGGAU-==C========-U\1" 
    588             "PbcAcet2\1" "  PbcAcet2            0     2  0.0 176 0   CGGCUGGAU-==C=======N-N\1" 
    589             "DlcTolu2\1" "  DlcTolu2            0     3  0.0 176 0   CGGCUGGAU-==C======NN-N\1" 
    590             "ClfPerfr\1" "  ClfPerfr            1     1  0.0 176 0   AGAUUAAUA-=CC========-U\1"; 
     581        CCP expectd0 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCUCCUUUC'\1" 
     582            "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176   162 0   CGGCUGGAU-==C========-U\1" ""; // only N-mismatch accepted 
     583 
     584        CCP expectd1 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCUCCUUUC'\1" 
     585            "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176   162 0   CGGCUGGAU-==C========-U\1" 
     586            "PbcAcet2\1" "  PbcAcet2            0     2  0.0 176   162 0   CGGCUGGAU-==C=======N-N\1" 
     587            "ClfPerfr\1" "  ClfPerfr            1     1  0.0 176   162 0   AGAUUAAUA-=CC========-U\1"; 
     588 
     589        CCP expectd2 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCUCCUUUC'\1" 
     590            "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176   162 0   CGGCUGGAU-==C========-U\1" 
     591            "PbcAcet2\1" "  PbcAcet2            0     2  0.0 176   162 0   CGGCUGGAU-==C=======N-N\1" 
     592            "DlcTolu2\1" "  DlcTolu2            0     3  0.0 176   162 0   CGGCUGGAU-==C======NN-N\1" 
     593            "ClfPerfr\1" "  ClfPerfr            1     1  0.0 176   162 0   AGAUUAAUA-=CC========-U\1"; 
     594 
     595        arguments[2] = "matchmismatches=0";  TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 
     596        arguments[2] = "matchmismatches=1";  TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1); 
     597        arguments[2] = "matchmismatches=2";  TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 
     598    } 
     599    { 
     600        const char *arguments[] = { 
     601            "prgnamefake", 
     602            "matchsequence=UCACCUCCUUUC", // contains no N 
     603            NULL // matchmismatches 
     604        }; 
     605 
     606        CCP expectd0 = "    name---- fullname mis N_mis wmis pos ecoli rev          'UCACCUCCUUUC'\1" 
     607            "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175   161 0   GCGGCUGGA-============-U\1" 
     608            "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175   161 0   GCGGCUGGA-===========N-N\1"; 
     609 
     610        CCP expectd1 = "    name---- fullname mis N_mis wmis pos ecoli rev          'UCACCUCCUUUC'\1" 
     611            "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175   161 0   GCGGCUGGA-============-U\1" 
     612            "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175   161 0   GCGGCUGGA-===========N-N\1" 
     613            "DlcTolu2\1" "  DlcTolu2            0     2  0.0 175   161 0   GCGGCUGGA-==========NN-N\1" ""; 
     614 
     615        CCP expectd2 = "    name---- fullname mis N_mis wmis pos ecoli rev          'UCACCUCCUUUC'\1" 
     616            "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175   161 0   GCGGCUGGA-============-U\1" 
     617            "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175   161 0   GCGGCUGGA-===========N-N\1" 
     618            "DlcTolu2\1" "  DlcTolu2            0     2  0.0 175   161 0   GCGGCUGGA-==========NN-N\1" 
     619            "ClfPerfr\1" "  ClfPerfr            2     0  0.0 175   161 0   AAGAUUAAU-A=C=========-U\1" ""; 
    591620 
    592621        arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 
     
    594623        arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 
    595624    } 
    596     { 
    597         const char *arguments[] = { 
    598             "fake", // "program"-name 
    599             "matchsequence=UCACCUCCUUUC", // contains no N 
    600             NULL // matchmismatches 
    601         }; 
    602  
    603         CCP expectd0 = "    name---- fullname mis N_mis wmis pos rev          'UCACCUCCUUUC'\1" 
    604             "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175 0   GCGGCUGGA-============-U\1" 
    605             "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175 0   GCGGCUGGA-===========N-N\1" ""; 
    606  
    607         CCP expectd1 = "    name---- fullname mis N_mis wmis pos rev          'UCACCUCCUUUC'\1" 
    608             "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175 0   GCGGCUGGA-============-U\1" 
    609             "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175 0   GCGGCUGGA-===========N-N\1" 
    610             "DlcTolu2\1" "  DlcTolu2            0     2  0.0 175 0   GCGGCUGGA-==========NN-N\1" ""; 
    611  
    612         CCP expectd2 = "    name---- fullname mis N_mis wmis pos rev          'UCACCUCCUUUC'\1" 
    613             "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175 0   GCGGCUGGA-============-U\1" 
    614             "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175 0   GCGGCUGGA-===========N-N\1" 
    615             "DlcTolu2\1" "  DlcTolu2            0     2  0.0 175 0   GCGGCUGGA-==========NN-N\1" 
    616             "ClfPerfr\1" "  ClfPerfr            2     0  0.0 175 0   AAGAUUAAU-A=C=========-U\1" ""; 
     625 
     626    // ---------------------------------------------- 
     627    //      do not accept any N-matches as match 
     628 
     629    { 
     630        const char *arguments[] = { 
     631            "prgnamefake", 
     632            "matchsequence=CANCUCCUUUC", // contains 1 N 
     633            NULL, // matchmismatches 
     634            "matchacceptN=0", 
     635        }; 
     636 
     637        CCP expectd0 = ""; // nothing matches 
     638 
     639        CCP expectd1 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCUCCUUUC'\1" 
     640            "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176   162 0   CGGCUGGAU-==C========-U\1" ""; 
     641  
     642        CCP expectd2 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCUCCUUUC'\1" 
     643            "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176   162 0   CGGCUGGAU-==C========-U\1" 
     644            "PbcAcet2\1" "  PbcAcet2            0     2  0.0 176   162 0   CGGCUGGAU-==C=======N-N\1" 
     645            "ClfPerfr\1" "  ClfPerfr            1     1  0.0 176   162 0   AGAUUAAUA-=CC========-U\1" ""; 
    617646 
    618647        arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 
     
    620649        arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 
    621650    } 
    622  
    623     // ---------------------------------------------- 
    624     //      do not accept any N-matches as match 
    625  
    626     { 
    627         const char *arguments[] = { 
    628             "fake", // "program"-name 
    629             "matchsequence=CANCUCCUUUC", // contains 1 N 
    630             NULL, // matchmismatches 
    631             "matchacceptN=0", 
    632         }; 
    633  
    634         CCP expectd0 = ""; // nothing matches 
    635  
    636         CCP expectd1 = "    name---- fullname mis N_mis wmis pos rev          'CANCUCCUUUC'\1" 
    637             "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176 0   CGGCUGGAU-==C========-U\1" ""; 
    638  
    639         CCP expectd2 = "    name---- fullname mis N_mis wmis pos rev          'CANCUCCUUUC'\1" 
    640             "BcSSSS00\1" "  BcSSSS00            0     1  0.0 176 0   CGGCUGGAU-==C========-U\1" 
    641             "PbcAcet2\1" "  PbcAcet2            0     2  0.0 176 0   CGGCUGGAU-==C=======N-N\1" 
    642             "ClfPerfr\1" "  ClfPerfr            1     1  0.0 176 0   AGAUUAAUA-=CC========-U\1" ""; 
    643  
    644         arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 
    645         arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1); 
    646         arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 
    647     } 
    648     { 
    649         const char *arguments[] = { 
    650             "fake", // "program"-name 
     651    { 
     652        const char *arguments[] = { 
     653            "prgnamefake", 
    651654            "matchsequence=UCACCUCCUUUC", // contains no N 
    652655            NULL, // matchmismatches 
     
    654657        }; 
    655658 
    656         CCP expectd0 = "    name---- fullname mis N_mis wmis pos rev          'UCACCUCCUUUC'\1" 
    657             "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175 0   GCGGCUGGA-============-U\1" ""; 
    658  
    659         CCP expectd1 = "    name---- fullname mis N_mis wmis pos rev          'UCACCUCCUUUC'\1" 
    660             "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175 0   GCGGCUGGA-============-U\1" 
    661             "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175 0   GCGGCUGGA-===========N-N\1" ""; 
    662  
    663         CCP expectd2 = "    name---- fullname mis N_mis wmis pos rev          'UCACCUCCUUUC'\1" 
    664             "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175 0   GCGGCUGGA-============-U\1" 
    665             "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175 0   GCGGCUGGA-===========N-N\1" 
    666             "DlcTolu2\1" "  DlcTolu2            0     2  0.0 175 0   GCGGCUGGA-==========NN-N\1" 
    667             "ClfPerfr\1" "  ClfPerfr            2     0  0.0 175 0   AAGAUUAAU-A=C=========-U\1" ""; 
     659        CCP expectd0 = "    name---- fullname mis N_mis wmis pos ecoli rev          'UCACCUCCUUUC'\1" 
     660            "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175   161 0   GCGGCUGGA-============-U\1" ""; 
     661 
     662        CCP expectd1 = "    name---- fullname mis N_mis wmis pos ecoli rev          'UCACCUCCUUUC'\1" 
     663            "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175   161 0   GCGGCUGGA-============-U\1" 
     664            "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175   161 0   GCGGCUGGA-===========N-N\1" ""; 
     665 
     666        CCP expectd2 = "    name---- fullname mis N_mis wmis pos ecoli rev          'UCACCUCCUUUC'\1" 
     667            "BcSSSS00\1" "  BcSSSS00            0     0  0.0 175   161 0   GCGGCUGGA-============-U\1" 
     668            "PbcAcet2\1" "  PbcAcet2            0     1  0.0 175   161 0   GCGGCUGGA-===========N-N\1" 
     669            "DlcTolu2\1" "  DlcTolu2            0     2  0.0 175   161 0   GCGGCUGGA-==========NN-N\1" 
     670            "ClfPerfr\1" "  ClfPerfr            2     0  0.0 175   161 0   AAGAUUAAU-A=C=========-U\1" ""; 
    668671         
    669672        arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 
     
    677680    { 
    678681        const char *arguments[] = { 
    679             "fake", // "program"-name 
     682            "prgnamefake", 
    680683            "matchsequence=CANCUCCUUNC", // contains 2 N 
    681684            NULL, // matchmismatches 
     
    684687        }; 
    685688 
    686         CCP expectd0 = "    name---- fullname mis N_mis wmis pos rev          'CANCUCCUUNC'\1" 
    687             "BcSSSS00\1" "  BcSSSS00            0     2  0.0 176 0   CGGCUGGAU-==C======U=-U\1" ""; 
     689        CCP expectd0 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCUCCUUNC'\1" 
     690            "BcSSSS00\1" "  BcSSSS00            0     2  0.0 176   162 0   CGGCUGGAU-==C======U=-U\1" ""; 
     691 
     692        CCP expectd1 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCUCCUUNC'\1" 
     693            "BcSSSS00\1" "  BcSSSS00            0     2  0.0 176   162 0   CGGCUGGAU-==C======U=-U\1" 
     694            "DlcTolu2\1" "  DlcTolu2            0     3  0.0 176   162 0   CGGCUGGAU-==C=======N-N\1" 
     695            "PbcAcet2\1" "  PbcAcet2            0     3  0.0 176   162 0   CGGCUGGAU-==C======UN-N\1" 
     696            "ClfPerfr\1" "  ClfPerfr            1     2  0.0 176   162 0   AGAUUAAUA-=CC======U=-U\1" ""; 
    688697         
    689         CCP expectd1 = "    name---- fullname mis N_mis wmis pos rev          'CANCUCCUUNC'\1" 
    690             "BcSSSS00\1" "  BcSSSS00            0     2  0.0 176 0   CGGCUGGAU-==C======U=-U\1" 
    691             "DlcTolu2\1" "  DlcTolu2            0     3  0.0 176 0   CGGCUGGAU-==C=======N-N\1" 
    692             "PbcAcet2\1" "  PbcAcet2            0     3  0.0 176 0   CGGCUGGAU-==C======UN-N\1" 
    693             "ClfPerfr\1" "  ClfPerfr            1     2  0.0 176 0   AGAUUAAUA-=CC======U=-U\1" ""; 
    694          
    695         CCP expectd2 = "    name---- fullname mis N_mis wmis pos rev          'CANCUCCUUNC'\1" 
    696             "BcSSSS00\1" "  BcSSSS00            0     2  0.0 176 0   CGGCUGGAU-==C======U=-U\1" 
    697             "DlcTolu2\1" "  DlcTolu2            0     3  0.0 176 0   CGGCUGGAU-==C=======N-N\1" 
    698             "PbcAcet2\1" "  PbcAcet2            0     3  0.0 176 0   CGGCUGGAU-==C======UN-N\1" 
    699             "ClfPerfr\1" "  ClfPerfr            1     2  0.0 176 0   AGAUUAAUA-=CC======U=-U\1" ""; 
     698        CCP expectd2 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCUCCUUNC'\1" 
     699            "BcSSSS00\1" "  BcSSSS00            0     2  0.0 176   162 0   CGGCUGGAU-==C======U=-U\1" 
     700            "DlcTolu2\1" "  DlcTolu2            0     3  0.0 176   162 0   CGGCUGGAU-==C=======N-N\1" 
     701            "PbcAcet2\1" "  PbcAcet2            0     3  0.0 176   162 0   CGGCUGGAU-==C======UN-N\1" 
     702            "ClfPerfr\1" "  ClfPerfr            1     2  0.0 176   162 0   AGAUUAAUA-=CC======U=-U\1" ""; 
    700703         
    701704        arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 
     
    709712    { 
    710713        const char *arguments[] = { 
    711             "fake", // "program"-name 
     714            "prgnamefake", 
    712715            "matchsequence=CANCNCNNUNC", // contains 5N 
    713716            NULL, // matchmismatches 
     
    717720        }; 
    718721 
    719         CCP expectd0 = "    name---- fullname mis N_mis wmis pos rev          'CANCNCNNUNC'\1" 
    720             "BcSSSS00\1" "  BcSSSS00            0     5  0.0 176 0   CGGCUGGAU-==C=U=CU=U=-U\1" ""; 
    721              
    722         CCP expectd1 = "    name---- fullname mis N_mis wmis pos rev          'CANCNCNNUNC'\1"  
    723             "BcSSSS00\1" "  BcSSSS00            0     5  0.0 176 0   CGGCUGGAU-==C=U=CU=U=-U\1" 
    724             "DlcTolu2\1" "  DlcTolu2            0     6  0.0 176 0   CGGCUGGAU-==C=U=CU==N-N\1" 
    725             "PbcAcet2\1" "  PbcAcet2            0     6  0.0 176 0   CGGCUGGAU-==C=U=CU=UN-N\1" 
    726             "LgtLytic\1" "  LgtLytic            1     5  0.0  31 0   GUCGAACGG-==G=A=AG=CU-AGCUUGCUA\1" 
    727             "ClfPerfr\1" "  ClfPerfr            1     5  0.0 111 0   CGGCUGGAU-==U=AUAA=G=-AGCGAUUGG\1"; // one hit is truncated here 
     722        CCP expectd0 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCNCNNUNC'\1" 
     723            "BcSSSS00\1" "  BcSSSS00            0     5  0.0 176   162 0   CGGCUGGAU-==C=U=CU=U=-U\1" ""; 
     724 
     725        CCP expectd1 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCNCNNUNC'\1" 
     726            "BcSSSS00\1" "  BcSSSS00            0     5  0.0 176   162 0   CGGCUGGAU-==C=U=CU=U=-U\1" 
     727            "DlcTolu2\1" "  DlcTolu2            0     6  0.0 176   162 0   CGGCUGGAU-==C=U=CU==N-N\1" 
     728            "PbcAcet2\1" "  PbcAcet2            0     6  0.0 176   162 0   CGGCUGGAU-==C=U=CU=UN-N\1" 
     729            "LgtLytic\1" "  LgtLytic            1     5  0.0  31    26 0   GUCGAACGG-==G=A=AG=CU-AGCUUGCUA\1" 
     730            "ClfPerfr\1" "  ClfPerfr            1     5  0.0 111    99 0   CGGCUGGAU-==U=AUAA=G=-AGCGAUUGG\1"; // one hit is truncated here 
    728731         
    729         CCP expectd2 = "    name---- fullname mis N_mis wmis pos rev          'CANCNCNNUNC'\1" 
    730             "VbrFurni\1" "  VbrFurni            2     5  0.0  40 0   CGGCAGCGA-==A=AUUGAA=-CUUCGGGGG\1" 
    731             "HllHalod\1" "  HllHalod            2     5  0.0  45 0   AAACGAUGG-A=G=UUGC=U=-CAGGCGUCG\1" 
    732             "VblVulni\1" "  VblVulni            2     5  0.0  49 0   AGCACAGAG-A=A=UUGU=U=-UCGGGUGGC\1" 
    733             "LgtLytic\1" "  LgtLytic            2     5  0.0 101 0   GGGGAAACU-==AGCUAA=A=-CGCAUAAUC\1" 
    734             "ClfPerfr\1" "  ClfPerfr            2     5  0.0 172 0   AGGAAGAUU-A=UAC=CC=C=-UUUCU\1" ""; // many hits are truncated here 
     732        CCP expectd2 = "    name---- fullname mis N_mis wmis pos ecoli rev          'CANCNCNNUNC'\1" 
     733            "VbrFurni\1" "  VbrFurni            2     5  0.0  40    35 0   CGGCAGCGA-==A=AUUGAA=-CUUCGGGGG\1" 
     734            "HllHalod\1" "  HllHalod            2     5  0.0  45    40 0   AAACGAUGG-A=G=UUGC=U=-CAGGCGUCG\1" 
     735            "VblVulni\1" "  VblVulni            2     5  0.0  49    44 0   AGCACAGAG-A=A=UUGU=U=-UCGGGUGGC\1" 
     736            "LgtLytic\1" "  LgtLytic            2     5  0.0 101    89 0   GGGGAAACU-==AGCUAA=A=-CGCAUAAUC\1" 
     737            "ClfPerfr\1" "  ClfPerfr            2     5  0.0 172   158 0   AGGAAGAUU-A=UAC=CC=C=-UUUCU\1"; // many hits are truncated here 
    735738 
    736739        arguments[2] = "matchmismatches=0"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd0); 
    737740        arguments[2] = "matchmismatches=1"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd1); 
    738741        arguments[2] = "matchmismatches=2"; TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd2); 
     742    } 
     743} 
     744 
     745void TEST_SLOW_match_geneprobe() { 
     746    bool use_gene_ptserver = true; 
     747    { 
     748        const char *arguments[] = { 
     749            "prgnamefake", 
     750            "matchsequence=NNUCNN", 
     751            "matchacceptN=4",  
     752            "matchlimitN=5",  
     753        }; 
     754        CCP expectd = "    organism genename------- mis N_mis wmis pos gpos rev          'NNUCNN'\1" 
     755            "genome2\1" "  genome2  gene3             0     4  0.0   2    1 0   .........-UU==GG-UUGAUC\1" 
     756            "genome2\1" "  genome2  joined1           0     4  0.0   2    1 0   .........-UU==GG-UUGAUCCUG\1" 
     757            "genome2\1" "  genome2  gene2             0     4  0.0  10    4 0   ......GUU-GA==CU-GCCA\1" 
     758            "genome2\1" "  genome2  intergene_19_65   0     4  0.0  31   12 0   GGUUACUGC-AU==GG-UGUUCGCCU\1" 
     759            "genome1\1" "  genome1  intergene_17_65   0     4  0.0  31   14 0   GGUUACUGC-UA==GG-UGUUCGCCU\1" 
     760            "genome2\1" "  genome2  intergene_19_65   0     4  0.0  38   19 0   GCAUUCGGU-GU==GC-CUAAGCACU\1" 
     761            "genome1\1" "  genome1  intergene_17_65   0     4  0.0  38   21 0   GCUAUCGGU-GU==GC-CUAAGCCAU\1" 
     762            "genome1\1" "  genome1  intergene_17_65   0     4  0.0  56   39 0   AGCCAUGCG-AG==AU-AUGUA\1" ""; 
     763         
     764        TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); 
     765    } 
     766    { 
     767        const char *arguments[] = { 
     768            "prgnamefake", 
     769            "matchsequence=NGGUUN", 
     770            "matchacceptN=2",  
     771            "matchlimitN=3",  
     772        }; 
     773        CCP expectd = "    organism genename------- mis N_mis wmis pos gpos rev          'NGGUUN'\1" 
     774            "genome1\1" "  genome1  joined1           0     2  0.0   5    2 0   ........C-U====G-AUCCUGC\1" 
     775            "genome2\1" "  genome2  intergene_19_65   0     2  0.0  21    2 0   ........G-A====A-CUGCAUUCG\1" 
     776            "genome1\1" "  genome1  intergene_17_65   0     2  0.0  21    4 0   ......CAG-A====A-CUGCUAUCG\1" 
     777            "genome2\1" "  genome2  gene3             0     2  0.0   5    4 0   ......UUU-C====G-AUC\1" 
     778            "genome2\1" "  genome2  joined1           0     2  0.0   5    4 0   ......UUU-C====G-AUCCUGCCA\1" ""; 
     779 
     780        TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); 
     781    } 
     782 
     783    { 
     784        const char *arguments[] = { 
     785            "prgnamefake", 
     786            "matchsequence=UGAUCCU", // exists in data 
     787        }; 
     788        CCP expectd = "    organism genename mis N_mis wmis pos gpos rev          'UGAUCCU'\1" 
     789            "genome1\1" "  genome1  gene2      0     0  0.0   9    1 0   .........-=======-GC\1" 
     790            "genome2\1" "  genome2  gene2      0     0  0.0   9    3 0   .......GU-=======-GCCA\1" ""; 
     791 
     792        TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: probe exists as well in 'joined1' (of both genomes) 
     793    } 
     794    { 
     795        const char *arguments[] = { 
     796            "prgnamefake", 
     797            "matchsequence=GAUCCU", 
     798        }; 
     799        CCP expectd = "    organism genename mis N_mis wmis pos gpos rev          'GAUCCU'\1" 
     800            "genome2\1" "  genome2  gene2      0     0  0.0  10    4 0   ......GUU-======-GCCA\1" ""; 
     801 
     802        TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: probe is part of above probe, but reports less hits 
     803    } 
     804    { 
     805        const char *arguments[] = { 
     806            "prgnamefake", 
     807            "matchsequence=UUUCGG", // exists only in genome2  
     808        }; 
     809        CCP expectd = "    organism genename mis N_mis wmis pos gpos rev          'UUUCGG'\1" 
     810            "genome2\1" "  genome2  gene3      0     0  0.0   2    1 0   .........-======-UUGAUC\1" 
     811            "genome2\1" "  genome2  joined1    0     0  0.0   2    1 0   .........-======-UUGAUCCUG\1" ""; 
     812 
     813        TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: also exists in genome2/gene1 
     814    } 
     815    { 
     816        const char *arguments[] = { 
     817            "prgnamefake", 
     818            "matchsequence=AUCCUG",  
     819        }; 
     820        CCP expectd = "    organism genename mis N_mis wmis pos gpos rev          'AUCCUG'\1" 
     821            "genome2\1" "  genome2  gene2      0     0  0.0  11    5 0   .....GUUG-======-CCA\1" ""; 
     822 
     823        TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: exists in 'gene2' and 'joined1' of both genomes 
     824    } 
     825    { 
     826        const char *arguments[] = { 
     827            "prgnamefake", 
     828            "matchsequence=UUGAUCCUGC", 
     829        }; 
     830        CCP expectd = "    organism genename mis N_mis wmis pos gpos rev          'UUGAUCCUGC'\1" 
     831            "genome2\1" "  genome2  gene2      0     0  0.0   8    2 0   ........G-==========-CA\1" 
     832            "genome1\1" "  genome1  joined1    0     0  0.0   8    5 0   .....CUGG-==========-\1" ""; 
     833 
     834        TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expectd); // @@@ defect: also exists in 'genome2/joined1' 
    739835    } 
    740836} 
     
    773869 
    774870void TEST_SLOW_design_probe() { 
     871    bool use_gene_ptserver = false; 
    775872    const char *arguments[] = { 
    776         "fake", // "program"-name 
     873        "prgnamefake", 
    777874        "designnames=ClnCorin#CltBotul#CPPParap#ClfPerfr", 
    778875        "designmintargets=100", 
     
    787884        "Min Group Hits       100%\n" 
    788885        "Target             le     apos ecol grps  G+C 4GC+2AT Probe sequence     | Decrease T by n*.3C -> probe matches n non group species\n" 
    789         "CGAAAGGAAGAUUAAUAC 18 A=    94   94    4 33.3 48.0    GUAUUAAUCUUCCUUUCG |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
    790         "GAAAGGAAGAUUAAUACC 18 A+     1   95    4 33.3 48.0    GGUAUUAAUCUUCCUUUC |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
    791         "UCAAGUCGAGCGAUGAAG 18 B=    18   18    4 50.0 54.0    CUUCAUCGCUCGACUUGA |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
    792         "AUCAAGUCGAGCGAUGAA 18 B-     1   17    4 44.4 52.0    UUCAUCGCUCGACUUGAU |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  2,  3,\n"; 
     886        "CGAAAGGAAGAUUAAUAC 18 A=    94   82    4 33.3 48.0    GUAUUAAUCUUCCUUUCG |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
     887        "GAAAGGAAGAUUAAUACC 18 A+     1   83    4 33.3 48.0    GGUAUUAAUCUUCCUUUC |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
     888        "UCAAGUCGAGCGAUGAAG 18 B=    18   17    4 50.0 54.0    CUUCAUCGCUCGACUUGA |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
     889        "AUCAAGUCGAGCGAUGAA 18 B-     1   16    4 44.4 52.0    UUCAUCGCUCGACUUGAU |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  2,  3,\n"; 
    793890 
    794891    TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expected); 
     
    804901 
    805902    const char *arguments_loc[] = { 
    806         "fake", // "program"-name 
     903        "prgnamefake", 
    807904        // "designnames=Stsssola#Stsssola", // @@@ crashes the ptserver 
    808905        "designnames=CPPParap#PsAAAA00", 
     
    823920 
    824921void TEST_SLOW_match_designed_probe() { 
     922    bool use_gene_ptserver = false; 
    825923    const char *arguments[] = { 
    826         "fake", // "program"-name  
     924        "prgnamefake",  
    827925        "matchsequence=UCAAGUCGAGCGAUGAAG",  
    828926    }; 
    829     const char *expected = 
    830     "    name---- fullname mis N_mis wmis pos rev          'UCAAGUCGAGCGAUGAAG'\1" 
    831     "ClnCorin\1" "  ClnCorin            0     0  0.0  18 0   .GAGUUUGA-==================-UUCCUUCGG\1" 
    832     "CltBotul\1" "  CltBotul            0     0  0.0  18 0   ........A-==================-CUUCUUCGG\1" 
    833     "CPPParap\1" "  CPPParap            0     0  0.0  18 0   AGAGUUUGA-==================-UUCCUUCGG\1" 
    834     "ClfPerfr\1" "  ClfPerfr            0     0  0.0  18 0   AGAGUUUGA-==================-UUUCCUUCG\1"; 
     927    CCP expected = "    name---- fullname mis N_mis wmis pos ecoli rev          'UCAAGUCGAGCGAUGAAG'\1" 
     928        "ClnCorin\1" "  ClnCorin            0     0  0.0  18    17 0   .GAGUUUGA-==================-UUCCUUCGG\1" 
     929        "CltBotul\1" "  CltBotul            0     0  0.0  18    17 0   ........A-==================-CUUCUUCGG\1" 
     930        "CPPParap\1" "  CPPParap            0     0  0.0  18    17 0   AGAGUUUGA-==================-UUCCUUCGG\1" 
     931        "ClfPerfr\1" "  ClfPerfr            0     0  0.0  18    17 0   AGAGUUUGA-==================-UUUCCUUCG\1"; 
    835932 
    836933    TEST_ARB_PROBE(ARRAY_ELEMS(arguments), arguments, expected); 
  • trunk/TOOLS/arb_test.cxx

    r8037 r8041  
    6666    TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink("ascii2bin.ARF")); 
    6767    TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink("ascii2bin2.ARF")); 
    68 } 
    69  
    70 void TEST_SLOW_arb_gene_probe() { 
    71     const char *genome   = "tools/gene_probe.arb"; 
    72     const char *out      = "tools/gene_probe_out.arb"; 
    73     const char *expected = "tools/gene_probe_expected.arb"; 
    74  
    75     TEST_RUN_TOOL(GBS_global_string("arb_gene_probe %s %s", genome, out)); 
    76     TEST_ASSERT_FILES_EQUAL(out, expected); 
    77     TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink(out)); 
    78     TEST_ASSERT_ZERO_OR_SHOW_ERRNO(GB_unlink("tools/gene_probe_out.ARM")); 
    7968} 
    8069 
     
    181170 
    182171void TEST_arb_replace() { 
    183     const char *infile = "tools/gene_probe.arb"; 
     172    const char *infile = "tools/arb_replace.in"; 
    184173    const char *file1  = "tools/arb_replace_1.out"; 
    185174    const char *file2  = "tools/arb_replace_2.out"; 
     
    299288                       " matchsequence=UAUCGGAGAGUUUGA", 
    300289 
    301                        "    name---- fullname mis N_mis wmis pos rev          'UAUCGGAGAGUUUGA'" 
    302                        "BcSSSS00" 
    303                        "  BcSSSS00            0     0  0.0   3 0   .......UU-===============-UCAAGUCGA" 
    304                        ); 
     290                       /* ---- */ "    name---- fullname mis N_mis wmis pos ecoli rev          'UAUCGGAGAGUUUGA'\1" 
     291                       "BcSSSS00\1" "  BcSSSS00            0     0  0.0   3     2 0   .......UU-===============-UCAAGUCGA\1" 
     292        ); 
    305293 
    306294    TEST_STDOUT_EQUALS("arb_probe" 
     
    317305                       "Min Group Hits       100%\n" 
    318306                       "Target             le     apos ecol grps  G+C 4GC+2AT Probe sequence     | Decrease T by n*.3C -> probe matches n non group species\n" 
    319                        "CGAAAGGAAGAUUAAUAC 18 A=    94   94    4 33.3 48.0    GUAUUAAUCUUCCUUUCG |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
    320                        "GAAAGGAAGAUUAAUACC 18 A+     1   95    4 33.3 48.0    GGUAUUAAUCUUCCUUUC |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
    321                        "UCAAGUCGAGCGAUGAAG 18 B=    18   18    4 50.0 54.0    CUUCAUCGCUCGACUUGA |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
    322                        "AUCAAGUCGAGCGAUGAA 18 B-     1   17    4 44.4 52.0    UUCAUCGCUCGACUUGAU |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  2,  3,\n" 
     307                       "CGAAAGGAAGAUUAAUAC 18 A=    94   82    4 33.3 48.0    GUAUUAAUCUUCCUUUCG |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
     308                       "GAAAGGAAGAUUAAUACC 18 A+     1   83    4 33.3 48.0    GGUAUUAAUCUUCCUUUC |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
     309                       "UCAAGUCGAGCGAUGAAG 18 B=    18   17    4 50.0 54.0    CUUCAUCGCUCGACUUGA |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,\n" 
     310                       "AUCAAGUCGAGCGAUGAA 18 B-     1   16    4 44.4 52.0    UUCAUCGCUCGACUUGAU |  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  2,  3,\n" 
    323311                       ); 
    324312} 
  • trunk/UNIT_TESTER/TestEnvironment.cxx

    r7819 r8041  
    270270//      ptserver 
    271271 
    272 static void test_ptserver_activate(bool start) { 
    273     const char *server_tag = GBS_ptserver_tag(TEST_SERVER_ID); 
     272static void test_ptserver_activate(bool start, int serverid) { 
     273    const char *server_tag = GBS_ptserver_tag(serverid); 
    274274    if (start) { 
    275275        TEST_ASSERT_NO_ERROR(arb_look_and_start_server(AISC_MAGIC_NUMBER, server_tag, 0)); 
     
    290290    switch (mode) { 
    291291        case SETUP: { 
    292             test_ptserver_activate(false);                        // first kill pt-server (otherwise we may test an outdated pt-server) 
    293             TEST_ASSERT_NO_ERROR(GB_system("touch TEST_pt.arb")); // force rebuild 
    294             test_ptserver_activate(true); 
     292            test_ptserver_activate(false, TEST_SERVER_ID);                     // first kill pt-server (otherwise we may test an outdated pt-server) 
     293            TEST_ASSERT_NO_ERROR(GB_system("cp TEST_pt_src.arb TEST_pt.arb")); // force rebuild 
     294            test_ptserver_activate(true, TEST_SERVER_ID); 
    295295            TEST_ASSERT_FILES_EQUAL("TEST_pt.arb.pt.expected", "TEST_pt.arb.pt"); 
    296296            TEST_ASSERT(GB_time_of_file("TEST_pt.arb.pt") >= GB_time_of_file("TEST_pt.arb")); 
     
    298298        } 
    299299        case CLEAN: { 
    300             test_ptserver_activate(false); 
     300            test_ptserver_activate(false, TEST_SERVER_ID); 
    301301            TEST_ASSERT_ZERO_OR_SHOW_ERRNO(unlink("TEST_pt.arb.pt")); 
    302302            break; 
     
    307307    } 
    308308 
     309    return NULL; 
     310} 
     311 
     312static Error ptserver_gene(Mode mode) { 
     313    // test-gene-ptserver is restarted and rebuild. 
     314    // This is done only once in the complete test suite. 
     315    //  
     316    // every unit-test using the test-gene-ptserver should simply call 
     317    // TEST_SETUP_GLOBAL_ENVIRONMENT("ptserver_gene"); 
     318 
     319// #define TEST_AUTO_UPDATE 
     320 
     321    switch (mode) { 
     322        case SETUP: { 
     323            test_ptserver_activate(false, TEST_GENESERVER_ID);                     // first kill pt-server (otherwise we may test an outdated pt-server) 
     324            TEST_ASSERT_NO_ERROR(GB_system("arb_gene_probe TEST_gpt_src.arb TEST_gpt.arb")); // prepare gene-ptserver-db (forcing rebuild) 
     325 
     326#if defined(TEST_AUTO_UPDATE) 
     327            TEST_COPY_FILE("TEST_gpt.arb", "TEST_gpt.arb.expected"); 
     328#else // !defined(TEST_AUTO_UPDATE) 
     329            TEST_ASSERT_FILES_EQUAL("TEST_gpt.arb.expected", "TEST_gpt.arb"); 
     330#endif 
     331 
     332            test_ptserver_activate(true, TEST_GENESERVER_ID); 
     333 
     334#if defined(TEST_AUTO_UPDATE) 
     335            TEST_COPY_FILE("TEST_gpt.arb.pt", "TEST_gpt.arb.pt.expected"); 
     336#else // !defined(TEST_AUTO_UPDATE) 
     337            TEST_ASSERT_FILES_EQUAL("TEST_gpt.arb.pt.expected", "TEST_gpt.arb.pt"); 
     338#endif 
     339 
     340            TEST_ASSERT(GB_time_of_file("TEST_gpt.arb.pt") >= GB_time_of_file("TEST_gpt.arb")); 
     341            break; 
     342        } 
     343        case CLEAN: { 
     344            test_ptserver_activate(false, TEST_GENESERVER_ID); 
     345            TEST_ASSERT_ZERO_OR_SHOW_ERRNO(unlink("TEST_gpt.arb.pt")); 
     346            break; 
     347        } 
     348        case UNKNOWN: 
     349            env_assert(0); 
     350            break; 
     351    } 
     352 
     353#undef TEST_AUTO_UPDATE 
     354     
    309355    return NULL; 
    310356} 
     
    414460static FunInfo modules[] = { 
    415461    FUNINFO(ptserver), 
     462    FUNINFO(ptserver_gene), 
    416463}; 
    417464 
  • trunk/UNIT_TESTER/run

    • Property svn:ignore set to
      TEST_gpt.ARM
      TEST_gpt.arb
      TEST_pt.arb
      *.ARF
      TEST_pt.ARM
  • trunk/UNIT_TESTER/run/TEST_pt_cleaned_expected.arb

    r7993 r8041  
    22genom_db                %i 0 
    33presets                 %% (% 
    4         alignment       :6000   %% (% 
    5                 alignment_name  :7600   "ali_mini" 
    6                 alignment_len   :7000   %i 187 
    7                 aligned         :7000   %i 1 
    8                 alignment_write_security        :7600   %i 0 
    9                 alignment_type  :7000   "rna" 
    10                 auto_format             %i 0 
    11                 alignment_rem           "<NONE>" 
    12                 %) /*alignment*/ 
    13  
    14         key_data                %% (% 
    15                 key                     %% (% 
    16                         key_name                "name" 
    17                         key_type                %i 12 
    18                         key_hidden              %i 0 
    19                         %) /*key*/ 
    20  
    21                 key                     %% (% 
    22                         key_name                "acc" 
    23                         key_type                %i 12 
    24                         key_hidden              %i 0 
    25                         %) /*key*/ 
    26  
    27                 key                     %% (% 
    28                         key_name                "ali_mini" 
    29                         key_type                %i 15 
    30                         key_hidden              %i 0 
    31                         %) /*key*/ 
    32  
    33                 key                     %% (% 
    34                         key_name                "ali_mini/data" 
    35                         key_type                %i 12 
    36                         key_hidden              %i 0 
    37                         %) /*key*/ 
    38  
    39                 %) /*key_data*/ 
    40  
    414        use                     "ali_mini" 
    425        %) /*presets*/ 
     
    246209        extended                %% (% 
    247210                name            :7000   "ECOLI" 
    248                 errors                  %i 0 
    249211                acc                     "J01695" 
    250212                full_name               "Escherichia coli" 
     
    257219        %) /*extended_data*/ 
    258220 
    259 tree_data       :7000   %% (% 
    260         tree_ph_24306           %% (% 
    261                 tree                    "N0.03618,0.03618;N0.04082,0.06452;N0.0404,0.28364;N0.0473,0.2638;N0.06826,0.13072;N0.09494,0.11285;LHllHalod\ALLgtLytic\ALPslFlave\AN0.04416,0.07602;N0.02484,0.01242;LVbhChole\ALVblVulni\ALVbrFurni\AN0.13971,0.16265;N0.02,0.35135;N0.07947,0.09524;LClnCorin\ALCPPParap\ALCltBotul\ALClfPerfr\AN0.28846,0.2;N0.06844,0.10559;N0.06211,0.58369;N0.09357,0.06548;LAclPleur\ALPtVVVulg\ALPsAAAA00\ALDcdNodos\ALFrhhPhil\AN0.19802,0.06369;N0.04192,0.02516;LBcSSSS00\ALBl0LLL00\AN0.04516,0.04487;N0.03974,0.04516;N0.09717,0.10759;N0.10726,0.77778;LDlcTolu2\ALDsssDesu\ALStsssola\ALPbcAcet2\ALPbrPropi\A" 
    262                 nnodes                  %i 21 
    263                 remark                  "PRG=neighbor CORR=F84 FILTER=none PKG=phylip\n\nSun Aug 22 21:38:37 2010: Loaded from outtree\n\nTree loaded from 'outtree' on Sun Aug 22 21:38:37 2010\nSun Aug 22 22:01:06 2010: tree_ph_24306 saved to /home/ralf/data/db/ph_24306.tree\nSun Aug 22 22:02:33 2010: Loaded from /home/ralf/data/db/ph_24306.tree\n" 
    264                 security                %i 0 
    265                 ruler                   %% (% 
    266                         size                    %f 0.1 
    267                         LIST                    %% (% 
    268                                 ruler_y                 %f 0 
    269                                 ruler_x                 %f 0 
    270                                 text_x                  %f 0 
    271                                 text_y                  %f 0 
    272                                 %) /*LIST*/ 
    273  
    274                         ruler_width             %i 0 
    275                         %) /*ruler*/ 
    276  
    277                 %) /*tree_ph_24306*/ 
    278  
    279         %) /*tree_data*/ 
    280  
    281 focus                   %% (% 
    282         tree_name               "tree_ph_24306" 
    283         %) /*focus*/ 
    284  
    285 description             "db for unit-test pt-server" 
    286 checks                  %% (% 
    287         check                   "fix gene_data" 
    288         check                   "fix_dict_compress" 
    289         check                   "del_mark_move_REF" 
    290         check                   "duplicated_item_colors" 
    291         %) /*checks*/ 
    292  
    293 tmp                     %% (% 
    294         message                 %% (% 
    295                 pending                 %% (% 
    296                         %) /*pending*/ 
    297  
    298                 %) /*message*/ 
    299  
    300         %) /*tmp*/ 
    301  
  • trunk/UNIT_TESTER/test_unit.h

    r8040 r8041  
    593593}; 
    594594 
     595#define TEST_COPY_FILE(src, dst) TEST_ASSERT(system(GBS_global_string("cp '%s' '%s'", src, dst)) == 0) 
     596 
    595597#define TEST_ASSERT_TEXTFILE_DIFFLINES(f1,f2,diff)         TEST_ASSERT(arb_test::test_textfile_difflines(f1,f2, diff)) 
    596598#define TEST_ASSERT_TEXTFILE_DIFFLINES__BROKEN(f1,f2,diff) TEST_ASSERT__BROKEN(arb_test::test_textfile_difflines(f1,f2, diff)) 
     
    625627// -------------------------------------------------------------------------------- 
    626628 
    627 #define TEST_SETUP_GLOBAL_ENVIRONMENT(modulename) TEST_ASSERT_NO_ERROR(GB_system("../test_environment setup " modulename)) 
     629#define TEST_SETUP_GLOBAL_ENVIRONMENT(modulename) TEST_ASSERT_NO_ERROR(GB_system(GBS_global_string("../test_environment setup %s",  (modulename)))) 
    628630// cleanup is done (by Makefile.suite) after all unit tests have been run 
    629631 
  • trunk/lib/arb_tcp_org.dat

    r6708 r8041  
    3232 
    3333ARB_TEST_PT_SERVER          localhost:3200          arb_pt_server   -D$(ARBHOME)/UNIT_TESTER/run/TEST_pt.arb 
    34  
     34ARB_TEST_PT_SERVER_GENE     localhost:3201          arb_pt_server   -D$(ARBHOME)/UNIT_TESTER/run/TEST_gpt.arb 
    3535 
    3636#***********    Private Servers (for each user) ****************** 
  • trunk/util/arb_srclst.pl

    r7997 r8041  
    168168                             qr/\/UNIT_TESTER\/run\/.*\.tree$/o, 
    169169                             qr/\/UNIT_TESTER\/run\/impexp\/.*\.exported$/o, 
    170                              qr/\/UNIT_TESTER\/run\/TEST_.*\.pt$/o, # has to move to skipped_when_matchesFull (when merging test env) 
    171170                             qr/\/UNIT_TESTER\/valgrind\/arb_valgrind_logged$/o, 
    172171                             qr/^\.\/etc\//o, 
     
    211210                                qr/^\.\/SOURCE_TOOLS\/valgrind2grep\.lst$/o, 
    212211                                qr/^\.\/TEMPLATES\/arb_build\.h$/o, 
     212                                qr/^\.\/UNIT_TESTER\/run\/TEST_g?pt\.arb$/o, 
     213                                qr/^\.\/UNIT_TESTER\/run\/.*\.ARM$/o, 
     214                                qr/^\.\/UNIT_TESTER\/run\/.*\.ARF$/o, 
    213215                                qr/date\.xsl$/o, 
    214216                               );