Commits

chuttenh  committed e358caa

[svn r421] Add SVDer from AJ Sedgewick's JP
Performs SVD-space PCL rescaling as per Matt's SPELL procedure
Add CFullMatrix::SVD from AJ's JP
Add motif matching algorithm selection to COALESCE
PWM correlation p-value, RMSE, or Jenson-Shannon divergence
Fix gene list mismatch behavior for CDat::Open from a base CDat
Add proper duplicate handling to CDat::Open from a filename
Fix CPCL::Normalize( ENormalizeColumn ) stdev calcuation typo
Fix KNNImputer and CPCL::Impute for k=0 to eliminate genes with missing values
Fix Answerer to properly match positive gene names with output CDat
Add row/column PCL normalization to Normalizer

  • Participants
  • Parent commits 8511b95

Comments (0)

Files changed (26)

File proj/vs2008/SVDer/SVDer.vcproj

+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="SVDer"
+	ProjectGUID="{56C30EA3-24DF-4AB4-B68E-17C954F8A962}"
+	RootNamespace="SVDer"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+		<ToolFile
+			RelativePath="..\gengetopts.rules"
+		/>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="GenGetOpts"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="../../../../extlib/pthreads-w32-2-8-0-release/;../../../../extlib/gengetopt-2.22/gl/;../../../src/"
+				PreprocessorDefinitions="PTW32_STATIC_LIB"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				WarningLevel="3"
+				WarnAsError="true"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="log4cpp.lib pthreads.lib ws2_32.lib"
+				AdditionalLibraryDirectories="../../../../extlib/proj/vs2008/$(ConfigurationName)"
+				GenerateDebugInformation="true"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="GenGetOpts"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				AdditionalIncludeDirectories="../../../../extlib/pthreads-w32-2-8-0-release/;../../../../extlib/gengetopt-2.22/gl/;../../../src/"
+				PreprocessorDefinitions="PTW32_STATIC_LIB;_SECURE_SCL=0"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				BufferSecurityCheck="false"
+				EnableEnhancedInstructionSet="2"
+				WarningLevel="3"
+				WarnAsError="true"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="log4cpp.lib pthreads.lib ws2_32.lib"
+				AdditionalLibraryDirectories="../../../../extlib/proj/vs2008/$(ConfigurationName)"
+				GenerateDebugInformation="true"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752AF63}"
+			>
+			<File
+				RelativePath="..\..\..\tools\SVDer\cmdline.c"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\..\../extlib\gengetopt-2.22\gl\getopt.c"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\..\../extlib\gengetopt-2.22\gl\getopt1.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\..\tools\SVDer\stdafx.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\..\tools\SVDer\SVDer.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EAA9}"
+			>
+			<File
+				RelativePath="..\..\..\tools\SVDer\stdafx.h"
+				>
+			</File>
+		</Filter>
+		<File
+			RelativePath="..\..\..\tools\SVDer\SVDer.ggo"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

File proj/vs2008/Sleipnir.sln

 		{772E04C2-CF1E-412B-9BAE-3A4A132837DB} = {772E04C2-CF1E-412B-9BAE-3A4A132837DB}
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SVDer", "SVDer\SVDer.vcproj", "{56C30EA3-24DF-4AB4-B68E-17C954F8A962}"
+	ProjectSection(ProjectDependencies) = postProject
+		{772E04C2-CF1E-412B-9BAE-3A4A132837DB} = {772E04C2-CF1E-412B-9BAE-3A4A132837DB}
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SubversionScc) = preSolution
 		Svn-Managed = True
 		{56C30EA3-24DF-4AB4-B68E-17C954F869B0}.Debug|Win32.Build.0 = Debug|Win32
 		{56C30EA3-24DF-4AB4-B68E-17C954F869B0}.Release|Win32.ActiveCfg = Release|Win32
 		{56C30EA3-24DF-4AB4-B68E-17C954F869B0}.Release|Win32.Build.0 = Release|Win32
+		{56C30EA3-24DF-4AB4-B68E-17C954F8A962}.Debug|Win32.ActiveCfg = Debug|Win32
+		{56C30EA3-24DF-4AB4-B68E-17C954F8A962}.Debug|Win32.Build.0 = Debug|Win32
+		{56C30EA3-24DF-4AB4-B68E-17C954F8A962}.Release|Win32.ActiveCfg = Release|Win32
+		{56C30EA3-24DF-4AB4-B68E-17C954F8A962}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

File src/coalescecluster.cpp

 	CCoalesceClusterImpl::Snapshot( m_setsMotifs, m_vecsPrevMotifs );
 	CCoalesceClusterImpl::Snapshot( GetGenes( ), m_veciPrevGenes ); }
 
-bool CCoalesceCluster::LabelMotifs( const CCoalesceMotifLibrary& Motifs, float dPenaltyGap,
-	float dPenaltyMismatch, float dPValue ) {
+bool CCoalesceCluster::LabelMotifs( const CCoalesceMotifLibrary& Motifs, SMotifMatch::EType eMatchType,
+	float dPenaltyGap, float dPenaltyMismatch, float dPValue ) {
 	set<SMotifMatch>::iterator	iterMotif;
 
 	if( !Motifs.GetKnowns( ) )
 	for( iterMotif = m_setsMotifs.begin( ); iterMotif != m_setsMotifs.end( ); ++iterMotif ) {
 		SMotifMatch&	sMotif	= (SMotifMatch&)*iterMotif;
 // For some obscure reason, Linux won't let me use this as a non-const iterator...
-		if( !sMotif.Label( Motifs, dPenaltyGap, dPenaltyMismatch, dPValue ) )
+		if( !sMotif.Label( Motifs, eMatchType, dPenaltyGap, dPenaltyMismatch, dPValue ) )
 			return false; }
 
 	return true; }

File src/coalescecluster.h

 		float dCutoffPWMs = 0, float dPenaltyGap = 0, float dPenaltyMismatch = 0, bool fNoRCs = false ) const;
 	float GetSimilarity( const CCoalesceCluster& Cluster, size_t iGenes, size_t iDatasets ) const;
 	void Snapshot( const CCoalesceGeneScores& GeneScores, CCoalesceGroupHistograms& Histograms );
-	bool LabelMotifs( const CCoalesceMotifLibrary&, float dPenaltyGap, float dPenaltyMismatch,
-		float dPValue );
+	bool LabelMotifs( const CCoalesceMotifLibrary&, SMotifMatch::EType eMatchType, float dPenaltyGap,
+		float dPenaltyMismatch, float dPValue );
 
 	bool IsConverged( ) {
 

File src/coalescemotifs.cpp

 const char	CCoalesceMotifLibraryImpl::c_szBases[]			= "ACGT";
 const char	CCoalesceMotifLibraryImpl::c_szComplements[]	= "TGCA";
 
-void CCoalesceMotifLibraryImpl::SKnowns::Match( const vector<float>& vecdMotif,
+void CCoalesceMotifLibraryImpl::SKnowns::Match( const vector<float>& vecdMotif, SMotifMatch::EType eMatchType,
 	map<string, float>& mapstrdKnown ) const {
 	static const size_t					c_iOverlap	= 5;
 	map<string, TVecPr>::const_iterator	iterKnown;
 			if( iMax < iMin )
 				continue;
 			for( j = iMin; j <= iMax; j += strlen( c_szBases ) ) {
-				iTests += 2;
 				if( j < vecdMotif.size( ) ) {
 					adMotif = &vecdMotif[ vecdMotif.size( ) - j - 1 ];
 					adPWM = &vecdPWM.front( );
 					adPWM = &vecdPWM[ k ];
 					adRC = &vecdRC[ k ];
 					k = min( vecdMotif.size( ), vecdPWM.size( ) - k ); }
-				if( ( dR = (float)max( CMeasurePearson::Pearson( adMotif, k, adPWM, k,
-					IMeasure::EMapNone ), CMeasurePearson::Pearson( adMotif, k, adRC, k,
-					IMeasure::EMapNone ) ) ) < 0 )
-					continue;
-				if( ( dP = (float)CStatistics::PValuePearson( dR, k ) ) < dMin )
+				switch( eMatchType ) {
+					case SMotifMatch::ETypeRMSE:
+						dP = (float)min( CStatistics::RootMeanSquareError( adMotif, adMotif + k, adPWM,
+							adPWM + k ), CStatistics::RootMeanSquareError( adMotif, adMotif + k, adRC,
+							adRC + k ) );
+						break;
+
+					case SMotifMatch::ETypeJensenShannon:
+						dP = (float)min( CStatistics::JensenShannonDivergence( adMotif, adMotif + k, adPWM,
+							adPWM + k ), CStatistics::JensenShannonDivergence( adMotif, adMotif + k, adRC,
+							adRC + k ) );
+						break;
+
+					case SMotifMatch::ETypePValue:
+						iTests += 2;
+						if( ( dR = (float)max( CMeasurePearson::Pearson( adMotif, k, adPWM, k,
+							IMeasure::EMapNone ), CMeasurePearson::Pearson( adMotif, k, adRC, k,
+							IMeasure::EMapNone ) ) ) > 0 )
+							dP = (float)CStatistics::PValuePearson( dR, k );
+						else
+							dP = FLT_MAX;
+						break; }
+				if( dP < dMin )
 					dMin = dP; } }
 		if( dMin != FLT_MAX )
-			mapstrdKnown[ iterKnown->first ] = dMin * iTests; } }
+			mapstrdKnown[ iterKnown->first ] = dMin * max( 1, iTests ); } }
 
 bool CCoalesceMotifLibrary::Open( istream& istm, vector<SMotifMatch>& vecsMotifs,
 	CCoalesceMotifLibrary* pMotifs ) {
 
 	return true; }
 
