SamFlag.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __SAM_FLAG_H__
00019 #define __SAM_FLAG_H__
00020
00021 #include <stdint.h>
00022
00023 #ifdef DUPLICATE
00024 #undef DUPLICATE
00025 #endif
00026
00027
00028 class SamFlag
00029 {
00030 public:
00031
00032
00033
00034 static const int16_t PAIRED = 0x0001;
00035 static const int16_t PROPER_PAIR = 0x0002;
00036 static const int16_t UNMAPPED = 0x0004;
00037 static const int16_t MATE_UNMAPPED = 0x0008;
00038 static const int16_t REVERSE = 0x0010;
00039 static const int16_t MATE_REVERSED = 0x0020;
00040 static const int16_t FIRST_READ = 0x0040;
00041 static const int16_t SECOND_READ = 0x0080;
00042 static const int16_t SECONDARY_ALIGNMENT = 0x0100;
00043 static const int16_t FAILED_QUALITY = 0x0200;
00044 static const int16_t DUPLICATE = 0x0400;
00045 static const int16_t FRAGMENT_INFO = 0x00C0;
00046 static const int16_t FRAGMENT_SHIFT = 6;
00047
00048
00049
00050
00051
00052 static inline bool isMapped(uint16_t flag) {return(!(flag & UNMAPPED));}
00053 static inline bool isMateMapped(uint16_t flag) {return(!(flag & MATE_UNMAPPED));}
00054
00055 static inline bool isPaired(uint16_t flag) {return(flag & PAIRED);}
00056 static inline bool isReverse(uint16_t flag) {return(flag & REVERSE);}
00057 static inline bool isMateReverse(uint16_t flag) {return(flag & MATE_REVERSED);}
00058 static inline bool isProperPair(uint16_t flag)
00059 {
00060
00061 return(isPaired(flag) && (flag & PROPER_PAIR));
00062 }
00063 static inline bool isDuplicate(uint16_t flag) {return(flag & DUPLICATE);}
00064 static inline bool isQCFailure(uint16_t flag) {return(flag & FAILED_QUALITY);}
00065
00066
00067
00068 static inline bool isFirstFragment(uint16_t flag)
00069 {
00070
00071 return((flag & FIRST_READ) && !(flag & SECOND_READ));
00072 }
00073
00074
00075 static inline bool isLastFragment(uint16_t flag)
00076 {
00077
00078 return(!(flag & FIRST_READ) && (flag & SECOND_READ));
00079 }
00080
00081
00082 static inline bool isMidFragment(uint16_t flag)
00083 {
00084
00085 return((flag & FIRST_READ) && (flag & SECOND_READ));
00086 }
00087
00088
00089 static inline bool isUnknownFragment(uint16_t flag)
00090 {
00091
00092 return(!(flag & FIRST_READ) && !(flag & SECOND_READ));
00093 }
00094
00095 static inline uint8_t getFragmentType(uint16_t flag)
00096 {
00097 return((flag & FRAGMENT_INFO) >> FRAGMENT_SHIFT);
00098 }
00099
00100
00101 static inline void setUnmapped(uint16_t& flag) { flag |= UNMAPPED;}
00102
00103 static inline void setNotDuplicate(uint16_t& flag) { flag ^= DUPLICATE;}
00104
00105 static inline void setDuplicate(uint16_t& flag) { flag |= DUPLICATE;}
00106
00107
00108 private:
00109 SamFlag();
00110 };
00111
00112
00113 #endif