GATB的使用小例子test.cpp

1.touch test.cpp,,文件夹中 出现test.cpp

touch test.cpp

2. test.cpp的内容

#include <gatb/gatb_core.hpp>
    int main (int argc, char* argv[])
    {
        // a small GATB example

        const size_t span = KMER_SPAN(1);
        typedef Kmer<span>::ModelCanonical Model;
        Model model (5);
        Model::Kmer kmer = model.codeSeed ("AAGTC", Data::ASCII);
        std::cout << "revcomp kmer: " << model.toString(kmer.revcomp())    << std::endl;
    }

3.编译,显示结果

具体

To get started with your own code (let's say, test.cpp), here is a quick walkthrough

wget https://github.com/GATB/gatb-core/releases/download/v1.2.2/gatb-core-1.2.2-bin-Linux.tar.gz
tar xf gatb-core-1.2.2-bin-Linux.tar.gz
mv gatb-core-1.2.2-bin-Linux gatb-core

Create a small example code in test.cpp:

#include <gatb/gatb_core.hpp>
int main (int argc, char* argv[])
{
    // a small GATB example
​
    const size_t span = KMER_SPAN(1);
    typedef Kmer<span>::ModelCanonical Model;
    Model model (5);
    Model::Kmer kmer = model.codeSeed ("AAGTC", Data::ASCII);
    std::cout << "revcomp kmer: " << model.toString(kmer.revcomp())    << std::endl;
}

Now the folder structure looks like:

test.cpp
gatb-core/
gatb-core/include/
gatb-core/lib/
...

To compile:

g++ test.cpp -Igatb-core/include -Lgatb-core/lib -lgatbcore -lhdf5 -ldl -lz -lpthread  -std=c++0x -O3 -o test 

Then the program is ready to run:

./test

Output:

revcomp kmer: GACTT

========================================

使用它同样的方法

Here, we simply compile a snippet taken from the 'examples' directory: 将它 取出来

(二)debruijn1.cpp

g++ debruijn1.cpp -Igatb-core/include -Lgatb-core/lib -lgatbcore -lhdf5 -ldl -lz -lpthread  -std=c++0x -O3 -o debruijn1

./debruijn

//! [snippet1]

// We include what we need for the test
#include <gatb/gatb_core.hpp>

/********************************************************************************/
/*  Graph creation from command line options                                    */
/*                                                                              */
/*  This snippet uses the OptionsParser facility of GATB-Core library.          */
/*                                                                              */
/* Cmd-line: debruijn1 -in <fasta/q file>                                       */
/*                                                                              */
/* Sample: debruijn1 -in gatb-core/gatb-core/test/db/reads1.fa                  */
/*                                                                              */
/********************************************************************************/
int main (int argc, char* argv[])
{
    // We get a command line parser for graphs available options.
    IOptionsParser* parser = Graph::getOptionsParser();
    LOCAL (parser);

    // We use a try/catch block in case we have some command line parsing issue.
    try
    {
        // We parse the user options.
        parser->parse (argc, argv);

        // We create the graph with the provided options.
        Graph graph = Graph::create (parser->getProperties());

        // We dump some information about the graph.
        std::cout << graph.getInfo() << std::endl;
    }
    catch (OptionFailure& e)
    {
        return e.displayErrors (std::cout);
    }
    catch (Exception& e)
    {
        std::cerr << "EXCEPTION: " << e.getMessage() << std::endl;
    }

    return EXIT_SUCCESS;
}
//! [snippet1]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wangchuang2017

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值