@@ -22,6 +22,12 @@ namespace cmaple {
2222 */
2323 NumSeqsType count_ = 0 ;
2424
25+ /* *
26+ The vector of local refs were integrated to build
27+ the current lower regions from its original regions
28+ */
29+ std::vector<cmaple::Index> local_ref_vec_;
30+
2531 public:
2632
2733 /* *
@@ -59,6 +65,22 @@ namespace cmaple {
5965 Set lower_regions_
6066 */
6167 auto setSeqRegions (std::unique_ptr<SeqRegions>&& lower_regions) -> void;
68+
69+ /* *
70+ Get local_ref_vec_
71+ */
72+ auto getLocalRefVec () -> std::vector<cmaple::Index>&;
73+
74+ /* *
75+ Set local_ref_vec_
76+ */
77+ auto setLocalRefVec (
78+ const std::vector<cmaple::Index>& local_ref_vec) -> void;
79+
80+ /* *
81+ Add a ref index into local_ref_vec_
82+ */
83+ auto addLocalRefIndex (const cmaple::Index& local_ref_index) -> void;
6284 };
6385
6486/* * A dedicated memory class to store a vector of SeqRegionsWithCounts
@@ -83,6 +105,19 @@ namespace cmaple {
83105 std::unique_ptr<SeqRegions>& mutations,
84106 const bool inverse = false )
85107 -> SeqRegionsWithCount*;
108+
109+ /* *
110+ Same as the above but with a local ref index added
111+ to keep track of the list of local refs are being used
112+ */
113+ template <const cmaple::StateType num_states>
114+ auto getMutIntegratedSeqRegions (
115+ SeqRegionsWithCount* const in_seqregions,
116+ const Alignment* aln,
117+ const cmaple::Index& local_ref_index,
118+ std::unique_ptr<SeqRegions>& mutations,
119+ const bool inverse = false )
120+ -> SeqRegionsWithCount*;
86121 };
87122
88123template <const cmaple::StateType num_states>
@@ -132,7 +167,37 @@ auto cmaple::SeqRegionsMem::getMutIntegratedSeqRegions(
132167 out_seqregions->setSeqRegions (std::move (mut_integrated_seqregions));
133168 out_seqregions->increaseCount ();
134169
170+ // inherit the local_ref_vec
171+ if (in_seqregions->getLocalRefVec ().size ())
172+ {
173+ out_seqregions->setLocalRefVec (in_seqregions->getLocalRefVec ());
174+ }
175+
135176 return out_seqregions;
136177}
178+
179+ template <const cmaple::StateType num_states>
180+ auto cmaple::SeqRegionsMem::getMutIntegratedSeqRegions (
181+ SeqRegionsWithCount* const in_seqregions,
182+ const Alignment* aln,
183+ const cmaple::Index& local_ref_index,
184+ std::unique_ptr<SeqRegions>& mutations,
185+ const bool inverse)
186+ -> SeqRegionsWithCount*
187+ {
188+ // first call the simple version of this function first
189+ SeqRegionsWithCount* out_seqregion_ptr =
190+ getMutIntegratedSeqRegions<num_states>(
191+ in_seqregions, aln, mutations, inverse);
192+
193+ // if we integrate the mutations/local ref, record it
194+ if (mutations)
195+ {
196+ assert (local_ref_index.getMiniIndex () != UNDEFINED);
197+ out_seqregion_ptr->addLocalRefIndex (local_ref_index);
198+ }
199+
200+ return out_seqregion_ptr;
201+ }
137202
138203} // namespace cmaple
0 commit comments