Commits

Anonymous committed 0d6ec2f

- Modified joint probability computation between the species.
- Added a few user friendly command line arguments

Comments (0)

Files changed (4)

tools/SpeciesConnector/SpeciesConnector.cpp

 
 int main( int iArgs, char** aszArgs ) {
 	gengetopt_args_info			sArgs;
-	CDataPair					DatOne, DatTwo;
-	size_t						i, j, k, iDatOne, iDatTwo, iGeneOne, iGeneTwo, count1, count2;
+	size_t						i, j, k, iDatOne, iDatTwo, iGeneOne, iGeneTwo, iZero;
 	size_t						iCountJoint, iValueOne, iValueTwo;
-	vector<size_t>				veciGenesOne, veciGenesTwo, veciSizes;
 	vector<vector<size_t> >		vecveciJoint;
-	vector<string>				vecstrTInputs, vecstrInputs, vecstrxInputs, vecstrlInputs, vecstrlxInputs, vecstrGenes, vecstrAllGenes;
-	float						dValueOne, dValueTwo;
+	vector<string>				vecstrInputs, vecstrxInputs, vecstrGenes;
 	map<string, size_t>			mapZeros;
 	CBayesNetSmile				BNIn;
-				
+	vector<size_t>				veciGenesOneI, veciGenesTwoI;
+	float						Threshold;
+
 	if( cmdline_parser( iArgs, aszArgs, &sArgs ) ) {
 		cmdline_parser_print_help( );
 		return 1; }
 	CMeta Meta( sArgs.verbosity_arg, sArgs.random_arg );
 
-	if( sArgs.inputs_num%2 !=0 ){
-		cerr << "Number of inputs should be even." <<  endl;
-		return 1;}
-	
-	vecstrTInputs.resize( sArgs.inputs_num );
-	copy( sArgs.inputs, sArgs.inputs + sArgs.inputs_num, vecstrTInputs.begin( ) );
+	Threshold = ( sArgs.threshold_arg == -1 ) ? 0.5f : float( sArgs.threshold_arg );
 
-	vecstrInputs.resize( sArgs.inputs_num/2 );
-	vecstrxInputs.resize( sArgs.inputs_num/2 );
-	vecstrlInputs.resize( sArgs.inputs_num/2 );
-	vecstrlxInputs.resize( sArgs.inputs_num/2 );
-	
-	for( count1 = count2 = 0, i = 0; i < vecstrTInputs.size( ); ++i ){
-		if( strcmp( &vecstrTInputs[ i ][ vecstrTInputs[ i ].rfind( "." ) + 1 ] , "dab" ) == 0 ){
-			vecstrInputs[ count1 ] = vecstrTInputs[ i ];
-			vecstrlInputs[ count1 ].resize( vecstrTInputs[ i ].rfind( "." ) - vecstrTInputs[ i ].rfind( "/" ) - 1 );
-			vecstrlInputs[ count1 ] = vecstrTInputs[ i ].substr( vecstrTInputs[ i ].rfind( "/" ) + 1, vecstrTInputs[ i ].rfind( "." ) - vecstrTInputs[ i ].rfind( "/" ) - 1 ); 
-			count1++;}
-		else if( strcmp( &vecstrTInputs[ i ][ vecstrTInputs[ i ].rfind( "." ) + 1 ], "xdsl" ) == 0 ){ 
-			vecstrxInputs[ count2 ] = vecstrTInputs[ i ];
-			vecstrlxInputs[ count2 ].resize( vecstrTInputs[ i ].rfind( "." ) - vecstrTInputs[ i ].rfind( "/" ) - 1 );
-			vecstrlxInputs[ count2 ] = vecstrTInputs[ i ].substr( vecstrTInputs[ i ].rfind( "/" ) + 1, vecstrTInputs[ i ].rfind( "." ) - vecstrTInputs[ i ].rfind( "/" ) - 1 ); 
-			count2++;}
+	vecstrInputs.resize( sArgs.inputs_num );
+	copy( sArgs.inputs, sArgs.inputs + sArgs.inputs_num, vecstrInputs.begin( ) );
+
+	vecstrxInputs.resize( sArgs.inputs_num );
+
+	for( i = 0; i < vecstrInputs.size( ); ++i ){
+		if( strcmp( &vecstrInputs[ i ][ vecstrInputs[ i ].rfind( "." ) + 1 ], "xdsl" ) == 0 ){ 
+			vecstrxInputs[ i ].resize( vecstrInputs[ i ].rfind( "." ) - vecstrInputs[ i ].rfind( "/" ) - 1 );
+			vecstrxInputs[ i ] = vecstrInputs[ i ].substr( vecstrInputs[ i ].rfind( "/" ) + 1, vecstrInputs[ i ].rfind( "." ) - vecstrInputs[ i ].rfind( "/" ) - 1 );}
 		else{
-			cerr << "Input file types should be xdsl and dab." <<  endl;
+			cerr << "inputs file types should be xdsl." <<  endl;
 			return 1;}}
 
-	vector<size_t>				vecIndInputs;
-	vecIndInputs.resize( vecstrlInputs.size( ) );
-	for( i = 0; i < vecstrlInputs.size( ); ++i ){
-		for( j = 0; j < vecstrlxInputs.size( ); ++j ){
-			if( !vecstrlInputs[ i ].compare( vecstrlxInputs[ j ] ) ){
-				vecIndInputs[ i ] = j;
-				break;}}}
-
-	{	CDataset	Data;
-
-		Data.OpenGenes( vecstrInputs );
-
-		vecstrAllGenes.resize( Data.GetGenes( ) );
-		copy( Data.GetGeneNames( ).begin( ), Data.GetGeneNames( ).end( ), vecstrAllGenes.begin( ) );}
-
-	if( sArgs.genex_arg ) {
-
-		CGenome				Genome;		
-		CGenes				GenesEx( Genome );
-
-		if( !GenesEx.Open( sArgs.genex_arg ) ) {
-			cerr << "Could not open: " << sArgs.genex_arg << endl;
-			return 1; } 
-
-		vecstrGenes.resize( vecstrAllGenes.size( ) - GenesEx.GetGenes( ) );
-
-		size_t		GenesExCount = 0;
-		for( i = 0; i < vecstrAllGenes.size( ); ++i ){
-			if( !GenesEx.IsGene( vecstrAllGenes[ i ] ) ){
-				vecstrGenes[ GenesExCount ] = vecstrAllGenes[ i ];
-				GenesExCount++;}}}
-	else{
-		vecstrGenes.resize( vecstrAllGenes.size( ) );
-		for( i = 0; i < vecstrAllGenes.size( ); ++i )
-			vecstrGenes[ i ] = vecstrAllGenes[ i ];}
-	
-	veciSizes.resize( vecstrInputs.size( ) );
-	for( i = 0; i < veciSizes.size( ); ++i ) {
-		DatOne.OpenQuants( vecstrInputs[ i ].c_str( ) );
-		veciSizes[ i ] = DatOne.GetValues( );}
-
 	if( sArgs.zeros_arg ) {
 		ifstream		ifsm;
 		vector<string>	vecstrZeros;
 	CDataMatrix		MatCPT;
 	vector<string>	vecstrFiles;
 
-	vecPrior.resize( sArgs.inputs_num/2 );
-	vecDataGSpZero.resize( sArgs.inputs_num/2 );
-	vecDataGSpOne.resize( sArgs.inputs_num/2 );
-	vecvecSpDat.resize( sArgs.inputs_num/2 );
+	vecPrior.resize( sArgs.inputs_num );
+	vecDataGSpZero.resize( sArgs.inputs_num );
+	vecDataGSpOne.resize( sArgs.inputs_num );
+	vecvecSpDat.resize( sArgs.inputs_num );
 	for( i = 0; i < vecPrior.size(  ); ++i ){
-		if( !BNIn.Open( vecstrxInputs[ vecIndInputs[ i ] ].c_str( ) ) ) {
-			cerr << "Couldn't open: " << vecstrxInputs[ vecIndInputs[ i ] ] << endl;
+		if( !BNIn.Open( vecstrInputs[ i ].c_str( ) ) ) {
+			cerr << "Couldn't open: " << vecstrInputs[ i ] << endl;
 			return 1;}
 		BNIn.GetCPT( 0, MatCPT );
 		vecPrior[ i ].resize( MatCPT.GetRows( ) );
 				vecDataGSpOne[ i ][ j ][ k ] = MatCPT.Get( k , 1 );}}
 		vecstrFiles.clear( );}
 
+	_mkdir( sArgs.directory_arg );
+
+	vector<vector<string> >		vecvecstrInputs;
+	size_t						countstrInputs;
+	vecvecstrInputs.resize( vecvecSpDat.size( ) );
+	countstrInputs = 0;
+	for( i = 0; i < vecvecSpDat.size( ); ++i ){
+		vecvecstrInputs[ i ].resize( vecvecSpDat[ i ].size( ) ); 
+		for( j = 0; j < vecvecSpDat[ i ].size( ); ++j ){
+			vecvecstrInputs[ i ][ j ] =  ( string )sArgs.ndirectory_arg + '/' + vecstrxInputs[ i ] + '/' + vecvecSpDat[ i ][ j ] + c_acDab;
+			countstrInputs++;}}
+
+	vector<string>				vecstrFInputs;
+	vector<string>				vecstrFDAInputs;
+	size_t						countstrFDAInputs;
+	vector<vector<size_t> >		InputMaps;
+	vecstrFInputs.resize( countstrInputs );
+	vecstrFDAInputs.resize( countstrInputs + vecvecstrInputs.size( ) );
+	countstrInputs = 0;
+	countstrFDAInputs = 0;
+	InputMaps.resize( vecvecstrInputs.size( ) );
+	for( i = 0; i < vecvecstrInputs.size( ); ++i ){
+		InputMaps[ i ].resize( vecvecstrInputs[ i ].size( ) );
+		for( j = 0; j < vecvecstrInputs[ i ].size( ); ++j ){
+			vecstrFInputs[ countstrInputs ] = vecvecstrInputs[ i ][ j ].c_str( );
+			vecstrFDAInputs[ countstrFDAInputs ] = vecvecstrInputs[ i ][ j ].c_str( );
+			countstrInputs++;
+			countstrFDAInputs++;}
+		vecstrFDAInputs[ countstrFDAInputs ] = ( string )sArgs.adirectory_arg + '/' + vecstrxInputs[ i ] + c_acDab;
+		countstrFDAInputs++;}
+
+	vector<string>		vecstrFGenes;
+	{	CDataset	DataF;
+
+	DataF.OpenGenes( vecstrFDAInputs );
+	vecstrFGenes.resize( DataF.GetGenes( ) );
+	copy( DataF.GetGeneNames( ).begin( ), DataF.GetGeneNames( ).end( ), vecstrFGenes.begin( ) );}
+
+	if( sArgs.genelist_flag ){
+		for( i = 0; i < vecstrFGenes.size( ); ++i )
+			cout << vecstrFGenes[ i ] << endl;
+		return 1;}
+
+	vector<CDat*>			DatOutB;
+	DatOutB.resize( vecvecstrInputs.size( ) );
+	for( i = 0; i < DatOutB.size( ); ++i ){
+		DatOutB[ i ] = new CDat( );
+		DatOutB[ i ]->Open( vecstrFGenes );}
+
+	vector<CDat*>		vecDataIntZero;
+	vector<CDat*>		vecDataIntOne;
+	vecDataIntZero.resize( vecvecstrInputs.size( ) );
+	vecDataIntOne.resize( vecvecstrInputs.size( ) );
+	for( i = 0; i < vecvecstrInputs.size( ); ++i ){
+		vecDataIntZero[ i ] = new CDat( );
+		vecDataIntOne[ i ] = new CDat( );
+		vecDataIntZero[ i ]->Open( vecstrFGenes );
+		vecDataIntOne[ i ]->Open( vecstrFGenes );}
+
+	for( i = 0; i < vecvecstrInputs.size( ); ++i ){
+		map<string,size_t>::const_iterator	iterZero;
+		for( j = 0; j < vecvecstrInputs[ i ].size( ); ++j ){
+			iZero = ( ( iterZero = mapZeros.find( vecvecstrInputs[ i ][ j ] ) ) == mapZeros.end( ) ) ? -1 : iterZero->second;
+			
+			CDataPair		DataF;
+			if( !( DataF.Open( vecvecstrInputs[ i ][ j ].c_str( ), false, !!sArgs.memmap_flag ) ||
+				DataF.Open( vecvecstrInputs[ i ][ j ].c_str( ), true, !!sArgs.memmap_flag ) ) ){
+					cerr << "Could not open:" << vecvecstrInputs[ i ][ j ] << endl;
+					return 1;}
+			vector<size_t>		vecGeneIndex;
+			vecGeneIndex.resize( vecstrFGenes.size( ) );
+			for( k = 0; k < vecstrFGenes.size( ); ++k )
+				vecGeneIndex[ k ] = DataF.GetGene( vecstrFGenes[ k ] );
+			
+			for( iDatOne = 0; iDatOne < vecstrFGenes.size( ); ++iDatOne ){ 
+				for( iDatTwo = ( iDatOne + 1 ); iDatTwo < vecstrFGenes.size( ); ++iDatTwo ){ 
+					iGeneOne = vecGeneIndex[ iDatOne ];
+					iGeneTwo = vecGeneIndex[ iDatTwo ];
+					float		DFValue;
+					DFValue = ( ( iGeneOne == -1 ) || ( iGeneTwo == -1 ) ) ? CMeta::GetNaN( ) : DataF.Get( iGeneOne, iGeneTwo );
+					if( !CMeta::IsNaN( DFValue ) ) {
+						size_t		DatPFI = DataF.Quantize( DFValue );
+						float		Zero, One;
+
+						if( CMeta::IsNaN( Zero = vecDataIntZero[ i ]->Get( iDatOne, iDatTwo ) ) )
+							vecDataIntZero[ i ]->Set( iDatOne, iDatTwo, log( vecDataGSpZero[ i ][ j ][ DatPFI ] ) );
+						else
+							vecDataIntZero[ i ]->Set( iDatOne, iDatTwo, Zero + log( vecDataGSpZero[ i ][ j ][ DatPFI ] ) );
+
+						if( CMeta::IsNaN( One = vecDataIntOne[ i ]->Get( iDatOne, iDatTwo ) ) )
+							vecDataIntOne[ i ]->Set( iDatOne, iDatTwo, log( vecDataGSpOne[ i ][ j ][ DatPFI ] ) );
+						else
+							vecDataIntOne[ i ]->Set( iDatOne, iDatTwo, One + log( vecDataGSpOne[ i ][ j ][ DatPFI ] ) );}
+
+					if( CMeta::IsNaN( DFValue ) && ( iZero != -1 ) ){
+						float		Zero, One;
+						
+						if( CMeta::IsNaN( Zero = vecDataIntZero[ i ]->Get( iDatOne, iDatTwo ) ) )
+							vecDataIntZero[ i ]->Set( iDatOne, iDatTwo, log( vecDataGSpZero[ i ][ j ][ iZero ] ) );
+						else
+							vecDataIntZero[ i ]->Set( iDatOne, iDatTwo, Zero + log( vecDataGSpZero[ i ][ j ][ iZero ] ) );
+
+						if( CMeta::IsNaN( One = vecDataIntOne[ i ]->Get( iDatOne, iDatTwo ) ) )
+							vecDataIntOne[ i ]->Set( iDatOne, iDatTwo, log( vecDataGSpOne[ i ][ j ][ iZero ] ) );
+						else
+							vecDataIntOne[ i ]->Set( iDatOne, iDatTwo, One + log( vecDataGSpOne[ i ][ j ][ iZero ] ) );}}}}
+
+		for( iDatOne = 0; iDatOne < vecstrFGenes.size( ); ++iDatOne ){ 
+			for( iDatTwo = ( iDatOne + 1 ); iDatTwo < vecstrFGenes.size( ); ++iDatTwo ){ 
+				float		sumOneB = 0, sumZeroB = 0, FinalB = 0 ;
+				float		Zero, One;
+				
+				if( CMeta::IsNaN( Zero = vecDataIntZero[ i ]->Get( iDatOne, iDatTwo ) ) ){
+					vecDataIntZero[ i ]->Set( iDatOne, iDatTwo, 0.0f);
+					sumZeroB =  log( vecPrior[ i ][ 0 ] );}
+				else 
+					sumZeroB =  Zero + log( vecPrior[ i ][ 0 ] );
+
+				if( CMeta::IsNaN( One = vecDataIntOne[ i ]->Get( iDatOne, iDatTwo ) ) ){
+					vecDataIntOne[ i ]->Set( iDatOne, iDatTwo, 0.0f );
+					sumOneB =  log( vecPrior[ i ][ 1 ] );}
+				else
+					sumOneB =  One + log( vecPrior[ i ][ 1 ] );
+								
+				FinalB = (float) ( 1 / ( 1 + exp ( sumZeroB - sumOneB ) ) );
+				DatOutB[ i ]->Set( iDatOne, iDatTwo, FinalB );}}}
+
+	for( i = 0; i < vecvecstrInputs.size( ); ++i ){
+		DatOutB[ i ]->Save( ( ( string ) sArgs.directory_arg + '/' + vecstrxInputs[ i ] + 'b' + c_acDab ).c_str( ) );}	
+	
+	vector<size_t>		MapstrGenes;	
+	if( sArgs.genex_arg ) {
+		CGenome				Genome;		
+		CGenes				GenesEx( Genome );
+		if( !GenesEx.Open( sArgs.genex_arg ) ) {
+			cerr << "Could not open: " << sArgs.genex_arg << endl;
+			return 1; } 
+		vecstrGenes.resize( vecstrFGenes.size( ) - GenesEx.GetGenes( ) );
+		MapstrGenes.resize( vecstrGenes.size( ) );
+		size_t		GenesExCount = 0;
+		for( i = 0; i < vecstrFGenes.size( ); ++i ){
+			if( !GenesEx.IsGene( vecstrFGenes[ i ] ) ){
+				vecstrGenes[ GenesExCount ] = vecstrFGenes[ i ];
+				MapstrGenes[ GenesExCount ] = i;
+				GenesExCount++;}}}
+	else{
+		vecstrGenes.resize( vecstrFGenes.size( ) );
+		MapstrGenes.resize( vecstrFGenes.size( ) );
+		for( i = 0; i < vecstrFGenes.size( ); ++i ){
+			vecstrGenes[ i ] = vecstrFGenes[ i ];
+			MapstrGenes[ i ] = i;}}
+
 	vector<vector<vector<vector<float> > > >		vec4OSpGSp;
-	vec4OSpGSp.resize( sArgs.inputs_num/2 );
+	vec4OSpGSp.resize( sArgs.inputs_num );
+	for( iDatOne = 0; iDatOne < vecstrInputs.size( ); ++iDatOne ) {
+		vec4OSpGSp[ iDatOne ].resize( sArgs.inputs_num );
+		for( iDatTwo = ( iDatOne + 1 ); iDatTwo < vecstrInputs.size( ); ++iDatTwo ) {
+			vec4OSpGSp[ iDatOne ][ iDatTwo ].resize( vecPrior[ iDatOne ].size( ) );
+			for( i = 0; i < vecPrior[ iDatOne ].size( ); ++i )
+				vec4OSpGSp[ iDatOne ][ iDatTwo ][ i ].resize( vecPrior[ iDatTwo ].size( ) );}}
 
 	for( iDatOne = 0; iDatOne < vecstrInputs.size( ); ++iDatOne ) {
-			vec4OSpGSp[ iDatOne ].resize( sArgs.inputs_num/2 );
-			for( iDatTwo = ( iDatOne + 1 ); iDatTwo < vecstrInputs.size( ); ++iDatTwo ) {
-				vec4OSpGSp[ iDatOne ][ iDatTwo ].resize( veciSizes[ iDatOne ] );
-				for( i = 0; i < veciSizes[ iDatOne ]; ++i )
-					vec4OSpGSp[ iDatOne ][ iDatTwo ][ i ].resize( veciSizes[ iDatTwo ] );}}
-	
-	for( iDatOne = 0; iDatOne < vecstrInputs.size( ); ++iDatOne ) {
-			vec4OSpGSp[ iDatOne ].resize( sArgs.inputs_num/2 );
-			for( iDatTwo = 0; iDatTwo < iDatOne; ++iDatTwo ) {
-				vec4OSpGSp[ iDatOne ][ iDatTwo ].resize( veciSizes[ iDatOne ] );
-				for( i = 0; i < veciSizes[ iDatOne ]; ++i )
-					vec4OSpGSp[ iDatOne ][ iDatTwo ][ i ].resize( veciSizes[ iDatTwo ] );}}
-	
-	vector<float>		veciValueOnep;
-	vector<float>		veciValueTwop;
-	
-	for( iDatOne = 0; iDatOne < vecstrInputs.size( ); ++iDatOne ) {
-			if( !( DatOne.Open( vecstrInputs[ iDatOne ].c_str( ), false, !!sArgs.memmap_flag ) ||
-				DatOne.Open( vecstrInputs[ iDatOne ].c_str( ), true, !!sArgs.memmap_flag ) ) ) {
-					cerr << "Could not open: " << vecstrInputs[ iDatOne ] << endl;
-					return 1; }
+		vec4OSpGSp[ iDatOne ].resize( sArgs.inputs_num );
+		for( iDatTwo = 0; iDatTwo < iDatOne; ++iDatTwo ) {
+			vec4OSpGSp[ iDatOne ][ iDatTwo ].resize( vecPrior[ iDatOne ].size( ) );
+			for( i = 0; i < vecPrior[ iDatOne ].size( ); ++i )
+				vec4OSpGSp[ iDatOne ][ iDatTwo ][ i ].resize( vecPrior[ iDatTwo ].size( ) );}}
 
-			veciGenesOne.resize( vecstrGenes.size( ) );
-			for( i = 0; i < vecstrGenes.size( ); ++i )
-				veciGenesOne[ i ] = DatOne.GetGene( vecstrGenes[ i ] );
+	if( !sArgs.uniformjoint_flag && !sArgs.normaljoint_flag ){
+		
+		vector<float>		veciValueOnep;
+		vector<float>		veciValueTwop;
 
+		for( iDatOne = 0; iDatOne < vecstrInputs.size( ); ++iDatOne ) {
 			if( ( iDatOne + 1 ) == vecstrInputs.size( ) )
 				break;
 
+			veciGenesOneI.resize( vecstrGenes.size( ) );
+			CDataset	DataInd;
+			vector<string>				vecstrIndInputs;
+			vecstrIndInputs.resize( vecvecstrInputs[ iDatOne ].size( ) + 1 );
+			for( i = 0; i < vecvecstrInputs[ iDatOne ].size( ); ++i ){
+				vecstrIndInputs[ i ] = vecvecstrInputs[ iDatOne ][ i ].c_str( );}
+			vecstrIndInputs[ i ] = ( string )sArgs.adirectory_arg + '/' + vecstrxInputs[ iDatOne ] + c_acDab;
+			DataInd.OpenGenes( vecstrIndInputs );
+			for( i = 0; i < vecstrGenes.size( ); ++i )
+				veciGenesOneI[ i ] = DataInd.GetGene( vecstrGenes[ i ] );
+
 			for( iDatTwo = ( iDatOne + 1 ); iDatTwo < vecstrInputs.size( ); ++iDatTwo ) {
-				if( !( DatTwo.Open( vecstrInputs[ iDatTwo ].c_str( ), false, !!sArgs.memmap_flag ) ||
-					DatTwo.Open( vecstrInputs[ iDatTwo ].c_str( ), true, !!sArgs.memmap_flag ) ) ) {
-						cerr << "Could not open: " << vecstrInputs[ iDatTwo ] << endl;
-						return 1; }
+				veciGenesTwoI.resize( vecstrGenes.size( ) );
+				CDataset	DataInd;
+				vector<string>				vecstrIndInputs;
+				vecstrIndInputs.resize( vecvecstrInputs[ iDatTwo ].size( ) + 1 );
+				for( i = 0; i < vecvecstrInputs[ iDatTwo ].size( ); ++i ){
+					vecstrIndInputs[ i ] = vecvecstrInputs[ iDatTwo ][ i ].c_str( );}
+				vecstrIndInputs[ i ] = ( string )sArgs.adirectory_arg + '/' + vecstrxInputs[ iDatTwo ] + c_acDab;
+				DataInd.OpenGenes( vecstrIndInputs );
+				for( i = 0; i < vecstrGenes.size( ); ++i )
+					veciGenesTwoI[ i ] = DataInd.GetGene( vecstrGenes[ i ] );
 
-				veciGenesTwo.resize( vecstrGenes.size( ) );
-				for( i = 0; i < veciGenesTwo.size( ); ++i )
-					veciGenesTwo[ i ] = DatTwo.GetGene( vecstrGenes[ i ] );
-				
-				vecveciJoint.resize( veciSizes[ iDatOne ] );
+				vecveciJoint.resize( vecPrior[ iDatOne ].size( ) );
 				for( i = 0; i < vecveciJoint.size( ); ++i ) {
-					vecveciJoint[ i ].resize( veciSizes[ iDatTwo ] );
+					vecveciJoint[ i ].resize( vecPrior[ iDatTwo ].size( ) );
 					fill( vecveciJoint[ i ].begin( ), vecveciJoint[ i ].end( ), 0 ); }
-				
+
 				for( i = iCountJoint = 0; i < vecstrGenes.size( ); ++i ) {
-					iGeneOne = veciGenesOne[ i ];
-					iGeneTwo = veciGenesTwo[ i ];
+					if( ( veciGenesOneI[ i ] == -1 ) || ( veciGenesTwoI[ i ] == -1 ) )
+						continue;
+
 					for( j = ( i + 1 ); j < vecstrGenes.size( ); ++j ) {
-						dValueTwo = find_value( iGeneTwo, veciGenesTwo[ j ], DatTwo );
-						dValueOne = find_value( iGeneOne, veciGenesOne[ j ], DatOne );
-						if( ( !CMeta::IsNaN( dValueTwo ) ) && ( !CMeta::IsNaN( dValueOne ) ) ){
-								iValueTwo = DatTwo.Quantize( dValueTwo );
-								iValueOne = DatOne.Quantize( dValueOne );
-								iCountJoint++;
-								vecveciJoint[ iValueOne ][ iValueTwo ]++;}
-						if( ( CMeta::IsNaN( dValueTwo ) ) && ( !CMeta::IsNaN( dValueOne ) ) ){
-								iValueTwo = 0;
-								iValueOne = DatOne.Quantize( dValueOne );
-								iCountJoint++;
-								vecveciJoint[ iValueOne ][ iValueTwo ]++;}
-						if( ( !CMeta::IsNaN( dValueTwo ) ) && ( CMeta::IsNaN( dValueOne ) ) ){
-								iValueTwo = DatTwo.Quantize( dValueTwo );
-								iValueOne = 0;
-								iCountJoint++;
-								vecveciJoint[ iValueOne ][ iValueTwo ]++;}
-						if( ( CMeta::IsNaN( dValueTwo ) ) && ( CMeta::IsNaN( dValueOne ) ) ){
-								iValueTwo = 0;
-								iValueOne = 0;
-								iCountJoint++;
-								vecveciJoint[ iValueOne ][ iValueTwo ]++;}}}
+						if( ( veciGenesOneI[ j ] == -1 ) || ( veciGenesTwoI[ j ] == -1 ) )
+							continue;
+
+						iValueOne = DatOutB[ iDatOne ]->Get( MapstrGenes[ i ], MapstrGenes[ j ] ) >= Threshold ? 1 : 0;
+						iValueTwo = DatOutB[ iDatTwo ]->Get( MapstrGenes[ i ], MapstrGenes[ j ] ) >= Threshold ? 1 : 0;
+						vecveciJoint[ iValueOne ][ iValueTwo ]++;
+						iCountJoint++;}}
+
+				for( i = 0; i < vecveciJoint.size( ); ++i ){
+					for( j = 0; j < vecveciJoint.size( ); ++j ){
+						vecveciJoint[ i ][ j ]++;
+						iCountJoint++;}}					
 
 				vector<vector<float> >		vecveciTJoint;
 				vecveciTJoint.resize( vecveciJoint.size( ) );
 				for( i = 0; i < vecveciTJoint.size( ); ++i ){
 					vecveciTJoint[ i ].resize( vecveciJoint[ i ].size( ) );
 					for( j = 0; j < vecveciTJoint.size( ); ++j ){ 
-						vecveciTJoint[ i ][ j ] = (float)vecveciJoint[ i ][ j ] / iCountJoint;}}				
-									 							
-				veciValueOnep.resize( veciSizes[ iDatOne ] );
-				veciValueTwop.resize( veciSizes[ iDatTwo ] );
+						vecveciTJoint[ i ][ j ] = ( (float)vecveciJoint[ i ][ j ] ) / iCountJoint;}}				
+				
+				veciValueOnep.resize( vecPrior[ iDatOne ].size( ) );
+				veciValueTwop.resize( vecPrior[ iDatTwo ].size( ) );
 				fill( veciValueOnep.begin( ), veciValueOnep.end( ), 0.0f );
 				fill( veciValueTwop.begin( ), veciValueTwop.end( ), 0.0f );
+
+				for( i = 0; i < vecveciJoint.size( ); ++i ){
+					for( j = 0; j < vecveciJoint[ i ].size( ); ++j ){
+						veciValueOnep[ i ] += vecveciTJoint[ i ][ j ];
+						veciValueTwop[ j ] += vecveciTJoint[ i ][ j ];}} 
+
+				for( i = 0; i < vecveciJoint.size( ); ++i ){
+					for( j = 0; j < vecveciJoint[ i ].size(  ); ++j ){
+						vec4OSpGSp[ iDatOne ][ iDatTwo ][ i ][ j ] = vecveciTJoint[ i ][ j ] / veciValueOnep[ i ];
+						vec4OSpGSp[ iDatTwo ][ iDatOne ][ i ][ j ] = vecveciTJoint[ j ][ i ] / veciValueTwop[ i ];}}}}}
+
+	if( sArgs.uniformjoint_flag ){
+		for( iDatOne = 0; iDatOne < vec4OSpGSp.size( ); ++iDatOne )
+			for( iDatTwo = 0; iDatTwo < vec4OSpGSp[ iDatOne ].size( ); ++iDatTwo ){
+				if( iDatOne == iDatTwo )
+					continue;
+				for( i = 0; i < vec4OSpGSp[ iDatOne ][ iDatTwo ].size( ); ++i )
+					for( j = 0; j < vec4OSpGSp[ iDatOne ][ iDatTwo ][ i ].size( ); ++j )
+						vec4OSpGSp[ iDatOne ][ iDatTwo ][ i ][ j ] = 0.5f;}}
+
+	if( sArgs.normaljoint_flag ){
+
+		vector<float>		veciValueOnep;
+		vector<float>		veciValueTwop;
+		vector<vector<float> >		vecveciJoint;
+		float				iCountJoint;
+
+		for( iDatOne = 0; iDatOne < vec4OSpGSp.size( ); ++iDatOne )
+			for( iDatTwo = ( iDatOne + 1 ); iDatTwo < vec4OSpGSp[ iDatOne ].size( ); ++iDatTwo ){
+				if( iDatOne == iDatTwo )
+					continue;
+				vecveciJoint.resize( vecPrior[ iDatOne ].size( ) );
+				iCountJoint = 0;
+				for( i = 0; i < vecveciJoint.size( ); ++i ){
+					vecveciJoint[ i ].resize( vecPrior[ iDatTwo ].size( ) );
+					for( j = 0; j < vecveciJoint[ i ].size( ); ++j ){
+						vecveciJoint[ i ][ j ] = ( float )rand( ) / RAND_MAX;
+						iCountJoint += vecveciJoint[ i ][ j ];}}
 				
 				for( i = 0; i < vecveciJoint.size( ); ++i ){
+					for( j = 0; j < vecveciJoint.size( ); ++j ){
+						vecveciJoint[ i ][ j ]++;
+						iCountJoint++;}}					
+
+				vector<vector<float> >		vecveciTJoint;
+				vecveciTJoint.resize( vecveciJoint.size( ) );
+				for( i = 0; i < vecveciTJoint.size( ); ++i ){
+					vecveciTJoint[ i ].resize( vecveciJoint[ i ].size( ) );
+					for( j = 0; j < vecveciTJoint.size( ); ++j ){ 
+						vecveciTJoint[ i ][ j ] = ( (float)vecveciJoint[ i ][ j ] ) / iCountJoint;}}				
+				
+				veciValueOnep.resize( vecPrior[ iDatOne ].size( ) );
+				veciValueTwop.resize( vecPrior[ iDatTwo ].size( ) );
+				fill( veciValueOnep.begin( ), veciValueOnep.end( ), 0.0f );
+				fill( veciValueTwop.begin( ), veciValueTwop.end( ), 0.0f );
+
+				for( i = 0; i < vecveciJoint.size( ); ++i ){
 					for( j = 0; j < vecveciJoint[ i ].size( ); ++j ){
 						veciValueOnep[ i ] += vecveciTJoint[ i ][ j ];
 						veciValueTwop[ j ] += vecveciTJoint[ i ][ j ];}} 
 					for( j = 0; j < vecveciJoint[ i ].size(  ); ++j ){
 						vec4OSpGSp[ iDatOne ][ iDatTwo ][ i ][ j ] = vecveciTJoint[ i ][ j ] / veciValueOnep[ i ];
 						vec4OSpGSp[ iDatTwo ][ iDatOne ][ i ][ j ] = vecveciTJoint[ j ][ i ] / veciValueTwop[ i ];}}}}
