Sleipnir
|
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 CDat Dat; 00027 size_t i, j; 00028 gengetopt_args_info sArgs; 00029 float dFrac; 00030 00031 if( cmdline_parser( iArgs, aszArgs, &sArgs ) ) { 00032 cmdline_parser_print_help( ); 00033 return 1; } 00034 CMeta Meta( sArgs.verbosity_arg, sArgs.random_arg ); 00035 00036 if( !Dat.Open( sArgs.input_arg ) ) { 00037 cerr << "Could not open input: " << sArgs.input_arg << endl; 00038 return 1; } 00039 00040 dFrac = 0; 00041 for( i = 0; i < Dat.GetGenes( ); ++i ) 00042 for( j = ( i + 1 ); j < Dat.GetGenes( ); ++j ) 00043 if( !CMeta::IsNaN( Dat.Get( i, j ) ) ) { 00044 dFrac++; 00045 Dat.Set( i, j, CMeta::GetNaN( ) ); } 00046 if( sArgs.count_arg ) 00047 dFrac = (float)sArgs.count_arg; 00048 dFrac /= Dat.GetGenes( ) * ( Dat.GetGenes( ) - 1 ) / 2; 00049 for( i = 0; i < Dat.GetGenes( ); ++i ) 00050 for( j = ( i + 1 ); j < Dat.GetGenes( ); ++j ) 00051 if( ( (float)rand( ) / RAND_MAX ) < dFrac ) 00052 Dat.Set( i, j, 1 ); 00053 00054 Dat.Save( sArgs.input_arg ); 00055 00056 return 0; }