-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfindMethyl.cpp
81 lines (67 loc) · 2.01 KB
/
findMethyl.cpp
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
77
78
79
80
81
#include <iostream>
#include <cmath>
#include <fstream>
#include <string>
#include <cstring>
#include <unordered_map>
#include <iomanip>
#include <vector>
extern "C"{
#include "./lib/libBigWig/bigWig.h"
}
using namespace std;
float findMethyl(string, string, int, float, string, string);
int main(){
string nstrand = "+";
string chr = "chr1";
int loci = 10059;
float sig = 100.1;
string nuc = "C";
string bw_file = "examples/WGBS/ENCFF073DUG.bigWig";
float meth = findMethyl(nstrand, chr, loci, sig, nuc, bw_file);
return 0;
}
float findMethyl(string nstrand,string chr,int loci,float sig,string nuc,string bw_file){
string str_loci = to_string(loci);
if(nstrand == "+"){
// loci = loci + 1;
//string loci_str = to_string(loci);
//string pos = chr + ":" + loci_str;
}
if(nstrand == "-"){
//string loci_str = to_string(loci);
//string pos = chr + ":" + loci_str;
}
int loci_end = loci + 1;
// if(sig.compare("NA") !=0 && sig.compare("-256.000000")){
if(nuc.compare("C") == 0){
//bwOverlappingIntervals_t *ptr
// bigWigFile_t *fp = NULL;
//fp = bwOpen(bw_file, NULL, "r");
//if(!fp) {
// fprintf(stderr, "An error occured while opening methylation file\n", bw_file);
// return 0;
//}
//int methyl = bwStats(bw_file, chr, loci, loci_end, 1, dev);
//cout << methyl << endl;
//6/6/20
// char *fname = new char[bw_file.length() + 1];
// strcpy(fname, bw_file.c_str());
//bigWigFile_t *bwFile = bwOpen(fname, NULL, "r");
//if(bwFile == NULL){
// cerr << "Failed to open bw_file: " << bw_file << endl;
// exit(1);
//}
//6/8/20
bwOverlappingIntervals_t *ptr = bwGetValues(bwFile, chr,
static_cast<uint32_t>(loci),
static_cast<uint32_t>(loci_end),
1);
intervals = bwGetOverlappingIntervals(bwFile, "chr1", loci, loci_end);
bwDestroyOverlappingIntervals(intervals);
}
else{
cout << "bad sig" << sig << endl;
}
return 0;
}