-bool CCoalesceMotifLibrary::GetKnown( uint32_t iMotif, float dPenaltyGap, float dPenaltyMismatch,
-	vector<pair<string, float> >& vecprstrdKnown, float dPValue ) const {
+bool CCoalesceMotifLibrary::GetKnown( uint32_t iMotif, SMotifMatch::EType eMatchType, float dPenaltyGap,
+	float dPenaltyMismatch, vector<pair<string, float> >& vecprstrdKnown, float dPValue ) const {
 	size_t							i, j, k, iSum;
 	vector<float>					vecdMotif;
 	CFullMatrix<uint16_t>			MatPWM;
 
 	if( !m_sKnowns.GetSize( ) )
 		return true;
-	dPValue /= m_sKnowns.GetSize( );
 	if( !CCoalesceMotifLibraryImpl::GetPWM( iMotif, 0, dPenaltyGap, dPenaltyMismatch, true, MatPWM ) )
 		return false;
 	vecdMotif.resize( MatPWM.GetRows( ) * MatPWM.GetColumns( ) );
 		for( j = 0; j < MatPWM.GetRows( ); ++j )
 			vecdMotif[ k++ ] = (float)MatPWM.Get( j, i ) / iSum; }
 
-	m_sKnowns.Match( vecdMotif, mapstrdKnown );
+	m_sKnowns.Match( vecdMotif, eMatchType, mapstrdKnown );
+	if( eMatchType == SMotifMatch::ETypePValue )
+		dPValue /= m_sKnowns.GetSize( );
 	for( iterKnown = mapstrdKnown.begin( ); iterKnown != mapstrdKnown.end( ); ++iterKnown )
 		if( iterKnown->second < dPValue )
 			vecprstrdKnown.push_back( *iterKnown );

File src/coalescemotifs.h

 	std::string GetPWM( uint32_t iMotif, float dCutoffPWMs, float dPenaltyGap, float dPenaltyMismatch,
 		bool fNoRCs ) const;
 	bool Simplify( uint32_t iMotif ) const;
-	bool GetKnown( uint32_t iMotif, float dPenaltyGap, float dPenaltyMismatch,
+	bool GetKnown( uint32_t iMotif, SMotifMatch::EType eMatchType, float dPenaltyGap, float dPenaltyMismatch,
 		std::vector<std::pair<std::string, float> >& vecprstrdKnown, float dPValue = 1 ) const;
 
 	size_t GetKnowns( ) const {

File src/coalescemotifsi.h

 #include <string.h>
 #include <map>
 
-#include "fullmatrix.h"
+#include "coalescestructsi.h"
 
 namespace Sleipnir {
 
 		typedef std::pair<TVecD, TVecD>		TPrVecDVecD;
 		typedef std::vector<TPrVecDVecD>	TVecPr;
 
-		void Match( const std::vector<float>&, std::map<std::string, float>& ) const;
+		void Match( const std::vector<float>&, SMotifMatch::EType, std::map<std::string, float>& ) const;
 
 		size_t GetSize( ) const {
 

File src/coalescestructs.cpp

 
 	return ossm.str( ); }
 
-bool SMotifMatch::Label( const CCoalesceMotifLibrary& Motifs, float dPenaltyGap, float dPenaltyMismatch,
-	float dPValue ) {
+bool SMotifMatch::Label( const CCoalesceMotifLibrary& Motifs, EType eMatchType, float dPenaltyGap,
+	float dPenaltyMismatch, float dPValue ) {
 
 	m_vecprstrdKnown.clear( );
-	return Motifs.GetKnown( m_iMotif, dPenaltyGap, dPenaltyMismatch, m_vecprstrdKnown, dPValue ); }
+	return Motifs.GetKnown( m_iMotif, eMatchType, dPenaltyGap, dPenaltyMismatch, m_vecprstrdKnown, dPValue ); }
 
 }

File src/coalescestructsi.h

 };
 
 struct SMotifMatch {
+	enum EType {
+		ETypePValue,
+		ETypeRMSE,
+		ETypeJensenShannon
+	};
+
 	SMotifMatch( ) { }
 
 	SMotifMatch( uint32_t iMotif, const std::string& strType,
 	uint32_t Open( const SMotifMatch&, const SMotifMatch&, CCoalesceMotifLibrary& );
 	std::string Save( const CCoalesceMotifLibrary*, bool = false, float = 0, float = 0, float = 0,
 		bool = false ) const;
-	bool Label( const CCoalesceMotifLibrary&, float, float, float );
+	bool Label( const CCoalesceMotifLibrary&, EType, float, float, float );
 
 	bool operator==( const SMotifMatch& sMotif ) const {
 
 	for( i = 0; i < DatKnown.GetGenes( ); ++i ) {
 		iOne = veciGenes[ i ];
 		for( j = ( i + 1 ); j < DatKnown.GetGenes( ); ++j ) {
-			d = DatKnown.Get( i, j );
-			if( CMeta::IsNaN( Get( iOne, iTwo = veciGenes[ j ] ) ) && ( fKnownNegatives == !d ) )
-				Set( iOne, iTwo, d ); } }
+			if( CMeta::IsNaN( Get( iOne, iTwo = veciGenes[ j ] ) ) ) {
+				if( CMeta::IsNaN( d = DatKnown.Get( i, j ) ) )
+					Set( iOne, iTwo, 0 );
+				else if( fKnownNegatives == !d )
+					Set( iOne, iTwo, d ); } } }
 
 	return true; }
 
  * \param fZScore
  * If true and the given file is a PCL, z-score similarity measures after pairwise calculation.
  * 
+ * \param fDuplicates
+ * If true, allow duplicates (DAT format only), ignoring all but the last value for each gene pair.
+ * 
  * \returns
  * True if CDat was successfully opened.
  * 
  * \see
  * Save | CPCL
  */
-bool CDat::Open( const char* szFile, bool fMemmap, size_t iSkip, bool fZScore ) {
+bool CDat::Open( const char* szFile, bool fMemmap, size_t iSkip, bool fZScore, bool fDuplicates ) {
 	ifstream	ifsm;
 	EFormat		eFormat;
 	size_t		i;
 
 	if( !szFile )
-		return Open( cin, EFormatText );
+		return Open( cin, EFormatText, (float)HUGE_VAL, fDuplicates );
 
 	for( i = 0; c_asFormats[ i ].m_szExtension; ++i )
 		if( !strcmp( szFile + strlen( szFile ) - strlen( c_asFormats[ i ].m_szExtension ),
 		ios_base::binary );
 	if( !ifsm.is_open( ) )
 		return false;
-	return Open( ifsm, eFormat, (float)HUGE_VAL, false, iSkip, fZScore ); }
+	return Open( ifsm, eFormat, (float)HUGE_VAL, fDuplicates, iSkip, fZScore ); }
 
 bool CDatImpl::OpenHelper( ) {
 	unsigned char*	pb;
 		ENormalizeSigmoid	= ENormalizeZScore + 1
 	};
 
-	bool Open( const char* szFile, bool fMemmap = false, size_t iSkip = 2, bool fZScore = false );
+	bool Open( const char* szFile, bool fMemmap = false, size_t iSkip = 2, bool fZScore = false,
+		bool fDuplicates = false );
 	bool Open( std::istream& istm, EFormat eFormat = EFormatBinary, float dDefault = HUGE_VAL,
 		bool fDuplicates = false, size_t iSkip = 2, bool fZScore = false );
 	bool Open( const CSlim& Slim );

File src/fullmatrix.h

 
 #include <fstream>
 #include <iostream>
+#include <limits>
 #include <sstream>
 #include <vector>
 
 
 		return true; }
 
+	bool Multiply( std::vector<tType>& vecRight ) {
+		size_t	i, j;
+
+		if( vecRight.size( ) != GetColumns( ) )
+			return false;
+
+		for( i = 0; i < GetColumns( ); ++i )
+			for( j = 0; j < GetRows( ); ++j )
+				Set( j, i, vecRight[ i ] * Get( j, i ) );
+
+		return true; }
+
+	bool Multiply( const CFullMatrix& MatRight, bool fTranspose = false ) {
+		CFullMatrix	MatTmp;
+		size_t		i, j, k, iRR, iRC;
+
+		iRR = fTranspose ? MatRight.GetColumns( ) : MatRight.GetRows( );
+		if( GetColumns( ) != iRR )
+			return false;
+
+		MatTmp.Initialize( GetRows( ), iRC = fTranspose ? MatRight.GetRows( ) : MatRight.GetColumns( ) );
+		MatTmp.Clear( );
+		for( i = 0; i < iRC; ++i )
+			for( j = 0; j < GetRows( ); ++j )
+				for( k = 0; k < iRR; ++k )
+					MatTmp.Get( j, i ) += Get( j, k ) * ( fTranspose ? MatRight.Get( i, k ) :
+						MatRight.Get( k, i ) );
+
+		return Open( MatTmp ); }
+
+	bool SVD( CFullMatrix<tType>& MatU, CFullMatrix<tType>& MatV, std::vector<tType>& vecS ) const {
+		size_t				i, j, k, iNU, iCT, iRT;
+		vector<tType>		vecE, vecWork;
+		CFullMatrix<tType>	MatA;
+		bool				fU, fV;
+		ESVD				eCase;
+		tType				F;
+		int					iMarker, iP, iPP;
+
+		iNU = min( GetRows( ), GetColumns( ) );
+		vecS.resize( min( GetRows( ) + 1, GetColumns( ) ) );
+		MatU.Initialize( GetRows( ), iNU );
+		MatU.Clear( );
+		MatV.Initialize( GetColumns( ), GetColumns( ) );
+
+		vecE.resize( GetColumns( ) );
+		vecWork.resize( GetRows( ) );
+		MatA.Open( *this );
+
+		// Reduce A to bidiagonal form, storing the diagonal elements
+		// in s and the super-diagonal elements in e.
+		fU = fV = true;
+		iCT = min( GetRows( ) - 1, GetColumns( ) );
+		iRT = max( 0, min( GetColumns( ) - 2, GetRows( ) ) );
+		for( k = 0; k < max( iCT, iRT ); ++k ) {
+			if( k < iCT ) {
+				// Compute the transformation for the k-th column and
+				// place the k-th diagonal in s[k].
+				// Compute 2-norm of k-th column without under/overflow.
+				vecS[ k ] = 0;
+				for( i = k; i < GetRows( ); ++i )
+					vecS[ k ] = Hypotenuse( vecS[ k ], MatA.Get( i, k ) );
+				if( vecS[ k ] ) {
+					if( MatA.Get( k, k ) < 0 )
+						vecS[ k ] *= -1;
+					for( i = k; i < GetRows( ); ++i )
+						MatA.Get( i, k ) /= vecS[ k ];
+					MatA.Get( k, k ) += 1; }
+				vecS[ k ] *= -1; }
+
+			for( j = ( k + 1 ); j < GetColumns( ); ++j ) {
+				if( ( k < iCT ) && vecS[ k ] ) {
+					tType	T;
+
+					// Apply the transformation.
+					T = 0;
+					for( i = k; i < GetRows( ); ++i )
+						T += MatA.Get( i, k ) * MatA.Get( i, j );
+					T /= -MatA.Get( k, k );
+					for( i = k; i < GetRows( ); ++i )
+						MatA.Get( i, j ) += T * MatA.Get( i, k ); }
+
+				// Place the k-th row of A into e for the
+				// subsequent calculation of the row transformation.
+				vecE[ j ] = MatA.Get( k, j ); }
+
+			if( fU && ( k < iCT ) )
+				// Place the transformation in U for subsequent back
+				// multiplication.
+				for( i = k; i < GetRows( ); ++i )
+					MatU.Set( i, k, MatA.Get( i, k ) );
+			if( k < iRT ) {
+				// Compute the k-th row transformation and place the
+				// k-th super-diagonal in e[k].
+				// Compute 2-norm without under/overflow.
+				vecE[ k ] = 0;
+				for( i = ( k + 1 ); i < GetColumns( ); ++i )
+					vecE[ k ] = Hypotenuse( vecE[ k ], vecE[ i ] );
+				if( vecE[ k ] ) {
+					if( vecE[ k + 1 ] < 0 )
+						vecE[ k ] *= -1;
+					for( i = ( k + 1 ); i < GetColumns( ); ++i )
+						vecE[ i ] /= vecE[ k ];
+					vecE[ k + 1 ] += 1; }
+				vecE[ k ] *= -1;
+
+				if( ( ( k + 1 ) < GetRows( ) ) && vecE[ k ] ) {
+					// Apply the transformation.
+					for( i = ( k + 1 ); i < GetRows( ); ++i )
+						vecWork[ i ] = 0;
+					for( j = ( k + 1 ); j < GetColumns( ); ++j )
+						for( i = ( k + 1 ); i < GetRows( ); ++i )
+							vecWork[ i ] += vecE[ j ] * MatA.Get( i, j );
+					for( j = ( k + 1 ); j < GetColumns( ); ++j ) {
+						tType	T;
+
+						T = -vecE[ j ] / vecE[ k + 1 ];
+						for( i = ( k + 1 ); i < GetRows( ); ++i )
+							MatA.Get( i, j ) += T * vecWork[ i ]; } }
+
+				if( fV )
+					// Place the transformation in V for subsequent
+					// back multiplication.
+					for( i = ( k + 1 ); i < GetColumns( ); ++i )
+						MatV.Set( i, k, vecE[ i ] ); } }
+
+		// Set up the final bidiagonal matrix or order p.
+		iP = (int)min( GetColumns( ), GetRows( ) + 1 );
+		if( iCT < GetColumns( ) )
+			vecS[ iCT ] = MatA.Get( iCT, iCT );
+		if( GetRows( ) < (size_t)iP )
+			vecS[ iP - 1 ] = 0;
+		if( ( iRT + 1 ) < (size_t)iP )
+			vecE[ iRT ] = MatA.Get( iRT, iP - 1 );
+		vecE[ iP - 1 ] = 0;
+
+		// If required, generate U.
+		if( fU ) {
+			for( j = iCT; j < iNU; ++j ) {
+				for( i = 0; i < GetRows( ); ++i )
+					MatU.Set( i, j, 0 );
+				MatU.Set( j, j, 1 ); }
+			for( size_t iTmp = 0; iTmp < iCT; ++iTmp ) {
+				k = iCT - 1 - iTmp;
+				if( vecS[ k ] ) {
+					for( j = ( k + 1 ); j < iNU; ++j ) {
+						tType	T;
+
+						T = 0;
+						for( i = k; i < GetRows( ); ++i )
+							T += MatU.Get( i, k ) * MatU.Get( i, j );
+						T /= -MatU.Get( k, k );
+						for( i = k; i < GetRows( ); ++i )
+							MatU.Get( i, j ) += T * MatU.Get( i, k ); }
+					for( i = k; i < GetRows( ); ++i )
+						MatU.Get( i, k ) *= -1;
+					MatU.Get( k, k ) += 1;
+					for( i = 0; ( i + 1 ) < k; ++i )
+						MatU.Set( i, k, 0 ); }
+				else {
+					for( i = 0; i < GetRows( ); ++i )
+						MatU.Set( i, k, 0 );
+					MatU.Set( k, k, 1 ); } } }
+
+		// If required, generate V.
+		if( fV ) {
+			for( size_t iTmp = 0; iTmp < GetColumns( ); ++iTmp ) {
+				k = GetColumns( ) - 1 - iTmp;
+				if( ( k < iRT ) && vecE[ k ] )
+					for( j = ( k + 1 ); j < iNU; ++j ) {
+						tType	T;
+
+						T = 0;
+						for( i = ( k + 1 ); i < GetColumns( ); ++i )
+							T += MatV.Get( i, k ) * MatV.Get( i, j );
+						T /= -MatV.Get( k + 1, k );
+						for( i = ( k + 1 ); i < GetColumns( ); ++i )
+							MatV.Get( i, j ) += T * MatV.Get( i, k ); }
+				for( i = 0; i < GetColumns( ); ++i )
+					MatV.Set( i, k, 0 );
+				MatV.Set( k, k, 1 ); } }
+
+		// Main iteration loop for the singular values.
+		iPP = iP - 1;
+		while( iP ) {
+			// Here is where a test for too many iterations would go.
+			// This section of the program inspects for
+			// negligible elements in the s and e arrays.  On
+			// completion the variables kase and k are set as follows.
+			for( iMarker = ( iP - 2 ); iMarker >= 0; --iMarker )
+				if( fabs( vecE[ iMarker ] ) <= ( std::numeric_limits<tType>::epsilon( ) *
+					( fabs( vecS[ iMarker ] ) + fabs( vecS[ iMarker + 1 ] ) ) ) ) {
+					vecE[ iMarker ] = 0;
+					break; }
+			if( iMarker == ( iP - 2 ) )
+				eCase = ESVDConverged;
+			else {
+				int	iKS;
+
+				for( iKS = ( iP - 1 ); iKS > iMarker; --iKS ) {
+					tType	T;
+
+					T = ( ( iKS != iP ) ? fabs( vecE[ iKS ] ) : 0 ) + 
+						( ( iKS != ( iMarker + 1 ) ) ? fabs( vecE[ iKS - 1 ] ) : 0 );
+					if( fabs( vecS[ iKS ] ) <= ( std::numeric_limits<tType>::epsilon( ) * T ) ) {
+						vecS[ iKS ] = 0;
+						break; } }
+				if( iKS == iMarker )
+					eCase = ESVDSmallE;
+				else if( iKS == ( iP - 1 ) )
+					eCase = ESVDSmallSE;
+				else {
+					eCase = ESVDSmallS;
+					iMarker = iKS; } }
+			iMarker++;
+
+		switch( eCase ) {
+			// Deflate negligible s(p).
+			case ESVDSmallSE:
+				F = vecE[ iP - 2 ];
+				vecE[ iP - 2 ] = 0;
+				for( int iTmp = ( iP - 2 ); iTmp >= iMarker; --iTmp ) {
+					tType	T, CS, SN;
+
+					T = Hypotenuse( vecS[ iTmp ], F );
+					CS = vecS[ iTmp ] / T;
+					SN = F / T;
+					vecS[ iTmp ] = T;
+					if( iTmp != iMarker ) {
+						F = -SN * vecE[ iTmp - 1 ];
+						vecE[ iTmp - 1 ] = CS * vecE[ iTmp - 1 ]; }
+					if( fV )
+						for( i = 0; i < GetColumns( ); ++i ) {
+							T = ( CS * MatV.Get( i, iTmp ) ) + ( SN * MatV.Get( i, iP - 1 ) );
+							MatV.Set( i, iP - 1, ( -SN * MatV.Get( i, iTmp ) ) +
+								( CS * MatV.Get( i, iP - 1 ) ) );
+							MatV.Set( i, iTmp, T ); } }
+				break;
+
+			// Split at negligible s(k).
+			case ESVDSmallS:
+				F = vecE[ iMarker - 1 ];
+				vecE[ iMarker - 1 ] = 0;
+				for( j = iMarker; (int)j < iP; ++j ) {
+					tType	T, CS, SN;
+
+					T = Hypotenuse( vecS[ j ], F );
+					CS = vecS[ j ] / T;
+					SN = F / T;
+					vecS[ j ] = T;
+					F = -SN * vecE[ j ];
+					vecE[ j ] *= CS;
+					if( fU )
+						for( i = 0; i < GetRows( ); ++i ) {
+							T = ( CS * MatU.Get( i, j ) ) + ( SN * MatU.Get( i, iMarker - 1 ) );
+							MatU.Set( i, iMarker - 1, ( -SN * MatU.Get( i, j ) ) +
+								( CS * MatU.Get( i, iMarker - 1 ) ) );
+							MatU.Set( i, j, T ); } }
+				break;
+
+			// Perform one qr step.
+			case ESVDSmallE:
+				// Calculate the shift.
+				tType	Scale, SP, SPM1, EPM1, SK, EK, B, C, Shift, G;
+
+				Scale = Max( fabs( vecS[ iP - 1 ] ), fabs( vecS[ iP - 2 ] ), fabs( vecE[ iP - 2 ] ),
+					fabs( vecS[ iMarker ] ), fabs( vecE[ iMarker ] ) );
+				SP = vecS[ iP - 1 ] / Scale;
+				SPM1 = vecS[ iP - 2 ] / Scale;
+				EPM1 = vecE[ iP - 2 ] / Scale;
+				SK = vecS[ iMarker ] / Scale;
+				EK = vecE[ iMarker ] / Scale;
+				B = ( ( ( SPM1 + SP ) * ( SPM1 - SP ) ) + ( EPM1 * EPM1 ) ) / 2;
+				C = SP * SP * EPM1 * EPM1;
+				Shift = 0;
+				if( B || C ) {
+					Shift = sqrt( ( B * B ) + C );
+					if( B < 0 )
+						Shift *= -1;
+					Shift = C / ( B + Shift ); }
+				F = ( ( SK + SP ) * ( SK - SP ) ) + Shift;
+				G = SK * EK;
+
+				// Chase zeros.
+				for( j = iMarker; (int)( j + 1 ) < iP; ++j ) {
+					tType	T, CS, SN;
+
+					T = Hypotenuse( F, G );
+					CS = F / T;
+					SN = G / T;
+					if( j != iMarker )
+						vecE[ j - 1 ] = T;
+					F = ( CS * vecS[ j ] ) + ( SN * vecE[ j ] );
+					vecE[ j ] = ( CS * vecE[ j ] ) - ( SN * vecS[ j ] );
+					G = SN * vecS[ j + 1 ];
+					vecS[ j + 1 ] = CS * vecS[ j + 1 ];
+					if( fV )
+						for( i = 0; i < GetColumns( ); ++i ) {
+							T = ( CS * MatV.Get( i, j ) ) + ( SN * MatV.Get( i, j + 1 ) );
+							MatV.Set( i, j + 1, ( -SN * MatV.Get( i, j ) ) + ( CS * MatV.Get( i, j + 1 ) ) );
+							MatV.Set( i, j, T ); }
+					T = Hypotenuse( F, G );
+					CS = F / T;
+					SN = G / T;
+					vecS[ j ] = T;
+					F = ( CS * vecE[ j ] ) + ( SN * vecS[ j + 1 ] );
+					vecS[ j + 1 ] = ( -SN * vecE[ j ] ) + ( CS * vecS[ j + 1 ] );
+					G = SN * vecE[ j + 1 ];
+					vecE[ j + 1 ] = CS * vecE[ j + 1 ];
+					if( fU && ( ( j + 1 ) < GetRows( ) ) )
+						for( i = 0; i < GetRows( ); ++i ) {
+							T = ( CS * MatU.Get( i, j ) ) + ( SN * MatU.Get( i, j + 1 ) );
+							MatU.Set( i, j + 1, ( -SN * MatU.Get( i, j ) ) + ( CS * MatU.Get( i, j + 1 ) ) );
+							MatU.Set( i, j, T ); } }
+				vecE[ iP - 2 ] = F;
+				break;
+
+			// Convergence.
+			case ESVDConverged:
+				// Make the singular values positive.
+				if( vecS[ iMarker ] < 0 ) {
+					vecS[ iMarker ] = ( vecS[ iMarker ] < 0 ) ? -vecS[ iMarker ] : 0;
+					if( fV )
+						for( i = 0; (int)i <= iPP; ++i )
+							MatV.Get( i, iMarker ) *= -1; }
+
+				// Order the singular values.
+				while( iMarker < iPP ) {
+					tType	T;
+
+					if( vecS[ iMarker ] >= vecS[ iMarker + 1 ] )
+						break;
+					std::swap( vecS[ iMarker ], vecS[ iMarker + 1 ] );
+					if( fV && ( ( iMarker + 1 ) < (int)GetColumns( ) ) )
+						for( i = 0; i < GetColumns( ); ++i ) {
+							T = MatV.Get( i, iMarker + 1 );
+							MatV.Set( i, iMarker + 1, MatV.Get( i, iMarker ) );
+							MatV.Set( i, k, T ); }
+					if( fU && ( ( iMarker + 1 ) < (int)GetRows( ) ) )
+						for( i = 0; i < GetRows( ); ++i ) {
+							T = MatU.Get( i, iMarker + 1 );
+							MatU.Set( i, iMarker + 1, MatU.Get( i, iMarker ) );
+							MatU.Set( i, iMarker, T ); }
+					iMarker++; }
+				iP--;
+				break; } }
+
+		return true; }
+
 private:
 	static const size_t	c_iBuffer	= 131072;
 
+	enum ESVD {
+		ESVDSmallSE,	// s(p) and e[k-1] are negligible and k<p
+		ESVDSmallS,		// s(k) is negligible and k<p
+		ESVDSmallE,		// e[k-1] is negligible, k<p, s(k), ..., s(p) are not negligible (qr step)
+		ESVDConverged	// e(p-1) is negligible (convergence).
+	};
+
+	static tType Max( const tType& A, const tType& B, const tType& C, const tType& D, const tType& E ) {
+
+		return max( A, max( B, max( C, max( D, E ) ) ) ); }
+
+	static tType Hypotenuse( const tType& A, const tType& B ) {
+
+		return sqrt( ( A * A ) + ( B * B ) ); }
+
 	bool OpenBinary( std::istream& istm ) {
 		size_t		i;
 		uint32_t	iSize;
 			iSkip, szSimilarityMeasure, fNormalize, fZScore, fAutocorrelate, szGeneFile ? szGeneFile : "",
 			dCutoff );
 		return 1; }
+	if( !szSimilarityMeasure )
+		return 0;
 
 	CMeasureSigmoid				EuclideanSig( &Euclidean, false, 1.0f / PCL.GetExperiments( ) );
 	IMeasure*					apMeasures[]	= { &Pearson, &EuclideanSig, &KendallsTau,
 						dStd += d * d; }
 				if( iCount ) {
 					dAve /= iCount;
-					dStd = ( ( ( dStd / iCount ) - ( dAve * dAve ) ) <= 0 ) ? 1 : sqrt( dStd );
+					dStd = ( dStd / iCount ) - ( dAve * dAve );
+					dStd = ( dStd <= 0 ) ? 1 : sqrt( dStd );
 					for( j = 0; j < GetGenes( ); ++j )
 						if( !CMeta::IsNaN( d = Get( j, i ) ) )
 							Set( j, i, (float)( ( d - dAve ) / dStd ) ); } }
 		if( ( vecdMissing[ i ] = (float)( GetExperiments( ) - iMissing ) / GetExperiments( ) ) >=
 			dMinimumPresent )
 			veciMissing.push_back( i ); }
