You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

62 lines
2.3 KiB

  1. /*
  2. This file is part of BioD.
  3. Copyright (C) 2012 Artem Tarasov <lomereiter@gmail.com>
  4. Permission is hereby granted, free of charge, to any person obtaining a
  5. copy of this software and associated documentation files (the "Software"),
  6. to deal in the Software without restriction, including without limitation
  7. the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. and/or sell copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  17. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  18. DEALINGS IN THE SOFTWARE.
  19. */
  20. module bio.core.bgzf.constants;
  21. immutable BGZF_MAGIC = 0x04_08_8B_1F; // little endian
  22. immutable ubyte[16] BLOCK_HEADER_START =
  23. [ 31, 139, 8, 4, // BGZF magic
  24. 0, 0, 0, 0, // GZIP modification time
  25. 0, // GZIP extra flags
  26. 255, // GZIP OS identifier
  27. 6, 0, // GZIP extra length == 6 (LE)
  28. 66, 67, // Subfield 'BC'
  29. 2, 0]; // Subfield length (holds 1 ushort)
  30. // empty block
  31. immutable ubyte[28] BGZF_EOF =
  32. [31, 139, 8, 4,
  33. 0, 0, 0, 0,
  34. 0,
  35. 255,
  36. 6, 0,
  37. 66, 67,
  38. 2, 0,
  39. 27, 0,
  40. 3, 0,
  41. 0, 0, 0, 0,
  42. 0, 0, 0, 0];
  43. // BGZF block header length in bytes.
  44. // Block header holds BLOCK_HEADER_START + block size (ushort)
  45. immutable BLOCK_HEADER_LENGTH = BLOCK_HEADER_START.length + ushort.sizeof;
  46. // BGZF footer holds CRC32 and size of decompressed block.
  47. immutable BLOCK_FOOTER_LENGTH = uint.sizeof + uint.sizeof;
  48. immutable BGZF_MAX_BLOCK_SIZE = 65536;
  49. immutable BGZF_BLOCK_SIZE = 0xFF00;