Commits

Jian Zhou committed b3a05fd

add an option of not weighting negative standards in Counter when using weights

  • Participants
  • Parent commits 8c61988

Comments (0)

Files changed (3)

File tools/Counter/Counter.cpp

 typedef CFullMatrix<size_t>	CCountMatrix;
 
 struct SLearn {
-    CCountMatrix*           m_pMatCounts;
-    const CGenes*           m_pGenes;
+    CCountMatrix*	    m_pMatCounts;
+    const CGenes*	    m_pGenes;
     const CGenes*           m_pUbikGenes;
-    const CDataPair*        m_pAnswers;
-    const CDatFilter*       m_pDat;
-    size_t                  m_iZero;
-    CRegularize*            m_pRegularize;
-    size_t                  m_iDat;
+    const CDataPair*	    m_pAnswers;
+    const CDatFilter*	    m_pDat;
+    size_t	            m_iZero;
+    CRegularize*	    m_pRegularize;
+    size_t		    m_iDat;
     bool                    m_bInPos;
     bool                    m_bInNeg;
     bool                    m_bBridgePos;
     bool                    m_bBridgeNeg;
     bool                    m_bOutPos;
     bool                    m_bOutNeg;
-        bool					m_isDatWeighted;
-        bool					m_bFlipNeg;
-        const CDat*         m_pwDat;
+	bool					m_isDatWeighted;
+	bool					m_bFlipNeg;
+	bool					m_bdWeightPos;
+	bool					m_bNoWeightNeg;
+	const CDat*	    m_pwDat;
 };
 
 struct SEvaluate {
                     }
                 }
                 /*
-                                                if( iDatasetOne == iDatasetTwo ) {
-                                                        MatJoint.Clear( );
-                                                        for( iValueOne = 0; iValueOne < vecdOne.size( ); ++iValueOne )
-                                                                MatJoint.Set( iValueOne, iValueOne, vecdOne[iValueOne] ); }
+                				if( iDatasetOne == iDatasetTwo ) {
+                					MatJoint.Clear( );
+                					for( iValueOne = 0; iValueOne < vecdOne.size( ); ++iValueOne )
+                						MatJoint.Set( iValueOne, iValueOne, vecdOne[iValueOne] ); }
                 //*/
                 /*
                 cerr << "One: " << vecstrNames[iDatasetOne] << endl;
         return 1;
     }
     CMeta Meta( sArgs.verbosity_arg );
-        if(sArgs.reggroups_given && sArgs.weights_flag){
-                cerr << "Regularization is not supported for weighted contexts." << endl;
-                return 1;}
+	if(sArgs.reggroups_given && sArgs.weights_flag){
+		cerr << "Regularization is not supported for weighted contexts." << endl;
+		return 1;}
     if( sArgs.pseudocounts_arg < 0 )
         sArgs.pseudocounts_arg = CMeta::GetNaN( );
     if( sArgs.zeros_arg ) {
     vector<CCountMatrix*>		vecpMatRoots;
     vector<CGenes*>			vecpGenes;
     CDataPair				Answers, Dat;
-        CDat					wDat;
+	CDat					wDat;
     CDatFilter				Filter, FilterIn, FilterEx, FilterTm, FilterEd;
     CDatFilter*				pFilter;
-    string                              strFile;
-    vector<pthread_t>                   vecpthdThreads;
+    string	    			strFile;
+    vector<pthread_t>	    		vecpthdThreads;
     vector<SLearn>			vecsData;
     map<string, size_t>::const_iterator	iterZero;
-    CGenome                             Genome;
-        vector<CGenome>			Genomes;
+    CGenome			    	Genome;
+	vector<CGenome>			Genomes;
     vector<string>			vecstrNames;
-    CRegularize                                 Regularize;
-        bool					isDatWeighted=false;
+    CRegularize			        Regularize;
+	bool					isDatWeighted=false;
     if( !Answers.Open( sArgs.answers_arg, false, !!sArgs.memmap_flag ) ) {
         cerr << "Could not open: " << sArgs.answers_arg << endl;
         return 1;
     }
 
     vecpGenes.resize( sArgs.inputs_num );
-        Genomes.resize(vecpGenes.size( ));
+	Genomes.resize(vecpGenes.size( ));
     for( i = 0; i < vecpGenes.size( ); ++i ) {
         ifstream	ifsm;
 
         vecpGenes[ i ]  = new CGenes( Genome );
         ifsm.open( sArgs.inputs[ i ] );
 
-                if(sArgs.weights_flag){
-                        delete vecpGenes[ i ];
-                        vecpGenes[ i ] = new CGenes(Genomes[ i ]);
-                        if( !vecpGenes[ i ]->OpenWeighted( ifsm ) ) {
-                                if(!wDat.Open(sArgs.inputs[i], !!sArgs.memmap_flag )){
-                                        cerr << "Couldn't open: " << sArgs.inputs[ i ] << endl;
-                                        return 1;	}
-                                else{
-                                        isDatWeighted = true;
-                                        vecpGenes[ i ]->Open(wDat.GetGeneNames());}
-                        }
-                }
-                else{
-                        if( !vecpGenes[ i ]->Open( ifsm ) ) {
-                                cerr << "Couldn't open: " << sArgs.inputs[ i ] << endl;
-                                return 1;	}
-                }
-        }
-
+		if(sArgs.weights_flag){
+			delete vecpGenes[ i ];
+			vecpGenes[ i ] = new CGenes(Genomes[ i ]);
+			if( !vecpGenes[ i ]->OpenWeighted( ifsm ) ) {
+				if(!wDat.Open(sArgs.inputs[i], !!sArgs.memmap_flag )){
+					cerr << "Couldn't open: " << sArgs.inputs[ i ] << endl;
+					return 1;	}
+				else{
+					isDatWeighted = true;
+					vecpGenes[ i ]->Open(wDat.GetGeneNames());}
+			}
+		}	
+		else{
+			if( !vecpGenes[ i ]->Open( ifsm ) ) {
+				cerr << "Couldn't open: " << sArgs.inputs[ i ] << endl;
+				return 1;	}	
+		}
+	}
+    
     if( !vecpGenes.size( ) ) {
         vecpGenes.insert( vecpGenes.begin( ), new CGenes( Genome ) );
         vecpGenes[ 0 ]->Open( Answers.GetGeneNames( ) );
             vecsData[ i ].m_pDat = NULL;
             vecsData[ i ].m_iDat = -1;
             vecsData[ i ].m_pGenes = vecpGenes[ i ];
-            vecsData[ i ].m_pUbikGenes = &GenesUbik;
+	    vecsData[ i ].m_pUbikGenes = &GenesUbik;
             vecsData[ i ].m_pAnswers = &Answers;
             vecsData[ i ].m_iZero = -1;
             vecsData[ i ].m_pRegularize = &Regularize;
             vecsData[ i ].m_bBridgeNeg = sArgs.bridgeneg_flag;
             vecsData[ i ].m_bOutPos = sArgs.outpos_flag;
             vecsData[ i ].m_bOutNeg = sArgs.outneg_flag;
-                        vecsData[ i ].m_isDatWeighted = false;
-                        vecsData[ i ].m_bFlipNeg =false;
-                        vecsData[ i ].m_pwDat = NULL;
+			vecsData[ i ].m_isDatWeighted = false;
+			vecsData[ i ].m_bFlipNeg =false;
+			vecsData[ i ].m_bdWeightPos = false;
+			vecsData[ i ].m_bNoWeightNeg = sArgs.noweightneg_flag;
+			vecsData[ i ].m_pwDat = NULL;
             if( pthread_create( &vecpthdThreads[ i ], NULL, learn, &vecsData[ i ] ) ) {
                 cerr << "Couldn't create root thread: " << sArgs.inputs[ i ] << endl;
                 return 1;
     FOR_EACH_DIRECTORY_FILE((string)sArgs.directory_arg, strFile)
     string					strName;
     vector<CCountMatrix*>*	pvecpMatCounts;
-
+    
     if( CMeta::IsExtension( strFile, c_acDab ) ) {
         i = strFile.rfind( '.' );
         strName = (string) sArgs.directory_arg + "/" + strFile.substr( 0, i ) + c_acDab;
         i = strFile.rfind( '.' );
         strName = (string) sArgs.directory_arg + "/" + strFile.substr( 0, i ) + c_acQDab;
     } else if( CMeta::IsExtension( strFile, c_acDat ) ) {
-        i = strFile.rfind( '.' );
-        strName = (string) sArgs.directory_arg + "/" + strFile.substr( 0, i ) + c_acDat;
+	i = strFile.rfind( '.' );
+	strName = (string) sArgs.directory_arg + "/" + strFile.substr( 0, i ) + c_acDat;
     } else {
         continue;
     }
             vecsData[ i ].m_pDat = pFilter;
             vecsData[ i ].m_iDat = vecstrNames.size( ) - 1;
             vecsData[ i ].m_pGenes = vecpGenes[ i ];
-            vecsData[ i ].m_pUbikGenes = &GenesUbik;
+	    vecsData[ i ].m_pUbikGenes = &GenesUbik;
             vecsData[ i ].m_pAnswers = &Answers;
             vecsData[ i ].m_iZero = ( ( iterZero = mapstriZeros.find( strName ) ) == mapstriZeros.end( ) ) ? -1 : iterZero->second;
             vecsData[ i ].m_pRegularize = &Regularize;
             vecsData[ i ].m_bBridgeNeg = sArgs.bridgeneg_flag;
             vecsData[ i ].m_bOutPos = sArgs.outpos_flag;
             vecsData[ i ].m_bOutNeg = sArgs.outneg_flag;
-                        vecsData[ i ].m_isDatWeighted = isDatWeighted;
-                        vecsData[ i ].m_bFlipNeg = !!sArgs.flipneg_flag;
-                        vecsData[ i ].m_pwDat = isDatWeighted? &wDat : NULL;
+			vecsData[ i ].m_isDatWeighted = isDatWeighted;
+			vecsData[ i ].m_bFlipNeg = !!sArgs.flipneg_flag;
+			vecsData[ i ].m_bdWeightPos = !!sArgs.dweightpos_flag;
+			vecsData[ i ].m_bNoWeightNeg = !!sArgs.noweightneg_flag;
+			vecsData[ i ].m_pwDat = isDatWeighted? &wDat : NULL;
             if( pthread_create( &vecpthdThreads[ i ], NULL, learn, &vecsData[ i ] ) ) {
                 cerr << "Couldn't create root thread: " << sArgs.inputs[ i ] << endl;
                 return 1;
     ofstream	ofsm;
 
     ofsm.open( ( (string)sArgs.output_arg + '/' + ( sArgs.inputs ?
-                 CMeta::Deextension( CMeta::Basename( sArgs.inputs[ i ] ) ) : sArgs.countname_arg ) + c_acTxt ).c_str( ) );
-    ofsm << ( sArgs.inputs ? CMeta::Deextension( CMeta::Basename( sArgs.inputs[ i ] ) ) : sArgs.countname_arg ) <<
+                 CMeta::Deextension( CMeta::Basename( sArgs.inputs[ i ] ) ) : "global" ) + c_acTxt ).c_str( ) );
+    ofsm << ( sArgs.inputs ? CMeta::Deextension( CMeta::Basename( sArgs.inputs[ i ] ) ) : "global" ) <<
          '\t' << vecpvecpMats.size( ) << endl;
     for( j = 0; j < vecpMatRoots[ i ]->GetRows( ); ++j )
         ofsm << ( j ? "\t" : "" ) << vecpMatRoots[ i ]->Get( j, 0 );
     size_t		i, j, k, iAnswer, iVal, iOne, iTwo;
     vector<bool>	vecfGenes, vecfUbik;
     vector<size_t>	veciGenes, vecfiGenes;
-        vector<float>	vecGeneWeights;
+	vector<float>	vecGeneWeights;
     psData = (SLearn*)pData;
-        float			w;
+	float			w;
 
     if (psData->m_pUbikGenes->GetGenes( )) {
-                vecfUbik.resize( psData->m_pAnswers->GetGenes( ) );
-                for( i = 0; i < vecfUbik.size( ); ++i) {
-                        vecfUbik[ i ] = psData->m_pUbikGenes->IsGene( psData->m_pAnswers->GetGene( i ) );
-                }
+		vecfUbik.resize( psData->m_pAnswers->GetGenes( ) );
+		for( i = 0; i < vecfUbik.size( ); ++i) {
+			vecfUbik[ i ] = psData->m_pUbikGenes->IsGene( psData->m_pAnswers->GetGene( i ) );
+		}
     }
     vecfGenes.resize( psData->m_pAnswers->GetGenes( ) );
-        vecGeneWeights.resize( psData->m_pAnswers->GetGenes( ) );
-        vecfiGenes.resize(psData->m_pAnswers->GetGenes( ));
+	vecGeneWeights.resize( psData->m_pAnswers->GetGenes( ) );
+	vecfiGenes.resize(psData->m_pAnswers->GetGenes( ));
     for( i = 0; i < vecfGenes.size( ); ++i ){
-                vecfGenes[ i ] = psData->m_pGenes->IsGene( psData->m_pAnswers->GetGene( i ) );}
-    if(psData->m_isDatWeighted){
-      for( i = 0; i < vecfGenes.size( ); ++i ){
-        vecfiGenes[ i ] = psData->m_pwDat->GetGene( psData->m_pAnswers->GetGene( i ) );}
-    }
-    else{
-    for( i = 0; i < vecfGenes.size( ); ++i ){
-                vecfiGenes[ i ] = psData->m_pGenes->GetGene( psData->m_pAnswers->GetGene( i ) );}
-    }
-        if(psData->m_pGenes->IsWeighted()){
-                for( i = 0; i < vecfGenes.size( ); ++i ){
-                        vecGeneWeights[ i ] = psData->m_pGenes->GetGeneWeight(psData->m_pGenes->GetGene( psData->m_pAnswers->GetGene( i ) ));}}
+		vecfGenes[ i ] = psData->m_pGenes->IsGene( psData->m_pAnswers->GetGene( i ) );}
+	for( i = 0; i < vecfGenes.size( ); ++i ){
+		vecfiGenes[ i ] = psData->m_pGenes->GetGene( psData->m_pAnswers->GetGene( i ) );}
+	if(psData->m_pGenes->IsWeighted()){
+		for( i = 0; i < vecfGenes.size( ); ++i ){
+			vecGeneWeights[ i ] = psData->m_pGenes->GetGeneWeight(psData->m_pGenes->GetGene( psData->m_pAnswers->GetGene( i ) ));}}
     if( psData->m_pDat ) {
         psData->m_pMatCounts->Initialize( psData->m_pDat->GetValues( ), psData->m_pAnswers->GetValues( ) );
         veciGenes.resize( psData->m_pAnswers->GetGenes( ) );
     }
     else
         psData->m_pMatCounts->Initialize( psData->m_pAnswers->GetValues( ), 1 );
-        psData->m_pMatCounts->Clear( );
+	psData->m_pMatCounts->Clear( );
     for( i = 0; i < psData->m_pAnswers->GetGenes( ); ++i ) {
         if( psData->m_pDat )
             iOne = veciGenes[ i ];
         for( j = ( i + 1 ); j < psData->m_pAnswers->GetGenes( ); ++j ) {
-                        iAnswer = psData->m_pAnswers->Quantize( psData->m_pAnswers->Get( i, j ) );
-                                if( iAnswer == -1 ) {
-                                        continue;
-                                }
+			iAnswer = psData->m_pAnswers->Quantize( psData->m_pAnswers->Get( i, j ) );
+				if( iAnswer == -1 ) {
+					continue;
+				}
+	    
+			if ( CMeta::SkipEdge( !!iAnswer, i, j, vecfGenes, vecfUbik, psData->m_bInPos, psData->m_bInNeg, psData->m_bBridgePos, psData->m_bBridgeNeg, psData->m_bOutPos, psData->m_bOutNeg ) ) {
+			continue;
+			}
 
-                        if ( CMeta::SkipEdge( !!iAnswer, i, j, vecfGenes, vecfUbik, psData->m_bInPos, psData->m_bInNeg, psData->m_bBridgePos, psData->m_bBridgeNeg, psData->m_bOutPos, psData->m_bOutNeg ) ) {
-                        continue;
-                        }
-
-                        if( psData->m_pDat ) {
-                                        iTwo = veciGenes[ j ];
-                                        iVal = -1;
-                                        iVal = psData->m_pDat->Quantize( iOne, iTwo, psData->m_iZero );
-                                        if( iVal == -1 )
-                                                continue;
-                                        //When contexts are weighted, add counts = WT_MULTIPLIER * weight1 * weight 2
-                                        if(psData->m_pGenes->IsWeighted()){
-                                                if(iAnswer==1 || !psData->m_bFlipNeg)
-                                                        for( k = 0; k <(vecGeneWeights[i]*vecGeneWeights[j]*WT_MULTIPLIER-0.5); k++){
-                                                                psData->m_pMatCounts->Get( iVal, iAnswer )++;
-                                                                }
-                                                else
-                                                        for( k = 0; k <((1-vecGeneWeights[i]*vecGeneWeights[j])*WT_MULTIPLIER-0.5); k++){
-                                                                psData->m_pMatCounts->Get( iVal, iAnswer )++;
-                                                                }
-                                        }
-                                        else if(psData->m_isDatWeighted){
-                                                if(vecfiGenes[i] == -1 || vecfiGenes[j] == -1)
-                                                        continue;
-                                                if(CMeta::IsNaN(w = psData->m_pwDat->Get( vecfiGenes[i],vecfiGenes[j] )) )
-                                                  continue;
-                                                if(iAnswer==1 || !psData->m_bFlipNeg)
-                                                        for( k = 0; k <(w *WT_MULTIPLIER-0.5); k++){
-                                                                psData->m_pMatCounts->Get( iVal, iAnswer )++;
-                                                                }
-                                                else
-                                                        for( k = 0; k <((1-w) *WT_MULTIPLIER-0.5); k++){
-                                                                psData->m_pMatCounts->Get( iVal, iAnswer )++;
-                                                                }
-                                        }
-                                        else{
-                                        psData->m_pMatCounts->Get( iVal, iAnswer )++;
-                                        //FIXME: Regularization has not been supported for weighted context
-                                        psData->m_pRegularize->Add( psData->m_iDat, *psData->m_pDat, i, j, iVal );
-                                        }
-                        }
-                        else{
-                                psData->m_pMatCounts->Get( iAnswer, 0 )++;}
+			if( psData->m_pDat ) {
+					iTwo = veciGenes[ j ];
+					iVal = -1;
+					iVal = psData->m_pDat->Quantize( iOne, iTwo, psData->m_iZero );
+					if( iVal == -1 )
+						continue;
+					//When contexts are weighted, add counts = WT_MULTIPLIER * weight1 * weight 2 
+					if(psData->m_pGenes->IsWeighted()){ //use gene weights
+						if(iAnswer==1 || (!psData->m_bFlipNeg && !psData->m_bNoWeightNeg)){
+							for( k = 0; k <(vecGeneWeights[i]*vecGeneWeights[j]*WT_MULTIPLIER-0.5); k++){
+								psData->m_pMatCounts->Get( iVal, iAnswer )++;
+								}
+							if(iAnswer==1 && psData->m_bdWeightPos)
+								for( k = 0; k <( (1-vecGeneWeights[i]*vecGeneWeights[j])*WT_MULTIPLIER-0.5); k++){
+								psData->m_pMatCounts->Get( iVal, 0 )++;
+								}
+						}
+						else{
+							if(psData->m_bNoWeightNeg)
+								for( k = 0; k <(WT_MULTIPLIER-0.5); k++)
+									psData->m_pMatCounts->Get( iVal, iAnswer )++;
+							else
+								for( k = 0; k <((1-vecGeneWeights[i]*vecGeneWeights[j])*WT_MULTIPLIER-0.5); k++){
+									psData->m_pMatCounts->Get( iVal, iAnswer )++;
+									}
+						}
+					}	
+					else if(psData->m_isDatWeighted){ //use pair weights
+						if(CMeta::IsNaN(w = psData->m_pwDat->Get( vecfiGenes[i],vecfiGenes[j] )) || vecfiGenes[i] == -1 ||
+							vecfiGenes[j] == -1)
+							continue;
+						if(iAnswer==1 || (!psData->m_bFlipNeg && !psData->m_bNoWeightNeg)){
+							for( k = 0; k <(w *WT_MULTIPLIER-0.5); k++){
+								psData->m_pMatCounts->Get( iVal, iAnswer )++;
+								}
+							if(iAnswer==1 && psData->m_bdWeightPos)
+								for( k = 0; k <( (1-w)*WT_MULTIPLIER-0.5); k++){
+								psData->m_pMatCounts->Get( iVal, 0 )++;
+								}
+						}
+						else{
+							if(psData->m_bNoWeightNeg)
+								for( k = 0; k <(WT_MULTIPLIER-0.5); k++)
+									psData->m_pMatCounts->Get( iVal, iAnswer )++;
+							else
+								for( k = 0; k <((1-w) *WT_MULTIPLIER-0.5); k++){
+									psData->m_pMatCounts->Get( iVal, iAnswer )++;
+									}
+						}
+					}
+					//
+					else{
+					psData->m_pMatCounts->Get( iVal, iAnswer )++;
+					//FIXME: Regularization has not been supported for weighted context
+					psData->m_pRegularize->Add( psData->m_iDat, *psData->m_pDat, i, j, iVal );
+					}
+			}
+			else{
+				psData->m_pMatCounts->Get( iAnswer, 0 )++;}
         }
     }
 
-
-        //Recale counts
-        if(psData->m_pGenes->IsWeighted()||psData->m_isDatWeighted){
-                for (i=0; i< psData->m_pMatCounts->GetRows();i++)
-                        for(j=0; j<psData->m_pMatCounts->GetColumns();j++)
-                                psData->m_pMatCounts->Get( i,j ) = int(psData->m_pMatCounts->Get( i,j )/ WT_MULTIPLIERf + 0.5);
-        }
+	//Recale counts 
+	if(psData->m_pGenes->IsWeighted()||psData->m_isDatWeighted){
+		for (i=0; i< psData->m_pMatCounts->GetRows();i++)
+			for(j=0; j<psData->m_pMatCounts->GetColumns();j++)
+				psData->m_pMatCounts->Get( i,j ) = int(psData->m_pMatCounts->Get( i,j )/ WT_MULTIPLIERf + 0.5);
+	}
 
     return NULL;
 }
         vecpGenes[ i ]  = new CGenes( Genome );
         if( sArgs.inputs_num ) {
             ifstream	ifsm;
+
+            ifsm.open( sArgs.inputs[ i ] );
+            if( !vecpGenes[ i ]->Open( ifsm, false ) ) {
+                cerr << "Couldn't open: " << sArgs.inputs[ i ] << endl;
+                return 1;
+            }
         }
         else
             vecpGenes[ i ]->Open( Genome.GetGeneNames( ), false );
             vecsData[ i ].m_pYes = vecpYes[ i ];
             vecsData[ i ].m_pNo = vecpNo[ i ];
             vecsData[ i ].m_strName = sArgs.inputs_num ? sArgs.inputs[ i ] : "global";
-            vecsData[ i ].m_bLogratio = sArgs.logratio_flag;
+	    vecsData[ i ].m_bLogratio = sArgs.logratio_flag;
             if( pthread_create( &vecpthdThreads[ i ], NULL, finalize, &vecsData[ i ] ) ) {
                 cerr << "Couldn't create finalization thread: " << sArgs.inputs[ i ] << endl;
                 return 1;
             if( ( ( iTwo = (*psData->m_pveciGenes)[ j ] ) == -1 ) && ( psData->m_iZero == -1 ) )
                 continue;
 
-            iBin = psData->m_pDat->Quantize( iOne, iTwo, psData->m_iZero );
+	    iBin = psData->m_pDat->Quantize( iOne, iTwo, psData->m_iZero );
             if( iBin == -1 )
                 continue;
             if( CMeta::IsNaN( adYes[ iIndex = ( j - i - 1 ) ] ) ) {
         memcpy( adYes, psData->m_pYes->Get( i ), ( psData->m_pYes->GetGenes( ) - i - 1 ) * sizeof(*adYes) );
         memcpy( adNo, psData->m_pNo->Get( i ), ( psData->m_pNo->GetGenes( ) - i - 1 ) * sizeof(*adNo) );
         for( j = 0; j < ( psData->m_pYes->GetGenes( ) - i - 1 ); ++j ) {
-            if( psData->m_bLogratio ) {
-                adYes[ j ] = CMeta::IsNaN( adYes[ j ] ) ? 0.0 :
-                             (float)( (double)(adYes[ j ] - dYes) - (double)(adNo[ j ] - dNo) );
-            }
-            else {
-                adYes[ j ] = CMeta::IsNaN( adYes[ j ] ) ? dPrior :
-                             (float)( 1 / ( 1 + exp( (double)adNo[ j ] - (double)adYes[ j ] ) ) );
-            }
-        }
+	    if( psData->m_bLogratio ) {
+		adYes[ j ] = CMeta::IsNaN( adYes[ j ] ) ? 0.0 :
+		             (float)( (double)(adYes[ j ] - dYes) - (double)(adNo[ j ] - dNo) );
+	    }
+	    else {
+		adYes[ j ] = CMeta::IsNaN( adYes[ j ] ) ? dPrior :
+		             (float)( 1 / ( 1 + exp( (double)adNo[ j ] - (double)adYes[ j ] ) ) );
+	    }
+	}
         psData->m_pYes->Set( i, adYes );
     }
     delete[] adNo;
         vecpGenes[ i ]  = new CGenes( Genome );
         if( sArgs.inputs_num ) {
             ifstream	ifsm;
+
+            ifsm.open( sArgs.inputs[ i ] );
+            if( !vecpGenes[ i ]->Open( ifsm, false ) ) {
+                cerr << "Couldn't open: " << sArgs.inputs[ i ] << endl;
+                return 1;
+            }
         }
         else
             vecpGenes[ i ]->Open( Genome.GetGeneNames( ), false );
             if( ( ( iTwo = (*psData->m_pveciGenes)[ j ] ) == -1 ) && ( psData->m_iZero == -1 ) )
                 continue;
 
-            iBin = psData->m_pDat->Quantize( iOne, iTwo, psData->m_iZero );
+	    iBin = psData->m_pDat->Quantize( iOne, iTwo, psData->m_iZero );
             if( iBin == -1 )
                 continue;
 

File tools/Counter/Counter.ggo

 section "Main"
 option	"output"		o	"Output count directory, Bayes nets, or inferences"
 							string	typestr="filename or directory"	yes
-option	"countname"		O	"For learning stage, what should the countname be called if no contexts are used (default: global)."
-							string	typestr="filename"	default="global"
 option	"directory"		d	"Data directory"
 							string	typestr="directory"	default="."
 option	"datasets"		s	"Dataset ID text file"
                                                         flag    off
 option	"weights"           W       "Use weighted context file"
                                                         flag    off
+option	"dweightpos"           D       "Use weights to divide positive counts into correponding proportion of positives and negatives"
+	                                                    flag    off
 option	"flipneg"           F       "Flip weights(one minus original) for negative standards"
                                                         flag    on
+option	"noweightneg"           N       "Use weight one for all negative standards"
+                                                        flag    off
 
 section "Network Features"
 option	"default"		b	"Count file containing defaults for cases with missing data"

File tools/SVMhierarchy/SVMhierarchy.ggo

 option	"input"					i	"Input PCL file "
 										string	typestr="filename"  yes
 option	"dab_input"				d	"Input Dat/Dab file "
-										string	typestr="filename"  yes
+										string	typestr="filename"  no
 option	"model"					m	"Model file"
 										string	typestr="filename"  no
 option	"test_labels"			T	"Test Labels file"