File: AminoAcidDatabaseQuickReader.hpp

package info (click to toggle)
plast 2.3.2%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,344 kB
  • sloc: cpp: 28,979; ansic: 2,075; sh: 478; makefile: 80
file content (109 lines) | stat: -rwxr-xr-x 4,687 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*****************************************************************************
 *                                                                           *
 *   PLAST : Parallel Local Alignment Search Tool                            *
 *   Version 2.3, released November 2015                                     *
 *   Copyright (c) 2009-2015 Inria-Cnrs-Ens                                  *
 *                                                                           *
 *   PLAST is free software; you can redistribute it and/or modify it under  *
 *   the Affero GPL ver 3 License, that is compatible with the GNU General   *
 *   Public License                                                          *
 *                                                                           *
 *   This program is distributed in the hope that it will be useful,         *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
 *   Affero GPL ver 3 License for more details.                              *
 *****************************************************************************/

/** \file AminoAcidDatabaseQuickReader.hpp
 *  \brief IDatabaseQuickReader implementation for amino acid database.
 *  \date 07/11/2011
 *  \author edrezen
 */

#ifndef _AMINO_ACID_DATABASE_QUICK_READER_HPP_
#define _AMINO_ACID_DATABASE_QUICK_READER_HPP_

/********************************************************************************/

#include <database/api/IDatabaseQuickReader.hpp>

/********************************************************************************/
namespace database {
/** \brief Implementation of concepts related to genomic databases. */
namespace impl {
/********************************************************************************/

/** \brief Implementation of IDatabaseQuickReader for amino acid database.
 *
 *  This class takes a IDatabaseQuickReader instance as a reference (reference supposed
 *  to point to a nucleotide database). The different getters are then proxies to the
 *  reference. Most of the getters return the same information than the referenced instance
 *  but note for instance the 'getDataSize' method that divides by 3 the data size (which
 *  means that 3 nucleotides are needed to code an amino acid).
 *
 *  This class is a Proxy Design Pattern.
 */
class AminoAcidDatabaseQuickReader : public IDatabaseQuickReader
{
public:

    /** Constructor.
     * \param[in] ref : a IDatabaseQuickReader instance on a nucleotide database.
     */
    AminoAcidDatabaseQuickReader (IDatabaseQuickReader* ref)  : _ref(0)   {  setRef (ref);  }

    /** Destructor. */
    virtual ~AminoAcidDatabaseQuickReader  ()  {  setRef (0);  }

    /** \copydoc IDatabaseQuickReader::read */
    void read (u_int64_t  maxblocksize)  { _ref->read (maxblocksize);  }

    /** \copydoc IDatabaseQuickReader::getUri */
    std::string& getUri         () { return _ref->getUri();          }

    /** \copydoc IDatabaseQuickReader::getTotalSize */
    u_int64_t    getTotalSize   () { return _ref->getTotalSize();    }

    /** Returns the total read size (including only sequences data). This is the data size of the nucleotide
     * reference divided by 3.
     * \return the total size.
     */
    u_int64_t    getDataSize    () { return _ref->getDataSize() / 3; }

    /** \copydoc IDatabaseQuickReader::getNbSequences */
    u_int32_t    getNbSequences () { return _ref->getNbSequences();  }

    /** \copydoc IDatabaseQuickReader::getOffsets */
    std::vector<u_int64_t>& getOffsets ()  { return _ref->getOffsets(); }

    /** Returns the kind of database (ADN or protein).
     * \return always ENUM_AMINO_ACID.
     */
    DatabaseKind_e getKind ()  { return ENUM_AMINO_ACID; }

    /** Max block size of a bank. */
    u_int64_t  getMaxBlockSize() { return _ref->getMaxBlockSize(); }

    /** */
    dp::IProperties* getProperties ()  { return _ref->getProperties(); }

    /** \copydoc IDatabaseQuickReader::load */
    int load (const std::string& uri)  { return _ref->load (uri); }

    /** \copydoc IDatabaseQuickReader::save */
    int save (const std::string& uri)  { return _ref->save (uri); }

private:

    /** Referenced nucleotide instance. */
    IDatabaseQuickReader* _ref;

    /** Smart setter for the _ref attribute. */
    void setRef (IDatabaseQuickReader* ref)  { SP_SETATTR(ref); }
};

/********************************************************************************/
} } /* end of namespaces. */
/********************************************************************************/

#endif /* _AMINO_ACID_DATABASE_QUICK_READER_HPP_  */