diff --git a/.prettierrc.json b/.prettierrc.json index a1b59c6..b6cb800 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -2,5 +2,6 @@ "semi": false, "trailingComma": "all", "singleQuote": true, - "arrowParens": "avoid" + "arrowParens": "avoid", + "proseWrap": "always" } diff --git a/CHANGELOG.md b/CHANGELOG.md index c3622c2..a41ca94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # [6.0.0](https://github.com/GMOD/vcf-js/compare/v5.0.10...v6.0.0) (2024-11-30) -- Changes the default Variant object to have a SAMPLES() function call instead of a SAMPLES getter, to make it mor abundantly clear that it is a lazy operation. Also adds a GENOTYPES() function that returns the raw string of genotype fields +- Changes the default Variant object to have a SAMPLES() function call instead + of a SAMPLES getter, to make it mor abundantly clear that it is a lazy + operation. Also adds a GENOTYPES() function that returns the raw string of + genotype fields ## [5.0.10](https://github.com/GMOD/vcf-js/compare/v5.0.9...v5.0.10) (2022-12-17) @@ -30,7 +33,8 @@ ## [5.0.5](https://github.com/GMOD/vcf-js/compare/v5.0.4...v5.0.5) (2022-01-12) -- Add optimization related to better allocation of variant records, thanks to @bpow for contributing +- Add optimization related to better allocation of variant records, thanks to + @bpow for contributing diff --git a/README.md b/README.md index d49fdb4..fd2f116 100644 --- a/README.md +++ b/README.md @@ -108,8 +108,8 @@ The `variant` object returned by `parseLine()` would be } ``` -The `variant.SAMPLES()` and `variant.GENOTYPES()` are functions because it does not -try to eagerly parse all the genotype data, so will only do so when you call +The `variant.SAMPLES()` and `variant.GENOTYPES()` are functions because it does +not try to eagerly parse all the genotype data, so will only do so when you call either of these which can save time especially if your VCF has a lot of samples in it. @@ -125,13 +125,11 @@ using the header metadata. For example, if there is a header line like ``` The parser will expect any INFO entry ABC to be an array of two integers, so it -would convert `ABC=12,20` to `{ ABC: [12, 20] }`. Each INFO entry value will be -an array unless `Type=Flag` is specified, in which case it will be `true`. If no -metadata can be found for the entry, it will assume `Number=1` and -`Type=String`. +would convert `ABC=12,20` to `{ ABC: [12, 20] }`. -_NOTE: the vcf specification allows percent-encoded characters. this library -does not decode them, an end-use library can call url-decode methods_ +Each INFO entry value will be an array unless `Type=Flag` is specified, in which +case it will be `true`. If no metadata can be found for the entry, it will +assume `Number=1` and `Type=String`. Some fields are pre-defined by the [VCF spec](https://samtools.github.io/hts-specs/VCFv4.3.pdf), which is why in @@ -199,7 +197,8 @@ you can access the VCF's header metadata like (some output omitted for clarity): 1 ``` -A list of sample names is also available in the `samples` attribute of the parser object: +A list of sample names is also available in the `samples` attribute of the +parser object: ```typescript > console.log(vcfParser.samples) @@ -285,22 +284,27 @@ Class representing a VCF parser, instantiated with the VCF header. #### Parameters -- `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** +- `args` + **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** - - `args.header` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The VCF header. Supports both LF and CRLF - newlines. (optional, default `''`) - - `args.strict` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether to parse in strict mode or not - (default true) (optional, default `true`) + - `args.header` + **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** + The VCF header. Supports both LF and CRLF newlines. (optional, default `''`) + - `args.strict` + **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** + Whether to parse in strict mode or not (default true) (optional, default + `true`) #### getMetadata -Get metadata filtered by the elements in args. For example, can pass -('INFO', 'DP') to only get info on an metadata tag that was like -"##INFO=\" +Get metadata filtered by the elements in args. For example, can pass ('INFO', +'DP') to only get info on an metadata tag that was like "##INFO=\" ##### Parameters -- `args` **...[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** List of metadata filter strings. +- `args` + **...[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** + List of metadata filter strings. Returns **any** An object, string, or number, depending on the filtering @@ -337,8 +341,8 @@ Parse a VCF line into an object like ``` SAMPLES and GENOTYPES methods are functions instead of static data fields -because it avoids parsing the potentially long list of samples from e.g. -1000 genotypes data unless requested. +because it avoids parsing the potentially long list of samples from e.g. 1000 +genotypes data unless requested. The SAMPLES function gives all info about the samples @@ -347,4 +351,6 @@ potentially optimized parsing by programs that need it ##### Parameters -- `line` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A string of a line from a VCF +- `line` + **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** + A string of a line from a VCF