1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
/*
FILE: BEDOPS.Constants.hpp
AUTHOR: Shane Neph & Alex Reynolds
CREATE DATE: Thu Sep 13 13:19:15 PDT 2012
*/
//
// BEDOPS
// Copyright (C) 2011-2022 Shane Neph, Scott Kuehn and Alex Reynolds
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#ifndef CONSTANTS_BEDOPS_H
#define CONSTANTS_BEDOPS_H
//
// Typically don't use these directly in an application
// (further down are comments on stuff to use)
//
#ifdef __cplusplus
#include "utility/CompilerMath.hpp"
#define BASE_VALUE 2
#define INT_TOKEN_CHR_MAX_LENGTH Ext::Pow<BASE_VALUE, CHROM_EXPONENT>::value-1
#define INT_TOKEN_ID_MAX_LENGTH Ext::Pow<BASE_VALUE, ID_EXPONENT>::value-1
#define INT_TOKEN_REST_MAX_LENGTH Ext::Pow<BASE_VALUE, REST_EXPONENT>::value-1
#else
#define pwrtwo(x) (1UL << (x))
#define INT_TOKEN_CHR_MAX_LENGTH pwrtwo(CHROM_EXPONENT)-1
#define INT_TOKEN_ID_MAX_LENGTH pwrtwo(ID_EXPONENT)-1
#define INT_TOKEN_REST_MAX_LENGTH pwrtwo(REST_EXPONENT)-1
#endif
#undef NORMAL_REST
#undef NORMAL_ID
#undef NORMAL_CHR
#define SPECIALFLOAT_BUILD 1
#ifndef REST_EXPONENT
#define REST_EXPONENT 15
#define NORMAL_REST 1
#endif
#ifndef ID_EXPONENT
#define ID_EXPONENT 13
#define NORMAL_ID 1
#endif
#ifndef CHROM_EXPONENT
#define CHROM_EXPONENT 7
#define NORMAL_CHR 1
#endif
#ifndef MEASURE_TYPE /* could be long double for 128 bits, for example */
#define MEASURE_TYPE double
#undef SPECIALFLOAT_BUILD
#endif
#if !defined NORMAL_REST || !defined NORMAL_ID || !defined NORMAL_CHR
#define MEGASIZE_BUILD 1
#endif
#if defined MEGASIZE_BUILD
#if defined SPECIALFLOAT_BUILD
#define BUILD_OPTS "(megarow, quadruple precision float)"
#endif
#define BUILD_OPTS "(megarow)"
#elif defined SPECIALFLOAT_BUILD
#define BUILD_OPTS "(typical, quadruple precision float)"
#else
#define BUILD_OPTS "(typical)"
#endif
#define INT_MAX_DEC_INTEGERS 12L
#define INT_MAX_COORD_VALUE 999999999999 /* INT_MAX_DEC_INTEGERS decimal integers; we assume >= 64-bit systems */
#define INT_TOKENS_MAX_LENGTH (INT_TOKEN_CHR_MAX_LENGTH + INT_TOKEN_ID_MAX_LENGTH + INT_TOKEN_REST_MAX_LENGTH + 2*INT_MAX_DEC_INTEGERS)
#define INT_TOKENS_HEADER_MAX_LENGTH INT_TOKENS_MAX_LENGTH
#define INT_TOKEN_CHR_FIELD_INDEX 0
#define INT_TOKEN_START_FIELD_INDEX 1
#define INT_TOKEN_STOP_FIELD_INDEX 2
#define INT_MEM_CHUNK_SZ 64 // how many BED elements allocated at a time
//
// The constants and typedefs to use in applications are defined below
//
#ifdef __cplusplus
#include <cinttypes>
#include <cstddef>
namespace Bed {
// Use these typedef's in applications
typedef uint64_t CoordType;
typedef int64_t SignedCoordType;
typedef CoordType LineCountType;
typedef CoordType BaseCountType;
typedef unsigned long LineLengthType;
typedef MEASURE_TYPE MeasurementType;
static_assert(sizeof(SignedCoordType) >= sizeof(INT_MAX_COORD_VALUE), "INT_MAX_COORD_VALUE is too big!"); // expected-warning {{static_assert declarations are incompatible with C++98}}
constexpr LineLengthType TOKEN_CHR_MAX_LENGTH = INT_TOKEN_CHR_MAX_LENGTH;
constexpr LineLengthType TOKEN_ID_MAX_LENGTH = INT_TOKEN_ID_MAX_LENGTH;
constexpr LineLengthType TOKEN_REST_MAX_LENGTH = INT_TOKEN_REST_MAX_LENGTH;
constexpr unsigned long MAX_DEC_INTEGERS = INT_MAX_DEC_INTEGERS;
constexpr SignedCoordType MAX_COORD_VALUE = INT_MAX_COORD_VALUE;
constexpr LineLengthType TOKENS_MAX_LENGTH = INT_TOKENS_MAX_LENGTH;
constexpr LineLengthType TOKENS_HEADER_MAX_LENGTH = INT_TOKENS_HEADER_MAX_LENGTH;
constexpr unsigned long TOKEN_CHR_FIELD_INDEX = INT_TOKEN_CHR_FIELD_INDEX;
constexpr unsigned long TOKEN_START_FIELD_INDEX = INT_TOKEN_START_FIELD_INDEX;
constexpr unsigned long TOKEN_STOP_FIELD_INDEX = INT_TOKEN_STOP_FIELD_INDEX;
constexpr std::size_t CHUNKSZ = INT_MEM_CHUNK_SZ;
} // namespace Bed
#else
#include <inttypes.h>
// Use these typedef's in applications
typedef uint64_t CoordType;
typedef int64_t SignedCoordType;
typedef CoordType LineCountType;
typedef CoordType BaseCountType;
typedef unsigned long LineLengthType;
typedef MEASURE_TYPE MeasurementType;
#define TOKEN_CHR_MAX_LENGTH INT_TOKEN_CHR_MAX_LENGTH
#define TOKEN_ID_MAX_LENGTH INT_TOKEN_ID_MAX_LENGTH
#define TOKEN_REST_MAX_LENGTH INT_TOKEN_REST_MAX_LENGTH
#define MAX_DEC_INTEGERS INT_MAX_DEC_INTEGERS
#define MAX_COORD_VALUE INT_MAX_COORD_VALUE
#define TOKENS_MAX_LENGTH INT_TOKENS_MAX_LENGTH
#define TOKENS_HEADER_MAX_LENGTH INT_TOKENS_HEADER_MAX_LENGTH
#define TOKEN_CHR_FIELD_INDEX INT_TOKEN_CHR_FIELD_INDEX
#define TOKEN_START_FIELD_INDEX INT_TOKEN_START_FIELD_INDEX
#define TOKEN_STOP_FIELD_INDEX INT_TOKEN_STOP_FIELD_INDEX
#define CHUNKSZ INT_MEM_CHUNK_SZ
#endif
#endif // CONSTANTS_BEDOPS_H
|