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


C++ Sequence::Size方法代码示例

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


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

示例1: InsertSequence

void HashGraph::InsertSequence(const Sequence &seq, uint64 prefix, uint64 mask)
{
    if (seq.Size() < kmerLength)
        return;

    Kmer kmer;
    for (int i = 0; i < kmerLength-1; ++i)
        kmer.AddRight(seq[i]);
    for (int i = kmerLength-1; i < seq.Size(); ++i)
    {
        kmer.AddRight(seq[i]);
        Kmer key = kmer;
        Kmer rev_comp = kmer;
        rev_comp.ReverseComplement();
        if (rev_comp < kmer)
            key = rev_comp;

        if ((key.Hash() & mask) == prefix)
        {
            KmerNodeAdapter adp(InsertKmer(kmer), kmer);
            if (i >= (int)kmerLength)
            {
                adp.AddInEdge(3 - seq[i-kmerLength]);
            }

            if (i+1 < seq.Size())
            {
                adp.AddOutEdge(seq[i+1]);
            }
        }
    }
}
开发者ID:brettin,项目名称:hku-idba,代码行数:32,代码来源:HashGraph.cpp

示例2: AddEdgesFromSequence

bool HashGraph::AddEdgesFromSequence(const Sequence &seq)
{
    if (seq.Size() < kmerLength)
        return false;

    bool flag = false;
    Kmer kmer;
    for (int i = 0; i < kmerLength-1; ++i)
        kmer.AddRight(seq[i]);
    for (int i = kmerLength-1; i < seq.Size(); ++i)
    {
        kmer.AddRight(seq[i]);

        KmerNodeAdapter adp = GetNodeAdapter(kmer);
        if (!adp.IsNull())
        {
            flag = true;
            adp.Increase();
            if (i >= (int)kmerLength)
            {
                adp.AddInEdge(3 - seq[i-kmerLength]);
            }

            if (i+1 < seq.Size())
            {
                adp.AddOutEdge(seq[i+1]);
            }
        }
    }

    return flag;
}
开发者ID:brettin,项目名称:hku-idba,代码行数:32,代码来源:HashGraph.cpp

示例3: IsValid

bool HashGraph::IsValid(const Sequence &seq)
{
    Kmer kmer;
    for (int i = 0; i < kmerLength-1; ++i)
        kmer.AddRight(seq[i]);
    for (int i = kmerLength-1; i < seq.Size(); ++i)
    {
        kmer.AddRight(seq[i]);
        if (GetNode(kmer) == NULL)
            return false;
    }

    return true;
}
开发者ID:brettin,项目名称:hku-idba,代码行数:14,代码来源:HashGraph.cpp

示例4: AddInternalKmers

void HashGraph::AddInternalKmers(const Sequence &seq, int minCount)
{
    if (seq.Size() <= kmerLength)
        return;

    vector<int> v;
    int count = 0;
    int sum = 0;
    Kmer kmer;
    for (int i = 0; i < kmerLength-1; ++i)
        kmer.AddRight(seq[i]);
    for (int i = kmerLength-1; i < seq.Size(); ++i)
    {
        kmer.AddRight(seq[i]);

        KmerNode *node = GetNode(kmer);
        if (node != NULL && node->Count() >= (unsigned)minCount)
        {
            sum += node->Count();
            ++count;
            v.push_back(i);
        }
    }

    if (count > max(seq.Size() - kmerLength*2 + 1, (seq.Size() - kmerLength + 1)/2))
    {
        Kmer kmer;
        for (int i = 0; i < kmerLength-1; ++i)
            kmer.AddRight(seq[i]);
        for (int i = kmerLength-1; i < seq.Size(); ++i)
        {
            kmer.AddRight(seq[i]);

            if (v.front() <= i && i <= v.back() && GetNode(kmer) == NULL)
            {
                KmerNodeAdapter adp(InsertKmer(kmer), kmer);
                if (i >= (int)kmerLength)
                {
                    adp.AddInEdge(3 - seq[i-kmerLength]);
                }

                if (i+1 < seq.Size())
                {
                    adp.AddOutEdge(seq[i+1]);
                }
            }
        }
    }
}
开发者ID:brettin,项目名称:hku-idba,代码行数:49,代码来源:HashGraph.cpp

示例5: ReadBunchOfReads

void AbstractAssembler::ReadBunchOfReads(vector<Read> &reads, int64 expected_num)
{
    reads.resize(expected_num);
    Sequence seq;
    string comment;
    int count = 0;
    for (int64 i = 0; i < (int64)reads.size(); ++i)
    {
        if (!read_reader->Read(seq, comment))
        {
            reads.resize(i);
            break;
        }

        reads[i].Inactivate();
        seq.Trim(option.trim);

        int from = 0;
        int to = 0;
        int last = 0;
        
        for (int current = 0; current < seq.Size(); ++current)
        {
            if (seq[current] == 'N')
            {
                if (current - last > to - from)
                {
                    from = last;
                    to = current;
                }

                last = current + 1;
            }
        }

        if (seq.Size() - last > to - from)
        {
            from = last;
            to = seq.Size();
        }

        Sequence valid_seq;
        seq.GetSubSequence(valid_seq, from, to - from);

        seq = valid_seq;

//        seq.TrimError();
//        seq.ReverseComplement();
//        seq.TrimError();
//        seq.ReverseComplement();


        if (!seq.IsChar())
            continue;

        ++count;

        seq.Encode();
        reads[i] = seq;
    }

    printf("reads %d\n", count);
}
开发者ID:brettin,项目名称:hku-idba,代码行数:63,代码来源:AbstractAssembler.cpp

示例6: main

int main(int argc, char *argv[])
{
    AddParameter("length", &length, INTEGER);
    AddParameter("mate", &mate, SIMPLE);

    ProcessParameters(argc, argv);

    if (argc < 3
        || strcmp(argv[1], "--help") == 0
        || strcmp(argv[1], "-h") == 0)
    {
        fprintf(stderr, "usage: normReads fa-file norm-fa-file\n");
        fprintf(stderr, "       [--length l] [--mate]\n");
        exit(1);
    }

    FastAReader reader(argv[1]);
    FastAWriter writer(argv[2]);

    Sequence seq;
    Sequence seq2;
    unsigned index = 0;
    string comment;
    string comment2;

    if (mate)
    {
        while (reader.Read(seq, comment))
        {
            if (!reader.Read(seq2, comment2))
                break;

            if (length == 0)
            {
                writer.Write(seq, comment);
                writer.Write(seq2, comment2);
                index += 2;
            }
            else
            {
                if (seq.Size() >= length && seq2.Size() >= length)
                {
                    seq.Resize(length);
                    seq2.Resize(length);
                    writer.Write(seq, comment);
                    writer.Write(seq2, comment2);
                    index += 2;
                }
            }
        }
    }
    else
    {
        while (reader.Read(seq, comment))
        {
            if (length == 0)
            {
                writer.Write(seq, comment);
                ++index;
            }
            else
            {
                if (seq.Size() >= length)
                {
                    seq.Resize(length);
                    writer.Write(seq, comment);
                    ++index;
                }
            }
        }
    }

//    fclose(freadFile);
//    fclose(ftableFile);

    return 0;
}
开发者ID:brettin,项目名称:hku-idba,代码行数:77,代码来源:normReads.cpp


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