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 // all of the original fields in the record 39 vector<string> fields; 40 // indices of the "other" fields 41 vector<uint16_t> other_idxs; 42 }; 43 44 45 46 47 //************************************************ 48 // BedFile Class methods and elements 49 //************************************************ 50 class BedFilePE { 51 52 public: 53 54 // Constructor 55 BedFilePE(string &); 56 57 // Destructor 58 ~BedFilePE(void); 59 60 // Open a BEDPE file for reading (creates an istream pointer) 61 void Open(void); 62 63 // Close an opened BEDPE file. 64 void Close(void); 65 66 // Get the next BED entry in an opened BED file. 67 BedLineStatus GetNextBedPE (BEDPE &bedpe, int &lineNum); 68 69 70 // Methods 71 72 void reportBedPETab(const BEDPE &a); 73 void reportBedPENewLine(const BEDPE &a); 74 void loadBedPEFileIntoMap(); 75 void splitBedPEIntoBeds(const BEDPE &a, const int &lineNum, MATE *bedEntry1, MATE *bedEntry2); 76 77 78 void FindOverlapsPerBin(int bEnd, string chrom, CHRPOS start, CHRPOS end, string name, string strand, 79 vector<MATE> &hits, float overlapFraction, bool forceStrand, bool enforceDiffNames); 80 81 82 string bedFile; 83 unsigned int bedType; 84 85 masterMateMap bedMapEnd1; 86 masterMateMap bedMapEnd2; 87 88 private: 89 istream *_bedStream; 90 91 // methods 92 BedLineStatus parseLine (BEDPE &bedpe, const vector<string> &lineVector, int &lineNum); 93 bool parseBedPELine (BEDPE &bed, const vector<string> &lineVector, const int &lineNum); 94 }; 95 96 #endif /* BEDFILEPE_H */ 97