Haplo Prediction
predict haplogroups
Enumerations | Functions
output.h File Reference

Output related functions. More...

#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <assert.h>
#include <libxml/tree.h>
#include <jwsc/base/error.h>
#include <jwsc/vector/vector.h>
#include <jwsc/matblock/matblock.h>

Go to the source code of this file.

Enumerations

enum  Haplo_output_format { HAPLO_OUTPUT_TXT, HAPLO_OUTPUT_CSV, HAPLO_OUTPUT_XML }
 Types of output file format to generate. More...
enum  Haplo_field_sep { HAPLO_SEP_PREFIX, HAPLO_SEP_SUFFIX, HAPLO_SEP_BOTH, HAPLO_SEP_NONE }
 Types of field separation in an output file. More...

Functions

Erroropen_output (FILE **fp_out, xmlDoc **xml_doc_out, const char *xml_name, const char *xml_dtd, const char *fname)
 Open an output file for writing.
Errorclose_output (FILE *fp, xmlDoc *doc, const char *fname)
 Close a file used for output writing.
void write_ids (const Matblock_u8 *ids, uint32_t i, Haplo_field_sep field_sep, FILE *fp, xmlNode *xml_node)
 Writes a sample ids to a file or an xml node.
void write_label (const Vector_u32 *labels, uint32_t i, Haplo_field_sep field_sep, FILE *fp, xmlNode *xml_node)
 Writes a sample label to a file or an xml node.
void write_conf (const Vector_d *confs, uint32_t i, Haplo_field_sep field_sep, FILE *fp, xmlNode *xml_node)
 Writes a label confidence value to a file stream.
void write_prediction (const char *type, const Vector_u32 *labels, const Vector_d *confs, uint32_t i, Haplo_field_sep field_sep, FILE *fp, xmlNode *xml_node)
 Writes a prediction.
void write_ancestor_label (const Vector_u32 *ancestor_types, const Vector_u32 *ancestor_labels, uint32_t i, Haplo_field_sep field_sep, FILE *fp, xmlNode *xml_node)
 Writes the ancestor to a file stream.

Detailed Description

Output related functions.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Definition in file output.h.


Enumeration Type Documentation

Types of output file format to generate.

Enumerator:
HAPLO_OUTPUT_TXT 
HAPLO_OUTPUT_CSV 
HAPLO_OUTPUT_XML 

Definition at line 65 of file output.h.

Types of field separation in an output file.

Enumerator:
HAPLO_SEP_PREFIX 
HAPLO_SEP_SUFFIX 
HAPLO_SEP_BOTH 
HAPLO_SEP_NONE 

Definition at line 75 of file output.h.


Function Documentation

Error* open_output ( FILE **  fp_out,
xmlDoc **  xml_doc_out,
const char *  xml_name,
const char *  xml_dtd,
const char *  fname 
)

Open an output file for writing.

Depending on the value of opts.output_format, either *fp_out or *doc_out will be initialized.

Parameters:
fp_outResult parameter. Contains the file stream pointer.
xml_doc_outResult parameter. Contains the xml document pointer. Can be NULL, in which case the (xml) function is a NOOP.
xml_nameName of the document type and root node.
xml_dtdName of the document type definition file to use.
fnameFile name to open for writing.

Definition at line 83 of file output.c.

Error* close_output ( FILE *  fp,
xmlDoc xml_doc,
const char *  fname 
)

Close a file used for output writing.

Depending on the value of opts.output_format, either fp or doc will be closed.

Parameters:
fpFile stream pointer.
xml_docXml document pointer. Can be NULL, in which case the (xml) functions is a NOOP.
fnameFile name to close that was used for writing.

Definition at line 128 of file output.c.

void write_ids ( const Matblock_u8 ids,
uint32_t  i,
Haplo_field_sep  field_sep,
FILE *  fp,
xmlNode *  xml_node 
)

Writes a sample ids to a file or an xml node.

Parameters:
idsSet of predicted haplo labels.
iIndex of the haplo label in labels to write.
field_sepType of field separation to maintain.
fpFile stream to write to.
xml_nodeParent xml node to attach a label node to.

Definition at line 167 of file output.c.

void write_label ( const Vector_u32 labels,
uint32_t  i,
Haplo_field_sep  field_sep,
FILE *  fp,
xmlNode *  xml_node 
)

Writes a sample label to a file or an xml node.

Parameters:
labelsSet of predicted haplo labels.
iIndex of the haplo label in labels to write.
field_sepType of field separation to maintain.
fpFile stream to write to.
xml_nodeParent xml node to attach a label node to.

Definition at line 237 of file output.c.

void write_conf ( const Vector_d confs,
uint32_t  i,
Haplo_field_sep  field_sep,
FILE *  fp,
xmlNode *  xml_node 
)

Writes a label confidence value to a file stream.

Parameters:
confsSet of predicted haplo label confidence values.
iIndex of the haplo label confidence in confs to write.
field_sepType of field separation to maintain.
fpFile stream to write to.
xml_nodeParent xml node to attach a label node to.

Definition at line 305 of file output.c.

void write_prediction ( const char *  type,
const Vector_u32 labels,
const Vector_d confs,
uint32_t  i,
Haplo_field_sep  field_sep,
FILE *  fp,
xmlNode *  xml_node 
)

Writes a prediction.

Parameters:
typeName of this type of prediction.
labelsSet of predicted haplo labels.
confsSet of predicted haplo label confidence values.
iIndex of the haplo label confidence in confs to write.
field_sepType of field separation to maintain.
fpFile stream to write to.
xml_nodeParent xml node to attach a label node to.

Definition at line 370 of file output.c.

void write_ancestor_label ( const Vector_u32 ancestor_types,
const Vector_u32 ancestor_labels,
uint32_t  i,
Haplo_field_sep  field_sep,
FILE *  fp,
xmlNode *  xml_node 
)

Writes the ancestor to a file stream.

Parameters:
ancestor_typesTypes of ancestor relationship per label.
ancestor_labelsSet of ancestors.
iIndex of the ancestor to write.
field_sepType of field separation to maintain.
fpFile stream to write to.
xml_nodeParent xml node to attach a label node to.

Definition at line 405 of file output.c.