Skip to content

Commit 2f438e3

Browse files
committed
Adds version info.
1 parent fe417e9 commit 2f438e3

5 files changed

Lines changed: 45 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ find_package(Threads)
2222

2323
#get_target_property(SHRINKWRAP_LIBS shrinkwrap INTERFACE_LINK_LIBRARIES)
2424

25-
add_definitions(-DSAVVY_VERSION="${PROJECT_VERSION}")
25+
add_definitions(-DSAVVY_VERSION="${PROJECT_VERSION}-alpha")
2626

2727
set(HEADER_FILES
2828
include/savvy/savvy.hpp include/savvy/reader.hpp include/savvy/m3vcf_reader.hpp include/savvy/sav_reader.hpp include/savvy/allele_status.hpp include/savvy/vcf_reader.hpp include/savvy/varint.hpp include/savvy/s1r.hpp include/savvy/site_info.hpp include/savvy/variant_iterator.hpp include/savvy/portable_endian.hpp include/savvy/region.hpp include/savvy/compressed_vector.hpp include/savvy/eigen3_vector.hpp include/savvy/ublas_vector.hpp include/savvy/armadillo_vector.hpp include/savvy/utility.hpp include/savvy/data_format.hpp)

include/savvy/utility.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace savvy
1313
// return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
1414
// }
1515

16+
static const std::string version = SAVVY_VERSION;
17+
1618
std::string parse_header_id(std::string header_value);
1719

1820
namespace detail

