TEST_F(RegionUtilTestFixture, GetHighQulitySubreadsIntervals) { vector<ReadInterval> intervals; intervals.push_back(ReadInterval(0, 712)); intervals.push_back(ReadInterval(760, 2040)); intervals.push_back(ReadInterval(2098, 3452)); vector<int> directions; directions.push_back(0); directions.push_back(1); directions.push_back(0); int indx = GetHighQualitySubreadsIntervals(intervals, directions, hqStart, hqEnd); EXPECT_EQ(intervals.size(), 3); EXPECT_EQ(indx, 2); int starts [3] = {0, 760, 2098}; int ends [3] = {712, 2040, 3424}; int ds [3] = {0, 1, 0}; for(int i=0; i < 3; i++) { EXPECT_EQ(intervals[i].start, starts[i]); EXPECT_EQ(intervals[i].end , ends[i] ); EXPECT_EQ(directions[i] , ds[i] ); } indx = GetHighQualitySubreadsIntervals(intervals, directions, hqStart, hqEnd, 800); EXPECT_EQ(intervals.size(), 2); // The first interval and its direction has been removed as the length is less // than 800. for(int i=0; i < 2; i++) { EXPECT_EQ(intervals[i].start, starts[i+1]); EXPECT_EQ(intervals[i].end , ends[i+1] ); } }
void handleVector(std::vector < libmaus2::dazzler::align::Overlap > & VOVL, libmaus2::dazzler::align::AlignmentWriter & AW) { uint64_t maxaepos = 0; for ( uint64_t i = 0; i < VOVL.size(); ++i ) maxaepos = std::max(maxaepos,static_cast<uint64_t>(VOVL[i].path.aepos)); libmaus2::util::SimpleQueue< libmaus2::geometry::RangeSet<ReadInterval>::search_q_element > SQ; libmaus2::geometry::RangeSet<ReadInterval> RS(maxaepos); for ( uint64_t i = 0; i < VOVL.size(); ++i ) { uint64_t const abpos = VOVL[i].path.abpos; uint64_t const aepos = VOVL[i].path.aepos; uint64_t const nf = RS.search(ReadInterval(abpos,aepos,i),SQ); bool const primary = (! nf); if ( primary ) { VOVL[i].setPrimary(); //std::cerr << "primary " << VOVL[i] << std::endl; RS.insert(ReadInterval(abpos,aepos,i)); } else { //std::cerr << "secondary " << VOVL[i] << std::endl; } } for ( uint64_t i = 0; i < VOVL.size(); ++i ) AW.put(VOVL[i]); VOVL.resize(0); }
std::vector<ReadInterval> RegionAnnotations::SubreadIntervals(const DNALength wholeLength, const bool byAdapter, const bool byHQRegion) const { std::vector<RegionAnnotation> inserts; if (not byAdapter) { inserts = Inserts(); } else { if (Adapters().size() != 0) { // Must have at least one adapter in order find inserts by adapter. std::vector<DNALength> starts, ends; starts.push_back(0); for(auto adapter: Adapters()) { assert(wholeLength >= static_cast<DNALength>(adapter.GetStart()) and wholeLength >= static_cast<DNALength>(adapter.GetEnd())); // bug if fail assert starts.push_back(adapter.GetEnd()); ends.push_back(adapter.GetStart()); } ends.push_back(wholeLength); for (size_t i = 0; i < starts.size(); i++) { // Use adapter to infer subreads, read score considered unknown. if (ends[i] > starts[i]) { inserts.push_back(RegionAnnotation(holeNumber_, Insert, starts[i], ends[i], 0)); } } } // else no inserts can be found } std::vector<ReadInterval> ret; for (auto insert: inserts) { if (byHQRegion) { if (HasHQRegion()) { DNALength s = std::max(static_cast<UInt>(insert.GetStart()), HQStart()); DNALength e = std::min(static_cast<UInt>(insert.GetEnd()), HQEnd()); if (s < e) { // subreads' read score = HQRegion score. ret.push_back(ReadInterval(s, e, HQScore())); } } // else ret = {} } else { ret.push_back(ReadInterval(insert)); } } return ret; }
std::vector<ReadInterval> RegionAnnotations::AdapterIntervals() const { std::vector<ReadInterval> ret; for (auto adapter: Adapters()) { ret.push_back(ReadInterval(adapter)); } return ret; }
void MakeSubreadIntervals(vector<SMRTSequence> & subreads, vector<ReadInterval> & subreadIntervals) { subreadIntervals.clear(); for (auto subread: subreads) { subreadIntervals.push_back(ReadInterval(subread.SubreadStart(), subread.SubreadEnd(), subread.highQualityRegionScore)); } }
void CSoundParametersInternal::SoundLevelFromString( const char *sz ) { if ( !Q_strncasecmp( sz, "SNDLVL_", strlen( "SNDLVL_" ) ) ) { soundlevel.start = TextToSoundLevel( sz ); soundlevel.range = 0; } else { soundlevel.FromInterval( ReadInterval( sz ) ); } }
void CSoundParametersInternal::VolumeFromString( const char *sz ) { if ( !Q_strcasecmp( sz, "VOL_NORM" ) ) { volume.start = VOL_NORM; volume.range = 0.0f; } else { volume.FromInterval( ReadInterval( sz ) ); } }
void CSoundEmitterSystemBase::CSoundParametersInternal::SoundLevelFromString( const char *sz ) { if ( !Q_strncasecmp( sz, "SNDLVL_", strlen( "SNDLVL_" ) ) ) { soundlevel.start = TextToSoundLevel( sz ); soundlevel.range = 0.0f; } else { soundlevel = ReadInterval( sz ); } Q_strncpy( m_szSoundLevel, sz, sizeof( m_szSoundLevel ) ); }
void CSoundEmitterSystemBase::CSoundParametersInternal::VolumeFromString( const char *sz ) { if ( !Q_strcasecmp( sz, "VOL_NORM" ) ) { volume.start = VOL_NORM; volume.range = 0.0f; } else { volume = ReadInterval( sz ); } Q_strncpy( m_szVolume, sz, sizeof( m_szVolume ) ); }
void CSoundParametersInternal::PitchFromString( const char *sz ) { if ( !Q_strcasecmp( sz, "PITCH_NORM" ) ) { pitch.start = PITCH_NORM; pitch.range = 0; } else if ( !Q_strcasecmp( sz, "PITCH_LOW" ) ) { pitch.start = PITCH_LOW; pitch.range = 0; } else if ( !Q_strcasecmp( sz, "PITCH_HIGH" ) ) { pitch.start = PITCH_HIGH; pitch.range = 0; } else { pitch.FromInterval( ReadInterval( sz ) ); } }
void CSoundEmitterSystemBase::CSoundParametersInternal::PitchFromString( const char *sz ) { if ( !Q_strcasecmp( sz, "PITCH_NORM" ) ) { pitch.start = PITCH_NORM; pitch.range = 0.0f; } else if ( !Q_strcasecmp( sz, "PITCH_LOW" ) ) { pitch.start = PITCH_LOW; pitch.range = 0.0f; } else if ( !Q_strcasecmp( sz, "PITCH_HIGH" ) ) { pitch.start = PITCH_HIGH; pitch.range = 0.0f; } else { pitch= ReadInterval( sz ) ; } Q_strncpy( m_szPitch, sz, sizeof( m_szPitch ) ); }
void SetUp() { /* The region table for hole number 14798 is as follows. * type start end score * 1 0 712 -1 * 1 760 2040 -1 * 1 2098 3452 -1 * 0 712 760 937 * 0 2040 2098 741 * 2 0 3424 819 * where type 1 = insertion, 0 = adapter, 2 = HQRegion * */ hqStart = 0; hqEnd = 3424; hqScore = 819; holeNumber = 14798; int srs[29][2] = {{95, 353}, {404, 955}, {998, 1243}, {1289, 1529}, {1576, 1824}, {1869, 2132}, {2178, 2444}, {2486, 2727}, {2767, 3004}, {3047, 3286}, {3329, 3537}, {3583, 3818}, {3862, 4096}, {4139, 4404}, {4447, 4673}, {4717, 4956}, {5004, 5228}, {5275, 5508}, {5552, 5790}, {5835, 6072}, {6113, 6338}, {6389, 6604}, {6647, 7145}, {7189, 7421}, {7468, 7693}, {7733, 7951}, {7989, 8197}, {8243, 8482}, {8522, 9244} }; int rgn[59][5] = {{9, 1, 95, 353, -1}, {9, 1, 404, 955, -1}, {9, 1, 998, 1243, -1}, {9, 1, 1289, 1529, -1}, {9, 1, 1576, 1824, -1}, {9, 1, 1869, 2132, -1}, {9, 1, 2178, 2444, -1}, {9, 1, 2486, 2727, -1}, {9, 1, 2767, 3004, -1}, {9, 1, 3047, 3286, -1}, {9, 1, 3329, 3537, -1}, {9, 1, 3583, 3818, -1}, {9, 1, 3862, 4096, -1}, {9, 1, 4139, 4404, -1}, {9, 1, 4447, 4673, -1}, {9, 1, 4717, 4956, -1}, {9, 1, 5004, 5228, -1}, {9, 1, 5275, 5508, -1}, {9, 1, 5552, 5790, -1}, {9, 1, 5835, 6072, -1}, {9, 1, 6113, 6338, -1}, {9, 1, 6389, 6604, -1}, {9, 1, 6647, 7145, -1}, {9, 1, 7189, 7421, -1}, {9, 1, 7468, 7693, -1}, {9, 1, 7733, 7951, -1}, {9, 1, 7989, 8197, -1}, {9, 1, 8243, 8482, -1}, {9, 1, 8522, 9244, -1}, {9, 0, 41, 95, 722}, {9, 0, 353, 404, 784}, {9, 0, 955, 998, 697}, {9, 0, 1243, 1289, 804}, {9, 0, 1529, 1576, 744}, {9, 0, 1824, 1869, 844}, {9, 0, 2132, 2178, 847}, {9, 0, 2444, 2486, 666}, {9, 0, 2727, 2767, 824}, {9, 0, 3004, 3047, 883}, {9, 0, 3286, 3329, 860}, {9, 0, 3537, 3583, 891}, {9, 0, 3818, 3862, 795}, {9, 0, 4096, 4139, 906}, {9, 0, 4404, 4447, 906}, {9, 0, 4673, 4717, 886}, {9, 0, 4956, 5004, 708}, {9, 0, 5228, 5275, 957}, {9, 0, 5508, 5552, 886}, {9, 0, 5790, 5835, 733}, {9, 0, 6072, 6113, 804}, {9, 0, 6338, 6389, 666}, {9, 0, 6604, 6647, 813}, {9, 0, 7145, 7189, 795}, {9, 0, 7421, 7468, 829}, {9, 0, 7693, 7733, 774}, {9, 0, 7951, 7989, 657}, {9, 0, 8197, 8243, 760}, {9, 0, 8482, 8522, 675}, {9, 2, 0, 9244, 834} }; for (int i = 0; i < 29; i++) { subreadIntervals.push_back(ReadInterval(srs[i][0], srs[i][1])); } for (int i = 0; i < 59; i++) { adapterIntervals.push_back(ReadInterval(rgn[i][2], rgn[i][3], rgn[i][4])); } }
//----------------------------------------------------------------------------- // Purpose: // Input : *soundname - // params - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CSoundEmitterSystemBase::InitSoundInternalParameters( const char *soundname, KeyValues *kv, CSoundParametersInternal& params ) { KeyValues *pKey = kv->GetFirstSubKey(); while ( pKey ) { if ( !Q_strcasecmp( pKey->GetName(), "channel" ) ) { params.ChannelFromString( pKey->GetString() ); } else if ( !Q_strcasecmp( pKey->GetName(), "volume" ) ) { params.VolumeFromString( pKey->GetString() ); } else if ( !Q_strcasecmp( pKey->GetName(), "pitch" ) ) { params.PitchFromString( pKey->GetString() ); } else if ( !Q_strcasecmp( pKey->GetName(), "wave" ) ) { CUtlSymbol sym = m_Waves.AddString( pKey->GetString() ); params.soundnames.AddToTail( sym ); } else if ( !Q_strcasecmp( pKey->GetName(), "rndwave" ) ) { KeyValues *pWaves = pKey->GetFirstSubKey(); while ( pWaves ) { CUtlSymbol sym = m_Waves.AddString( pWaves->GetString() ); params.soundnames.AddToTail( sym ); pWaves = pWaves->GetNextKey(); } } else if ( !Q_strcasecmp( pKey->GetName(), "attenuation" ) ) { if ( !Q_strncasecmp( pKey->GetString(), "SNDLVL_", strlen( "SNDLVL_" ) ) ) { DevMsg( "CSoundEmitterSystemBase::GetParametersForSound: sound %s has \"attenuation\" with %s value!\n", soundname, pKey->GetString() ); } if ( !Q_strncasecmp( pKey->GetString(), "ATTN_", strlen( "ATTN_" ) ) ) { params.soundlevel.start = ATTN_TO_SNDLVL( TranslateAttenuation( pKey->GetString() ) ); params.soundlevel.range = 0.0f; } else { interval_t interval; interval = ReadInterval( pKey->GetString() ); // Translate from attenuation to soundlevel float start = interval.start; float end = interval.start + interval.range; params.soundlevel.start = ATTN_TO_SNDLVL( start ); params.soundlevel.range = ATTN_TO_SNDLVL( end ) - ATTN_TO_SNDLVL( start ); } } else if ( !Q_strcasecmp( pKey->GetName(), "soundlevel" ) ) { if ( !Q_strncasecmp( pKey->GetString(), "ATTN_", strlen( "ATTN_" ) ) ) { DevMsg( "CSoundEmitterSystemBase::GetParametersForSound: sound %s has \"soundlevel\" with %s value!\n", soundname, pKey->GetString() ); } params.SoundLevelFromString( pKey->GetString() ); } else if ( !Q_strcasecmp( pKey->GetName(), "play_to_owner_only" ) ) { params.play_to_owner_only = pKey->GetInt() ? true : false; } else if ( !Q_strcasecmp( pKey->GetName(), "precache" ) ) { params.precache = pKey->GetInt() ? true : false; } pKey = pKey->GetNextKey(); } return true; }