18 #ifndef _GENOME_SEQUENCE_HELPERS_H
19 #define _GENOME_SEQUENCE_HELPERS_H
21 #if !defined(MD5_DIGEST_LENGTH)
22 #define MD5_DIGEST_LENGTH 16
25 #include "MemoryMapArray.h"
42 static const int MAX_GENOME_INFO_STRING=128;
44 void constructorClear()
46 memset(
this,0,
sizeof(*
this));
48 void setChromosomeName(
const char *n)
50 strncpy(name, n,
sizeof(name)-1);
51 name[
sizeof(name)-1] =
'\0';
55 char md5[2*MD5_DIGEST_LENGTH + 1];
56 char name[MAX_GENOME_INFO_STRING];
57 char assemblyID[MAX_GENOME_INFO_STRING];
58 char uri[MAX_GENOME_INFO_STRING];
59 char species[MAX_GENOME_INFO_STRING];
62 void setAssemblyID(
const char *newID)
64 strncpy(assemblyID, newID,
sizeof(assemblyID)-1);
65 name[
sizeof(name)-1] =
'\0';
67 void setSpecies(
const char *newSpecies)
69 strncpy(species, newSpecies,
sizeof(species)-1);
70 species[
sizeof(species)-1] =
'\0';
72 void setURI(
const char *newURI)
74 strncpy(uri, newURI,
sizeof(uri)-1);
75 uri[
sizeof(uri)-1] =
'\0';
84 uint32_t _chromosomeCount;
95 static size_t getHeaderSize(
int chromosomeCount)
113 inline uint8_t genomeSequenceAccess(
void *base, genomeIndex_t index)
117 return ((uint8_t *) base)[index>>1] & 0xf;
121 return (((uint8_t *) base)[index>>1] & 0xf0) >> 4;
124 inline void genomeSequenceSet(
void *base, genomeIndex_t index, uint8_t v)
128 ((uint8_t *) base)[index>>1] = (((uint8_t *) base)[index>>1] & 0xf0) | v;
132 ((uint8_t *) base)[index>>1] = (((uint8_t *) base)[index>>1] & 0x0f) | v<<4;
136 inline size_t mmapGenomeSequenceElementCount2Bytes(genomeIndex_t i)
138 return sizeof(uint8_t) * i / 2;
143 void set(
int index,
int val)
145 packedBases[index>>1] =
146 (packedBases[index>>1]
147 & ~(7<<((index&0x01)<<2)))
148 | ((val&0x0f)<<((index&0x1)<<2));
151 std::vector<uint8_t> packedBases;
162 void set(
const char *rhs,
int padWithNCount = 0);
163 uint8_t operator [](
int index)
165 return (packedBases[index>>1] >> ((index&0x1)<<2)) & 0xf;
Create/Access/Modify/Load Genome Sequences stored as binary mapped files.