src/sav2vcf.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ class prog_args
1818
std::string input_path_;
1919
std::string output_path_;
2020
bool help_ = false;
21+
bool version_ = false;
2122
savvy::fmt format_ = savvy::fmt::allele;
2223
public:
2324
prog_args() :
2425
long_options_(
2526
{
2627
{"format", required_argument, 0, 'f'},
2728
{"help", no_argument, 0, 'h'},
29+
{"version", no_argument, 0, 'v'},
2830
{0, 0, 0, 0}
2931
})
3032
{
@@ -34,6 +36,7 @@ class prog_args
3436
const std::string& output_path() { return output_path_; }
3537
savvy::fmt format() const { return format_; }
3638
bool help_is_set() const { return help_; }
39+
bool version_is_set() const { return version_; }
3740

3841
void print_usage(std::ostream& os)
3942
{
@@ -42,6 +45,7 @@ class prog_args
4245
os << "\n";
4346
//os << " -f, --format : Format field to copy (GT or GP, default: GT)\n";
4447
os << " -h, --help : Print usage\n";
48+
os << " -v, --version : Print version\n";
4549
os << "----------------------------------------------\n";
4650
os << std::flush;
4751
}
@@ -50,7 +54,7 @@ class prog_args
5054
{
5155
int long_index = 0;
5256
int opt = 0;
53-
while ((opt = getopt_long(argc, argv, "f:h", long_options_.data(), &long_index )) != -1)
57+
while ((opt = getopt_long(argc, argv, "f:hv", long_options_.data(), &long_index )) != -1)
5458
{
5559
std::string str_opt_arg(optarg ? optarg : "");
5660
char copt = char(opt & 0xFF);
@@ -70,6 +74,9 @@ class prog_args
7074
case 'h':
7175
help_ = true;
7276
break;
77+
case 'v':
78+
version_ = true;
79+
break;
7380
default:
7481
return false;
7582
}
@@ -117,6 +124,12 @@ int main(int argc, char** argv)
117124
return EXIT_SUCCESS;
118125
}
119126

127+
if (args.version_is_set())
128+
{
129+
std::cout << "sav2vcf v" << savvy::version << std::endl;
130+
return EXIT_SUCCESS;
131+
}
132+
120133
savvy::sav::reader<1> input(args.input_path(), args.format());
121134
savvy::site_info variant;
122135
std::vector<float> genotypes;

src/savvy_speed_test.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ class prog_args
1919
std::string input_path_;
2020
//std::string output_path_;
2121
bool help_ = false;
22+
bool version_ = false;
2223
savvy::fmt format_ = savvy::fmt::allele;
2324
public:
2425
prog_args() :
2526
long_options_(
2627
{
2728
{"format", required_argument, 0, 'f'},
2829
{"help", no_argument, 0, 'h'},
30+
{"version", no_argument, 0, 'v'},
2931
{0, 0, 0, 0}
3032
})
3133
{
@@ -35,6 +37,7 @@ class prog_args
3537
//const std::string& output_path() { return output_path_; }
3638
savvy::fmt format() const { return format_; }
3739
bool help_is_set() const { return help_; }
40+
bool version_is_set() const { return version_; }
3841

3942
void print_usage(std::ostream& os)
4043
{
@@ -43,6 +46,7 @@ class prog_args
4346
os << "\n";
4447
os << " -f, --format : Format field to copy (GT or GP, default: GT)\n";
4548
os << " -h, --help : Print usage\n";
49+
os << " -v, --version : Print version\n";
4650
os << "----------------------------------------------\n";
4751
os << std::flush;
4852
}
@@ -51,7 +55,7 @@ class prog_args
5155
{
5256
int long_index = 0;
5357
int opt = 0;
54-
while ((opt = getopt_long(argc, argv, "f:h", long_options_.data(), &long_index )) != -1)
58+
while ((opt = getopt_long(argc, argv, "f:hv", long_options_.data(), &long_index )) != -1)
5559
{
5660
std::string str_opt_arg(optarg ? optarg : "");
5761
char copt = char(opt & 0xFF);
@@ -70,6 +74,9 @@ class prog_args
7074
case 'h':
7175
help_ = true;
7276
break;
77+
case 'v':
78+
version_ = true;
79+
break;
7380
default:
7481
return false;
7582
}
@@ -117,6 +124,12 @@ int main(int argc, char** argv)
117124
return EXIT_SUCCESS;
118125
}
119126

127+
if (args.version_is_set())
128+
{
129+
std::cout << "Savvy Speed Test v" << savvy::version << std::endl;
130+
return EXIT_SUCCESS;
131+
}
132+
120133
// auto* hts_file = bcf_open(args.input_path().c_str(), "r");
121134
// auto* hts_hdr = bcf_hdr_read(hts_file);
122135
// bcf1_t* hts_rec = bcf_init1();

src/vcf2sav.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class prog_args
2121
int compression_level_ = -1;
2222
std::uint16_t block_size_ = default_block_size;
2323
bool help_ = false;
24+
bool version_ = false;
2425
savvy::fmt format_ = savvy::fmt::allele;
2526
public:
2627
prog_args() :
@@ -29,6 +30,7 @@ class prog_args
2930
{"block-size", required_argument, 0, 'b'},
3031
{"format", required_argument, 0, 'f'},
3132
{"help", no_argument, 0, 'h'},
33+
{"version", no_argument, 0, 'v'},
3234
{0, 0, 0, 0}
3335
})
3436
{
@@ -40,6 +42,7 @@ class prog_args
4042
std::uint16_t block_size() const { return block_size_; }
4143
savvy::fmt format() const { return format_; }
4244
bool help_is_set() const { return help_; }
45+
bool version_is_set() const { return version_; }
4346

4447
void print_usage(std::ostream& os)
4548
{
@@ -50,6 +53,7 @@ class prog_args
5053
os << " -b, --block-size : Number of markers in compression block (0-65535, default: " << default_block_size << ")\n";
5154
os << " -f, --format : Format field to copy (GT or GP, default: GT)\n";
5255
os << " -h, --help : Print usage\n";
56+
os << " -v, --version : Print version\n";
5357
os << "----------------------------------------------\n";
5458
os << std::flush;
5559
}
@@ -58,7 +62,7 @@ class prog_args
5862
{
5963
int long_index = 0;
6064
int opt = 0;
61-
while ((opt = getopt_long(argc, argv, "0123456789b:f:h", long_options_.data(), &long_index )) != -1)
65+
while ((opt = getopt_long(argc, argv, "0123456789b:f:hv", long_options_.data(), &long_index )) != -1)
6266
{
6367
std::string str_opt_arg(optarg ? optarg : "");
6468
char copt = char(opt & 0xFF);
@@ -96,6 +100,9 @@ class prog_args
96100
case 'h':
97101
help_ = true;
98102
break;
103+
case 'v':
104+
version_ = true;
105+
break;
99106
default:
100107
return false;
101108
}
@@ -149,6 +156,12 @@ int main(int argc, char** argv)
149156
return EXIT_SUCCESS;
150157
}
151158

159+
if (args.version_is_set())
160+
{
161+
std::cout << "vcf2sav v" << savvy::version << std::endl;
162+
return EXIT_SUCCESS;
163+
}
164+
152165
savvy::vcf::reader<1> input(args.input_path(), args.format());
153166

154167
if (input.good())

0 commit comments

Comments
 (0)