[opdev] C++ api for operon

4 views
Skip to first unread message

Pierre Lindenbaum

unread,
Jun 3, 2009, 10:00:21 AM6/3/09
to opero...@googlegroups.com, foglio, he...@cng.fr
Hi all,
I've started to write a C++ API for operon. As previously, most of the
classes are generated with apache-velocity from Mario's schema.

here is an example: first search all the SnpIds for "rs25" and then
search all the SnpIds between "rs25" and "rs26". Here is the source
code (or see it at
http://code.google.com/p/polymorphism/source/browse/trunk/operoncc/src/test01.cpp
):

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

#include "operon.h"

using namespace std;

int main(int argc,char** argv)
{
//open Operon
Operon operon("/operon/new/bdb");
//get a Handle to the SnpIds database for the NCBI/Human-Genome build 36
SnpIdsDB db(&operon,Assembly::HSA_NCBI_BUILD_36);
//open the database
db.open();

//simple search rs25
std::vector<SnpIds> array= db.get("rs25");
for(std::vector<SnpIds>::size_type i=0;i< array.size();++i)
{
//display the key and the value
cout << "\t" << array[i] << endl;
}

//get an iterator for all the SNP between rs25 and rs26 (include rs26 too)
SnpIdsDB::iterator_type* iter= db.listBetween("rs25","rs26",true);
//loop over the results
while(iter->hasNext())
{
//get the result
SnpIdsDB::pair_type pair=iter->next();
//display the key and the value
cout << pair.first << "\t" << pair.second << endl;
}
//delete the iterator
delete iter;
//close the database
db.close();
return 0;
}
===========================================================================================
ant here is the result
===========================================================================================
{fid: 101071011550667,acn: rs25}
rs25 {fid: 101071011550667,acn: rs25}
rs250 {fid: 101081019855303,acn: rs250}
rs2500 {fid: 101111066153896,acn: rs2500}
rs250000 {fid: 101051096174973,acn: rs250000}
rs2500000 {fid: 101111005021591,acn: rs2500000}
rs2500001 {fid: 101111005021614,acn: rs2500001}
rs2500002 {fid: 101111005021624,acn: rs2500002}
rs2500003 {fid: 101111005021650,acn: rs2500003}
rs2500004 {fid: 101111005021964,acn: rs2500004}
rs2500005 {fid: 101111005021972,acn: rs2500005}
rs2500006 {fid: 101111005022078,acn: rs2500006}
(...)
rs2599994 {fid: 101021130671888,acn: rs2599994}
rs2599994 {fid: 101021131950757,acn: rs2599994}
rs2599995 {fid: 101021130670741,acn: rs2599995}
rs2599995 {fid: 101021131951880,acn: rs2599995}
rs2599996 {fid: 101021130670316,acn: rs2599996}
rs2599996 {fid: 101021131952305,acn: rs2599996}
rs2599997 {fid: 101021130670041,acn: rs2599997}
rs2599998 {fid: 101121056176842,acn: rs2599998}
rs2599999 {fid: 101121056238062,acn: rs2599999}
rs26 {fid: 101071011549996,acn: rs26}


Pierre

Reply all
Reply to author
Forward
0 new messages