Changeset 8281

Show
Ignore:
Timestamp:
07/12/11 18:46:05 (6 months ago)
Author:
eissler
Message:

PTPan update to current version

Location:
branches/ptpan_back/ptpan
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branches/ptpan_back/ptpan/changelog.txt

    r8179 r8281  
    11PTPan ARB integration 
    22 
    3 v0.6.6 (?? ?? 2011) 
     3v0.6.7 (?? ?? 2011) 
    44 
    55- TODO 
     
    2323- added method probeNongroupIncreaseArrayWidth() 
    2424- added custom information field in index header 
     25- added convenience methods here and there 
    2526 
    2627- major refactoring to make interface easier to use 
  • branches/ptpan_back/ptpan/ptpan.cxx

    r8060 r8281  
    541541 
    542542/*! 
     543 * \brief Return pointer list of all Features 
     544 * 
     545 * \return const std::vector<PTPanFeature*> 
     546 */ 
     547const std::vector<PTPanFeature*> PTPanFeatureContainer::getAllFeatures() const { 
     548    if (m_normal_mode) { 
     549        return *m_features; 
     550    } 
     551    return std::vector<PTPanFeature*>(); 
     552} 
     553 
     554/*! 
     555 * \brief Return list of all Feature ids 
     556 * 
     557 * \return const std::vector<std::string> 
     558 */ 
     559const std::vector<std::string> PTPanFeatureContainer::getAllFeatureIds() const { 
     560    if (m_normal_mode) { 
     561        std::vector<std::string> ret_values; 
     562        std::vector<PTPanFeature*>::const_iterator it; 
     563        for (it = m_features->begin(); it != m_features->end(); it++) { 
     564            ret_values.push_back((*it)->pf_name); 
     565        } 
     566        return ret_values; 
     567    } 
     568    return std::vector<std::string>(); 
     569} 
     570 
     571/*! 
    543572 * \brief Returns the maximum byte size of this container for storing 
    544573 * 
  • branches/ptpan_back/ptpan/ptpan.h

    r8060 r8281  
    246246 
    247247    const PTPanFeature * getFeatureByNumber(ULONG number) const; 
     248    const std::vector<PTPanFeature*> getAllFeatures() const; 
     249    const std::vector<std::string> getAllFeatureIds() const; 
    248250 
    249251    ULONG byteSize() const; 
  • branches/ptpan_back/ptpan/ptpan_tree.cxx

    r8179 r8281  
    500500 * \brief Return PTPanReferenceEntry 
    501501 * 
    502  * \warning Do not free! PtpanTree is still owner! This is no copy! 
     502 * \warning Do not free! PtpanTree is still owner! Does not return a copy! 
    503503 * 
    504504 * May return NULL if not available! 
     
    525525 * \brief Return pointer to first PTPanEntry in list 
    526526 * 
    527  * \warning Do not free! PtpanTree is still owner! This is no copy! 
     527 * \warning Do not free! PtpanTree is still owner! Does not return a copy! 
    528528 * 
    529529 * \return struct PTPanEntry* 
     
    539539 * \brief Return PTPanEntry 
    540540 * 
    541  * \warning Do not free! PtpanTree is still owner! This is no copy! 
     541 * \warning Do not free! PtpanTree is still owner! Does not return a copy! 
    542542 * 
    543543 * May return NULL if not available! 
     
    551551 
    552552/*! 
     553 * \brief Return PTPanEntry for given id 
     554 * 
     555 * \warning Do not free! PtpanTree is still owner! Does not return a copy! 
     556 * 
     557 * May return NULL if not available! 
     558 */ 
     559const PTPanEntry* PtpanTree::getEntry(const std::string& id) const { 
     560 
     561    if (m_contains_features) { 
     562        // split id at '/' and try to find the parts! 
     563        // TODO FIXME better take '#' as delimiter, split and take first and second value of vector! 
     564        std::size_t pos = id.find('/'); 
     565        if (pos != std::string::npos) { 
     566            std::string entry = id.substr(0, pos); 
     567            // NUMBER OF ENTRY: it->second - 1 
     568            PtpanEntryMap::const_iterator it = m_entry_map.find(entry.data()); 
     569            if (it != m_entry_map.end()) { 
     570                PTPanEntry* ptpan_entry = m_EntriesMap[(it->second) - 1]; 
     571                if (ptpan_entry) { 
     572                    return ptpan_entry; 
     573                } 
     574            } 
     575        } else { 
     576            // no feature(s), but maybe whole genomes!! 
     577            PtpanEntryMap::const_iterator it = m_entry_map.find(id.data()); 
     578            if (it != m_entry_map.end()) { 
     579                PTPanEntry* ptpan_entry = m_EntriesMap[(it->second) - 1]; 
     580                if (ptpan_entry) { 
     581                    return ptpan_entry; 
     582                } 
     583            } 
     584        } 
     585    } else { 
     586        PtpanEntryMap::const_iterator it = m_entry_map.find(id.data()); 
     587        if (it != m_entry_map.end()) { 
     588            PTPanEntry* ptpan_entry = m_EntriesMap[(it->second) - 1]; 
     589            if (ptpan_entry) { 
     590                return ptpan_entry; 
     591            } 
     592        } 
     593    } 
     594    return NULL; 
     595} 
     596 
     597/*! 
    553598 * \brief Return full name of entry 
    554599 * 
    555  * \warning Do not free! PtpanTree is still owner! This is no copy! 
     600 * \warning Do not free! PtpanTree is still owner! Does not return a copy! 
    556601 * 
    557602 * May return NULL if not available! 
     
    567612 * \brief Return (string) id of entry 
    568613 * 
    569  * \warning Do not free! PtpanTree is still owner! This is no copy! 
     614 * \warning Do not free! PtpanTree is still owner! Does not return a copy! 
    570615 * 
    571616 * May return NULL if not available! 
     
    588633    while (ps->pe_Node.ln_Succ) { 
    589634        ret_values.push_back(ps->pe_Name); 
     635        ps = (struct PTPanEntry *) ps->pe_Node.ln_Succ; 
     636    } 
     637    return ret_values; 
     638} 
     639 
     640/*! 
     641 * \brief Returns all entries 
     642 * 
     643 * \return const std::vector<PTPanEntry*> 
     644 */ 
     645const std::vector<PTPanEntry*> PtpanTree::getAllEntries() const { 
     646    std::vector<PTPanEntry*> ret_values; 
     647    struct PTPanEntry* ps = (struct PTPanEntry *) m_entries->lh_Head; 
     648    while (ps->pe_Node.ln_Succ) { 
     649        ret_values.push_back(ps); 
    590650        ps = (struct PTPanEntry *) ps->pe_Node.ln_Succ; 
    591651    } 
     
    841901    UWORD seqcode = 0; 
    842902    ULONG length_corr = 
    843             (length < best_pp->pp_TreePruneLength) ? 
    844                     length : best_pp->pp_TreePruneLength; 
     903            (length < best_pp->pp_TreePruneLength) ? length : 
     904                    best_pp->pp_TreePruneLength; 
    845905 
    846906    ULONG buffer_size; 
     
    28482908        SearchQueryHandle& sqh) const { 
    28492909    LONG query_len = 
    2850             sq.sq_Query.size() > m_prune_length ? 
    2851                     m_prune_length : (LONG) sq.sq_Query.size(); 
     2910            sq.sq_Query.size() > m_prune_length ? m_prune_length : 
     2911                    (LONG) sq.sq_Query.size(); 
    28522912    LONG source_len = 
    2853             sqh.sqh_MaxLength > m_prune_length ? 
    2854                     m_prune_length : (LONG) sqh.sqh_MaxLength; 
     2913            sqh.sqh_MaxLength > m_prune_length ? m_prune_length : 
     2914                    (LONG) sqh.sqh_MaxLength; 
    28552915 
    28562916    LONG max_check = 
    2857             sq.sq_Query.size() < m_prune_length ? 
    2858                     m_prune_length - sq.sq_Query.size() : 0; 
     2917            sq.sq_Query.size() < m_prune_length ? m_prune_length 
     2918                    - sq.sq_Query.size() : 
     2919                    0; 
    28592920    if (max_check > sq.sq_MaxErrors) { 
    28602921        max_check = (LONG) sq.sq_MaxErrors; 
     
    31883249                        // find the match with the lowest error count in range 
    31893250                        // range = query length +- number of allowed indels 
    3190                         for (ULONG l = 1; l <= levenshtein.m_max_check; l++) { 
    3191                             if (levenshtein.m_distance_matrix[levenshtein.m_query_len 
    3192                                     + l][levenshtein.m_query_len] 
    3193                                     < sqh.sqh_State.sqs_ErrorCount && levenshtein.m_direction_matrix[levenshtein.m_query_len 
    3194                                     + l][levenshtein.m_query_len] 
    3195                                     == LEV_EQ) { // TODO FIXME why LEV_EQ?? 
    3196 sqh                            .sqh_State.sqs_ErrorCount = 
    3197                             levenshtein.m_distance_matrix[levenshtein.m_query_len 
    3198                             + l][levenshtein.m_query_len]; 
    3199                             length = levenshtein.m_query_len + l; 
     3251                        if (sq.sq_AllowInsert) { 
     3252                            for (ULONG l = 1; l <= levenshtein.m_max_check; 
     3253                                    l++) { 
     3254                                if (levenshtein.m_distance_matrix[levenshtein.m_query_len 
     3255                                        + l][levenshtein.m_query_len] 
     3256                                        < sqh.sqh_State.sqs_ErrorCount && levenshtein.m_direction_matrix[levenshtein.m_query_len 
     3257                                        + l][levenshtein.m_query_len] 
     3258                                        == LEV_EQ) { // TODO FIXME why LEV_EQ?? 
     3259sqh                                .sqh_State.sqs_ErrorCount = 
     3260                                levenshtein.m_distance_matrix[levenshtein.m_query_len 
     3261                                + l][levenshtein.m_query_len]; 
     3262                                length = levenshtein.m_query_len + l; 
     3263                            } 
    32003264                        } 
    32013265                    } 
     3266 
    32023267                        for (int l = 1; l <= (int) sq.sq_MaxErrors; l++) { 
    32033268                            if (levenshtein.m_distance_matrix[levenshtein.m_query_len 
     
    36833748                qh->qh_sortKey = 
    36843749                        (LLONG) ( 
    3685                                 (qh->qh_Flags & QHF_REVERSED) ? 
    3686                                         (1LL << 62) : 0LL) 
    3687                                 + ((qh->qh_InsertCount | qh->qh_DeleteCount) ? 
    3688                                         (1LL << 61) : 0LL) 
     3750                                (qh->qh_Flags & QHF_REVERSED) ? (1LL << 62) : 
     3751                                        0LL) 
     3752                                + ((qh->qh_InsertCount | qh->qh_DeleteCount) ? (1LL 
     3753                                        << 61) : 
     3754                                        0LL) 
    36893755                                + (((LLONG) (qh->qh_ReplaceCount 
    36903756                                        + qh->qh_InsertCount 
     
    37143780                qh->qh_sortKey = 
    37153781                        (LLONG) ( 
    3716                                 (LLONG) (qh->qh_Flags & QHF_REVERSED) ? 
    3717                                         (1LL << 62) : 0LL) 
     3782                                (LLONG) (qh->qh_Flags & QHF_REVERSED) ? (1LL 
     3783                                        << 62) : 
     3784                                        0LL) 
    37183785                                + ((LLONG) (qh->qh_InsertCount 
    3719                                         | qh->qh_DeleteCount) ? 
    3720                                         (1LL << 61) : 0LL) 
     3786                                        | qh->qh_DeleteCount) ? (1LL << 61) : 
     3787                                        0LL) 
    37213788                                + (((LLONG) round(qh->qh_ErrorCount * 10.0)) 
    37223789                                        << 56) 
     
    39674034    UWORD seqcode = m_as->wildcard_code + 1; 
    39684035    ULONG length = 
    3969             (dq.dq_ProbeLength < pp->pp_TreePruneLength) ? 
    3970                     dq.dq_ProbeLength : pp->pp_TreePruneLength; 
     4036            (dq.dq_ProbeLength < pp->pp_TreePruneLength) ? dq.dq_ProbeLength : 
     4037                    pp->pp_TreePruneLength; 
    39714038    double currtemp = 0.0; 
    39724039    UWORD currgc = 0; 
  • branches/ptpan_back/ptpan/ptpan_tree.h

    r8186 r8281  
    318318     */ 
    319319    static const std::string version() { 
    320         return "0.6.6_beta"; 
     320        return "0.6.7_beta"; 
    321321    } 
    322322 
     
    333333    const PTPanEntry* getFirstEntry() const; 
    334334    const PTPanEntry* getEntry(ULONG id) const; 
     335    const PTPanEntry* getEntry(const std::string& id) const; 
    335336    CONST_STRPTR getEntryFullName(ULONG id) const; 
    336337    CONST_STRPTR getEntryId(ULONG id) const; 
    337338 
    338339    const std::vector<std::string> getAllEntryIds() const; 
     340    const std::vector<PTPanEntry*> getAllEntries() const; 
    339341 
    340342    ULONG getPruneLength() const; 
  • branches/ptpan_back/ptpan/ptpan_tree_builder.cxx

    r8214 r8281  
    10001000                mergeEntry(); 
    10011001                m_threadpool->wait(); 
    1002                 m_threadpool->clear(); 
    10031002            } 
    10041003