@gmod/cram 3.0.7 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/dist/craiIndex.js +70 -87
  2. package/dist/craiIndex.js.map +1 -1
  3. package/dist/cram-bundle.js +1 -1
  4. package/dist/cramFile/codecs/_base.d.ts +1 -1
  5. package/dist/cramFile/codecs/beta.d.ts +2 -2
  6. package/dist/cramFile/codecs/beta.js +1 -1
  7. package/dist/cramFile/codecs/beta.js.map +1 -1
  8. package/dist/cramFile/codecs/byteArrayLength.d.ts +2 -2
  9. package/dist/cramFile/codecs/byteArrayStop.d.ts +4 -4
  10. package/dist/cramFile/codecs/byteArrayStop.js +1 -1
  11. package/dist/cramFile/codecs/byteArrayStop.js.map +1 -1
  12. package/dist/cramFile/codecs/external.d.ts +1 -1
  13. package/dist/cramFile/codecs/external.js +1 -1
  14. package/dist/cramFile/codecs/external.js.map +1 -1
  15. package/dist/cramFile/codecs/gamma.d.ts +1 -1
  16. package/dist/cramFile/codecs/gamma.js +1 -1
  17. package/dist/cramFile/codecs/gamma.js.map +1 -1
  18. package/dist/cramFile/codecs/getBits.d.ts +1 -1
  19. package/dist/cramFile/codecs/getBits.js.map +1 -1
  20. package/dist/cramFile/codecs/huffman.d.ts +1 -1
  21. package/dist/cramFile/codecs/huffman.js +1 -1
  22. package/dist/cramFile/codecs/huffman.js.map +1 -1
  23. package/dist/cramFile/codecs/index.d.ts +1 -1
  24. package/dist/cramFile/codecs/index.js +5 -5
  25. package/dist/cramFile/codecs/index.js.map +1 -1
  26. package/dist/cramFile/codecs/subexp.d.ts +2 -2
  27. package/dist/cramFile/codecs/subexp.js +1 -1
  28. package/dist/cramFile/codecs/subexp.js.map +1 -1
  29. package/dist/cramFile/container/compressionScheme.d.ts +2 -2
  30. package/dist/cramFile/container/compressionScheme.js +1 -1
  31. package/dist/cramFile/container/compressionScheme.js.map +1 -1
  32. package/dist/cramFile/container/index.d.ts +1 -2
  33. package/dist/cramFile/container/index.js +62 -79
  34. package/dist/cramFile/container/index.js.map +1 -1
  35. package/dist/cramFile/file.d.ts +9 -13
  36. package/dist/cramFile/file.js +218 -247
  37. package/dist/cramFile/file.js.map +1 -1
  38. package/dist/cramFile/record.js +2 -2
  39. package/dist/cramFile/record.js.map +1 -1
  40. package/dist/cramFile/sectionParsers.d.ts +16 -16
  41. package/dist/cramFile/sectionParsers.js +12 -9
  42. package/dist/cramFile/sectionParsers.js.map +1 -1
  43. package/dist/cramFile/slice/decodeRecord.d.ts +3 -3
  44. package/dist/cramFile/slice/decodeRecord.js +11 -11
  45. package/dist/cramFile/slice/decodeRecord.js.map +1 -1
  46. package/dist/cramFile/slice/index.d.ts +2 -2
  47. package/dist/cramFile/slice/index.js +241 -262
  48. package/dist/cramFile/slice/index.js.map +1 -1
  49. package/dist/cramFile/util.d.ts +4 -2
  50. package/dist/cramFile/util.js +29 -6
  51. package/dist/cramFile/util.js.map +1 -1
  52. package/dist/htscodecs/arith_gen.d.ts +9 -17
  53. package/dist/htscodecs/arith_gen.js +32 -272
  54. package/dist/htscodecs/arith_gen.js.map +1 -1
  55. package/dist/htscodecs/fqzcomp.d.ts +1 -2
  56. package/dist/htscodecs/fqzcomp.js +2 -421
  57. package/dist/htscodecs/fqzcomp.js.map +1 -1
  58. package/dist/htscodecs/index.d.ts +5 -5
  59. package/dist/htscodecs/index.js +10 -10
  60. package/dist/htscodecs/index.js.map +1 -1
  61. package/dist/htscodecs/iostream.d.ts +2 -1
  62. package/dist/htscodecs/iostream.js +3 -2
  63. package/dist/htscodecs/iostream.js.map +1 -1
  64. package/dist/htscodecs/rans.d.ts +1 -2
  65. package/dist/htscodecs/rans.js +3 -270
  66. package/dist/htscodecs/rans.js.map +1 -1
  67. package/dist/htscodecs/rans4x16.d.ts +0 -1
  68. package/dist/htscodecs/rans4x16.js +6 -497
  69. package/dist/htscodecs/rans4x16.js.map +1 -1
  70. package/dist/htscodecs/tok3.js +17 -1
  71. package/dist/htscodecs/tok3.js.map +1 -1
  72. package/dist/index.d.ts +1 -1
  73. package/dist/index.js +2 -2
  74. package/dist/index.js.map +1 -1
  75. package/dist/indexedCramFile.d.ts +4 -4
  76. package/dist/indexedCramFile.js +97 -108
  77. package/dist/indexedCramFile.js.map +1 -1
  78. package/dist/io/index.d.ts +2 -2
  79. package/dist/io/index.js +6 -6
  80. package/dist/io/index.js.map +1 -1
  81. package/dist/rans/constants.d.ts +1 -1
  82. package/dist/rans/constants.js +1 -1
  83. package/dist/rans/constants.js.map +1 -1
  84. package/dist/rans/d04.js.map +1 -1
  85. package/dist/rans/decoding.js.map +1 -1
  86. package/dist/rans/frequencies.js.map +1 -1
  87. package/dist/rans/index.js +5 -5
  88. package/dist/rans/index.js.map +1 -1
  89. package/dist/unzip.d.ts +1 -1
  90. package/dist/unzip.js +5 -3
  91. package/dist/unzip.js.map +1 -1
  92. package/esm/craiIndex.js +10 -12
  93. package/esm/craiIndex.js.map +1 -1
  94. package/esm/cramFile/codecs/_base.d.ts +1 -1
  95. package/esm/cramFile/codecs/beta.d.ts +2 -2
  96. package/esm/cramFile/codecs/beta.js +1 -1
  97. package/esm/cramFile/codecs/beta.js.map +1 -1
  98. package/esm/cramFile/codecs/byteArrayLength.d.ts +2 -2
  99. package/esm/cramFile/codecs/byteArrayStop.d.ts +4 -4
  100. package/esm/cramFile/codecs/byteArrayStop.js +1 -1
  101. package/esm/cramFile/codecs/byteArrayStop.js.map +1 -1
  102. package/esm/cramFile/codecs/external.d.ts +1 -1
  103. package/esm/cramFile/codecs/external.js +1 -1
  104. package/esm/cramFile/codecs/external.js.map +1 -1
  105. package/esm/cramFile/codecs/gamma.d.ts +1 -1
  106. package/esm/cramFile/codecs/gamma.js +1 -1
  107. package/esm/cramFile/codecs/gamma.js.map +1 -1
  108. package/esm/cramFile/codecs/getBits.d.ts +1 -1
  109. package/esm/cramFile/codecs/getBits.js.map +1 -1
  110. package/esm/cramFile/codecs/huffman.d.ts +1 -1
  111. package/esm/cramFile/codecs/huffman.js +1 -1
  112. package/esm/cramFile/codecs/huffman.js.map +1 -1
  113. package/esm/cramFile/codecs/index.d.ts +1 -1
  114. package/esm/cramFile/codecs/index.js +5 -5
  115. package/esm/cramFile/codecs/index.js.map +1 -1
  116. package/esm/cramFile/codecs/subexp.d.ts +2 -2
  117. package/esm/cramFile/codecs/subexp.js +1 -1
  118. package/esm/cramFile/codecs/subexp.js.map +1 -1
  119. package/esm/cramFile/container/compressionScheme.d.ts +2 -2
  120. package/esm/cramFile/container/compressionScheme.js +1 -1
  121. package/esm/cramFile/container/compressionScheme.js.map +1 -1
  122. package/esm/cramFile/container/index.d.ts +1 -2
  123. package/esm/cramFile/container/index.js +4 -7
  124. package/esm/cramFile/container/index.js.map +1 -1
  125. package/esm/cramFile/file.d.ts +9 -13
  126. package/esm/cramFile/file.js +47 -52
  127. package/esm/cramFile/file.js.map +1 -1
  128. package/esm/cramFile/record.js +2 -2
  129. package/esm/cramFile/record.js.map +1 -1
  130. package/esm/cramFile/sectionParsers.d.ts +16 -16
  131. package/esm/cramFile/sectionParsers.js +7 -7
  132. package/esm/cramFile/sectionParsers.js.map +1 -1
  133. package/esm/cramFile/slice/decodeRecord.d.ts +3 -3
  134. package/esm/cramFile/slice/decodeRecord.js +11 -11
  135. package/esm/cramFile/slice/decodeRecord.js.map +1 -1
  136. package/esm/cramFile/slice/index.d.ts +2 -2
  137. package/esm/cramFile/slice/index.js +7 -6
  138. package/esm/cramFile/slice/index.js.map +1 -1
  139. package/esm/cramFile/util.d.ts +4 -2
  140. package/esm/cramFile/util.js +19 -2
  141. package/esm/cramFile/util.js.map +1 -1
  142. package/esm/htscodecs/arith_gen.d.ts +9 -17
  143. package/esm/htscodecs/arith_gen.js +32 -272
  144. package/esm/htscodecs/arith_gen.js.map +1 -1
  145. package/esm/htscodecs/fqzcomp.d.ts +1 -2
  146. package/esm/htscodecs/fqzcomp.js +2 -421
  147. package/esm/htscodecs/fqzcomp.js.map +1 -1
  148. package/esm/htscodecs/index.d.ts +5 -5
  149. package/esm/htscodecs/index.js +10 -10
  150. package/esm/htscodecs/index.js.map +1 -1
  151. package/esm/htscodecs/iostream.d.ts +2 -1
  152. package/esm/htscodecs/iostream.js +3 -2
  153. package/esm/htscodecs/iostream.js.map +1 -1
  154. package/esm/htscodecs/rans.d.ts +1 -2
  155. package/esm/htscodecs/rans.js +3 -270
  156. package/esm/htscodecs/rans.js.map +1 -1
  157. package/esm/htscodecs/rans4x16.d.ts +0 -1
  158. package/esm/htscodecs/rans4x16.js +6 -497
  159. package/esm/htscodecs/rans4x16.js.map +1 -1
  160. package/esm/htscodecs/tok3.js +17 -1
  161. package/esm/htscodecs/tok3.js.map +1 -1
  162. package/esm/index.d.ts +1 -1
  163. package/esm/index.js +1 -1
  164. package/esm/index.js.map +1 -1
  165. package/esm/indexedCramFile.d.ts +4 -4
  166. package/esm/indexedCramFile.js +10 -10
  167. package/esm/indexedCramFile.js.map +1 -1
  168. package/esm/io/index.d.ts +2 -2
  169. package/esm/io/index.js +1 -1
  170. package/esm/io/index.js.map +1 -1
  171. package/esm/rans/constants.d.ts +1 -1
  172. package/esm/rans/constants.js +1 -1
  173. package/esm/rans/constants.js.map +1 -1
  174. package/esm/rans/d04.js.map +1 -1
  175. package/esm/rans/decoding.js.map +1 -1
  176. package/esm/rans/frequencies.js.map +1 -1
  177. package/esm/rans/index.js +5 -5
  178. package/esm/rans/index.js.map +1 -1
  179. package/esm/unzip.d.ts +1 -1
  180. package/esm/unzip.js +4 -1
  181. package/esm/unzip.js.map +1 -1
  182. package/package.json +7 -9
  183. package/src/craiIndex.ts +17 -16
  184. package/src/cramFile/codecs/_base.ts +1 -1
  185. package/src/cramFile/codecs/beta.ts +3 -3
  186. package/src/cramFile/codecs/byteArrayLength.ts +1 -1
  187. package/src/cramFile/codecs/byteArrayStop.ts +3 -4
  188. package/src/cramFile/codecs/external.ts +3 -3
  189. package/src/cramFile/codecs/gamma.ts +2 -2
  190. package/src/cramFile/codecs/getBits.ts +1 -1
  191. package/src/cramFile/codecs/huffman.ts +2 -3
  192. package/src/cramFile/codecs/index.ts +7 -8
  193. package/src/cramFile/codecs/subexp.ts +3 -3
  194. package/src/cramFile/container/compressionScheme.ts +3 -3
  195. package/src/cramFile/container/index.ts +7 -10
  196. package/src/cramFile/file.ts +71 -77
  197. package/src/cramFile/record.ts +3 -3
  198. package/src/cramFile/sectionParsers.ts +27 -22
  199. package/src/cramFile/slice/decodeRecord.ts +17 -17
  200. package/src/cramFile/slice/index.ts +8 -9
  201. package/src/cramFile/util.ts +24 -5
  202. package/src/htscodecs/arith_gen.js +33 -296
  203. package/src/htscodecs/fqzcomp.js +2 -476
  204. package/src/htscodecs/index.js +9 -11
  205. package/src/htscodecs/iostream.js +3 -2
  206. package/src/htscodecs/rans.js +3 -315
  207. package/src/htscodecs/rans4x16.js +6 -557
  208. package/src/htscodecs/tok3.js +18 -1
  209. package/src/index.ts +1 -1
  210. package/src/indexedCramFile.ts +6 -5
  211. package/src/io/index.ts +5 -4
  212. package/src/rans/constants.ts +1 -1
  213. package/src/rans/d04.ts +0 -1
  214. package/src/rans/decoding.ts +0 -1
  215. package/src/rans/frequencies.ts +0 -1
  216. package/src/rans/index.ts +5 -7
  217. package/src/unzip.ts +5 -1
  218. package/dist/cramFile/filehandle.d.ts +0 -1
  219. package/dist/cramFile/filehandle.js +0 -3
  220. package/dist/cramFile/filehandle.js.map +0 -1
  221. package/dist/htscodecs/main_arith_gen.d.ts +0 -1
  222. package/dist/htscodecs/main_arith_gen.js +0 -86
  223. package/dist/htscodecs/main_arith_gen.js.map +0 -1
  224. package/dist/htscodecs/main_fqzcomp.d.ts +0 -1
  225. package/dist/htscodecs/main_fqzcomp.js +0 -112
  226. package/dist/htscodecs/main_fqzcomp.js.map +0 -1
  227. package/dist/htscodecs/main_rans.d.ts +0 -1
  228. package/dist/htscodecs/main_rans.js +0 -83
  229. package/dist/htscodecs/main_rans.js.map +0 -1
  230. package/dist/htscodecs/main_rans4x16.d.ts +0 -1
  231. package/dist/htscodecs/main_rans4x16.js +0 -82
  232. package/dist/htscodecs/main_rans4x16.js.map +0 -1
  233. package/dist/htscodecs/main_tok3.d.ts +0 -1
  234. package/dist/htscodecs/main_tok3.js +0 -84
  235. package/dist/htscodecs/main_tok3.js.map +0 -1
  236. package/dist/unzip-pako.d.ts +0 -2
  237. package/dist/unzip-pako.js +0 -9
  238. package/dist/unzip-pako.js.map +0 -1
  239. package/esm/cramFile/filehandle.d.ts +0 -1
  240. package/esm/cramFile/filehandle.js +0 -2
  241. package/esm/cramFile/filehandle.js.map +0 -1
  242. package/esm/htscodecs/main_arith_gen.d.ts +0 -1
  243. package/esm/htscodecs/main_arith_gen.js +0 -86
  244. package/esm/htscodecs/main_arith_gen.js.map +0 -1
  245. package/esm/htscodecs/main_fqzcomp.d.ts +0 -1
  246. package/esm/htscodecs/main_fqzcomp.js +0 -112
  247. package/esm/htscodecs/main_fqzcomp.js.map +0 -1
  248. package/esm/htscodecs/main_rans.d.ts +0 -1
  249. package/esm/htscodecs/main_rans.js +0 -83
  250. package/esm/htscodecs/main_rans.js.map +0 -1
  251. package/esm/htscodecs/main_rans4x16.d.ts +0 -1
  252. package/esm/htscodecs/main_rans4x16.js +0 -82
  253. package/esm/htscodecs/main_rans4x16.js.map +0 -1
  254. package/esm/htscodecs/main_tok3.d.ts +0 -1
  255. package/esm/htscodecs/main_tok3.js +0 -84
  256. package/esm/htscodecs/main_tok3.js.map +0 -1
  257. package/esm/unzip-pako.d.ts +0 -2
  258. package/esm/unzip-pako.js +0 -6
  259. package/esm/unzip-pako.js.map +0 -1
  260. package/src/cramFile/filehandle.ts +0 -1
  261. package/src/htscodecs/Makefile +0 -142
  262. package/src/htscodecs/README.md +0 -64
  263. package/src/htscodecs/main_arith_gen.js +0 -96
  264. package/src/htscodecs/main_fqzcomp.js +0 -113
  265. package/src/htscodecs/main_rans.js +0 -88
  266. package/src/htscodecs/main_rans4x16.js +0 -87
  267. package/src/htscodecs/main_tok3.js +0 -86
  268. package/src/unzip-pako.ts +0 -6
