@@ -45,7 +45,8 @@ vector<map<string, string>> extract_hrecs(bcf_hdr_t *hdr, const char *key,
4545}
4646
4747string schemaDDL (const string &table_prefix, vector<map<string, string>> &info_hrecs,
48- vector<map<string, string>> &format_hrecs, int ploidy) {
48+ vector<map<string, string>> &format_hrecs, int ploidy,
49+ bool genotypes_without_rowid) {
4950
5051 OStringStream out;
5152 out << " CREATE TABLE " << table_prefix
@@ -120,7 +121,10 @@ string schemaDDL(const string &table_prefix, vector<map<string, string>> &info_h
120121 }
121122 }
122123 }
123- out << " \n , PRIMARY KEY (variant_rowid, sample_id)) WITHOUT ROWID" ;
124+ out << " \n , PRIMARY KEY (variant_rowid, sample_id))" ;
125+ if (genotypes_without_rowid) {
126+ out << " WITHOUT ROWID" ;
127+ }
124128 }
125129
126130 return string (out.Get ());
@@ -612,30 +616,33 @@ void help() {
612616 << ' \n '
613617 << " vcf_into_sqlite [options] in.vcf|- out.db" << ' \n '
614618 << " Options: " << ' \n '
615- << " --table-prefix PREFIX prefix to the name of each table created" << ' \n '
616- << " --ploidy N set max ploidy => # GT columns (default 2)" << ' \n '
617- << " --no-gri skip genomic range indexing" << ' \n '
618- << " -l,--level LEVEL database compression level (-7 to 22, default 6)" << ' \n '
619- << " -q,--quiet suppress progress information on standard error" << ' \n '
620- << " -h,--help show this help message" << ' \n '
619+ << " --table-prefix PREFIX prefix to the name of each table created" << ' \n '
620+ << " --ploidy N set max ploidy => # GT columns (default 2)" << ' \n '
621+ << " --genotypes-without-rowid make the genotypes table WITHOUT ROWID (advantageous if there are few/no FORMAT fields)"
622+ << ' \n '
623+ << " --no-gri skip genomic range indexing" << ' \n '
624+ << " -l,--level LEVEL database compression level (-7 to 22, default 6)" << ' \n '
625+ << " -q,--quiet suppress progress information on standard error" << ' \n '
626+ << " -h,--help show this help message" << ' \n '
621627 << ' \n ' ;
622628}
623629
624630int main (int argc, char *argv[]) {
625631 string table_prefix, infilename, outfilename;
626- bool gri = true , progress = true ;
632+ bool gri = true , progress = true , genotypes_without_rowid = false ;
627633 int level = 6 , ploidy = 2 ;
628634
629635 static struct option long_options[] = {{" help" , no_argument, 0 , ' h' },
630636 {" quiet" , no_argument, 0 , ' q' },
631637 {" level" , required_argument, 0 , ' l' },
632638 {" ploidy" , required_argument, 0 , ' p' },
639+ {" genotypes-without-rowid" , no_argument, 0 , ' R' },
633640 {" table-prefix" , required_argument, 0 , ' t' },
634641 {" no-gri" , no_argument, 0 , ' G' },
635642 {0 , 0 , 0 , 0 }};
636643
637644 int c;
638- while (-1 != (c = getopt_long (argc, argv, " hqGl :t:p:" , long_options, nullptr ))) {
645+ while (-1 != (c = getopt_long (argc, argv, " hqGRl :t:p:" , long_options, nullptr ))) {
639646 switch (c) {
640647 case ' h' :
641648 help ();
@@ -646,6 +653,9 @@ int main(int argc, char *argv[]) {
646653 case ' G' :
647654 gri = false ;
648655 break ;
656+ case ' R' :
657+ genotypes_without_rowid = true ;
658+ break ;
649659 case ' t' :
650660 table_prefix = optarg;
651661 break ;
@@ -751,7 +761,8 @@ int main(int argc, char *argv[]) {
751761
752762 // formulate & apply DDL
753763 // TODO: allow --append
754- string ddl = schemaDDL (table_prefix, info_hrecs, format_hrecs, ploidy);
764+ string ddl =
765+ schemaDDL (table_prefix, info_hrecs, format_hrecs, ploidy, genotypes_without_rowid);
755766 progress &&cerr << ddl << endl;
756767 db->exec (ddl);
757768
0 commit comments