Sleipnir
src/fasta.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 FASTA_H
00023 #define FASTA_H
00024 
00025 #include "fastai.h"
00026 
00027 namespace Sleipnir {
00028 
00074 class CFASTA : CFASTAImpl {
00075 public:
00076     bool Open( const char* szFile, const std::set<std::string>& setstrTypes );
00077     void Save( std::ostream& ostm, size_t iWrap = 80 ) const;
00078 
00099     bool Get( size_t iGene, std::vector<SFASTASequence>& vecsSequences ) const {
00100 
00101         return CFASTAImpl::Get( iGene, &vecsSequences, NULL ); }
00102 
00123     bool Get( size_t iGene, std::vector<SFASTAWiggle>& vecsValues ) const {
00124 
00125         return CFASTAImpl::Get( iGene, NULL, &vecsValues ); }
00126 
00145     bool Open( const char* szFile ) {
00146         std::set<std::string>   setstrDummy;
00147 
00148         return Open( szFile, setstrDummy ); }
00149 
00157     size_t GetGenes( ) const {
00158 
00159         return m_vecstrGenes.size( ); }
00160 
00171     const std::string& GetGene( size_t iGene ) const {
00172 
00173         return CFASTAImpl::GetGene( iGene ); }
00174 
00185     size_t GetGene( const std::string& strGene ) const {
00186         TMapStrI::const_iterator    iterGene;
00187 
00188         return ( ( ( iterGene = m_mapstriGenes.find( strGene ) ) == m_mapstriGenes.end( ) ) ? -1 :
00189             iterGene->second ); }
00190 
00207     const std::string GetHeader( size_t iGene, const std::string& strType ) const {
00208         const TMapStrStr&           mapstrstrHeaders    = m_vecmapstrstrHeaders[ iGene ];
00209         TMapStrStr::const_iterator  iterGene;
00210 
00211         return ( ( ( iterGene = mapstrstrHeaders.find( strType ) ) == mapstrstrHeaders.end( ) ) ? "" :
00212             iterGene->second ); }
00213 
00221     const std::set<std::string>& GetTypes( ) const {
00222 
00223         return m_setstrTypes; }
00224 };
00225 
00226 }
00227 
00228 #endif // FASTA_H