halapi hierarchichalalignmentformatapi

- Main Page
- Namespaces
- Classes
- Files

- File List

hdf5_impl/hdf5BottomSegment.h

    00001 /*
    00002  * Copyright (C) 2012 by Glenn Hickey (hickey@soe.ucsc.edu)
    00003  *
    00004  * Released under the MIT license, see LICENSE.txt
    00005  */
    00006
    00007 #ifndef _HDF5BOTTOMSEGMENT_H
    00008 #define _HDF5BOTTOMSEGMENT_H
    00009
    00010 #include <H5Cpp.h>
    00011 #include "halDefs.h"
    00012 #include "halBottomSegment.h"
    00013 #include "hdf5Genome.h"
    00014 #include "hdf5ExternalArray.h"
    00015
    00016 namespace hal {
    00017
    00018 class HDF5TopSegmentIterator;
    00019 class HDF5BottomSegmentIterator;
    00020
    00021 class HDF5BottomSegment : public BottomSegment
    00022 {
    00023 public:
    00024
    00025    friend class HDF5TopSegmentIterator;
    00026    friend class HDF5BottomSegmentIterator;
    00027
    00032    HDF5BottomSegment(HDF5Genome* genome,
    00033                      HDF5ExternalArray* array,
    00034                      hal_index_t index);
    00035
    00037    ~HDF5BottomSegment();
    00038
    00040    hal_size_t getLength() const;
    00041
    00044    void setLength(hal_size_t length);
    00045
    00047    const Genome* getGenome() const;
    00048
    00050    Genome* getGenome();
    00051
    00053    hal_index_t getStartPosition() const;
    00054
    00057    void setStartPosition(hal_index_t startPos);
    00058
    00060    hal_index_t getNextParalogyIndex() const;
    00061
    00065    void setNextParalogyIndex(hal_index_t parIdx);
    00066
    00069    hal_size_t getNumChildren() const;
    00070
    00073    hal_index_t getChildIndex(hal_size_t i) const;
    00074
    00078    void setChildIndex(hal_size_t i, hal_index_t childIndex);
    00079
    00083    hal_bool_t getChildReversed(hal_size_t i) const;
    00084
    00089    void setChildReversed(hal_size_t child, hal_bool_t isReversed);
    00090
    00093    hal_index_t getTopParseIndex() const;
    00094
    00098    void setTopParseIndex(hal_index_t parseIndex);
    00099
    00102    hal_offset_t getTopParseOffset() const;
    00103
    00107    void setTopParseOffset(hal_offset_t parseOffset);
    00108
    00110    hal_index_t getArrayIndex() const;
    00111
    00112    static H5::CompType dataType(hal_size_t numChildren);
    00113    static hal_size_t numChildrenFromDataType(
    00114      const H5::DataType& dataType);
    00115
    00116
    00117 protected:
    00118
    00119    static const size_t genomeIndexOffset;
    00120    static const size_t lengthOffset;
    00121    static const size_t topIndexOffset;
    00122    static const size_t topOffsetOffset;
    00123    static const size_t parIndexOffset;
    00124    static const size_t firstChildOffset;
    00125    static const size_t totalSize(hal_size_t numChildren);
    00126
    00127    mutable HDF5ExternalArray* _array;
    00128    mutable hal_index_t _index;
    00129    mutable HDF5Genome* _genome;
    00130 };
    00131
    00132 //INLINE members
    00133
    00134
    00135 inline hal_index_t HDF5BottomSegment::getStartPosition() const
    00136 {
    00137   assert(_index >= 0);
    00138   return _array->getValue<hal_index_t>((hsize_t)_index, genomeIndexOffset);
    00139 }
    00140
    00141 inline void
    00142 HDF5BottomSegment::setStartPosition(hal_index_t startPos)
    00143 {
    00144   assert(_index >= 0);
    00145   _array->setValue((hsize_t)_index, genomeIndexOffset, startPos);
    00146 }
    00147
    00148 inline hal_size_t HDF5BottomSegment::getLength() const
    00149 {
    00150   assert(_index >= 0);
    00151   return _array->getValue<hal_size_t>((hsize_t)_index, lengthOffset);
    00152 }
    00153
    00154 inline void
    00155 HDF5BottomSegment::setLength(hal_size_t length)
    00156 {
    00157   assert(_index >= 0);
    00158   _array->setValue((hsize_t)_index, lengthOffset, length);
    00159 }
    00160
    00161 inline const Genome* HDF5BottomSegment::getGenome() const
    00162 {
    00163   return _genome;
    00164 }
    00165
    00166 inline Genome* HDF5BottomSegment::getGenome()
    00167 {
    00168   return _genome;
    00169 }
    00170
    00171 inline hal_index_t HDF5BottomSegment::getNextParalogyIndex() const
    00172 {
    00173   return _array->getValue<hal_index_t>(_index, parIndexOffset);
    00174 }
    00175
    00176 inline void HDF5BottomSegment::setNextParalogyIndex(hal_index_t parIdx)
    00177 {
    00178   assert(_index >= 0);
    00179   _array->setValue((hsize_t)_index, parIndexOffset, parIdx);
    00180 }
    00181
    00182 inline hal_size_t HDF5BottomSegment::getNumChildren() const
    00183 {
    00184   return _genome->getNumChildren();
    00185 }
    00186
    00187 inline hal_index_t HDF5BottomSegment::getChildIndex(hal_size_t i) const
    00188 {
    00189   assert(_index >= 0);
    00190   return _array->getValue<hal_index_t>(
    00191     (hsize_t)_index, firstChildOffset +
    00192     i * (sizeof(hal_index_t) + sizeof(hal_bool_t)));
    00193 }
    00194
    00195 inline void HDF5BottomSegment::setChildIndex(hal_size_t i,
    00196                                              hal_index_t childIndex)
    00197 {
    00198   assert(_index >= 0);
    00199   _array->setValue((hsize_t)_index, firstChildOffset +
    00200                    i * (sizeof(hal_index_t) + sizeof(hal_bool_t)), childIndex);
    00201 }
    00202
    00203 inline hal_bool_t HDF5BottomSegment::getChildReversed(hal_size_t i) const
    00204 {
    00205   assert(_index >= 0);
    00206   return _array->getValue<hal_bool_t>(
    00207     (hsize_t)_index, firstChildOffset +
    00208     i * (sizeof(hal_index_t) + sizeof(hal_bool_t)) +
    00209     sizeof(hal_index_t));
    00210 }
    00211
    00212 inline void HDF5BottomSegment::setChildReversed(hal_size_t i,
    00213                                                 hal_bool_t isReversed)
    00214 {
    00215   assert(_index >= 0);
    00216   _array->setValue((hsize_t)_index, firstChildOffset +
    00217                    i * (sizeof(hal_index_t) + sizeof(hal_bool_t)) +
    00218                    sizeof(hal_index_t), isReversed);
    00219 }
    00220
    00221 inline hal_index_t HDF5BottomSegment::getTopParseIndex() const
    00222 {
    00223   assert(_index >= 0);
    00224   return _array->getValue<hal_index_t>(
    00225     (hsize_t)_index, topIndexOffset);
    00226 }
    00227
    00228 inline void HDF5BottomSegment::setTopParseIndex(hal_index_t parseIndex)
    00229 {
    00230   assert(_index >= 0);
    00231   _array->setValue((hsize_t)_index, topIndexOffset, parseIndex);
    00232 }
    00233
    00234 inline hal_offset_t HDF5BottomSegment::getTopParseOffset() const
    00235 {
    00236   assert(_index >= 0);
    00237   return _array->getValue<hal_offset_t>((hsize_t)_index, topOffsetOffset);
    00238 }
    00239
    00240 inline void HDF5BottomSegment::setTopParseOffset(hal_offset_t parseOffset)
    00241 {
    00242   assert(_index >= 0);
    00243   _array->setValue((hsize_t)_index, topOffsetOffset, parseOffset);
    00244 }
    00245
    00246 inline hal_index_t HDF5BottomSegment::getArrayIndex() const
    00247 {
    00248   return _index;
    00249 }
    00250 }
    00251
    00252 #endif

All Classes Namespaces Functions Variables Friends