+	
+	vector<CDat*>			DatOutCS;
 
-	_mkdir( sArgs.directory_arg );
-    
-    vector<vector<string> >		vecvecstrInputs;
-    size_t						countstrInputs;
-    vecvecstrInputs.resize( vecvecSpDat.size( ) );
-    countstrInputs = 0;
-    for( i = 0; i < vecvecSpDat.size( ); ++i ){
-        vecvecstrInputs[ i ].resize( vecvecSpDat[ i ].size( ) ); 
-        for( j = 0; j < vecvecSpDat[ i ].size( ); ++j ){
-            vecvecstrInputs[ i ][ j ] =  ( string )sArgs.ndirectory_arg + '/' + vecstrlInputs[ i ] + '/' + vecvecSpDat[ i ][ j ] + c_acDab;
-            countstrInputs++;}}
+	DatOutCS.resize( vecvecstrInputs.size( ) );
+	for( i = 0; i < DatOutCS.size( ); ++i ){
+		DatOutCS[ i ] = new CDat( );
+		DatOutCS[ i ]->Open( vecstrFGenes );}
+	
+	if( !sArgs.holdout_flag ){
+		for( i = 0; i < vecvecstrInputs.size( ); ++i ){
+			for( iDatOne = 0; iDatOne < vecstrFGenes.size( ); ++iDatOne ){ 
+				for( iDatTwo = ( iDatOne + 1 ); iDatTwo < vecstrFGenes.size( ); ++iDatTwo ){ 
+					float		sumOne = 0, sumZero = 0, Final = 0 ;
+					for( k = 0; k < vecvecstrInputs.size( ); ++k ){
+						if( k != i ){
+							sumOne += log( exp( log( vec4OSpGSp[ i ][ k ][ 1 ][ 0 ] ) + vecDataIntZero[ k ]->Get( iDatOne, iDatTwo ) ) + exp( log( vec4OSpGSp[ i ][ k ][ 1 ][ 1 ] ) + vecDataIntOne[ k ]->Get( iDatOne, iDatTwo ) ) );
+							sumZero += log( exp( log( vec4OSpGSp[ i ][ k ][ 0 ][ 0 ] ) + vecDataIntZero[ k ]->Get( iDatOne, iDatTwo ) ) + exp( log( vec4OSpGSp[ i ][ k ][ 0 ][ 1 ] ) + vecDataIntOne[ k ]->Get( iDatOne, iDatTwo ) ) );}}
+					sumOne += ( vecDataIntOne[ i ]->Get( iDatOne, iDatTwo ) + log( vecPrior[ i ][ 1 ] ) );
+					sumZero += ( vecDataIntZero[ i ]->Get( iDatOne, iDatTwo ) + log( vecPrior[ i ][ 0 ] ) );
+					Final = (float) ( 1 / ( 1 + exp ( sumZero - sumOne ) ) );
+					DatOutCS[ i ]->Set( iDatOne, iDatTwo, Final );}}}}
 
