1 /*=========================================================================== 2 * 3 * PUBLIC DOMAIN NOTICE 4 * National Center for Biotechnology Information 5 * 6 * This software/database is a "United States Government Work" under the 7 * terms of the United States Copyright Act. It was written as part of 8 * the author's official duties as a United States Government employee and 9 * thus cannot be copyrighted. This software/database is freely available 10 * to the public for use. The National Library of Medicine and the U.S. 11 * Government have not placed any restriction on its use or reproduction. 12 * 13 * Although all reasonable efforts have been taken to ensure the accuracy 14 * and reliability of the software and data, the NLM and the U.S. 15 * Government do not and cannot warrant the performance or results that 16 * may be obtained by using this software or data. The NLM and the U.S. 17 * Government disclaim all warranties, express or implied, including 18 * warranties of performance, merchantability or fitness for any particular 19 * purpose. 20 * 21 * Please cite the author in any work or product based on this material. 22 * 23 * =========================================================================== 24 * 25 */ 26 27 #ifndef _hpp_ngs_test_engine_referenceitf_ 28 #define _hpp_ngs_test_engine_referenceitf_ 29 30 #include <ngs/adapter/ErrorMsg.hpp> 31 #include <ngs/adapter/StringItf.hpp> 32 #include <ngs/adapter/ReferenceItf.hpp> 33 34 #include "AlignmentItf.hpp" 35 #include "PileupItf.hpp" 36 37 namespace ngs_test_engine 38 { 39 40 /*---------------------------------------------------------------------- 41 * forwards 42 */ 43 44 /*---------------------------------------------------------------------- 45 * ReferenceItf 46 */ 47 class ReferenceItf : public ngs_adapt :: ReferenceItf 48 { 49 public: 50 getCommonName() const51 virtual ngs_adapt :: StringItf * getCommonName () const 52 { 53 static std::string name = "common name"; 54 return new ngs_adapt :: StringItf ( name.c_str(), name.size() ); 55 } 56 getCanonicalName() const57 virtual ngs_adapt :: StringItf * getCanonicalName () const 58 { 59 static std::string name = "canonical name"; 60 return new ngs_adapt :: StringItf ( name.c_str(), name.size() ); 61 } 62 getIsCircular() const63 virtual bool getIsCircular () const 64 { 65 return false; 66 } 67 getIsLocal() const68 virtual bool getIsLocal () const 69 { 70 return true; 71 } 72 getLength() const73 virtual uint64_t getLength () const 74 { 75 return 101; 76 } 77 getReferenceBases(uint64_t offset,uint64_t length) const78 virtual ngs_adapt :: StringItf * getReferenceBases ( uint64_t offset, uint64_t length ) const 79 { 80 static std::string bases= "CAGT"; 81 return new ngs_adapt :: StringItf ( bases.c_str(), bases.size() ); 82 } 83 getReferenceChunk(uint64_t offset,uint64_t length) const84 virtual ngs_adapt :: StringItf * getReferenceChunk ( uint64_t offset, uint64_t length ) const 85 { 86 static std::string bases= "AG"; 87 return new ngs_adapt :: StringItf ( bases.c_str(), bases.size() ); 88 } 89 getAlignmentCount(bool wants_primary,bool wants_secondary) const90 virtual uint64_t getAlignmentCount ( bool wants_primary, bool wants_secondary ) const 91 { 92 return ( 13 * wants_primary ) + ( 6 * wants_secondary ); 93 } 94 getAlignment(const char * alignmentId) const95 virtual ngs_adapt :: AlignmentItf * getAlignment ( const char * alignmentId ) const 96 { 97 return new ngs_test_engine::AlignmentItf ( alignmentId ); 98 } 99 getAlignments(bool wants_primary,bool wants_secondary) const100 virtual ngs_adapt :: AlignmentItf * getAlignments ( bool wants_primary, bool wants_secondary ) const 101 { 102 return new ngs_test_engine::AlignmentItf ( 5 ); 103 } 104 getAlignmentSlice(int64_t start,uint64_t length,bool wants_primary,bool wants_secondary) const105 virtual ngs_adapt :: AlignmentItf * getAlignmentSlice ( int64_t start, uint64_t length, bool wants_primary, bool wants_secondary ) const 106 { 107 return new ngs_test_engine::AlignmentItf ( ( unsigned int ) length ); 108 } 109 getFilteredAlignmentSlice(int64_t start,uint64_t length,uint32_t flags,int32_t map_qual) const110 virtual ngs_adapt :: AlignmentItf * getFilteredAlignmentSlice ( int64_t start, uint64_t length, uint32_t flags, int32_t map_qual ) const 111 { 112 return new ngs_test_engine::AlignmentItf ( ( unsigned int ) length ); 113 } 114 getPileups(bool wants_primary,bool wants_secondary) const115 virtual ngs_adapt :: PileupItf * getPileups ( bool wants_primary, bool wants_secondary ) const 116 { 117 return new ngs_test_engine::PileupItf ( 3 ); 118 } 119 getFilteredPileups(uint32_t flags,int32_t map_qual) const120 virtual ngs_adapt :: PileupItf * getFilteredPileups ( uint32_t flags, int32_t map_qual ) const 121 { 122 return new ngs_test_engine::PileupItf ( 3 ); 123 } 124 getPileupSlice(int64_t start,uint64_t length,bool wants_primary,bool wants_secondary) const125 virtual ngs_adapt :: PileupItf * getPileupSlice ( int64_t start, uint64_t length, bool wants_primary, bool wants_secondary ) const 126 { 127 return new ngs_test_engine::PileupItf ( ( unsigned int ) length ); 128 } 129 getFilteredPileupSlice(int64_t start,uint64_t length,uint32_t flags,int32_t map_qual) const130 virtual ngs_adapt :: PileupItf * getFilteredPileupSlice ( int64_t start, uint64_t length, uint32_t flags, int32_t map_qual ) const 131 { 132 return new ngs_test_engine::PileupItf ( ( unsigned int ) length ); 133 } 134 nextReference()135 virtual bool nextReference () 136 { 137 switch ( iterateFor ) 138 { 139 case -1: throw ngs_adapt::ErrorMsg ( "invalid iterator access" ); 140 case 0: return false; 141 default: --iterateFor; return true; 142 } 143 } 144 145 public: ReferenceItf()146 ReferenceItf () 147 : iterateFor(-1) 148 { 149 ++instanceCount; 150 } ReferenceItf(unsigned int p_iterateFor)151 ReferenceItf ( unsigned int p_iterateFor ) 152 : iterateFor( ( int ) p_iterateFor ) 153 { 154 ++instanceCount; 155 } 156 ~ReferenceItf()157 ~ReferenceItf () 158 { 159 --instanceCount; 160 } 161 162 static unsigned int instanceCount; 163 164 int iterateFor; 165 }; 166 167 } // namespace ngs_test_engine 168 169 #endif // _hpp_ngs_test_engine_referenceitf_ 170