Debian Codegraph @

plink2_import.h

raw
1 #ifndef __PLINK2_IMPORT_H__
2 #define __PLINK2_IMPORT_H__
3
4 // This file is part of PLINK 2.0, copyright (C) 2005-2025 Shaun Purcell,
5 // Christopher Chang.
6 //
7 // This program is free software: you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by the Free
9 // Software Foundation, either version 3 of the License, or (at your option)
10 // any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 // more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20
21 #include "plink2_data.h"
22 #include "include/SFMT.h"
23
24 #ifdef __cplusplus
25 namespace plink2 {
26 #endif
27
28 ENUM_U31_DEF_START()
29 kVcfHalfCallReference,
30 kVcfHalfCallHaploid,
31 kVcfHalfCallMissing,
32 kVcfHalfCallError,
33 // gets converted to kVcfHalfCallError, but with a different error message
34 kVcfHalfCallDefault
35 ENUM_U31_DEF_END(VcfHalfCall);
36
37 CONSTI32(kPAR1IntersectionLast, 2699520);
38 CONSTI32(kPAR2IntersectionFirst, 155701383);
39
40 FLAGSET_DEF_START()
41 kfOxfordImport0,
42 kfOxfordImportRefFirst = (1 << 0),
43 kfOxfordImportRefLast = (1 << 1),
44 kfOxfordImportRefUnknown = (1 << 2),
45 kfOxfordImportRefAll = ((kfOxfordImportRefUnknown * 2) - kfOxfordImportRefFirst),
46 kfOxfordImportBgenSnpIdChr = (1 << 3)
47 FLAGSET_DEF_END(OxfordImportFlags);
48
49 FLAGSET_DEF_START()
50 kfPlink1Dosage0,
51 kfPlink1DosageNoheader = (1 << 0),
52 kfPlink1DosageFormatSingle = (1 << 1),
53 kfPlink1DosageFormatSingle01 = (1 << 2),
54 kfPlink1DosageFormatDouble = (1 << 3),
55 kfPlink1DosageFormatTriple = (1 << 4),
56 kfPlink1DosageRefFirst = (1 << 5),
57 kfPlink1DosageRefLast = (1 << 6)
58 FLAGSET_DEF_END(Plink1DosageFlags);
59
60 FLAGSET_DEF_START()
61 kfGenDummy0,
62 kfGenDummyAcgt = (1 << 0),
63 kfGenDummy1234 = (1 << 1),
64 kfGenDummy12 = (1 << 2),
65 kfGenDummyScalarPheno = (1 << 3)
66 FLAGSET_DEF_END(GenDummyFlags);
67
68 typedef struct Plink1DosageInfoStruct {
69 Plink1DosageFlags flags;
70 STD_ARRAY_DECL(uint32_t, 3, skips);
71 uint32_t chr_col_idx; // 0-based
72 uint32_t pos_col_idx;
73 char id_delim;
74 } Plink1DosageInfo;
75
76 typedef struct GenDummyInfoStruct {
77 GenDummyFlags flags;
78 uint32_t sample_ct;
79 uint32_t variant_ct;
80 uint32_t pheno_ct;
81 uint32_t geno_mfreq_ct;
82 double* geno_mfreqs;
83 double pheno_mfreq;
84 double phase_freq;
85 double dosage_freq;
86 } GenDummyInfo;
87
88 void InitPlink1Dosage(Plink1DosageInfo* plink1_dosage_info_ptr);
89
90 void InitGenDummy(GenDummyInfo* gendummy_info_ptr);
91
92 void CleanupGenDummy(GenDummyInfo* gendummy_info_ptr);
93
94 PglErr VcfToPgen(const char* vcfname, const char* preexisting_psamname, const char* const_fid, const char* dosage_import_field, MiscFlags misc_flags, ImportFlags import_flags, uint32_t no_samples_ok, uint32_t is_update_or_impute_sex, uint32_t is_splitpar, uint32_t hard_call_thresh, uint32_t dosage_erase_thresh, double import_dosage_certainty, char id_delim, char idspace_to, int32_t vcf_min_gq, int32_t vcf_min_dp, int32_t vcf_max_dp, VcfHalfCall halfcall_mode, FamCol fam_cols, uint32_t import_max_allele_ct, uint32_t max_thread_ct, char* outname, char* outname_end, ChrInfo* cip, uint32_t* pgen_generated_ptr, uint32_t* psam_generated_ptr);
95
96 PglErr BcfToPgen(const char* bcfname, const char* preexisting_psamname, const char* const_fid, const char* dosage_import_field, MiscFlags misc_flags, ImportFlags import_flags, uint32_t no_samples_ok, uint32_t is_update_or_impute_sex, uint32_t is_splitpar, uint32_t hard_call_thresh, uint32_t dosage_erase_thresh, double import_dosage_certainty, char id_delim, char idspace_to, int32_t vcf_min_gq, int32_t vcf_min_dp, int32_t vcf_max_dp, VcfHalfCall halfcall_mode, FamCol fam_cols, uint32_t import_max_allele_ct, uint32_t max_thread_ct, char* outname, char* outname_end, ChrInfo* cip, uint32_t* pgen_generated_ptr, uint32_t* psam_generated_ptr);
97
98 PglErr OxGenToPgen(const char* genname, const char* samplename, const char* const_fid, const char* ox_single_chr_str, const char* ox_missing_code, const char* missing_catname, MiscFlags misc_flags, ImportFlags import_flags, OxfordImportFlags oxford_import_flags, uint32_t psam_01, uint32_t is_splitpar, uint32_t hard_call_thresh, uint32_t dosage_erase_thresh, double import_dosage_certainty, char id_delim, uint32_t max_thread_ct, char* outname, char* outname_end, ChrInfo* cip);
99
100 PglErr OxBgenToPgen(const char* bgenname, const char* samplename, const char* const_fid, const char* ox_single_chr_str, const char* ox_missing_code, const char* missing_catname, MiscFlags misc_flags, ImportFlags import_flags, OxfordImportFlags oxford_import_flags, uint32_t psam_01, uint32_t is_update_or_impute_sex, uint32_t is_splitpar, uint32_t hard_call_thresh, uint32_t dosage_erase_thresh, double import_dosage_certainty, char id_delim, char idspace_to, uint32_t import_max_allele_ct, uint32_t max_thread_ct, char* outname, char* outname_end, ChrInfo* cip);
101
102 PglErr OxHapslegendToPgen(const char* hapsname, const char* legendname, const char* samplename, const char* const_fid, const char* ox_single_chr_str, const char* ox_missing_code, const char* missing_catname, MiscFlags misc_flags, ImportFlags import_flags, OxfordImportFlags oxford_import_flags, uint32_t psam_01, uint32_t is_update_or_impute_sex, uint32_t is_splitpar, char id_delim, uint32_t max_thread_ct, char* outname, char* outname_end, ChrInfo* cip, uint32_t* pgi_generated_ptr);
103
104 PglErr Plink1DosageToPgen(const char* dosagename, const char* famname, const char* mapname, const char* import_single_chr_str, const Plink1DosageInfo* pdip, const char* missing_catname, MiscFlags misc_flags, ImportFlags import_flags, uint32_t psam_01, FamCol fam_cols, int32_t missing_pheno, uint32_t hard_call_thresh, uint32_t dosage_erase_thresh, double import_dosage_certainty, uint32_t max_thread_ct, char* outname, char* outname_end, ChrInfo* cip);
105
106 PglErr GenerateDummy(const GenDummyInfo* gendummy_info_ptr, MiscFlags misc_flags, ImportFlags import_flags, uint32_t psam_01, uint32_t hard_call_thresh, uint32_t dosage_erase_thresh, uint32_t max_thread_ct, sfmt_t* sfmtp, char* outname, char* outname_end, ChrInfo* cip);
107
108 #ifdef __cplusplus
109 } // namespace plink2
110 #endif
111
112 #endif // __PLINK2_IMPORT_H__