GATB的使用小例子test.cpp
本站寻求有缘人接手,详细了解请联系站长QQ1493399855
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 exampleconst 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]