0
|
1 /*****************************************************************************
|
|
2 shuffleBed.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 #include "bedFile.h"
|
|
13 #include "genomeFile.h"
|
|
14
|
|
15 #include <vector>
|
|
16 #include <iostream>
|
|
17 #include <fstream>
|
|
18 #include <map>
|
|
19 #include <cstdlib>
|
|
20 #include <ctime>
|
|
21 #include <sys/time.h>
|
|
22 #include <unistd.h>
|
|
23 #include <sys/types.h>
|
|
24 using namespace std;
|
|
25
|
|
26 const int MAX_TRIES = 1000000;
|
|
27
|
|
28 //************************************************
|
|
29 // Class methods and elements
|
|
30 //************************************************
|
|
31 class BedShuffle {
|
|
32
|
|
33 public:
|
|
34
|
|
35 // constructor
|
|
36 BedShuffle(string &bedFile, string &genomeFile, string &excludeFile, string &includeFile,
|
|
37 bool haveSeed, bool haveExclude, bool haveInclude, bool sameChrom,
|
|
38 float overlapFraction, int seed);
|
|
39
|
|
40 // destructor
|
|
41 ~BedShuffle(void);
|
|
42
|
|
43 private:
|
|
44
|
|
45 string _bedFile;
|
|
46 string _genomeFile;
|
|
47 string _excludeFile;
|
|
48 string _includeFile;
|
|
49 float _overlapFraction;
|
|
50 int _seed;
|
|
51 bool _sameChrom;
|
|
52 bool _haveExclude;
|
|
53 bool _haveInclude;
|
|
54 bool _haveSeed;
|
|
55
|
|
56
|
|
57 // The BED file from which to compute coverage.
|
|
58 BedFile *_bed;
|
|
59 BedFile *_exclude;
|
|
60 BedFile *_include;
|
|
61
|
|
62 GenomeFile *_genome;
|
|
63
|
|
64 vector<string> _chroms;
|
|
65 int _numChroms;
|
|
66 vector<string> _includeChroms;
|
|
67 int _numIncludeChroms;
|
|
68
|
|
69 // methods
|
|
70 void Shuffle();
|
|
71 void ShuffleWithExclusions();
|
|
72 void ShuffleWithInclusions();
|
|
73
|
|
74 void ChooseLocus(BED &);
|
|
75 void ChooseLocusFromInclusionFile(BED &);
|
|
76 };
|