-    vector<string>				vecstrFInputs;
-    vector<vector<size_t> >		InputMaps;				
-    vecstrFInputs.resize( countstrInputs );
-    countstrInputs = 0;
-    InputMaps.resize( vecvecstrInputs.size( ) );
-    for( i = 0; i < vecvecstrInputs.size( ); ++i ){
-        InputMaps[ i ].resize( vecvecstrInputs[ i ].size( ) );
-        for( j = 0; j < vecvecstrInputs[ i ].size( ); ++j ){
-            vecstrFInputs[ countstrInputs ] = vecvecstrInputs[ i ][ j ].c_str( );
-            InputMaps[ i ][ j ] = countstrInputs;
-            countstrInputs++;}}
-    
-    vector<string>		vecstrFGenes;
-    
-    {	CDataset	DataF;
+	else{
+		for( i = 0; i < vecvecstrInputs.size( ); ++i ){
+			for( iDatOne = 0; iDatOne < vecstrFGenes.size( ); ++iDatOne ){ 
+				for( iDatTwo = ( iDatOne + 1 ); iDatTwo < vecstrFGenes.size( ); ++iDatTwo ){ 
+					float		sumOne = 0, sumZero = 0, Final = 0 ;
+					for( k = 0; k < vecvecstrInputs.size( ); ++k ){
+						if( k != i ){
+							sumOne += log( exp( log( vec4OSpGSp[ i ][ k ][ 1 ][ 0 ] ) + vecDataIntZero[ k ]->Get( iDatOne, iDatTwo ) ) + exp( log( vec4OSpGSp[ i ][ k ][ 1 ][ 1 ] ) + vecDataIntOne[ k ]->Get( iDatOne, iDatTwo ) ) );
+							sumZero += log( exp( log( vec4OSpGSp[ i ][ k ][ 0 ][ 0 ] ) + vecDataIntZero[ k ]->Get( iDatOne, iDatTwo ) ) + exp( log( vec4OSpGSp[ i ][ k ][ 0 ][ 1 ] ) + vecDataIntOne[ k ]->Get( iDatOne, iDatTwo ) ) );}}
+					sumOne += log( vecPrior[ i ][ 1 ] );
+					sumZero += log( vecPrior[ i ][ 0 ] );
+					Final = (float) ( 1 / ( 1 + exp ( sumZero - sumOne ) ) );
+					DatOutCS[ i ]->Set( iDatOne, iDatTwo, Final );}}}}
+	
+	for( i = 0; i < vecvecstrInputs.size( ); ++i ){
+		DatOutCS[ i ]->Save( ( ( string ) sArgs.directory_arg + '/' + vecstrxInputs[ i ] + c_acDab ).c_str( ) );
+		delete DatOutB[ i ];
+		delete DatOutCS[ i ];}	
 
-        DataF.OpenGenes( vecstrFInputs );
-        vecstrFGenes.resize( DataF.GetGenes( ) );
-        copy( DataF.GetGeneNames( ).begin( ), DataF.GetGeneNames( ).end( ), vecstrFGenes.begin( ) );}
-
-    vector<CDataPair*>			DataF;
-    size_t						iDatOneF, iDatTwoF, iGeneOneF, iGeneTwoF;
-    
-    DataF.resize( vecstrFInputs.size( ) );
-    for( i = 0; i < vecstrFInputs.size( ); ++i ){
-        DataF[ i ] = new CDataPair( );
-        if( !( DataF[ i ]->Open( vecstrFInputs[ i ].c_str( ), false, !!sArgs.memmap_flag ) ||
-            DataF[ i ]->Open( vecstrFInputs[ i ].c_str( ), true, !!sArgs.memmap_flag ) ) ){
-                cerr << "Could not open:" << vecstrFInputs[ i ] << endl;
-                return 1;}}
-        
-    vector<CDat*>			DatOutCS, DatOutCSH, DatOutB;	
-
-    DatOutCS.resize( vecvecstrInputs.size( ) );
-    for( i = 0; i < DatOutCS.size( ); ++i ){
-        DatOutCS[ i ] = new CDat( );
-        DatOutCS[ i ]->Open( vecstrFGenes );}
-
-    DatOutCSH.resize( vecvecstrInputs.size( ) );
-    for( i = 0; i < DatOutCSH.size( ); ++i ){
-        DatOutCSH[ i ] = new CDat( );
-        DatOutCSH[ i ]->Open( vecstrFGenes );}
-
-	DatOutB.resize( vecvecstrInputs.size( ) );
-    for( i = 0; i < DatOutB.size( ); ++i ){
-        DatOutB[ i ] = new CDat( );
-        DatOutB[ i ]->Open( vecstrFGenes );}
-
-    vector<vector<vector<size_t> > >		vec3GeneIndex;
-    vec3GeneIndex.resize( vecvecstrInputs.size( ) );
-    for( i = 0; i < vecvecstrInputs.size( ); ++i ){
-        vec3GeneIndex[ i ].resize( vecvecstrInputs[ i ].size( ) );
-        for( j = 0; j < vecvecstrInputs[ i ].size( ); ++j ){
-            vec3GeneIndex[ i ][ j ].resize( vecstrFGenes.size( ) );
-            for( k = 0; k < vecstrFGenes.size( ); ++k ){
-                vec3GeneIndex[ i ][ j ][ k ] = DataF[ InputMaps[ i ][ j ] ]->GetGene( vecstrFGenes[ k ] );}}}
-            
-    for( iDatOneF = 0; iDatOneF < vecstrFGenes.size( ); ++iDatOneF ){ 
-        for( iDatTwoF = ( iDatOneF + 1 ); iDatTwoF < vecstrFGenes.size( ); ++iDatTwoF ){ 
-            vector<float>		vecDataIntZero;
-            vector<float>		vecDataIntOne;
-            vecDataIntZero.resize( vecvecstrInputs.size( ) );
-            fill( vecDataIntZero.begin( ), vecDataIntZero.end( ), 0.0f );
-            vecDataIntOne.resize( vecvecstrInputs.size( ) );
-            fill( vecDataIntOne.begin( ), vecDataIntOne.end( ), 0.0f );
-            for( i = 0; i < vecvecstrInputs.size( ); ++i ){
-                float		sumZero = 0;
-                float		sumOne = 0;
-                for( j = 0; j < vecvecstrInputs[ i ].size( ); ++j ){
-                    iGeneOneF = vec3GeneIndex[ i ][ j ][ iDatOneF ];
-                    iGeneTwoF = vec3GeneIndex[ i ][ j ][ iDatTwoF ];
-                    float		DFValue;
-                    DFValue = ( ( iGeneOneF == -1 ) || ( iGeneTwoF == -1 ) ) ? CMeta::GetNaN( ) : DataF[ InputMaps[ i ][ j ] ]->Get( iGeneOneF, iGeneTwoF );
-                    if( !CMeta::IsNaN( DFValue ) ){
-                        size_t		DatPFI = DataF[ InputMaps[ i ][ j ] ]->Quantize( DFValue );
-                        sumZero += log( vecDataGSpZero[ i ][ j ][ DatPFI ] );
-                        sumOne += log( vecDataGSpOne[ i ][ j ][ DatPFI ] );}}
-                vecDataIntZero[ i ] = sumZero;
-                vecDataIntOne[ i ] = sumOne;}
-
-            for( i = 0; i < vecvecstrInputs.size( ); ++i ){
-                float		sumOne = 0, sumZero = 0, Final = 0 ;
-				float		sumOneB = 0, sumZeroB = 0, FinalB = 0 ;
-				float		sumOneT = 0, sumZeroT = 0, FinalT = 0;
-                for( k = 0; k < vecvecstrInputs.size( ); ++k ){
-                    if( k != i ){
-                        sumOne += log( exp( log( vec4OSpGSp[ i ][ k ][ 1 ][ 0 ] ) + vecDataIntZero[ k ] ) + exp( log( vec4OSpGSp[ i ][ k ][ 1 ][ 1 ] ) + vecDataIntOne[ k ] ) );
-                        sumZero += log( exp( log( vec4OSpGSp[ i ][ k ][ 0 ][ 0 ] ) + vecDataIntZero[ k ] ) + exp( log( vec4OSpGSp[ i ][ k ][ 0 ][ 1 ] ) + vecDataIntOne[ k ] ) );}}
-                sumOneT = sumOne + log( vecPrior[ i ][ 1 ] );
-				sumOne += ( vecDataIntOne[ i ] + log( vecPrior[ i ][ 1 ] ) );
-				sumOneB =  vecDataIntOne[ i ] + log( vecPrior[ i ][ 1 ] );
-                sumZeroT = sumZero + log( vecPrior[ i ][ 0 ] );
-				sumZero += ( vecDataIntZero[ i ] + log( vecPrior[ i ][ 0 ] ) );
-				sumZeroB =  vecDataIntZero[ i ] + log( vecPrior[ i ][ 0 ] );
-                Final = (float) ( 1 / ( 1 + exp ( sumZero - sumOne ) ) );
-				FinalT = (float) ( 1 / ( 1 + exp ( sumZeroT - sumOneT ) ) );
-				FinalB = (float) ( 1 / ( 1 + exp ( sumZeroB - sumOneB ) ) );
-				DatOutCS[ i ]->Set( iDatOneF, iDatTwoF, Final );
-				DatOutCSH[ i ]->Set( iDatOneF, iDatTwoF, FinalT );
-				DatOutB[ i ]->Set( iDatOneF, iDatTwoF, FinalB );}}}
-                
-    for( i = 0; i < vecvecstrInputs.size( ); ++i ){
-        DatOutCS[ i ]->Save( ( ( string ) sArgs.directory_arg + '/' + vecstrlInputs[ i ] + c_acDab ).c_str( ) );
-		DatOutCSH[ i ]->Save( ( ( string ) sArgs.directory_arg + '/' + vecstrlInputs[ i ] + 'h' + c_acDab ).c_str( ) );
-		DatOutB[ i ]->Save( ( ( string ) sArgs.directory_arg + '/' + vecstrlInputs[ i ] + 'b' + c_acDab ).c_str( ) );
-        delete DataF[ i ];
-    delete DatOutCS[ i ];
-	delete DatOutCSH[ i ];
-	delete DatOutB[ i ];}	
-	
-	return 0;}
+	return 0;} 

