Sleipnir
src/clusthierarchical.h
00001 /*****************************************************************************
00002 * This file is provided under the Creative Commons Attribution 3.0 license.
00003 *
00004 * You are free to share, copy, distribute, transmit, or adapt this work
00005 * PROVIDED THAT you attribute the work to the authors listed below.
00006 * For more information, please see the following web page:
00007 * http://creativecommons.org/licenses/by/3.0/
00008 *
00009 * This file is a component of the Sleipnir library for functional genomics,
00010 * authored by:
00011 * Curtis Huttenhower (chuttenh@princeton.edu)
00012 * Mark Schroeder
00013 * Maria D. Chikina
00014 * Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
00015 *
00016 * If you use this library, the included executable tools, or any related
00017 * code in your work, please cite the following publication:
00018 * Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
00019 * Olga G. Troyanskaya.
00020 * "The Sleipnir library for computational functional genomics"
00021 *****************************************************************************/
00022 #ifndef CLUSHIERARCHICAL_H
00023 #define CLUSHIERARCHICAL_H
00024 
00025 #include "clusthierarchicali.h"
00026 
00027 namespace Sleipnir {
00028 
00029 class CPCL;
00030 class IMeasure;
00031 
00041 class CHierarchy : public CHierarchyImpl {
00042 public:
00043     CHierarchy( size_t iID, float dSimilarity, const CHierarchy* pLeft, const CHierarchy* pRight );
00044 
00045     void GetGenes( std::vector<size_t>& veciGenes ) const;
00046     float SortChildren( const std::vector<float>& vecdScores );
00047 
00066     void Save( std::ostream& ostm, size_t iGenes,
00067         const std::vector<std::string>* pvecstrGenes = NULL ) const {
00068         size_t  i;
00069 
00070         for( i = 0; ( i + 1 ) < iGenes; ++i )
00071             CHierarchyImpl::Save( ostm, i, pvecstrGenes ); }
00072 
00080     void Destroy( ) {
00081 
00082         delete this; }
00083 
00091     float GetSimilarity( ) const {
00092 
00093         return m_dScore; }
00094 
00102     bool IsGene( ) const {
00103 
00104         return CHierarchyImpl::IsGene( ); }
00105 
00117     size_t GetID( ) const {
00118 
00119         return m_iID; }
00120 
00137     const CHierarchy& Get( bool fRight ) const {
00138 
00139         return *( fRight ? m_pRight : m_pLeft ); }
00140 
00148     size_t GetWeight( ) const {
00149 
00150         return m_iWeight; }
00151 };
00152 
00157 class CClustHierarchical : CClustHierarchicalImpl {
00158 public:
00159     static CHierarchy* Cluster( const CDistanceMatrix& MatSimilarities );
00160     static CHierarchy* Cluster( const CDistanceMatrix& MatSimilarities,
00161         const std::vector<bool>& vecfIncluded );
00162 };
00163 
00164 }
00165 
00166 #endif // CLUSHIERARCHICAL_H