|
| | SortedVCFWriter (const string &sample_name) |
| |
| bool | add_variant (vcflib::Variant &var, size_t block=0, bool hidden=false) |
| |
| void | set_contigs (vector< ReferenceContig > declared, bool only_with_records=false) |
| |
| void | add_info_line (string line) |
| |
| void | add_format_line (string line) |
| |
| void | add_filter_line (string line) |
| |
| void | write_variants (ostream &out, const SnarlDecomposition *sites=nullptr, const HandleGraph *graph=nullptr, const function< string(const net_handle_t &)> &record_id_of_site={}) |
| |
| void | set_nested (bool nested) |
| | Write the nesting INFO tags (LV, CH, PS, RC, RS, RD) to every record. More...
|
| |
| void | set_gref_levels (map< string, int > levels) |
| |
| void | set_translation (const NodeTranslation *translation) |
| | Name nodes in record IDs and AT by translation instead of by their IDs. More...
|
| |
| const NodeTranslation * | translation () const |
| |
| const string & | sample_name () const |
| |
| void | set_sample_names (vector< string > names) |
| |
| void | vcf_fixup (vcflib::Variant &var) const |
| | Run vcflib's vcffixup on a record, filling AC, AN and the like. More...
|
| |
A sorted VCF, built up from records and written out at the end.
Records can be added from any thread. This class is responsible for buffering them until the end, giving them the nesting INFO tags, sorting them, and writing them.
| bool vg::SortedVCFWriter::add_variant |
( |
vcflib::Variant & |
var, |
|
|
size_t |
block = 0, |
|
|
bool |
hidden = false |
|
) |
| |
Add a record to the output. The record is attached to the writer's VCF file, which gives it the writer's sample columns, and is then kept as its text.
A hidden record is not written. The writer keeps only its ID and the stretch of the reference its REF covers, so that a record nested inside it can still be placed on the reference when the nesting tags are computed.
- Parameters
-
| block | The number of the difference block of its site that the record holds, or 0 for a record of a whole site. Two blocks of one site share an ID and can share a POS. |
- Returns
- false, without adding the record, if its line is longer than
max_vcf_line_length.
| string vg::SortedVCFWriter::vcf_header |
( |
const unordered_set< string > * |
keep_contigs | ) |
const |
|
private |
Return the text of the whole header, each line ending in a newline. If keep_contigs is not null, only the contigs in it get ##contig lines.
The header starts with the fileformat line and the ##contig lines. The INFO, FORMAT and FILTER lines follow, grouped by type. Each group starts with the lines that the writer always writes, and then has the added lines. The ##SAMPLE lines and the column line come last.
| void vg::SortedVCFWriter::write_variants |
( |
ostream & |
out, |
|
|
const SnarlDecomposition * |
sites = nullptr, |
|
|
const HandleGraph * |
graph = nullptr, |
|
|
const function< string(const net_handle_t &)> & |
record_id_of_site = {} |
|
) |
| |
Write the header, then the records, sorted, and empty the buffer. Call it once, after every record and header line has been added.
With nesting on, each record first gets the nesting INFO tags, which say where its site lies in the snarl tree sites and where to find it on the reference. A record is matched to its site by its ID, so record_id_of_site must give each snarl's ID as its records carry it. When nesting is off, sites may be null.
- Parameters
-
| graph | The graph of sites, which the default record IDs read node IDs from. It may be null when record_id_of_site is given or nesting is off. |
| record_id_of_site | Returns the record ID of a snarl of sites, read the way the net handle traverses it. When empty, a snarl is named from its boundary nodes. |
| vcflib::VariantCallFile vg::SortedVCFWriter::output_vcf |
|
private |
The VCF file that the records belong to. Its sample names are the samples whose columns the records have, in order.
We take a deliberate shortcut with this file. vcflib expects a file to be opened with its header before any of its records exist. Here the records are printed to text as they are added, and the header is known only at the end. So while records are added, the file holds only the sample names. A record attached to the file copies them, and printing the record reads only those copies. The shortcut is safe because nothing reads the INFO or FORMAT types of the file through a record before the header is in place: a record is kept only as text once it is added. The file is opened with the real header just before anything is written.
| vector<unordered_map<string, Region> > vg::SortedVCFWriter::suppressed_ref_info |
|
private |
The reference interval of each hidden record, by its ID, one table per thread like output_variants.
A hidden record is one of a site that had no variant to report. A record nested under such a site may have no other reference coordinate to point its RC, RS and RD at. This is common in gref graphs, where the parent of an island of non-reference sequence is often a large snarl that only the reference and its own gref copy span.