Ticket #152: 12676_tests_fixed.patch

File 12676_tests_fixed.patch, 10.6 KB (added by westram, 10 years ago)

fix tests back in [12676]. results changed by [12677] marked with @@@

  • NTREE/ad_transpro.cxx

     
    861861#endif
    862862}
    863863
     864inline char *unalign(const char *data, size_t len, size_t& compressed_len) {
     865    // removes gaps from sequence
     866    char *compressed = (char*)malloc(len+1);
     867    compressed_len        = 0;
     868    for (size_t p = 0; p<len && data[p]; ++p) {
     869        if (!isGap(data[p])) {
     870            compressed[compressed_len++] = data[p];
     871        }
     872    }
     873    compressed[compressed_len] = 0;
     874    return compressed;
     875}
     876
    864877class Realigner {
    865878    const char *ali_source;
    866879    const char *ali_dest;
     
    870883
    871884    const char *fail_reason;
    872885
    873     char *unalign(const char *data, size_t len, size_t& compressed_len) {
    874         // removes gaps from sequence
    875         char *compressed = (char*)malloc(len+1);
    876         compressed_len        = 0;
    877         for (size_t p = 0; p<len && data[p]; ++p) {
    878             if (!isGap(data[p])) {
    879                 compressed[compressed_len++] = data[p];
    880             }
    881         }
    882         compressed[compressed_len] = 0;
    883         return compressed;
    884     }
    885 
    886886    GB_ERROR annotate_fail_position(const FailedAt& failed, const char *source, const char *dest, const char *compressed_dest) {
    887887        int source_fail_pos = failed.protein_at() - source;
    888888        int dest_fail_pos   = 0;
     
    16741674            const char*const NO_TI = "t=-1,cs=-1";
    16751675
    16761676            explicit_realign example[] = {
    1677                 { "LK", "TTGAAG", -1, NO_TI,        NULL }, // fine (for any table)
     1677                { "LK", "TTGAAG", -1, NO_TI, NULL }, // fine (for any table)
    16781678
    1679                 { "G",  "RGG",    -1, "t=10,cs=0", NULL }, // correctly detects TI(10)
     1679                { "G", "RGG", -1, "t=10,cs=0", NULL }, // correctly detects TI(10)
    16801680
    1681                 { "LK", "YTRAAR", 2,  "t=2,cs=0",   "Not all IUPAC-combinations of 'YTR' translate to 'L' at ali_pro:1 / ali_dna:1\n" }, // expected failure (CTA->T for table=2)
    1682                 { "LX", "YTRAAR", -1, NO_TI,        NULL }, // fine           (AAR->X for table=6,11,14)
    1683                 { "LX", "YTRAAR", 2,  "t=2,cs=0",   NULL }, // @@@ should fail(AAR->K for table=2)
    1684                 { "LK", "YTRAAR", -1, NO_TI,        NULL }, // fine           (AAR->K for table!=6,11,14)
    1685                 { "LK", "YTRAAR", 6,  "t=6,cs=0",   NULL }, // @@@ should fail(AAA->N for table=6)
    1686                 { "XK", "YTRAAR", -1, NO_TI,        NULL }, // fine           (YTR->X for table=2,9,16)
    1687                 { "XX", "YTRAAR", 0,  "t=0,cs=0",   NULL }, // @@@ should fail(none can translate to X with table=0)
    1688                 { "XX", "YTRAAR", -1, NO_TI,        NULL }, // @@@ should fail(not both can translate to 'X')
     1681                { "LK",  "YTRAAR",    2,  "t=2,cs=0", "Not all IUPAC-combinations of 'YTR' translate to 'L' at ali_pro:1 / ali_dna:1\n" }, // expected failure (CTA->T for table=2)
     1682                { "LX",  "YTRAAR",    -1, NO_TI,      NULL },                                                                              // fine (AAR->X for table=6,11,14)
     1683                { "LXX", "YTRAARATH", -1, NO_TI,      NULL },                                                                              // @@@ fails to correctly detect TI(14)
     1684                { "LXI", "YTRAARATH", -1, NO_TI,      NULL },                                                                              // fine (for table=6,11)
    16891685
    1690                 { "LX", "YTRATH", -1, NO_TI,        NULL }, // fine                (ATH->X for table=1,2,4,10,14)
    1691                 { "LX", "YTRATH", 2,  "t=2,cs=0",   NULL }, // @@@ should fail     (YTR->X for table=2)
    1692                 { "XX", "YTRATH", 2,  "t=2,cs=0",   NULL }, // fine                (both->X for table=2)
    1693                 { "XX", "YTRATH", -1, "t=-1,cs=-1", NULL }, // @@@ should detect TI(2)
     1686                { "LX", "YTRAAR", 2,  "t=2,cs=0", "Not all IUPAC-combinations of 'YTR' translate to 'L' at ali_pro:1 / ali_dna:1\n" }, // expected failure (AAR->K for table=2)
     1687                { "LK", "YTRAAR", -1, NO_TI,      NULL },                                                                              // fine           (AAR->K for table!=6,11,14)
     1688                { "LK", "YTRAAR", 6,  "t=6,cs=0", "Not all IUPAC-combinations of 'AAR' translate to 'K' at ali_pro:2 / ali_dna:4\n" }, // expected failure (AAA->N for table=6)
     1689                { "XK", "YTRAAR", -1, NO_TI,      NULL },                                                                              // fine           (YTR->X for table=2,9,16)
    16941690
    1695                 { "XX", "AARATH", 14, "t=14,cs=0",  NULL }, // fine (both->X for table=14)
    1696                 { "XX", "AARATH", -1, "t=-1,cs=-1", NULL }, // @@@ should detect TI (14)
    1697                 { "KI", "AARATH", -1, NO_TI,        NULL }, // fine (for table!=1,2,4,6,10,11,14)
    1698                 { "KI", "AARATH", 4,  "t=4,cs=0",   NULL }, // @@@ should fail (ATH->X for table=4)
    1699                 { "KX", "AARATH", 14, "t=14,cs=0",  NULL }, // @@@ should fail (AAR->X for table=14)
    1700                 { "KX", "AARATH", -1, NO_TI,        NULL }, // fine for table=1,2,4,10
    1701                 { "KX", "AARATH", 4,  "t=4,cs=0",   NULL }, // test table=4
    1702                 { "XI", "AARATH", 14, "t=14,cs=0",  NULL }, // @@@ should fail (ATH->X for table=14)
    1703                 { "KI", "AARATH", 14, "t=14,cs=0",  NULL }, // @@@ should fail
     1691                { "XX",   "-YTRAAR",      0,  "t=0,cs=0", NULL },                                                                                             // does not fail because it realigns such that it translates back to 'XXX'
     1692                { "XXL",  "YTRAARTTG",    0,  "t=0,cs=0", "Not enough gaps to place 2 extra nucs at start of sequence at ali_pro:1 / ali_dna:1\n" },          // expected failure (none can translate to X with table= 0, so it tries )
     1693                { "-XXL", "-YTRA-AR-TTG", 0,  "t=0,cs=0", NULL },                                                                                             // does not fail because it realigns such that it translates back to 'XXXL'
     1694                { "IXXL", "ATTYTRAARTTG", 0,  "t=0,cs=0", "Sync behind 'X' failed foremost with: 'RTT' never translates to 'L' at ali_pro:4 / ali_dna:9\n" }, // expected failure (none of the 2 middle codons can translate to X with table= 0)
     1695                { "XX",   "YTRAAR.",      -1, NO_TI,      NULL },                                                                                             // does not fail because it realigns such that it translates back to 'XXX'
     1696                { "IXXL", "ATTYTRAARTTG", -1, NO_TI,      NULL },                                                                                             // @@@ should fail (not both 2 middle codons can translate to X with same table)
    17041697
     1698                { "LX", "YTRATH", -1, NO_TI,      NULL },                                                                              // fine                (ATH->X for table=1,2,4,10,14)
     1699                { "LX", "YTRATH", 2,  "t=2,cs=0", "Not all IUPAC-combinations of 'YTR' translate to 'L' at ali_pro:1 / ali_dna:1\n" }, // expected failure (YTR->X for table=2)
     1700                { "XX", "YTRATH", 2,  "t=2,cs=0", NULL },                                                                              // fine                (both->X for table=2)
     1701                { "XX", "YTRATH", -1, NO_TI,      NULL },                                                                              // @@@ fails to correctly detect TI(2)
     1702
     1703                { "XX", "AARATH", 14, "t=14,cs=0", NULL },                                                                                                                    // fine (both->X for table=14)
     1704                { "XX", "AARATH", -1, NO_TI,       NULL },                                                                                                                    // @@@ fails to correctly detect TI(14)
     1705                { "KI", "AARATH", -1, NO_TI,       NULL },                                                                                                                    // fine (for table!=1,2,4,6,10,11,14)
     1706                { "KI", "AARATH", 4,  "t=4,cs=0",  "Not all IUPAC-combinations of 'ATH' translate to 'I' at ali_pro:2 / ali_dna:4\n" },                                       // expected failure (ATH->X for table=4)
     1707                { "KX", "AARATH", 14, "t=14,cs=0", "Not all IUPAC-combinations of 'AAR' translate to 'K' at ali_pro:1 / ali_dna:1\n" },                                       // expected failure (AAR->X for table=14)
     1708                { "KX", "AARATH", -1, NO_TI,       NULL },                                                                                                                    // fine for table=1,2,4,10
     1709                { "KX", "AARATH", 4,  "t=4,cs=0",  NULL },                                                                                                                    // test table=4
     1710                { "XI", "AARATH", 14, "t=14,cs=0", "Sync behind 'X' failed foremost with: Not all IUPAC-combinations of 'ATH' translate to 'I' at ali_pro:2 / ali_dna:4\n" }, // expected failure (ATH->X for table=14)
     1711                { "KI", "AARATH", 14, "t=14,cs=0", "Not all IUPAC-combinations of 'AAR' translate to 'K' at ali_pro:1 / ali_dna:1\n" },                                       // expected failure (AAR->X for table=14)
     1712
    17051713                { NULL, NULL, 0, NULL, NULL }
    17061714            };
    17071715
     
    17301738                    TEST_EXPECT_EQUAL(msgs.c_str()+ERRPREFIX_LEN, wanted_msgs);
    17311739                }
    17321740                else {
    1733                     TEST_EXPECT_CONTAINS(msgs, "");
     1741                    TEST_EXPECT_EQUAL(msgs, "");
    17341742                }
    17351743
    17361744                GB_transaction ta(gb_main);
    17371745                if (!error) {
    1738                     TEST_EXPECT_CONTAINS(GB_read_char_pntr(gb_TaxOcell_dna), E.dna);
     1746                    const char *dnaseq      = GB_read_char_pntr(gb_TaxOcell_dna);
     1747                    size_t      expextedLen = strlen(E.dna);
     1748                    size_t      seqlen      = strlen(dnaseq);
     1749                    char       *firstPart   = GB_strndup(dnaseq, expextedLen);
     1750                    size_t      dna_behind;
     1751                    char       *nothing     = unalign(dnaseq+expextedLen, seqlen-expextedLen, dna_behind);
     1752
     1753                    TEST_EXPECT_EQUAL(firstPart, E.dna);
     1754                    TEST_EXPECT_EQUAL(dna_behind, 0);
     1755                    TEST_EXPECT_EQUAL(nothing, "");
     1756
     1757                    free(nothing);
     1758                    free(firstPart);
    17391759                }
    17401760                TEST_EXPECT_EQUAL(translation_info(gb_TaxOcell), E.info);
    17411761            }