0
|
1 #ifndef BEDFILEPE_H
|
|
2 #define BEDFILEPE_H
|
|
3
|
|
4 #include <vector>
|
|
5 #include <map>
|
|
6 #include <string>
|
|
7 #include <iostream>
|
|
8 #include <fstream>
|
|
9 #include <sstream>
|
|
10 #include <cstring>
|
|
11 #include <algorithm>
|
|
12 #include "bedFile.h"
|
|
13 #include "lineFileUtilities.h"
|
|
14
|
|
15 using namespace std;
|
|
16
|
|
17
|
|
18 /*
|
|
19 Structure for paired-end records
|
|
20 */
|
|
21 struct BEDPE {
|
|
22
|
|
23 // UCSC BED fields
|
|
24 string chrom1;
|
|
25 CHRPOS start1;
|
|
26 CHRPOS end1;
|
|
27
|
|
28 string chrom2;
|
|
29 CHRPOS start2;
|
|
30 CHRPOS end2;
|
|
31
|
|
32 string name;
|
|
33 string score;
|
|
34
|
|
35 string strand1;
|
|
36 string strand2;
|
|
37
|
|
38 vector<string> otherFields;
|
|
39 };
|
|
40
|
|
41
|
|
42
|
|
43
|
|
44 //************************************************
|
|
45 // BedFile Class methods and elements
|
|
46 //************************************************
|
|
47 class BedFilePE {
|
|
48
|
|
49 public:
|
|
50
|
|
51 // Constructor
|
|
52 BedFilePE(string &);
|
|
53
|
|
54 // Destructor
|
|
55 ~BedFilePE(void);
|
|
56
|
|
57 // Open a BEDPE file for reading (creates an istream pointer)
|
|
58 void Open(void);
|
|
59
|
|
60 // Close an opened BEDPE file.
|
|
61 void Close(void);
|
|
62
|
|
63 // Get the next BED entry in an opened BED file.
|
|
64 BedLineStatus GetNextBedPE (BEDPE &bedpe, int &lineNum);
|
|
65
|
|
66
|
|
67 // Methods
|
|
68
|
|
69 void reportBedPETab(const BEDPE &a);
|
|
70 void reportBedPENewLine(const BEDPE &a);
|
|
71 void loadBedPEFileIntoMap();
|
|
72 void splitBedPEIntoBeds(const BEDPE &a, const int &lineNum, MATE *bedEntry1, MATE *bedEntry2);
|
|
73
|
|
74
|
|
75 void FindOverlapsPerBin(int bEnd, string chrom, CHRPOS start, CHRPOS end, string name, string strand,
|
|
76 vector<MATE> &hits, float overlapFraction, bool forceStrand, bool enforceDiffNames);
|
|
77
|
|
78
|
|
79 string bedFile;
|
|
80 unsigned int bedType;
|
|
81
|
|
82 masterMateMap bedMapEnd1;
|
|
83 masterMateMap bedMapEnd2;
|
|
84
|
|
85 private:
|
|
86 istream *_bedStream;
|
|
87
|
|
88 // methods
|
|
89 BedLineStatus parseLine (BEDPE &bedpe, const vector<string> &lineVector, int &lineNum);
|
|
90 bool parseBedPELine (BEDPE &bed, const vector<string> &lineVector, const int &lineNum);
|
|
91 };
|
|
92
|
|
93 #endif /* BEDFILEPE_H */
|