Skip to content

Commit

Permalink
rename and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Oct 25, 2022
1 parent 885e80c commit ea502d0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
.idea
*.log
a.*
t.*
a-*
.cache
tmp/
Expand Down
2 changes: 1 addition & 1 deletion tools/dosage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ int main(int argc, char* argv[])
var.setFORMAT("DS", ds);
bw.writeRecord(var);
}
bw.Close();
// bw.close();
return 0;
}
27 changes: 15 additions & 12 deletions vcfpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ namespace vcfpp
*/
BcfReader(const std::string& file) : fname(file)
{
Open(file);
open(file);
}

/**
Expand All @@ -960,7 +960,7 @@ namespace vcfpp
*/
BcfReader(const std::string& file, const std::string& samples) : fname(file)
{
Open(file);
open(file);
header.setSamples(samples);
nsamples = bcf_hdr_nsamples(header.hdr);
SamplesName = header.getSamples();
Expand All @@ -978,7 +978,7 @@ namespace vcfpp
*/
BcfReader(const std::string& file, const std::string& samples, const std::string& region) : fname(file)
{
Open(file);
open(file);
header.setSamples(samples);
nsamples = bcf_hdr_nsamples(header.hdr);
if (!region.empty())
Expand All @@ -993,7 +993,7 @@ namespace vcfpp
}

/// open a VCF/BCF/STDIN file for streaming in
void Open(const std::string& file)
void open(const std::string& file)
{
fname = file;
fp = hts_open(file.c_str(), "r");
Expand All @@ -1012,7 +1012,7 @@ namespace vcfpp
}

/// close the BcfReader object.
void Close()
void close()
{
if (fp)
hts_close(fp);
Expand Down Expand Up @@ -1128,7 +1128,7 @@ namespace vcfpp
*/
BcfWriter(const std::string& fname)
{
Open(fname);
open(fname);
}

/**
Expand All @@ -1142,18 +1142,19 @@ namespace vcfpp
*/
BcfWriter(const std::string& fname, const std::string& mode)
{
Open(fname, mode);
open(fname, mode);
}

virtual ~BcfWriter()
{
close();
}

/**
* @brief Open VCF/BCF file for writing. The format is infered from file's suffix
* @param fname The file name or "-" for stdin/stdout. For indexed files
*/
void Open(const std::string& fname)
void open(const std::string& fname)
{
std::string mode{"w"};
if (isEndWith(fname, "bcf.gz"))
Expand All @@ -1174,16 +1175,18 @@ namespace vcfpp
* [w]z .. compressed VCF \n
* [w] .. uncompressed VCF
*/
void Open(const std::string& fname, const std::string& mode)
void open(const std::string& fname, const std::string& mode)
{
fp = hts_open(fname.c_str(), mode.c_str());
}

/// close the BcfWriter object.
void Close()
void close()
{
hts_close(fp);
bcf_destroy(b);
if (fp)
hts_close(fp);
if (b)
bcf_destroy(b);
}

/// initial a VCF header using the internal template given a specific version. VCF4.1 is the default
Expand Down

0 comments on commit ea502d0

Please sign in to comment.