tools/SpeciesConnector/SpeciesConnector.ggo

 purpose	"Cross species connection calculator."
 
 section "Main"
+option	"adirectory" w	"Answer directory"
+						string	typestr="directory"	default="."
 option	"ndirectory" n	"Input directory"
 						string	typestr="directory"	default="."
 option	"directory"	d	"Output directory"
 option	"random"	r	"Seed random generator"
 						int	default="0"
 option	"verbosity"	v	"Message verbosity"
-						int	default="5"
+						int	default="5"
+option	"holdout"	h	"Holdout target dataset"
+						flag	off	
+option	"genelist"	l	"Print gene list on the screen"
+						flag	off			
+option	"uniformjoint"		u	"Uniform joint distribution"
+								flag	off
+option	"normaljoint"		g	"Normal joint distribution"
+								flag	off
+option	"threshold"	t	"Threshold for joint"
+						float	default="0.5"

tools/SpeciesConnector/cmdline.c

 const char *gengetopt_args_info_description = "";
 
 const char *gengetopt_args_info_help[] = {
-  "  -h, --help                  Print help and exit",
+  "      --help                  Print help and exit",
   "  -V, --version               Print version and exit",
   "\nMain:",
+  "  -w, --adirectory=directory  Answer directory  (default=`.')",
   "  -n, --ndirectory=directory  Input directory  (default=`.')",
   "  -d, --directory=directory   Output directory  (default=`.')",
   "\nNetwork Features:",
   "  -m, --memmap                Memory map input/output  (default=off)",
   "  -r, --random=INT            Seed random generator  (default=`0')",
   "  -v, --verbosity=INT         Message verbosity  (default=`5')",
+  "  -h, --holdout               Holdout target dataset  (default=off)",
+  "  -l, --genelist              Print gene list on the screen  (default=off)",
+  "  -u, --uniformjoint          Uniform joint distribution  (default=off)",
+  "  -g, --normaljoint           Normal joint distribution  (default=off)",
+  "  -t, --threshold=FLOAT       Threshold for joint  (default=`0.5')",
     0
 };
 
   , ARG_FLAG
   , ARG_STRING
   , ARG_INT