-	vecsNeighbors.resize( veciMissing.size( ) );
-	for( i = 0; i < vecsNeighbors.size( ); ++i )
-		vecsNeighbors[ i ].Initialize( Get( veciMissing[ i ] ), GetExperiments( ), iNeighbors );
-	for( i = 0; i < veciMissing.size( ); ++i ) {
-		if( !( i % 100 ) )
-			g_CatSleipnir.info( "CPCL::Impute( %d, %g ) finding neighbors for gene %d/%d", iNeighbors,
-				dMinimumPresent, i, veciMissing.size( ) );
-		ad = Get( iOne = veciMissing[ i ] );
-		for( j = ( i + 1 ); j < veciMissing.size( ); ++j ) {
-			d = DatSimilarity.Get( iOne, iTwo = veciMissing[ j ] );
-			vecsNeighbors[ i ].Add( iTwo, d, Get( iTwo ) );
-			vecsNeighbors[ j ].Add( iOne, d, ad ); } }
+	if( iNeighbors ) {
+		vecsNeighbors.resize( veciMissing.size( ) );
+		for( i = 0; i < vecsNeighbors.size( ); ++i )
+			vecsNeighbors[ i ].Initialize( Get( veciMissing[ i ] ), GetExperiments( ), iNeighbors );
+		for( i = 0; i < veciMissing.size( ); ++i ) {
+			if( !( i % 100 ) )
+				g_CatSleipnir.info( "CPCL::Impute( %d, %g ) finding neighbors for gene %d/%d", iNeighbors,
+					dMinimumPresent, i, veciMissing.size( ) );
+			ad = Get( iOne = veciMissing[ i ] );
+			for( j = ( i + 1 ); j < veciMissing.size( ); ++j ) {
+				d = DatSimilarity.Get( iOne, iTwo = veciMissing[ j ] );
+				vecsNeighbors[ i ].Add( iTwo, d, Get( iTwo ) );
+				vecsNeighbors[ j ].Add( iOne, d, ad ); } } }
 
 	for( iOne = i = 0; i < GetGenes( ); ++i ) {
 		if( vecdMissing[ i ] < dMinimumPresent ) {
 
 	/*!
 	 * \brief
+	 * Set a single gene's row in the PCL.
+	 * 
+	 * \param iGene
+	 * PCL row.
+	 * 
+	 * \param adValues
+	 * Values to which row is set.
+	 * 
+	 * \remarks
+	 * For efficiency, no bounds checking is performed.  The given index must be smaller than GetGenes.
+	 * The given array must contain a number of elements equal to GetExperiments.
+	 * 
+	 * \see
+	 * Get
+	 */
+	void Set( size_t iGene, const float* adValues ) {
+
+		m_Data.Set( iGene, adValues ); }
+
+	/*!
+	 * \brief
 	 * Return the PCL's underlying data matrix.
 	 * 
 	 * \returns
 #ifndef PCLI_H
 #define PCLI_H
 
+#include <map>
 #include <set>
 #include <vector>
 

File src/statistics.h

 		double	d, dRet;
 		size_t	iN;
 
-		for( dRet = 0,CurOne = BeginOne,CurTwo = BeginTwo; ( CurOne < EndOne ) && ( CurTwo < EndTwo );
+		for( dRet = 0,CurOne = BeginOne,CurTwo = BeginTwo; ( CurOne != EndOne ) && ( CurTwo != EndTwo );
 			++CurOne,++CurTwo ) {
 			d = *CurOne - *CurTwo;
 			dRet += d * d; }
 
 		return ( iN ? sqrt( dRet / iN ) : 0 ); }
 
+	template<class tType>
+	static double JensenShannonDivergence( tType BeginOne, tType EndOne, tType BeginTwo, tType EndTwo ) {
+
+		return ( ( KullbackLeiblerDivergence( BeginOne, EndOne, BeginTwo, EndTwo ) +
+			KullbackLeiblerDivergence( BeginTwo, EndTwo, BeginOne, EndOne ) ) / 2 ); }
+
+	template<class tType>
+	static double KullbackLeiblerDivergence( tType BeginOne, tType EndOne, tType BeginTwo, tType EndTwo ) {
+		double	dRet;
+		tType	CurOne, CurTwo;
+
+		if( ( EndOne - BeginOne ) != ( EndTwo - BeginTwo ) )
+			return CMeta::GetNaN( );
+
+		for( dRet = 0,CurOne = BeginOne,CurTwo = BeginTwo; ( CurOne != EndOne ) && ( CurTwo != EndTwo );
+			++CurOne,++CurTwo )
+			dRet += *CurOne * log( *CurOne / *CurTwo );
+
+		return ( dRet / log( 2.0 ) ); }
+
 	// P-value tests
 	static double LjungBox( const float* adX, size_t iN, size_t iH );
 

File tools/Answerer/Answerer.cpp

 		if( !DatPositives.Open( sArgs.input_arg, true ) ) {
 			cerr << "Could not open: " << sArgs.input_arg << endl;
 			return 1; }
+		for( i = 0; i < DatPositives.GetGenes( ); ++i )
+			Genome.AddGene( DatPositives.GetGene( i ) );
 		if( !Dat.Open( DatPositives, vecpNegatives, Genome, true ) ) {
 			cerr << "Could not open " << sArgs.input_arg << " with negatives" << endl;
 			return 1; } }

File tools/COALESCE/COALESCE.cpp

 	EFileError
 };
 
+const char*					c_aszMatchTypes[]	= {"pvalue", "rmse", "js", NULL};
+const SMotifMatch::EType	c_aeMatchTypes[]	=
+	{SMotifMatch::ETypePValue, SMotifMatch::ETypeRMSE, SMotifMatch::ETypeJensenShannon, SMotifMatch::ETypePValue};
+
 int main_postprocess( const gengetopt_args_info&, CCoalesceMotifLibrary& );
 bool recluster( const gengetopt_args_info&, size_t, CCoalesceMotifLibrary&, const CHierarchy&,
 	const vector<CCoalesceCluster>&, const vector<string>&, const CPCL&, size_t& );
 bool recluster( const gengetopt_args_info& sArgs, size_t iPairs, CCoalesceMotifLibrary& Motifs,
 	const CHierarchy& Hier, const vector<CCoalesceCluster>& vecClustersFrom,
 	const vector<string>& vecstrClustersFrom, const CPCL& PCL, size_t& iID ) {
+	SMotifMatch::EType	eMatchType;
+	size_t				i;
+
+	for( i = 0; c_aszMatchTypes[ i ]; ++i )
+		if( !strcmp( c_aszMatchTypes[ i ], sArgs.known_type_arg ) )
+			break;
+	eMatchType = c_aeMatchTypes[ i ];
 
 	if( Hier.IsGene( ) || ( Hier.GetSimilarity( ) >= sArgs.cutoff_postprocess_arg ) ) {
 		CCoalesceCluster	Cluster;
 			cerr << "Cluster too small: " << Cluster.GetGenes( ).size( ) << endl;
 			return true; }
 
-		if( !Cluster.LabelMotifs( Motifs, (float)sArgs.penalty_gap_arg, (float)sArgs.penalty_mismatch_arg,
-			(float)sArgs.known_cutoff_arg ) )
+		if( !Cluster.LabelMotifs( Motifs, eMatchType, (float)sArgs.penalty_gap_arg,
+			(float)sArgs.penalty_mismatch_arg, (float)sArgs.known_cutoff_arg ) )
 			return false;
 		if( sArgs.output_arg )
 			Cluster.Save( sArgs.output_arg, iID, PCL, &Motifs );

File tools/COALESCE/COALESCE.ggo

 							string	typestr="directory"
 option	"known_motifs"	K	"File containing known motifs"
 							string	typestr="filename"
-option	"known_cutoff"	F	"P-value cutoff for known motif labeling"
+option	"known_cutoff"	F	"Score cutoff for known motif labeling"
 							double	default="0.05"
+option	"known_type"	S	"Type of known motif matching"
+							values="pvalue","rmse","js"	default="pvalue"
 option	"cutoff_postprocess"	J	"Similarity cutoff for cluster merging"
 							double	default="1"
 option	"fraction_postprocess"	L	"Overlap fraction for postprocessing gene/condition inclusion"

File tools/KNNImputer/KNNImputer.cpp

 		return 1; }
 	CMeta Meta( sArgs.verbosity_arg );
 
-	if( iRet = CPCL::Distance( sArgs.input_arg, sArgs.skip_arg, sArgs.distance_arg, false, false,
-		!!sArgs.autocorrelate_flag, sArgs.genes_arg, CMeta::GetNaN( ), sArgs.limit_arg, PCL, Dat ) ) {
+	if( iRet = CPCL::Distance( sArgs.input_arg, sArgs.skip_arg, sArgs.neighbors_arg ? sArgs.distance_arg : NULL,
+		false, false, !!sArgs.autocorrelate_flag, sArgs.genes_arg, CMeta::GetNaN( ), sArgs.limit_arg, PCL,
+		Dat ) ) {
 		cmdline_parser_print_help( );
 		return iRet; }
 

File tools/Normalizer/Normalizer.cpp

 		if( sArgs.input_arg )
 			ifsm.close( );
 
-		PCL.Normalize( );
+		PCL.Normalize( sArgs.zscore_flag ? CPCL::ENormalizeColumn : CPCL::ENormalizeRow );
 		if( sArgs.output_arg ) {
 			ofsm.open( sArgs.output_arg );
 			postm = &ofsm; }

File tools/SVDer/SVDer.cpp

+/*****************************************************************************
+* This file is provided under the Creative Commons Attribution 3.0 license.
+*
+* You are free to share, copy, distribute, transmit, or adapt this work
+* PROVIDED THAT you attribute the work to the authors listed below.
+* For more information, please see the following web page:
+* http://creativecommons.org/licenses/by/3.0/
+*
+* This file is a component of the Sleipnir library for functional genomics,
+* authored by:
+* Curtis Huttenhower (chuttenh@princeton.edu)
+* Mark Schroeder
+* Maria D. Chikina
+* Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
+*
+* If you use this library, the included executable tools, or any related
+* code in your work, please cite the following publication:
+* Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
+* Olga G. Troyanskaya.
+* "The Sleipnir library for computational functional genomics"
+*****************************************************************************/
+#include "stdafx.h"
+#include "cmdline.h"
+
+int main( int iArgs, char** aszArgs ) {
+	gengetopt_args_info	sArgs;
+	CPCL				PCLIn, PCLOut;
+	CDataMatrix			MatU, MatV;
+	vector<float>		vecdS;
+	size_t				i, iNonzero;
+	float				dSum, dCur;
+
+	if( cmdline_parser( iArgs, aszArgs, &sArgs ) ) {
+		cmdline_parser_print_help( );
+		return 1; }
+	CMeta Meta( sArgs.verbosity_arg );
+
+	if( !PCLIn.Open( sArgs.input_arg, sArgs.skip_arg ) ) {
+		cerr << "Could not open: " << ( sArgs.input_arg ? sArgs.input_arg : "stdin" ) << endl;
+		return 1; }
+	PCLIn.Get( ).SVD( MatU, MatV, vecdS );
+
+	PCLOut.Open( PCLIn );
+	if( sArgs.umatrix_arg ) {
+		for( i = 0; i < PCLOut.GetGenes( ); ++i )
+			PCLOut.Set( i, MatU.Get( i ) );
+		PCLOut.Save( sArgs.umatrix_arg ); }
+
+	for( dSum = 0,i = 0; i < vecdS.size( ); ++i )
+		dSum += vecdS[ i ];
+	for( dCur = 0,i = 0; i < vecdS.size( ); ++i )
+		if( ( dCur += ( vecdS[ i ] / dSum ) ) > sArgs.reprojection_arg )
+			break;
+	i++;
+	iNonzero = min( vecdS.size( ), i );
+	for( ; i < vecdS.size( ); ++i ) {
+		dSum -= vecdS[ i ];
+		vecdS[ i ] = 0; }
+	if( sArgs.signal_balance_flag ) {
+		dSum /= iNonzero;
+		fill( vecdS.begin( ), vecdS.end( ), dSum ); }
+	else {
+		for( dCur = 0,i = 0; i < iNonzero; ++i )
+			dCur += ( vecdS[ i ] = pow( vecdS[ i ] / dSum, (float)sArgs.transform_arg ) );
+		for( i = 0; i < iNonzero; ++i )
+			vecdS[ i ] *= dSum / dCur; }
+
+	MatU.Multiply( vecdS );
+	MatU.Multiply( MatV, true );
+	for( i = 0; i < PCLOut.GetGenes( ); ++i )
+		PCLOut.Set( i, MatU.Get( i ) );
+	PCLOut.Save( sArgs.output_arg );
+
+	return 0; }

File tools/SVDer/SVDer.ggo

+package	"SVDer"
+version	"1.0"
+purpose	"Transforms PCL data through Support Vector Decomposition"
+
+section "Main"
+option	"input"			i	"Input PCL file"
+							string	typestr="filename"
+option	"output"		o	"Output PCL file"
+							string	typestr="filename"
+option	"umatrix"		u	"Output U matrix PCL file"
+							string	typestr="filename"
+
+section "SVD"
+option	"reprojection"	r	"Fraction of variance to reproject"
+							double	default="1"
+option	"transform"		t	"Transformation function parameter"
+							double	default="1"
+option	"signal_balance"	b	"Equally weight all SVs"
+							flag	off
+
+section "Optional"
+option	"skip"			s	"Columns to skip in input PCL"
+							int	default="2"
+option	"verbosity"		v	"Message verbosity"
+							int	default="5"

File tools/SVDer/cmdline.c

+/*
+  File autogenerated by gengetopt version 2.22
+  generated with the following command:
+  ..\..\..\..\extlib\proj\vs2008\release\gengetopt.exe --default-optional -N -e --output-dir=c:\Documents and Settings\eblis\My Documents\Visual Studio 2008\Projects\Sleipnir\trunk\tools\SVDer\ -i ..\..\..\tools\SVDer\SVDer.ggo 
+
+  The developers of gengetopt consider the fixed text that goes in all
+  gengetopt output files to be in the public domain:
+  we make no copyright claims on it.
+*/
+
+/* If we use autoconf.  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "getopt.h"
+
+#include "cmdline.h"
+
+const char *gengetopt_args_info_purpose = "Transforms PCL data through Support Vector Decomposition";
+
+const char *gengetopt_args_info_usage = "Usage: SVDer [OPTIONS]...";
+
+const char *gengetopt_args_info_description = "";
+
+const char *gengetopt_args_info_help[] = {
+  "  -h, --help                 Print help and exit",
+  "  -V, --version              Print version and exit",
+  "\nMain:",
+  "  -i, --input=filename       Input PCL file",
+  "  -o, --output=filename      Output PCL file",
+  "  -u, --umatrix=filename     Output U matrix PCL file",
+  "\nSVD:",
+  "  -r, --reprojection=DOUBLE  Fraction of variance to reproject  (default=`1')",
+  "  -t, --transform=DOUBLE     Transformation function parameter  (default=`1')",
+  "  -b, --signal_balance       Equally weight all SVs  (default=off)",
+  "\nOptional:",
+  "  -s, --skip=INT             Columns to skip in input PCL  (default=`2')",
+  "  -v, --verbosity=INT        Message verbosity  (default=`5')",
+    0
+};
+
+typedef enum {ARG_NO
+  , ARG_FLAG
+  , ARG_STRING
+  , ARG_INT
+  , ARG_DOUBLE
+} cmdline_parser_arg_type;
+
+static
+void clear_given (struct gengetopt_args_info *args_info);
+static
+void clear_args (struct gengetopt_args_info *args_info);
+
+static int
+cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+                        struct cmdline_parser_params *params, const char *additional_error);
+
+
+static char *
+gengetopt_strdup (const char *s);
+
+static
+void clear_given (struct gengetopt_args_info *args_info)
+{
+  args_info->help_given = 0 ;
+  args_info->version_given = 0 ;
+  args_info->input_given = 0 ;
+  args_info->output_given = 0 ;
+  args_info->umatrix_given = 0 ;
+  args_info->reprojection_given = 0 ;
+  args_info->transform_given = 0 ;
+  args_info->signal_balance_given = 0 ;
+  args_info->skip_given = 0 ;
+  args_info->verbosity_given = 0 ;
+}
+
+static
+void clear_args (struct gengetopt_args_info *args_info)
+{
+  args_info->input_arg = NULL;
+  args_info->input_orig = NULL;
+  args_info->output_arg = NULL;
+  args_info->output_orig = NULL;
+  args_info->umatrix_arg = NULL;
+  args_info->umatrix_orig = NULL;
+  args_info->reprojection_arg = 1;
+  args_info->reprojection_orig = NULL;
+  args_info->transform_arg = 1;
+  args_info->transform_orig = NULL;
+  args_info->signal_balance_flag = 0;
+  args_info->skip_arg = 2;
+  args_info->skip_orig = NULL;
+  args_info->verbosity_arg = 5;
+  args_info->verbosity_orig = NULL;
+  
+}
+
+static
+void init_args_info(struct gengetopt_args_info *args_info)
+{
+
+
+  args_info->help_help = gengetopt_args_info_help[0] ;
+  args_info->version_help = gengetopt_args_info_help[1] ;
+  args_info->input_help = gengetopt_args_info_help[3] ;
+  args_info->output_help = gengetopt_args_info_help[4] ;
+  args_info->umatrix_help = gengetopt_args_info_help[5] ;
+  args_info->reprojection_help = gengetopt_args_info_help[7] ;
+  args_info->transform_help = gengetopt_args_info_help[8] ;
+  args_info->signal_balance_help = gengetopt_args_info_help[9] ;
+  args_info->skip_help = gengetopt_args_info_help[11] ;
+  args_info->verbosity_help = gengetopt_args_info_help[12] ;
+  
+}
+
+void
+cmdline_parser_print_version (void)
+{
+  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
+}
+
+static void print_help_common(void) {
+  cmdline_parser_print_version ();
+
+  if (strlen(gengetopt_args_info_purpose) > 0)
+    printf("\n%s\n", gengetopt_args_info_purpose);
+
+  if (strlen(gengetopt_args_info_usage) > 0)
+    printf("\n%s\n", gengetopt_args_info_usage);
+
+  printf("\n");
+
+  if (strlen(gengetopt_args_info_description) > 0)
+    printf("%s\n", gengetopt_args_info_description);
+}
+
+void
+cmdline_parser_print_help (void)
+{
+  int i = 0;
+  print_help_common();
+  while (gengetopt_args_info_help[i])
+    printf("%s\n", gengetopt_args_info_help[i++]);
+}
+
+void
+cmdline_parser_init (struct gengetopt_args_info *args_info)
+{
+  clear_given (args_info);
+  clear_args (args_info);
+  init_args_info (args_info);
+}
+
+void
+cmdline_parser_params_init(struct cmdline_parser_params *params)
+{
+  if (params)
+    { 
+      params->override = 0;
+      params->initialize = 1;
+      params->check_required = 1;
+      params->check_ambiguity = 0;
+      params->print_errors = 1;
+    }
+}
+
+struct cmdline_parser_params *
+cmdline_parser_params_create(void)
+{
+  struct cmdline_parser_params *params = 
+    (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
+  cmdline_parser_params_init(params);  
+  return params;
+}
+
+static void
+free_string_field (char **s)
+{
+  if (*s)
+    {
+      free (*s);
+      *s = 0;
+    }
+}
+
+
+static void
+cmdline_parser_release (struct gengetopt_args_info *args_info)
+{
+
+  free_string_field (&(args_info->input_arg));
+  free_string_field (&(args_info->input_orig));
+  free_string_field (&(args_info->output_arg));
+  free_string_field (&(args_info->output_orig));
+  free_string_field (&(args_info->umatrix_arg));
+  free_string_field (&(args_info->umatrix_orig));
+  free_string_field (&(args_info->reprojection_orig));
+  free_string_field (&(args_info->transform_orig));
+  free_string_field (&(args_info->skip_orig));
+  free_string_field (&(args_info->verbosity_orig));
+  
+  
+
+  clear_given (args_info);
+}
+
+
+static void
+write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
+{
+  if (arg) {
+    fprintf(outfile, "%s=\"%s\"\n", opt, arg);
+  } else {
+    fprintf(outfile, "%s\n", opt);
+  }
+}
+
+
+int
+cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
+{
+  int i = 0;
+
+  if (!outfile)
+    {
+      fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
+      return EXIT_FAILURE;
+    }
+
+  if (args_info->help_given)
+    write_into_file(outfile, "help", 0, 0 );
+  if (args_info->version_given)
+    write_into_file(outfile, "version", 0, 0 );
+  if (args_info->input_given)
+    write_into_file(outfile, "input", args_info->input_orig, 0);
+  if (args_info->output_given)
+    write_into_file(outfile, "output", args_info->output_orig, 0);
+  if (args_info->umatrix_given)
+    write_into_file(outfile, "umatrix", args_info->umatrix_orig, 0);
+  if (args_info->reprojection_given)
+    write_into_file(outfile, "reprojection", args_info->reprojection_orig, 0);
+  if (args_info->transform_given)
+    write_into_file(outfile, "transform", args_info->transform_orig, 0);
+  if (args_info->signal_balance_given)
+    write_into_file(outfile, "signal_balance", 0, 0 );
+  if (args_info->skip_given)
+    write_into_file(outfile, "skip", args_info->skip_orig, 0);
+  if (args_info->verbosity_given)
+    write_into_file(outfile, "verbosity", args_info->verbosity_orig, 0);
+  
+
+  i = EXIT_SUCCESS;
+  return i;
+}
+
+int
+cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
+{
+  FILE *outfile;
+  int i = 0;
+
+  outfile = fopen(filename, "w");
+
+  if (!outfile)
+    {
+      fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
+      return EXIT_FAILURE;
+    }
+
+  i = cmdline_parser_dump(outfile, args_info);
+  fclose (outfile);
+
+  return i;
+}
+
+void
+cmdline_parser_free (struct gengetopt_args_info *args_info)
+{
+  cmdline_parser_release (args_info);
+}
+
+/** @brief replacement of strdup, which is not standard */
+char *
+gengetopt_strdup (const char *s)
+{
+  char *result = NULL;
+  if (!s)
+    return result;
+
+  result = (char*)malloc(strlen(s) + 1);
+  if (result == (char*)0)
+    return (char*)0;
+  strcpy(result, s);
+  return result;
+}
+
+int
+cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
+{
+  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
+}
+
+int
+cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+                   struct cmdline_parser_params *params)
+{
+  int result;
+  result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
+
+  return result;
+}
+
+int
+cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
+{
+  int result;
+  struct cmdline_parser_params params;
+  
+  params.override = override;
+  params.initialize = initialize;
+  params.check_required = check_required;
+  params.check_ambiguity = 0;
+  params.print_errors = 1;
+
+  result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
+
+  return result;
+}
+
+int
+cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
+{
+  return EXIT_SUCCESS;
+}
+
+
+static char *package_name = 0;
+
+/**
+ * @brief updates an option
+ * @param field the generic pointer to the field to update
+ * @param orig_field the pointer to the orig field
+ * @param field_given the pointer to the number of occurrence of this option
+ * @param prev_given the pointer to the number of occurrence already seen
+ * @param value the argument for this option (if null no arg was specified)
+ * @param possible_values the possible values for this option (if specified)
+ * @param default_value the default value (in case the option only accepts fixed values)
+ * @param arg_type the type of this option
+ * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
+ * @param override @see cmdline_parser_params.override
+ * @param no_free whether to free a possible previous value
+ * @param multiple_option whether this is a multiple option
+ * @param long_opt the corresponding long option
+ * @param short_opt the corresponding short option (or '-' if none)
+ * @param additional_error possible further error specification
+ */
+static
+int update_arg(void *field, char **orig_field,
+               unsigned int *field_given, unsigned int *prev_given, 
+               char *value, char *possible_values[], const char *default_value,
+               cmdline_parser_arg_type arg_type,
+               int check_ambiguity, int override,
+               int no_free, int multiple_option,
+               const char *long_opt, char short_opt,
+               const char *additional_error)
+{
+  char *stop_char = 0;
+  const char *val = value;
+  int found;
+  char **string_field;
+
+  stop_char = 0;
+  found = 0;
+
+  if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
+    {
+      if (short_opt != '-')
+        fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", 
+               package_name, long_opt, short_opt,
+               (additional_error ? additional_error : ""));
+      else
+        fprintf (stderr, "%s: `--%s' option given more than once%s\n", 
+               package_name, long_opt,
+               (additional_error ? additional_error : ""));
+      return 1; /* failure */
+    }
+
+    
+  if (field_given && *field_given && ! override)
+    return 0;
+  if (prev_given)
+    (*prev_given)++;
+  if (field_given)
+    (*field_given)++;
+  if (possible_values)
+    val = possible_values[found];
+
+  switch(arg_type) {
+  case ARG_FLAG:
+    *((int *)field) = !*((int *)field);
+    break;
+  case ARG_INT:
+    if (val) *((int *)field) = strtol (val, &stop_char, 0);
+    break;
+  case ARG_DOUBLE:
+    if (val) *((double *)field) = strtod (val, &stop_char);
+    break;
+  case ARG_STRING:
+    if (val) {
+      string_field = (char **)field;
+      if (!no_free && *string_field)
+        free (*string_field); /* free previous string */
+      *string_field = gengetopt_strdup (val);
+    }
+    break;
+  default:
+    break;
+  };
+
+  /* check numeric conversion */
+  switch(arg_type) {
+  case ARG_INT:
+  case ARG_DOUBLE:
+    if (val && !(stop_char && *stop_char == '\0')) {
+      fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
+      return 1; /* failure */
+    }
+    break;
+  default:
+    ;
+  };
+
+  /* store the original value */
+  switch(arg_type) {
+  case ARG_NO:
+  case ARG_FLAG:
+    break;
+  default:
+    if (value && orig_field) {
+      if (no_free) {
+        *orig_field = value;
+      } else {
+        if (*orig_field)
+          free (*orig_field); /* free previous string */
+        *orig_field = gengetopt_strdup (value);
+      }
+    }
+  };
+
+  return 0; /* OK */
+}
+
+
+int
+cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+                        struct cmdline_parser_params *params, const char *additional_error)
+{
+  int c;	/* Character of the parsed option.  */
+
+  int error = 0;
+  struct gengetopt_args_info local_args_info;
+  
+  int override;
+  int initialize;
+  int check_required;
+  int check_ambiguity;
+  
+  package_name = argv[0];
+  
+  override = params->override;
+  initialize = params->initialize;
+  check_required = params->check_required;
+  check_ambiguity = params->check_ambiguity;
+
+  if (initialize)
+    cmdline_parser_init (args_info);
+
+  cmdline_parser_init (&local_args_info);
+
+  optarg = 0;
+  optind = 0;
+  opterr = params->print_errors;
+  optopt = '?';
+
+  while (1)
+    {
+      int option_index = 0;
+
+      static struct option long_options[] = {
+        { "help",	0, NULL, 'h' },
+        { "version",	0, NULL, 'V' },
+        { "input",	1, NULL, 'i' },
+        { "output",	1, NULL, 'o' },
+        { "umatrix",	1, NULL, 'u' },
+        { "reprojection",	1, NULL, 'r' },
+        { "transform",	1, NULL, 't' },
+        { "signal_balance",	0, NULL, 'b' },
+        { "skip",	1, NULL, 's' },
+        { "verbosity",	1, NULL, 'v' },
+        { NULL,	0, NULL, 0 }
+      };
+
+      c = getopt_long (argc, argv, "hVi:o:u:r:t:bs:v:", 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.  */
+        
+        
+          if (update_arg( 0 , 
+               0 , &(args_info->version_given),
+              &(local_args_info.version_given), optarg, 0, 0, ARG_NO,
+              check_ambiguity, override, 0, 0,
+              "version", 'V',
+              additional_error))
+            goto failure;
+          cmdline_parser_free (&local_args_info);
+          return 0;
+        
+          break;
+        case 'i':	/* Input PCL file.  */
+        
+        
+          if (update_arg( (void *)&(args_info->input_arg), 
+               &(args_info->input_orig), &(args_info->input_given),
+              &(local_args_info.input_given), optarg, 0, 0, ARG_STRING,
+              check_ambiguity, override, 0, 0,
+              "input", 'i',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'o':	/* Output PCL file.  */
+        
+        
+          if (update_arg( (void *)&(args_info->output_arg), 
+               &(args_info->output_orig), &(args_info->output_given),
+              &(local_args_info.output_given), optarg, 0, 0, ARG_STRING,
+              check_ambiguity, override, 0, 0,
+              "output", 'o',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'u':	/* Output U matrix PCL file.  */
+        
+        
+          if (update_arg( (void *)&(args_info->umatrix_arg), 
+               &(args_info->umatrix_orig), &(args_info->umatrix_given),
+              &(local_args_info.umatrix_given), optarg, 0, 0, ARG_STRING,
+              check_ambiguity, override, 0, 0,
+              "umatrix", 'u',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'r':	/* Fraction of variance to reproject.  */
+        
+        
+          if (update_arg( (void *)&(args_info->reprojection_arg), 
+               &(args_info->reprojection_orig), &(args_info->reprojection_given),
+              &(local_args_info.reprojection_given), optarg, 0, "1", ARG_DOUBLE,
+              check_ambiguity, override, 0, 0,
+              "reprojection", 'r',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 't':	/* Transformation function parameter.  */
+        
+        
+          if (update_arg( (void *)&(args_info->transform_arg), 
+               &(args_info->transform_orig), &(args_info->transform_given),
+              &(local_args_info.transform_given), optarg, 0, "1", ARG_DOUBLE,
+              check_ambiguity, override, 0, 0,
+              "transform", 't',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'b':	/* Equally weight all SVs.  */
+        
+        
+          if (update_arg((void *)&(args_info->signal_balance_flag), 0, &(args_info->signal_balance_given),
+              &(local_args_info.signal_balance_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "signal_balance", 'b',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 's':	/* Columns to skip in input PCL.  */
+        
+        
+          if (update_arg( (void *)&(args_info->skip_arg), 
+               &(args_info->skip_orig), &(args_info->skip_given),
+              &(local_args_info.skip_given), optarg, 0, "2", ARG_INT,
+              check_ambiguity, override, 0, 0,
+              "skip", 's',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'v':	/* Message verbosity.  */
+        
+        
+          if (update_arg( (void *)&(args_info->verbosity_arg), 
+               &(args_info->verbosity_orig), &(args_info->verbosity_given),
+              &(local_args_info.verbosity_given), optarg, 0, "5", ARG_INT,
+              check_ambiguity, override, 0, 0,
+              "verbosity", 'v',
+              additional_error))
+            goto failure;
+        
+          break;
+
+        case 0:	/* Long option with no short option */
+        case '?':	/* Invalid option.  */
+          /* `getopt_long' already printed an error message.  */
+          goto failure;
+
+        default:	/* bug: option not considered.  */
+          fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
+          abort ();
+        } /* switch */
+    } /* while */
+
+
+
+
+  cmdline_parser_release (&local_args_info);
+
+  if ( error )
+    return (EXIT_FAILURE);
+
+  return 0;
+
+failure:
+  
+  cmdline_parser_release (&local_args_info);
+  return (EXIT_FAILURE);
+}

File tools/SVDer/stdafx.cpp

+/*****************************************************************************
+* This file is provided under the Creative Commons Attribution 3.0 license.
+*
+* You are free to share, copy, distribute, transmit, or adapt this work
+* PROVIDED THAT you attribute the work to the authors listed below.
+* For more information, please see the following web page:
+* http://creativecommons.org/licenses/by/3.0/
+*
+* This file is a component of the Sleipnir library for functional genomics,
+* authored by:
+* Curtis Huttenhower (chuttenh@princeton.edu)
+* Mark Schroeder
+* Maria D. Chikina
+* Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
+*
+* If you use this library, the included executable tools, or any related
+* code in your work, please cite the following publication:
+* Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
+* Olga G. Troyanskaya.
+* "The Sleipnir library for computational functional genomics"
+*****************************************************************************/
+#include "stdafx.h"

File tools/SVDer/stdafx.h

+/*****************************************************************************
+* This file is provided under the Creative Commons Attribution 3.0 license.
+*
+* You are free to share, copy, distribute, transmit, or adapt this work
+* PROVIDED THAT you attribute the work to the authors listed below.
+* For more information, please see the following web page:
+* http://creativecommons.org/licenses/by/3.0/
+*
+* This file is a component of the Sleipnir library for functional genomics,
+* authored by:
+* Curtis Huttenhower (chuttenh@princeton.edu)
+* Mark Schroeder
+* Maria D. Chikina
+* Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
+*
+* If you use this library, the included executable tools, or any related
+* code in your work, please cite the following publication:
+* Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
+* Olga G. Troyanskaya.
+* "The Sleipnir library for computational functional genomics"
+*****************************************************************************/
+#ifndef STDAFX_H
+#define STDAFX_H
+
+#include <fstream>
+using namespace std;
+
+#include "meta.h"
+#include "pcl.h"
+using namespace Sleipnir;
+
+#endif // STDAFX_H