forked from wuyangf7/OPERA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMR.h
76 lines (69 loc) · 3.72 KB
/
SMR.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// SMR.h
// SMR_CPP
//
// Created by Yang Wu on 06/08/2022.
// Copyright (c) 2022 Yang Wu. All rights reserved.
//
#ifndef SMR_CPP_SMR_h
#define SMR_CPP_SMR_h
void option(int option_num, char* option_str[]);
static inline bool not_in_flags(vector<string> &flags, string str)
{
return find(flags.begin(),flags.end(),str) == flags.end();
}
static inline void FLAGS_VALID_CK(int option_num, char* option_str[])
{
const char *flgs[] = { "--bfile","--gwas-summary","--beqtl-summary","--maf","--keep","--remove","--extract-snp","--exclude-snp","--extract-probe","--extract-outcome-probe","--extract-exposure-probe",
"--exclude-probe","--exclude-outcome-probe","--exclude-exposure-probe","--eqtl-summary","--ld-upper-limit","--peqtl-heidi","--heidi-min-m","--make-besd","--out", "--peqtl-smr","--smr",
"--cis-wind","--peqtl-trans","--peqtl-other","--efile","--query","--heidi-off","--target-snp","--extract-trait","--thread-num","--besd-flist",
"--trans-wind","--plot","--eqtl-flist","--smr-format","--merlin-fastassoc-format","--plink-qassoc-format","--gemma-format","--update-freq","--genes","--smr-wind", "--smr-file",
"--recode","--probe-var","--chr","--probe-chr","--snp-chr", "--snp", "--from-snp", "--to-snp", "--probe", "--from-probe", "--to-probe","--snp-wind","--probe-wind", "--gene","--from-snp-kb",
"--to-snp-kb","--from-probe-kb","--to-probe-kb","--extract-single-exposure-probe","--extract-single-outcome-probe","--exclude-single-exposure-probe","--exclude-single-outcome-probe","--gene-list",
"--set-list", "--set-wind","--smr-multi","--qfile","--make-besd-dense","--bolt-assoc-format","--geno-uni","--diff","--psmr","--beqtl-qc","--z-thresh","--heidi-mtd","--phet","--count-trans",
"--count-cis","--meta","--trans","--extract-cis","--rm-technical", "--p-technical","--ld-lower-limit","--heidi-max-m","--extract-snp-p","--exclude-snp-p","--matrix-eqtl-format",
"--fastqtl-nominal-format","--fastqtl-permu-format","--add-n","--show-n","--update-epi","--update-esi","--cis-to-all","--mecs","--pmecs","--mmecs","--sample-overlap","--ld-multi-snp",
"--extract-target-snp-probe","--extract-snp-probe","--disable-freq-ck","--diff-freq","--diff-freq-prop","--r","--r2","--ld-window",
// flags for opera
"--outcome-wind","--mbfile","--extract-target-cojo-snps","--extract-gwas-loci","--multi-exposure-smr","--multi-outcome-smr","--thresh-ppa","--thresh-smr","--thresh-heidi","--estimate-pi","--print-combo-ppa-res","--print-smr-res",
"--opera-joint-smr","--opera-smr","--opera-conditional-smr","--pi-wind","--prior-pi","--prior-pi-file","--prior-var","--prior-var-file","--summary-ppa","--ppa-file","--num-file","--rho-file","--sigma","--alpha"
};
vector<string> flags(flgs, flgs + sizeof(flgs)/sizeof(flgs[0]));
if(option_num<3)
{
cout<<"flags include:"<<endl;
int cur_mark=0;
for(int i=0;i<flags.size();i++)
{
int tmp=i>>2;
if(tmp>cur_mark)
{
cout<<endl;
cur_mark=tmp;
}
cout<<flags[i]<<",";
}
cout<<endl;
exit (EXIT_FAILURE);
}
for(int i=0;i<option_num;i++)
{
if(SMRDATA::has_prefix(option_str[i],"--"))
if(not_in_flags(flags, option_str[i]))
{
fprintf (stderr, "%s: Invalid option\n",
option_str[i]);
exit (EXIT_FAILURE);
}
}
}
static inline void FLAG_VALID_CK(string str, char* flag)
{
if(flag==NULL || SMRDATA::has_prefix(flag, "--"))
{
fprintf (stderr, "Please verify the flag %s!: \n",
str.c_str());
exit (EXIT_FAILURE);
}
}
#endif