Changeset 8282

Show
Ignore:
Timestamp:
08/12/11 11:31:56 (6 months ago)
Author:
eissler
Message:

PTPan: solved issue with including reverse-complement in ProbeMatch?

Location:
branches/ptpan_back/ptpan
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/ptpan_back/ptpan/ptpan.h

    r8281 r8282  
    463463    std::string sq_Query; /* query string */ 
    464464 
    465     bool sq_Reversed; /* query is reversed */ 
     465    bool sq_Reversed; /* check reversed complement as well */ 
    466466    bool sq_AllowReplace; /* allow replace operations */ 
    467467    bool sq_AllowInsert; /* allow inserting operations */ 
  • branches/ptpan_back/ptpan/ptpan_legacy.cxx

    r8060 r8282  
    381381#endif 
    382382    gettimeofday(&tsNow, NULL); 
    383     printf("... done in %li seconds.\n", 
    384             (tsNow.tv_sec - tsStart.tv_sec)); 
     383    printf("... done in %li seconds.\n", (tsNow.tv_sec - tsStart.tv_sec)); 
    385384#ifndef DEBUG 
    386385} 
     
    11811180    sq.sq_Query = std::string(locs->pm_sequence); 
    11821181    sq.sq_MaxErrors = (float) locs->pm_max; 
    1183     sq.sq_Reversed = false; 
     1182    if (locs->pm_reversed) { 
     1183        // include reversed-complement search as well 
     1184        sq.sq_Reversed = true; 
     1185    } else { 
     1186        sq.sq_Reversed = false; 
     1187    } 
    11841188    if (sq.sq_MaxErrors > 0) { 
    11851189        sq.sq_AllowReplace = true; // N-mismatches are listed anyways! 
     
    12011205    ULONG done = create_match_list(sq, results, locs->pm_max_hits); 
    12021206 
    1203     if (locs->pm_reversed) { 
    1204         SearchQuery compsq = sq; 
    1205         compsq.sq_Reversed = true; 
    1206         results = pl->pl_pt->searchTree(compsq, true, true); 
    1207         done = create_match_list(compsq, results, locs->pm_max_hits - done); 
    1208     } 
     1207#ifdef DEBUG 
     1208    if (done) { 
     1209        printf("done with search!\n"); 
     1210    } 
     1211#endif 
    12091212 
    12101213    // Just to be secure, we clear the PDC structure 
  • branches/ptpan_back/ptpan/ptpan_tree.cxx

    r8281 r8282  
    687687    if (!sq.sq_Query.empty()) { 
    688688        SearchQuery internal_sq = sq; 
     689        bool reversed_too = internal_sq.sq_Reversed; 
    689690        if (internal_sq.sq_MaxErrors == 0.0) { 
    690691            internal_sq.sq_AllowInsert = false; 
     
    692693            internal_sq.sq_AllowReplace = false; 
    693694        } 
     695        internal_sq.sq_Reversed = false; 
    694696        SearchQueryHandle sqh = SearchQueryHandle(internal_sq); 
    695697 
     
    735737            } 
    736738        } 
     739 
     740        if (reversed_too) { 
     741            STRPTR query_str = const_cast<char *>(internal_sq.sq_Query.c_str()); 
     742            m_as->complementSequence(query_str); 
     743            m_as->reverseSequence(query_str); 
     744            internal_sq.sq_Reversed = true; 
     745 
     746            SearchQueryHandle sqh_rev = SearchQueryHandle(internal_sq); 
     747#ifdef DEBUG 
     748            printf("check reverse complement as well (%s)\n", 
     749                    internal_sq.sq_Query.c_str()); 
     750#endif 
     751            // TODO FIXME double code is bad, but there is no time left :-( 
     752            std::vector<PTPanPartition *>::const_iterator pit; 
     753            for (pit = m_partitions.begin(); pit != m_partitions.end(); pit++) { 
     754                search_partition(*pit, internal_sq, sqh_rev); 
     755            } 
     756            post_filter_query_hits(sq, sqh_rev); 
     757 
     758#ifdef DEBUG 
     759            printf("after all partitions rev-compl count %lu\n", 
     760                    sqh_rev.sqh_hits.size()); 
     761#endif 
     762            if (m_prune_length < sqh_rev.sqh_MaxLength) { 
     763#ifdef DEBUG 
     764                printf("may contain UNSAFE! %lu\n", sqh_rev.sqh_MaxLength); 
     765#endif 
     766                validate_unsafe_hits(internal_sq, sqh_rev); 
     767            } 
     768            if (build_diff) { 
     769                if (!sqh_rev.sqh_hits.empty()) { 
     770#ifdef DEBUG 
     771                    printf(">> CreateDiffAlignment for %lu hits\n", 
     772                            sqh_rev.sqh_hits.size()); 
     773#endif 
     774                    if (sqh_rev.sqh_hits.size() < m_num_threads 
     775                            || m_num_threads <= 1) { 
     776                        create_diff_alignment(internal_sq, sqh_rev); 
     777                    } else { 
     778                        std::size_t i = 0; 
     779                        ULONG participators = m_num_threads; 
     780                        for (; i < participators - 1; i++) { 
     781                            boost::threadpool::schedule( 
     782                                    *m_threadpool, 
     783                                    boost::bind( 
     784                                            &PtpanTree::create_diff_alignment, 
     785                                            this, boost::ref(internal_sq), 
     786                                            boost::ref(sqh_rev), i, 
     787                                            participators)); 
     788                        } 
     789                        create_diff_alignment(internal_sq, sqh_rev, i, 
     790                                participators); // main thread can do some work as well! 
     791                        m_threadpool->wait(); 
     792                    } 
     793                } 
     794            } 
     795            // we want to transfer control over results to sqh 
     796            // before we sort and return results 
     797            sqh.sqh_hits.transfer(sqh.sqh_hits.end(), sqh_rev.sqh_hits); 
     798        } 
     799 
    737800        if (sort) { 
    738801            sort_hits_list(internal_sq, sqh); 
     
    901964    UWORD seqcode = 0; 
    902965    ULONG length_corr = 
    903             (length < best_pp->pp_TreePruneLength) ? length : 
    904                     best_pp->pp_TreePruneLength; 
     966            (length < best_pp->pp_TreePruneLength) ? 
     967                    length : best_pp->pp_TreePruneLength; 
    905968 
    906969    ULONG buffer_size; 
     
    29082971        SearchQueryHandle& sqh) const { 
    29092972    LONG query_len = 
    2910             sq.sq_Query.size() > m_prune_length ? m_prune_length : 
    2911                     (LONG) sq.sq_Query.size(); 
     2973            sq.sq_Query.size() > m_prune_length ? 
     2974                    m_prune_length : (LONG) sq.sq_Query.size(); 
    29122975    LONG source_len = 
    2913             sqh.sqh_MaxLength > m_prune_length ? m_prune_length : 
    2914                     (LONG) sqh.sqh_MaxLength; 
     2976            sqh.sqh_MaxLength > m_prune_length ? 
     2977                    m_prune_length : (LONG) sqh.sqh_MaxLength; 
    29152978 
    29162979    LONG max_check = 
    2917             sq.sq_Query.size() < m_prune_length ? m_prune_length 
    2918                     - sq.sq_Query.size() : 
    2919                     0; 
     2980            sq.sq_Query.size() < m_prune_length ? 
     2981                    m_prune_length - sq.sq_Query.size() : 0; 
    29202982    if (max_check > sq.sq_MaxErrors) { 
    29212983        max_check = (LONG) sq.sq_MaxErrors; 
     
    37483810                qh->qh_sortKey = 
    37493811                        (LLONG) ( 
    3750                                 (qh->qh_Flags & QHF_REVERSED) ? (1LL << 62) : 
    3751                                         0LL) 
    3752                                 + ((qh->qh_InsertCount | qh->qh_DeleteCount) ? (1LL 
    3753                                         << 61) : 
    3754                                         0LL) 
     3812                                (qh->qh_Flags & QHF_REVERSED) ? 
     3813                                        (1LL << 62) : 0LL) 
     3814                                + ((qh->qh_InsertCount | qh->qh_DeleteCount) ? 
     3815                                        (1LL << 61) : 0LL) 
    37553816                                + (((LLONG) (qh->qh_ReplaceCount 
    37563817                                        + qh->qh_InsertCount 
     
    37803841                qh->qh_sortKey = 
    37813842                        (LLONG) ( 
    3782                                 (LLONG) (qh->qh_Flags & QHF_REVERSED) ? (1LL 
    3783                                         << 62) : 
    3784                                         0LL) 
     3843                                (LLONG) (qh->qh_Flags & QHF_REVERSED) ? 
     3844                                        (1LL << 62) : 0LL) 
    37853845                                + ((LLONG) (qh->qh_InsertCount 
    3786                                         | qh->qh_DeleteCount) ? (1LL << 61) : 
    3787                                         0LL) 
     3846                                        | qh->qh_DeleteCount) ? 
     3847                                        (1LL << 61) : 0LL) 
    37883848                                + (((LLONG) round(qh->qh_ErrorCount * 10.0)) 
    37893849                                        << 56) 
     
    40344094    UWORD seqcode = m_as->wildcard_code + 1; 
    40354095    ULONG length = 
    4036             (dq.dq_ProbeLength < pp->pp_TreePruneLength) ? dq.dq_ProbeLength : 
    4037                     pp->pp_TreePruneLength; 
     4096            (dq.dq_ProbeLength < pp->pp_TreePruneLength) ? 
     4097                    dq.dq_ProbeLength : pp->pp_TreePruneLength; 
    40384098    double currtemp = 0.0; 
    40394099    UWORD currgc = 0; 
  • branches/ptpan_back/ptpan/ptpan_tree.h

    r8281 r8282  
    136136            } 
    137137            sqh_hits.clear(); 
     138        } 
     139 
     140        void clearHitsHash() { 
     141            if (sqh_HitsHash) { 
     142                sqh_HitsHash->clear(); 
     143            } 
    138144        } 
    139145