+  , ARG_FLOAT
 } cmdline_parser_arg_type;
 
 static
 {
   args_info->help_given = 0 ;
   args_info->version_given = 0 ;
+  args_info->adirectory_given = 0 ;
   args_info->ndirectory_given = 0 ;
   args_info->directory_given = 0 ;
   args_info->zeros_given = 0 ;
   args_info->memmap_given = 0 ;
   args_info->random_given = 0 ;
   args_info->verbosity_given = 0 ;
+  args_info->holdout_given = 0 ;
+  args_info->genelist_given = 0 ;
+  args_info->uniformjoint_given = 0 ;
+  args_info->normaljoint_given = 0 ;
+  args_info->threshold_given = 0 ;
 }
 
 static
 void clear_args (struct gengetopt_args_info *args_info)
 {
+  args_info->adirectory_arg = gengetopt_strdup (".");
+  args_info->adirectory_orig = NULL;
   args_info->ndirectory_arg = gengetopt_strdup (".");
   args_info->ndirectory_orig = NULL;
   args_info->directory_arg = gengetopt_strdup (".");
   args_info->random_orig = NULL;
   args_info->verbosity_arg = 5;
   args_info->verbosity_orig = NULL;
+  args_info->holdout_flag = 0;
+  args_info->genelist_flag = 0;
+  args_info->uniformjoint_flag = 0;
+  args_info->normaljoint_flag = 0;
+  args_info->threshold_arg = 0.5;
+  args_info->threshold_orig = NULL;
   
 }
 
 
   args_info->help_help = gengetopt_args_info_help[0] ;
   args_info->version_help = gengetopt_args_info_help[1] ;