@@ -1,64 +0,0 @@
1
- # Reference implementation files
2
-
3
- This directory contains javascript implementations of the custom codecs using in
4
- CRAM 3.1, capable of being run under node.js.
5
-
6
- These is not written for speed, but for clarity and as an exercise in checking
7
- the pseudocode in the CRAM specification. It is written as close to this
8
- pseudocode as is possible.
9
-
10
- Prerequisites: minimist package for command line parsing and bzip2 for part of
11
- the arith_gen.js code.
12
-
13
- npm install minimist
14
- npm install bzip2
15
-
16
- ## iostream.js
17
-
18
- Makes a buffer appear to be a stream with ReadByte, ReadITF8, etc functions.
19
-
20
- ## rans.js
21
-
22
- Implements the order-0 and order-1 rans (4x8) decoder as used in CRAM3.0.
23
-
24
- ## main_rans.js
25
-
26
- A command line tool to exercise the rans.js code, included for debug purposes.
27
-
28
- ## rans4x16.js, main_rans4x16.js
29
-
30
- A 16-bit renormalising variant of rANS above. This also includes transforms for
31
- RLE, bit-packing and 4-way interleaving.
32
-
33
- ## arith_sh.js
34
-
35
- Arithmetic (range) coding with Schindler carry handling.
36
-
37
- ## byte_model.js
38
-
39
- An adaptive model for keeping track of symbol frequencies.
40
-
41
- ## arith_gen.js, main_arith_gen.js
42
-
43
- Wrapper around arith_sh.js to perform order-0/1 encoding with RLE and
44
- bit-packing. Plus debug command line tool
45
-
46
- ## fqzcomp.js, main_fqzcomp.js
47
-
48
- Implements the fqzcomp quality compression codec. Plus debug command line tool.
49
-
50
- ## tok3.js, main_tok3.js
51
-
52
- Implements the tokenise_name3 read identifier compression codec. Plus debug
53
- command line tool.
54
-
55
- # Testing
56
-
57
- The various main js files can be used for adhoc testing. There is also a
58
- Makefile which performs checks against known defined data streams and does
59
- round-trip testing in both Javascript and if compiled the C variant. You can set
60
- CORPUS make variable to a larger data set such htscodecs-corpus.
61
-
62
- eg.
63
-
64
- make check CORPUS=../tests/htscodecs-corpus/
@@ -1,96 +0,0 @@
1
- /*
2
- * Copyright (c) 2019,2020 Genome Research Ltd.
3
- * Author(s): James Bonfield
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above
12
- * copyright notice, this list of conditions and the following
13
- * disclaimer in the documentation and/or other materials provided
14
- * with the distribution.
15
- *
16
- * 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
17
- * Institute nor the names of its contributors may be used to endorse
18
- * or promote products derived from this software without specific
19
- * prior written permission.
20
- *
21
- * THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS
22
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH
25
- * LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
- */
33
-
34
- // Command line tool to manually test the arith_gen.js code.
35
-
36
- var fs = require('fs')
37
- var RangeCoderGen = require('./arith_gen')
38
-
39
- var argv = require('minimist')(process.argv.slice(2), { boolean: ['d', 'r'] })
40
-
41
- if (argv._.length != 1) {
42
- process.stderr.write(
43
- 'Usage: node main_arith_gen.js [-d] [-o order] input-file > output-file\n',
44
- )
45
- process.exit(1)
46
- }
47
-
48
- var filein = argv._[0]
49
-
50
- var buf = fs.readFileSync(filein)
51
- var blk_size = 1024 * 1024
52
- var raw = argv.r
53
-
54
- var arith = new RangeCoderGen()
55
- if (!argv.d) {
56
- var order = argv.o != undefined ? argv.o : 0
57
- // -o8.4 => 8+(256*4)
58
- order += Math.round((order - (order >> 0)) * 10) * 256
59
- var pos = 0
60
- var out_len = 0
61
- if (raw) blk_size = buf.length
62
- while (pos < buf.length) {
63
- var buf2 = arith.encode(buf.slice(pos, pos + blk_size), order)
64
-
65
- // Compressed buffer size. Used in multi-block format.
66
- var csize = new Buffer.allocUnsafe(4)
67
- if (!raw) {
68
- csize.writeInt32LE(buf2.length, 0)
69
- process.stdout.write(csize)
70
- }
71
-
72
- // Write compressed buffer itself
73
- process.stdout.write(buf2)
74
-
75
- pos += blk_size
76
- out_len += buf2.length
77
- }
78
- process.stderr.write(
79
- 'Compress order ' + order + ', ' + buf.length + ' => ' + out_len + '\n',
80
- )
81
- } else {
82
- var pos = 0
83
- var out_len = 0
84
- var len = buf.length
85
- while (pos < buf.length) {
86
- if (!raw) {
87
- len = buf.readInt32LE(pos)
88
- pos += 4
89
- }
90
- var buf2 = arith.decode(buf.slice(pos, pos + len))
91
- process.stdout.write(buf2)
92
- out_len += buf2.length
93
- pos += len
94
- }
95
- process.stderr.write('Decompress ' + buf.length + ' => ' + out_len + '\n')
96
- }
@@ -1,113 +0,0 @@
1
- /*
2
- * Copyright (c) 2019,2020 Genome Research Ltd.
3
- * Author(s): James Bonfield
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above
12
- * copyright notice, this list of conditions and the following
13
- * disclaimer in the documentation and/or other materials provided
14
- * with the distribution.
15
- *
16
- * 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
17
- * Institute nor the names of its contributors may be used to endorse
18
- * or promote products derived from this software without specific
19
- * prior written permission.
20
- *
21
- * THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS
22
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH
25
- * LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
- */
33
-
34
- var fs = require('fs')
35
- var fqz = require('./fqzcomp')
36
- var argv = require('minimist')(process.argv.slice(2), { boolean: ['d', 'r'] })
37
-
38
- if (argv._.length != 1) {
39
- process.stderr.write(
40
- 'Usage: node main_fqzcomp.js [-d] input-file > output-file\n',
41
- )
42
- process.exit(1)
43
- }
44
-
45
- var filein = argv._[0]
46
-
47
- var buf = fs.readFileSync(filein)
48
- var raw = argv.r
49
-
50
- if (!argv.d) {
51
- // Line breaks to get sequence length, but then stitch together into
52
- // a single non-breaking buffer.
53
- var len = 0
54
- var j = 0
55
- var q_lens = new Array()
56
- var q_dirs = new Array()
57
- var q_len = 0
58
- for (var i = 0; i < buf.length; i++) {
59
- if (buf[i] == '\n'.charCodeAt(0) || buf[i] == '\t'.charCodeAt(0)) {
60
- q_lens.push(len)
61
- if (q_len == 0) q_len = len
62
- else if (q_len != len) q_len = -1 // marker for multiple lengths
63
- len = 0
64
-
65
- if (buf[i] == '\t'.charCodeAt(0)) {
66
- // parse 2nd token for read1/read2 status
67
- var dir = ''
68
- for (i++; i < buf.length && buf[i] != '\n'.charCodeAt(0); i++)
69
- dir += String.fromCharCode(buf[i])
70
- q_dirs.push(dir)
71
- } else {
72
- q_dirs.push(0)
73
- }
74
- } else {
75
- buf[j++] = buf[i] - 33 // ASCII phred to raw
76
- len++
77
- }
78
- }
79
- buf = buf.slice(0, j)
80
- if (q_len > 0) q_lens = [q_lens[0]]
81
-
82
- var buf2 = fqz.encode(buf, q_lens, q_dirs)
83
- process.stderr.write('Compress ' + buf.length + ' => ' + buf2.length + '\n')
84
- if (!raw) {
85
- var hdr = new Buffer.allocUnsafe(8)
86
- hdr.writeInt32LE(buf.length, 0)
87
- hdr.writeInt32LE(buf2.length, 4)
88
- process.stdout.write(hdr)
89
- }
90
- process.stdout.write(buf2)
91
- } else {
92
- var q_lens = new Array()
93
- // Consume ulen and clen from outer test harness (pointless as non-blocking atm)
94
- var buf2
95
- if (raw) buf2 = fqz.decode(buf, q_lens)
96
- else buf2 = fqz.decode(buf.slice(8), q_lens)
97
-
98
- // Split into newlines so we can do easy data comparison
99
- var buf3 = new Buffer.allocUnsafe(buf2.length + q_lens.length)
100
- var rec = 0
101
- var len = q_lens[rec++]
102
- var j = 0
103
- for (var i = 0; i < buf2.length; i++) {
104
- buf3[j++] = buf2[i] + 33
105
- if (--len == 0) {
106
- buf3[j++] = '\n'.charCodeAt(0)
107
- len = q_lens[rec++]
108
- }
109
- }
110
-
111
- process.stderr.write('Decompress ' + buf.length + ' => ' + buf3.length + '\n')
112
- process.stdout.write(buf3)
113
- }
@@ -1,88 +0,0 @@
1
- /*
2
- * Copyright (c) 2019-2020 Genome Research Ltd.
3
- * Author(s): James Bonfield
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above
12
- * copyright notice, this list of conditions and the following
13
- * disclaimer in the documentation and/or other materials provided
14
- * with the distribution.
15
- *
16
- * 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
17
- * Institute nor the names of its contributors may be used to endorse
18
- * or promote products derived from this software without specific
19
- * prior written permission.
20
- *
21
- * THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS
22
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH
25
- * LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
- */
33
-
34
- var fs = require('fs')
35
- var rans = require('./rans')
36
- var argv = require('minimist')(process.argv.slice(2), { boolean: ['d', 'r'] })
37
-
38
- if (argv._.length != 1) {
39
- process.stderr.write(
40
- 'Usage: node main_rans.js [-d] [-o order] input-file > output-file\n',
41
- )
42
- process.exit(1)
43
- }
44
-
45
- var filein = argv._[0]
46
-
47
- var buf = fs.readFileSync(filein)
48
- var blk_size = 1024 * 1024
49
- var raw = argv.r
50
-
51
- if (!argv.d) {
52
- var order = argv.o != undefined ? argv.o : 0
53
- var pos = 0
54
- var out_len = 0
55
- if (raw) blk_size = buf.length
56
- while (pos < buf.length) {
57
- var buf2 = rans.encode(buf.slice(pos, pos + blk_size), order)
58
- var header = new Buffer.allocUnsafe(5)
59
- if (!raw) {
60
- header[0] = order
61
- header.writeInt32LE(buf2.length, 1)
62
- process.stdout.write(header)
63
- }
64
- process.stdout.write(buf2)
65
- pos += blk_size
66
- out_len += buf2.length
67
- }
68
- process.stderr.write(
69
- 'Compress order ' + order + ', ' + buf.length + ' => ' + out_len + '\n',
70
- )
71
- } else {
72
- var pos = 0
73
- var out_len = 0
74
- var len = buf.length
75
- while (pos < buf.length) {
76
- if (!raw) {
77
- var order = buf[0]
78
- pos++
79
- len = buf.readInt32LE(pos)
80
- pos += 4
81
- }
82
- var buf2 = rans.decode(buf.slice(pos, pos + len))
83
- process.stdout.write(buf2)
84
- out_len += buf2.length
85
- pos += len
86
- }
87
- process.stderr.write('Decompress ' + buf.length + ' => ' + out_len + '\n')
88
- }
@@ -1,87 +0,0 @@
1
- /*
2
- * Copyright (c) 2019-2020 Genome Research Ltd.
3
- * Author(s): James Bonfield
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above
12
- * copyright notice, this list of conditions and the following
13
- * disclaimer in the documentation and/or other materials provided
14
- * with the distribution.
15
- *
16
- * 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
17
- * Institute nor the names of its contributors may be used to endorse
18
- * or promote products derived from this software without specific
19
- * prior written permission.
20
- *
21
- * THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS
22
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH
25
- * LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
- */
33
-
34
- var fs = require('fs')
35
- var rans = require('./rans4x16')
36
- var argv = require('minimist')(process.argv.slice(2), { boolean: ['d', 'r'] })
37
-
38
- if (argv._.length != 1) {
39
- processf.stderr.write(
40
- 'Usage: node main_rans4x16.js [-d] [-o order] input-file > output-file\n',
41
- )
42
- process.exit(1)
43
- }
44
-
45
- var filein = argv._[0]
46
-
47
- var buf = fs.readFileSync(filein)
48
- var blk_size = 1024 * 1024
49
- var raw = argv.r
50
-
51
- if (!argv.d) {
52
- var order = argv.o != undefined ? argv.o : 0
53
- // -o8.4 => 8+(256*4)
54
- order += Math.round((order - (order >> 0)) * 10) * 256
55
- var pos = 0
56
- var out_len = 0
57
- if (raw) blk_size = buf.length
58
- while (pos < buf.length) {
59
- var buf2 = rans.encode(buf.slice(pos, pos + blk_size), order)
60
- var header = new Buffer.allocUnsafe(4)
61
- if (!raw) {
62
- header.writeInt32LE(buf2.length, 0)
63
- process.stdout.write(header)
64
- }
65
- process.stdout.write(buf2)
66
- pos += blk_size
67
- out_len += buf2.length + 4
68
- }
69
- process.stderr.write(
70
- 'Compress order ' + order + ', ' + buf.length + ' => ' + out_len + '\n',
71
- )
72
- } else {
73
- var pos = 0
74
- var out_len = 0
75
- var len = buf.length
76
- while (pos < buf.length) {
77
- if (!raw) {
78
- len = buf.readInt32LE(pos)
79
- pos += 4
80
- }
81
- var buf2 = rans.decode(buf.slice(pos, pos + len))
82
- process.stdout.write(buf2)
83
- out_len += buf2.length
84
- pos += len
85
- }
86
- process.stderr.write('Decompress ' + buf.length + ' => ' + out_len + '\n')
87
- }
@@ -1,86 +0,0 @@
1
- /*
2
- * Copyright (c) 2019,2020 Genome Research Ltd.
3
- * Author(s): James Bonfield
4
- *
5
- * Redistribution and use in source and binary forms, with or without
6
- * modification, are permitted provided that the following conditions are met:
7
- *
8
- * 1. Redistributions of source code must retain the above copyright notice,
9
- * this list of conditions and the following disclaimer.
10
- *
11
- * 2. Redistributions in binary form must reproduce the above
12
- * copyright notice, this list of conditions and the following
13
- * disclaimer in the documentation and/or other materials provided
14
- * with the distribution.
15
- *
16
- * 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
17
- * Institute nor the names of its contributors may be used to endorse
18
- * or promote products derived from this software without specific
19
- * prior written permission.
20
- *
21
- * THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS
22
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH
25
- * LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
- */
33
-
34
- var fs = require('fs')
35
- var tok3 = require('./tok3')
36
- var argv = require('minimist')(process.argv.slice(2), {
37
- boolean: ['d', 'a', 'r'],
38
- })
39
-
40
- if (argv._.length != 1) {
41
- process.stderr.write(
42
- 'Usage: node main_tok3.js [-a] [-d] input-file > output-file\n',
43
- )
44
- process.exit(1)
45
- }
46
-
47
- var filein = argv._[0]
48
-
49
- var buf = fs.readFileSync(filein)
50
- var blk_size = 1024 * 1024
51
- var raw = argv.r
52
-
53
- if (!argv.d) {
54
- var pos = 0
55
- var out_len = 0
56
- if (raw) blk_size = buf.length
57
- while (pos < buf.length) {
58
- var blk_end = blk_size
59
- while (pos + blk_end < buf.length && buf[pos + blk_end - 1] != 10) blk_end--
60
- var buf2 = tok3.encode(buf.slice(pos, pos + blk_end), argv.a)
61
- var header = new Buffer.allocUnsafe(4)
62
- if (!raw) {
63
- header.writeInt32LE(buf2.length, 0)
64
- process.stdout.write(header)
65
- }
66
- process.stdout.write(buf2)
67
- pos += blk_end
68
- out_len += buf2.length + 4
69
- }
70
- process.stderr.write('Compress ' + buf.length + ' => ' + out_len + '\n')
71
- } else {
72
- var pos = 0
73
- var out_len = 0
74
- var len = buf.length
75
- while (pos < buf.length) {
76
- if (!raw) {
77
- len = buf.readInt32LE(pos)
78
- pos += 4
79
- }
80
- var buf2 = tok3.decode(buf.slice(pos, pos + len), len)
81
- process.stdout.write(buf2)
82
- out_len += buf2.length
83
- pos += len
84
- }
85
- process.stderr.write('Decompress ' + buf.length + ' => ' + out_len + '\n')
86
- }
package/src/unzip-pako.ts DELETED
@@ -1,6 +0,0 @@
1
- import { inflate } from 'pako'
2
- import { Buffer } from 'buffer'
3
-
4
- export function unzip(input: Buffer) {
5
- return Buffer.from(inflate(input))
6
- }