Skip to content

Commit

Permalink
support removing temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Dec 24, 2024
1 parent 44719c8 commit 9544799
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/FilePlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void FileBed::read_block_initial(uint64 start_idx, uint64 stop_idx, bool standar
// should remove sites with F=0 and 1.0
if (F(snp_idx) == 0.0 || F(snp_idx) == 1.0) cao.error("sites with MAF=0 found! remove them first!");
// in LD r2,F=0.5 means sample standard deviation is 0
if (params.verbose > 1 && F(snp_idx) == 0.5)
if (params.ld && params.verbose > 1 && F(snp_idx) == 0.5)
cao.warn("MAF for site ", snp_idx, "is 0.5. NaN values expected in calculating LD R2.");
// do centering and initialing
centered_geno_lookup(1, snp_idx) = 0.0; // missing
Expand Down
17 changes: 16 additions & 1 deletion src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "Arnoldi.hpp"
#include "Cmd.hpp"
#include "Common.hpp"
#include "Data.hpp"
#include "FileBeagle.hpp"
#include "FileBgen.hpp"
Expand Down Expand Up @@ -126,12 +127,26 @@ int main(int argc, char* argv[]) {
cao.error("unsupported PCA method!");
}

cao.print(tick.date(), "total elapsed reading time: ", data->readtime, " seconds");

delete data;

if (params.file_t == FileType::PLINK)
make_plink2_eigenvec_file(params.k, params.fileout + ".eigvecs2", params.fileout + ".eigvecs",
params.filein + ".fam");

cao.print(tick.date(), "total elapsed reading time: ", data->readtime, " seconds");
// remove temp files if verbose < 3
if (params.perm && params.out_of_core && params.verbose < 3) {
if (params.file_t == FileType::PLINK) {
for (auto suf : std::vector<std::string>{".bed", ".bim", ".fam"}) {
std::filesystem::path tmpfile{params.filein + suf};
std::filesystem::remove(tmpfile);
}
}
if ((params.file_t == FileType::BGEN) || (params.file_t == FileType::CSV)) {
std::filesystem::path tmpfile{params.filein};
std::filesystem::remove(tmpfile);
}
}
return bye();
}

0 comments on commit 9544799

Please sign in to comment.