当前位置: 首页>>代码示例>>C++>>正文


C++ util::bits2nuc方法代码示例

本文整理汇总了C++中util::bits2nuc方法的典型用法代码示例。如果您正苦于以下问题:C++ util::bits2nuc方法的具体用法?C++ util::bits2nuc怎么用?C++ util::bits2nuc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util的用法示例。


在下文中一共展示了util::bits2nuc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

bam1_t * punchout_read(
        const bam1_t * const in_bam,
        const vector< cov_t > & variants,
        const aligned_t & read
        )
{
    aligned_t::const_iterator rit = read.begin();
    var_citer vit = variants.begin();
    vector< pair< bool, unsigned > > keep;
    vector< int > cols;

    bam1_t * const out_bam = bam_init1();

    if ( !out_bam ) {
        cerr << "memory allocation error" << endl;
        exit( 1 );
    }

    out_bam->core = in_bam->core;
    out_bam->core.l_qseq = 0;

    // build a vector of which positions we're keeping,
    // and how long our new seq will be
    for ( ; rit != read.end() && vit != variants.end(); ) {

#if 0
        cerr << "r: ( " << rit->col << ", " << rit->op == INS << ", ";
        for ( unsigned j = 0; j < rit->elem.size(); ++j )
            cerr << bits2nuc( rit->elem[ j ] );
        cerr << " )" << endl;
        cerr << "v: ( " << vit->col << ", " << vit->op == INS << " )" << endl;
#endif

        if ( rit->col == vit->col && rit->op == vit->op ) {
            elem_t elem;
            obs_citer it;

            rit->get_seq( elem );
            it = vit->obs.find( elem );

            if ( it == vit->obs.end() ) {
                cerr << "unknown variant observed, which is weird...( 1 )" << endl;
                exit( 1 );
            }

            if ( it->second ) {
                keep.push_back( make_pair( true, it->first.size() ) );
                cols.push_back( rit->col );
                out_bam->core.l_qseq += it->first.size();
            }
            else
                keep.push_back( make_pair( false, it->first.size() ) );

            ++rit;
            ++vit;
        }
        // matching column in variants, but insertion in read
        else if ( rit->col == vit->col && rit->op == INS ) {
            ++vit;
        }
        // matching column in read, but insertion in variants:
        // we got ahead in read somehow, which should never happen
        else if ( rit->col == vit->col && vit->op == INS ) {
            cerr << "unknown variant observed, which is weird...( 2 )" << endl;
            exit( 1 );
        }
        // read is behind variants for some reason, which should never happen
        else if ( rit->col < vit->col ) {
            cerr << "unknown variant observed, which is weird...( 3 )" << endl;
            exit( 1 );
        }
        else // ( vit->col < rit->col )
            ++vit;
    }

    // cerr << "seqlen: " << out_bam->core.l_qseq << endl;

    out_bam->data_len = in_bam->data_len;
    out_bam->m_data = out_bam->data_len;
    out_bam->data = NULL;

    realloc_data( out_bam );

    // copy the read name
    memcpy( bam1_qname( out_bam ), bam1_qname( in_bam ), in_bam->core.l_qname );

    // update the cigar string
    {
        const uint32_t * cigar = bam1_cigar( in_bam );
        int in_idx = 0, out_idx = 0;
        vector< int > cigar_;

        for ( int i = 0; i < in_bam->core.n_cigar; ++i ) {
            const int op = cigar[ i ] & BAM_CIGAR_MASK;
            const int nop = cigar[ i ] >> BAM_CIGAR_SHIFT;

            if ( op == BAM_CDEL )
                for ( int j = 0; j < nop; ++j )
                    cigar_.push_back( BAM_CDEL );
            else if ( op == BAM_CINS ) {
//.........这里部分代码省略.........
开发者ID:kemaleren,项目名称:sequtil,代码行数:101,代码来源:main.cpp

示例2: main

int main( int argc, const char * argv[] )
{
    args_t args = args_t( argc, argv );
    coverage_t coverage;
    vector< cov_t > variants;
    vector< pair< int, int > > data;

    // accumulate the data at each position in a linked list
    {
        cov_citer cit;
        bam1_t * in_bam = bam_init1();

        while ( args.bamin->next( in_bam ) ) {
            aligned_t read( in_bam );
            coverage.include( read );
        }

        for ( cit = coverage.begin(); cit != coverage.end(); ++cit ) {
            int cov = 0;

            for ( obs_citer it = cit->obs.begin(); it != cit->obs.end(); ++it )
                cov += it->second;
           
            for ( obs_citer it = cit->obs.begin(); it != cit->obs.end(); ++it )
                if ( it->second )
                    data.push_back( make_pair( cov, it->second ) );

#if 0
            obs_citer it = cit->obs.begin();
            int cov = 0, maj;

            if ( it == cit->obs.end() )
                continue;

            maj = it->second;
            cov += maj;

            for ( ++it; it != cit->obs.end(); ++it ) {
                if ( it->second > maj )
                    maj = it->second;
                cov += it->second;
            }

            data.push_back( make_pair( cov, maj ) );
#endif
        }

        bam_destroy1( in_bam );
    }

    // learn a joint multi-binomial model for the mutation rate classes
    {
        cov_iter cit;
        double lg_L, aicc, bg, lg_bg, lg_invbg;
        rateclass_t rc( data );
        vector< pair< double, double > > params;

        rc( lg_L, aicc, params );

        bg = params[ 0 ].second;
        lg_bg = log( bg );
        lg_invbg = log( 1.0 - bg );

        params_json_dump( stderr, lg_L, aicc, params );

        // cerr << "background: " << bg << endl;

        // determine which variants are above background and those which are not
        for ( cit = coverage.begin(); cit != coverage.end(); ++cit ) {
            if ( cit->op == INS )
                continue;

            int cov = 0;

            for ( obs_citer it = cit->obs.begin(); it != cit->obs.end(); ++it )
                cov += it->second;

            for ( obs_iter it = cit->obs.begin(); it != cit->obs.end(); ++it ) {
                const double p = prob_background( lg_bg, lg_invbg, cov, it->second );
                if ( p < args.cutoff ) {
                    cout << cit->col << "\t" << cov << "\t" << it->second;
                    for ( unsigned i = 0; i < it->first.size(); ++i )
                        cout << bits2nuc( it->first[ i ] );
                    cout << ":" << p << endl;
                    it->second = 1;
                }
                else {
                    it->second = 0;
                }
            }

#if 0
            variants.push_back( *cit );
#endif
        }
    }

    return 0;

    // write out the input reads, but only with "real" variants this time
//.........这里部分代码省略.........
开发者ID:kemaleren,项目名称:sequtil,代码行数:101,代码来源:main.cpp


注:本文中的util::bits2nuc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。