Haplo Prediction
predict haplogroups
output.h
Go to the documentation of this file.
00001 /*
00002  * This work is licensed under a Creative Commons 
00003  * Attribution-Noncommercial-Share Alike 3.0 United States License.
00004  * 
00005  *    http://creativecommons.org/licenses/by-nc-sa/3.0/us/
00006  * 
00007  * You are free:
00008  * 
00009  *    to Share - to copy, distribute, display, and perform the work
00010  *    to Remix - to make derivative works
00011  * 
00012  * Under the following conditions:
00013  * 
00014  *    Attribution. You must attribute the work in the manner specified by the
00015  *    author or licensor (but not in any way that suggests that they endorse you
00016  *    or your use of the work).
00017  * 
00018  *    Noncommercial. You may not use this work for commercial purposes.
00019  * 
00020  *    Share Alike. If you alter, transform, or build upon this work, you may
00021  *    distribute the resulting work only under the same or similar license to
00022  *    this one.
00023  * 
00024  * For any reuse or distribution, you must make clear to others the license
00025  * terms of this work. The best way to do this is by including this header.
00026  * 
00027  * Any of the above conditions can be waived if you get permission from the
00028  * copyright holder.
00029  * 
00030  * Apart from the remix rights granted under this license, nothing in this
00031  * license impairs or restricts the author's moral rights.
00032  */
00033 
00034 
00046 #ifndef OUTPUT_H
00047 #define OUTPUT_H
00048 
00049 
00050 #include <config.h>
00051 
00052 #include <stdlib.h>
00053 #include <stdio.h>
00054 #include <inttypes.h>
00055 #include <assert.h>
00056 
00057 #include <libxml/tree.h>
00058 
00059 #include <jwsc/base/error.h>
00060 #include <jwsc/vector/vector.h>
00061 #include <jwsc/matblock/matblock.h>
00062 
00063 
00065 typedef enum
00066 {
00067     HAPLO_OUTPUT_TXT,
00068     HAPLO_OUTPUT_CSV,
00069     HAPLO_OUTPUT_XML
00070 }
00071 Haplo_output_format;
00072 
00073 
00075 typedef enum
00076 {
00077     HAPLO_SEP_PREFIX,
00078     HAPLO_SEP_SUFFIX,
00079     HAPLO_SEP_BOTH,
00080     HAPLO_SEP_NONE
00081 }
00082 Haplo_field_sep;
00083 
00084 
00086 Error* open_output
00087 (
00088     FILE**      fp_out, 
00089     xmlDoc**    xml_doc_out, 
00090     const char* xml_name,
00091     const char* xml_dtd,
00092     const char* fname
00093 );
00094 
00095 
00097 Error* close_output(FILE* fp, xmlDoc* doc, const char* fname);
00098 
00099 
00101 void write_ids
00102 (
00103     const Matblock_u8* ids,
00104     uint32_t           i,
00105     Haplo_field_sep    field_sep,
00106     FILE*              fp,
00107     xmlNode*           xml_node
00108 );
00109 
00110 
00112 void write_label
00113 (
00114     const Vector_u32* labels,
00115     uint32_t          i,
00116     Haplo_field_sep   field_sep,
00117     FILE*             fp,
00118     xmlNode*          xml_node
00119 );
00120 
00121 
00123 void write_conf
00124 (
00125     const Vector_d* confs,
00126     uint32_t        i,
00127     Haplo_field_sep field_sep,
00128     FILE*           fp,
00129     xmlNode*        xml_node
00130 );
00131 
00132 
00134 void write_prediction
00135 (
00136     const char*       type,
00137     const Vector_u32* labels,
00138     const Vector_d*   confs,
00139     uint32_t          i,
00140     Haplo_field_sep   field_sep,
00141     FILE*             fp,
00142     xmlNode*          xml_node
00143 );
00144 
00145 
00147 void write_ancestor_label
00148 (
00149     const Vector_u32*  ancestor_types,
00150     const Vector_u32*  ancestor_labels,
00151     uint32_t           i,
00152     Haplo_field_sep    field_sep,
00153     FILE*              fp,
00154     xmlNode*           xml_node
00155 );
00156 
00157 #endif