0
|
1 /*****************************************************************************
|
|
2 intersectBed.h
|
|
3
|
|
4 (c) 2009 - Aaron Quinlan
|
|
5 Hall Laboratory
|
|
6 Department of Biochemistry and Molecular Genetics
|
|
7 University of Virginia
|
|
8 aaronquinlan@gmail.com
|
|
9
|
|
10 Licenced under the GNU General Public License 2.0 license.
|
|
11 ******************************************************************************/
|
|
12 #ifndef INTERSECTBED_H
|
|
13 #define INTERSECTBED_H
|
|
14
|
|
15 #include "bedFile.h"
|
|
16 #include "chromsweep.h"
|
|
17 #include "api/BamReader.h"
|
|
18 #include "api/BamWriter.h"
|
|
19 #include "api/BamAux.h"
|
|
20 #include "BamAncillary.h"
|
|
21 using namespace BamTools;
|
|
22
|
|
23
|
|
24 #include <vector>
|
|
25 #include <iostream>
|
|
26 #include <fstream>
|
|
27 #include <stdlib.h>
|
|
28 using namespace std;
|
|
29
|
|
30
|
|
31
|
|
32 class BedIntersect {
|
|
33
|
|
34 public:
|
|
35
|
|
36 // constructor
|
|
37 BedIntersect(string bedAFile, string bedBFile, bool anyHit,
|
|
38 bool writeA, bool writeB, bool writeOverlap, bool writeAllOverlap,
|
|
39 float overlapFraction, bool noHit, bool writeCount, bool sameStrand, bool diffStrand,
|
|
40 bool reciprocal, bool obeySplits, bool bamInput, bool bamOutput, bool isUncompressedBam,
|
|
41 bool sortedInput);
|
|
42
|
|
43 // destructor
|
|
44 ~BedIntersect(void);
|
|
45
|
|
46 private:
|
|
47
|
|
48 //------------------------------------------------
|
|
49 // private attributes
|
|
50 //------------------------------------------------
|
|
51 string _bedAFile;
|
|
52 string _bedBFile;
|
|
53
|
|
54 bool _writeA; // should the original A feature be reported?
|
|
55 bool _writeB; // should the original B feature be reported?
|
|
56 bool _writeOverlap;
|
|
57 bool _writeAllOverlap;
|
|
58
|
|
59 bool _sameStrand;
|
|
60 bool _diffStrand;
|
|
61 bool _reciprocal;
|
|
62 float _overlapFraction;
|
|
63
|
|
64 bool _anyHit;
|
|
65 bool _noHit;
|
|
66 bool _writeCount; // do we want a count of the number of overlaps in B?
|
|
67 bool _obeySplits;
|
|
68 bool _bamInput;
|
|
69 bool _bamOutput;
|
|
70 bool _isUncompressedBam;
|
|
71 bool _sortedInput;
|
|
72 bool _printable;
|
|
73
|
|
74 // instance of a bed file class.
|
|
75 BedFile *_bedA, *_bedB;
|
|
76
|
|
77 //------------------------------------------------
|
|
78 // private methods
|
|
79 //------------------------------------------------
|
|
80 void IntersectBed(istream &bedInput);
|
|
81
|
|
82 void IntersectBed();
|
|
83
|
|
84 void IntersectBam(string bamFile);
|
|
85
|
|
86 bool processHits(const BED &a, const vector<BED> &hits);
|
|
87
|
|
88 bool FindOverlaps(const BED &a, vector<BED> &hits);
|
|
89
|
|
90 bool FindOneOrMoreOverlap(const BED &a);
|
|
91
|
|
92 void ReportOverlapDetail(int overlapBases, const BED &a, const BED &b, CHRPOS s, CHRPOS e);
|
|
93
|
|
94 void ReportOverlapSummary(const BED &a, const int &numOverlapsFound);
|
|
95
|
|
96 };
|
|
97
|
|
98 #endif /* INTERSECTBED_H */
|