Sleipnir
tools/KNNImputer/KNNImputer.cpp
00001 /*****************************************************************************
00002 * This file is provided under the Creative Commons Attribution 3.0 license.
00003 *
00004 * You are free to share, copy, distribute, transmit, or adapt this work
00005 * PROVIDED THAT you attribute the work to the authors listed below.
00006 * For more information, please see the following web page:
00007 * http://creativecommons.org/licenses/by/3.0/
00008 *
00009 * This file is a component of the Sleipnir library for functional genomics,
00010 * authored by:
00011 * Curtis Huttenhower (chuttenh@princeton.edu)
00012 * Mark Schroeder
00013 * Maria D. Chikina
00014 * Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
00015 *
00016 * If you use this library, the included executable tools, or any related
00017 * code in your work, please cite the following publication:
00018 * Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
00019 * Olga G. Troyanskaya.
00020 * "The Sleipnir library for computational functional genomics"
00021 *****************************************************************************/
00022 #include "stdafx.h"
00023 #include "cmdline.h"
00024 
00025 int main( int iArgs, char** aszArgs ) {
00026     gengetopt_args_info sArgs;
00027     CPCL                PCL;
00028     CDat                Dat;
00029     int                 iRet;
00030     ofstream            ofsm;
00031 
00032     if( cmdline_parser( iArgs, aszArgs, &sArgs ) ) {
00033         cmdline_parser_print_help( );
00034         return 1; }
00035     CMeta Meta( sArgs.verbosity_arg );
00036 
00037     if( iRet = CPCL::Distance( sArgs.input_arg, sArgs.skip_arg, sArgs.neighbors_arg ? sArgs.distance_arg : NULL,
00038         false, false, !!sArgs.autocorrelate_flag, sArgs.genes_arg, CMeta::GetNaN( ), sArgs.limit_arg, PCL,
00039         Dat ) ) {
00040         cmdline_parser_print_help( );
00041         return iRet; }
00042 
00043     PCL.Impute( sArgs.neighbors_arg, (float)sArgs.missing_arg, Dat );
00044 
00045     if( sArgs.output_arg ) {
00046         ofsm.open( sArgs.output_arg );
00047         PCL.Save( ofsm );
00048         ofsm.close( ); }
00049     else {
00050         PCL.Save( cout );
00051         cout.flush( ); }
00052 
00053     return 0; }