-  args_info->ndirectory_help = gengetopt_args_info_help[3] ;
-  args_info->directory_help = gengetopt_args_info_help[4] ;
-  args_info->zeros_help = gengetopt_args_info_help[6] ;
-  args_info->genex_help = gengetopt_args_info_help[8] ;
-  args_info->memmap_help = gengetopt_args_info_help[9] ;
-  args_info->random_help = gengetopt_args_info_help[10] ;
-  args_info->verbosity_help = gengetopt_args_info_help[11] ;
+  args_info->adirectory_help = gengetopt_args_info_help[3] ;
+  args_info->ndirectory_help = gengetopt_args_info_help[4] ;
+  args_info->directory_help = gengetopt_args_info_help[5] ;
+  args_info->zeros_help = gengetopt_args_info_help[7] ;
+  args_info->genex_help = gengetopt_args_info_help[9] ;
+  args_info->memmap_help = gengetopt_args_info_help[10] ;
+  args_info->random_help = gengetopt_args_info_help[11] ;
+  args_info->verbosity_help = gengetopt_args_info_help[12] ;
+  args_info->holdout_help = gengetopt_args_info_help[13] ;
+  args_info->genelist_help = gengetopt_args_info_help[14] ;
+  args_info->uniformjoint_help = gengetopt_args_info_help[15] ;
+  args_info->normaljoint_help = gengetopt_args_info_help[16] ;
+  args_info->threshold_help = gengetopt_args_info_help[17] ;
   
 }
 
 cmdline_parser_release (struct gengetopt_args_info *args_info)
 {
   unsigned int i;
+  free_string_field (&(args_info->adirectory_arg));
+  free_string_field (&(args_info->adirectory_orig));
   free_string_field (&(args_info->ndirectory_arg));
   free_string_field (&(args_info->ndirectory_orig));
   free_string_field (&(args_info->directory_arg));
   free_string_field (&(args_info->genex_orig));
   free_string_field (&(args_info->random_orig));
   free_string_field (&(args_info->verbosity_orig));
+  free_string_field (&(args_info->threshold_orig));
   
   
   for (i = 0; i < args_info->inputs_num; ++i)
     write_into_file(outfile, "help", 0, 0 );
   if (args_info->version_given)
     write_into_file(outfile, "version", 0, 0 );
+  if (args_info->adirectory_given)
+    write_into_file(outfile, "adirectory", args_info->adirectory_orig, 0);
   if (args_info->ndirectory_given)
     write_into_file(outfile, "ndirectory", args_info->ndirectory_orig, 0);
   if (args_info->directory_given)
     write_into_file(outfile, "random", args_info->random_orig, 0);
   if (args_info->verbosity_given)
     write_into_file(outfile, "verbosity", args_info->verbosity_orig, 0);
+  if (args_info->holdout_given)
+    write_into_file(outfile, "holdout", 0, 0 );
+  if (args_info->genelist_given)
+    write_into_file(outfile, "genelist", 0, 0 );
+  if (args_info->uniformjoint_given)
+    write_into_file(outfile, "uniformjoint", 0, 0 );
+  if (args_info->normaljoint_given)
+    write_into_file(outfile, "normaljoint", 0, 0 );
+  if (args_info->threshold_given)
+    write_into_file(outfile, "threshold", args_info->threshold_orig, 0);
   
 
   i = EXIT_SUCCESS;
   case ARG_INT:
     if (val) *((int *)field) = strtol (val, &stop_char, 0);
     break;
+  case ARG_FLOAT:
+    if (val) *((float *)field) = (float)strtod (val, &stop_char);
+    break;
   case ARG_STRING:
     if (val) {
       string_field = (char **)field;
   /* check numeric conversion */
   switch(arg_type) {
   case ARG_INT:
+  case ARG_FLOAT:
     if (val && !(stop_char && *stop_char == '\0')) {
       fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
       return 1; /* failure */
       int option_index = 0;
 
       static struct option long_options[] = {
-        { "help",	0, NULL, 'h' },
+        { "help",	0, NULL, 0 },
         { "version",	0, NULL, 'V' },
+        { "adirectory",	1, NULL, 'w' },
         { "ndirectory",	1, NULL, 'n' },
         { "directory",	1, NULL, 'd' },
         { "zeros",	1, NULL, 'Z' },
         { "memmap",	0, NULL, 'm' },
         { "random",	1, NULL, 'r' },
         { "verbosity",	1, NULL, 'v' },
+        { "holdout",	0, NULL, 'h' },
+        { "genelist",	0, NULL, 'l' },
+        { "uniformjoint",	0, NULL, 'u' },
+        { "normaljoint",	0, NULL, 'g' },
+        { "threshold",	1, NULL, 't' },
         { NULL,	0, NULL, 0 }
       };
 
-      c = getopt_long (argc, argv, "hVn:d:Z:G:mr:v:", long_options, &option_index);
+      c = getopt_long (argc, argv, "Vw:n:d:Z:G:mr:v:hlugt:", long_options, &option_index);
 
       if (c == -1) break;	/* Exit from `while (1)' loop.  */
 
       switch (c)
         {
-        case 'h':	/* Print help and exit.  */
-          cmdline_parser_print_help ();
-          cmdline_parser_free (&local_args_info);
-          exit (EXIT_SUCCESS);
-
         case 'V':	/* Print version and exit.  */
         
         
           return 0;
         
           break;
+        case 'w':	/* Answer directory.  */
+        
+        
+          if (update_arg( (void *)&(args_info->adirectory_arg), 
+               &(args_info->adirectory_orig), &(args_info->adirectory_given),
+              &(local_args_info.adirectory_given), optarg, 0, ".", ARG_STRING,
+              check_ambiguity, override, 0, 0,
+              "adirectory", 'w',
+              additional_error))
+            goto failure;
+        
+          break;
         case 'n':	/* Input directory.  */
         
         
             goto failure;
         
           break;
+        case 'h':	/* Holdout target dataset.  */
+        
+        
+          if (update_arg((void *)&(args_info->holdout_flag), 0, &(args_info->holdout_given),
+              &(local_args_info.holdout_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "holdout", 'h',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'l':	/* Print gene list on the screen.  */
+        
+        
+          if (update_arg((void *)&(args_info->genelist_flag), 0, &(args_info->genelist_given),
+              &(local_args_info.genelist_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "genelist", 'l',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'u':	/* Uniform joint distribution.  */
+        
+        
+          if (update_arg((void *)&(args_info->uniformjoint_flag), 0, &(args_info->uniformjoint_given),
+              &(local_args_info.uniformjoint_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "uniformjoint", 'u',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'g':	/* Normal joint distribution.  */
+        
+        
+          if (update_arg((void *)&(args_info->normaljoint_flag), 0, &(args_info->normaljoint_given),
+              &(local_args_info.normaljoint_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "normaljoint", 'g',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 't':	/* Threshold for joint.  */
+        
+        
+          if (update_arg( (void *)&(args_info->threshold_arg), 
+               &(args_info->threshold_orig), &(args_info->threshold_given),
+              &(local_args_info.threshold_given), optarg, 0, "0.5", ARG_FLOAT,
+              check_ambiguity, override, 0, 0,
+              "threshold", 't',
+              additional_error))
+            goto failure;
+        
+          break;
 
         case 0:	/* Long option with no short option */
+          if (strcmp (long_options[option_index].name, "help") == 0) {
+            cmdline_parser_print_help ();
+            cmdline_parser_free (&local_args_info);
+            exit (EXIT_SUCCESS);
+          }
+
         case '?':	/* Invalid option.  */
           /* `getopt_long' already printed an error message.  */
           goto failure;

tools/SpeciesConnector/cmdline.h

 {
   const char *help_help; /**< @brief Print help and exit help description.  */
   const char *version_help; /**< @brief Print version and exit help description.  */
+  char * adirectory_arg;	/**< @brief Answer directory (default='.').  */
+  char * adirectory_orig;	/**< @brief Answer directory original value given at command line.  */
+  const char *adirectory_help; /**< @brief Answer directory help description.  */
   char * ndirectory_arg;	/**< @brief Input directory (default='.').  */
   char * ndirectory_orig;	/**< @brief Input directory original value given at command line.  */
   const char *ndirectory_help; /**< @brief Input directory help description.  */
   int verbosity_arg;	/**< @brief Message verbosity (default='5').  */
   char * verbosity_orig;	/**< @brief Message verbosity original value given at command line.  */
   const char *verbosity_help; /**< @brief Message verbosity help description.  */
+  int holdout_flag;	/**< @brief Holdout target dataset (default=off).  */
+  const char *holdout_help; /**< @brief Holdout target dataset help description.  */
+  int genelist_flag;	/**< @brief Print gene list on the screen (default=off).  */
+  const char *genelist_help; /**< @brief Print gene list on the screen help description.  */
+  int uniformjoint_flag;	/**< @brief Uniform joint distribution (default=off).  */
+  const char *uniformjoint_help; /**< @brief Uniform joint distribution help description.  */
+  int normaljoint_flag;	/**< @brief Normal joint distribution (default=off).  */
+  const char *normaljoint_help; /**< @brief Normal joint distribution help description.  */
+  float threshold_arg;	/**< @brief Threshold for joint (default='0.5').  */
+  char * threshold_orig;	/**< @brief Threshold for joint original value given at command line.  */
+  const char *threshold_help; /**< @brief Threshold for joint help description.  */
   
   unsigned int help_given ;	/**< @brief Whether help was given.  */
   unsigned int version_given ;	/**< @brief Whether version was given.  */
+  unsigned int adirectory_given ;	/**< @brief Whether adirectory was given.  */
   unsigned int ndirectory_given ;	/**< @brief Whether ndirectory was given.  */
   unsigned int directory_given ;	/**< @brief Whether directory was given.  */
   unsigned int zeros_given ;	/**< @brief Whether zeros was given.  */
   unsigned int memmap_given ;	/**< @brief Whether memmap was given.  */
   unsigned int random_given ;	/**< @brief Whether random was given.  */
   unsigned int verbosity_given ;	/**< @brief Whether verbosity was given.  */
+  unsigned int holdout_given ;	/**< @brief Whether holdout was given.  */
+  unsigned int genelist_given ;	/**< @brief Whether genelist was given.  */
+  unsigned int uniformjoint_given ;	/**< @brief Whether uniformjoint was given.  */
+  unsigned int normaljoint_given ;	/**< @brief Whether normaljoint was given.  */
+  unsigned int threshold_given ;	/**< @brief Whether threshold was given.  */
 
   char **inputs ; /**< @brief unamed options (options without names) */
   unsigned inputs_num ; /**< @brief unamed options number */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.