#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace OpenBabel; #include "ECMol.hpp" #include "WrapSQLite_Base.hpp" #include "WrapSQLite.hpp" #include "Overlap.hpp" #include "Fragmentation.hpp" #include "BBMol.hpp" #include "Library.hpp" #include "Build.hpp" void print_usage(void) { printf("merge \n"); printf(" DB1\tフラグメントDB(入力1) \n"); printf(" DB2\tフラグメントDB(入力2) \n"); printf(" DB3\tマージされたフラグメントDB(出力) \n"); printf("\n"); printf("options:\n"); printf(" -p : フラグメントIDの接頭辞 (default \"X\")\n"); printf("SVN# %d\n",REV); } int main(int argc, char *argv[]) { ifstream ifs; string identifier="frag"; string prefix="X"; string comment=""; int c; while((c=getopt(argc, argv, "p:")) != -1){ switch (c){ case 'p': prefix=string(optarg); break; default: print_usage(); exit(1); } } if ((argc-optind) != 3) { print_usage(); exit(1); } string fdb1=argv[optind++]; string fdb2=argv[optind++]; string fdb3=argv[optind++]; // SQLite WrapSQLite dbh; dbh.open(fdb3); dbh.init(identifier); // merge string SQL; SQL="attach '" + fdb1 + "' as xx"; dbh.exec_sql(SQL); SQL="attach '" + fdb2 + "' as yy"; dbh.exec_sql(SQL); SQL="create table tmp_s as select * from xx.frag_s"; dbh.exec_sql(SQL); SQL="insert into tmp_s select * from yy.frag_s"; dbh.exec_sql(SQL); SQL="create table tmp_f as select * from xx.frag_f"; dbh.exec_sql(SQL); SQL="insert into tmp_f select * from yy.frag_f"; dbh.exec_sql(SQL); SQL="detach xx"; dbh.exec_sql(SQL); SQL="detach yy"; dbh.exec_sql(SQL); // unique SQL="insert into frag_s select * from tmp_s group by smarts"; dbh.exec_sql(SQL); SQL="insert into frag_f select * from tmp_f group by smarts"; dbh.exec_sql(SQL); SQL="drop table tmp_s"; dbh.exec_sql(SQL); SQL="drop table tmp_f"; dbh.exec_sql(SQL); // ID dbh.Rename(identifier, prefix); // コメント挿入 dbh.Comment(identifier, comment); // コメント挿入 dbh.CountFrag(identifier); cout << "\tdone\n" << flush; dbh.close(); return 0; }