Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 7, 2024
1 parent a5687ff commit 3f07000
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,29 @@ Returns **any** An object, string, or number, depending on the filtering
#### parseLine
Parse a VCF line into an object like { CHROM POS ID REF ALT QUAL FILTER
INFO } with SAMPLES optionally included if present in the VCF
Parse a VCF line into an object like
```ts
interface Variant {
CHROM: string
POS: number
ID: string[]
REF: string
ALT: string[]
QUAL: number[]
FILTER: string[]
INFO: unknown[]
SAMPLES: () => Record<string, unknown[]>
GENOTYPES: () => Record<string, string>
}
```
SAMPLES is a function that can be invoked. the long list of samples from
1000 genotypes is not parsed eagerly, and is only parsed when SAMPLES or
GENOTYPES is invoked. The SAMPLES function gives all info about the
samples, while the GENOTYPES function only extracts the raw GT string if
it exists, for 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. Supports both LF and
CRLF newlines.
- `line` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A string of a line from a VCF
27 changes: 23 additions & 4 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,30 @@ export default class VCFParser {
}

/**
* Parse a VCF line into an object like { CHROM POS ID REF ALT QUAL FILTER
* INFO } with SAMPLES optionally included if present in the VCF
* Parse a VCF line into an object like
*
* @param {string} line - A string of a line from a VCF. Supports both LF and
* CRLF newlines.
* ```ts
* interface Variant {
* CHROM: string
* POS: number
* ID: string[]
* REF: string
* ALT: string[]
* QUAL: number[]
* FILTER: string[]
* INFO: unknown[]
* SAMPLES: () => Record<string,unknown[]>
* GENOTYPES: () => Record<string,string>
* }
* ```
*
* SAMPLES is a function that can be invoked. the long list of samples from
* 1000 genotypes is not parsed eagerly, and is only parsed when SAMPLES or
* GENOTYPES is invoked. The SAMPLES function gives all info about the
* samples, while the GENOTYPES function only extracts the raw GT string if
* it exists, for potentially optimized parsing by programs that need it
*
* @param {string} line - A string of a line from a VCF
*/
parseLine(line: string) {
let currChar = 0
Expand Down

0 comments on commit 3f07000

Please sign in to comment.