43 typedef pair<TSignedSeqPos, TPhyloCSFScore>
TElement;
46 if(!from.read(
reinterpret_cast<char*
>(m_scores.data()),
len*
sizeof(
TElement))) {
47 cerr <<
"Error in PhyloCSF compact read\n";
52 if(!
out.write(
reinterpret_cast<const char*
>(m_scores.data()), Size()*
sizeof(
TElement))) {
53 cerr <<
"Error in PhyloCSF compact write\n";
58 auto rslt = lower_bound(m_scores.begin(), m_scores.end(), p, [](
const TElement& e,
TSignedSeqPos i) { return e.first < i; });
59 if(rslt == m_scores.end() || rslt->first != p)
66 size_t Size()
const {
return m_scores.size(); }
73 if(
m_map !=
nullptr) {
82 if(
m_map !=
nullptr) {
84 if(edited_range.
Empty())
88 if(orig_range.
Empty())
90 size_t left = (*m_scoresp)[s].LowerBound(orig_range.
GetFrom()+
m_shift);
94 size_t right = (*m_scoresp)[s].UpperBound(orig_range.
GetTo()+
m_shift)-1;
112 if(!from.read(
reinterpret_cast<char*
>(&data_length),
sizeof data_length)) {
113 cerr <<
"Error in PhyloCSF read\n";
117 from.seekg(data_length, ios_base::cur);
119 while(from.read(
reinterpret_cast<char*
>(&slen),
sizeof slen)) {
120 vector<char>
buf(slen);
121 from.read(
buf.data(), slen);
122 string contig_acc(
buf.begin(),
buf.end());
124 from.read(
reinterpret_cast<char*
>(&shift),
sizeof(
size_t));
126 from.read(
reinterpret_cast<char*
>(&plus_len),
sizeof(
TSignedSeqPos));
128 from.read(
reinterpret_cast<char*
>(&minus_len),
sizeof(
TSignedSeqPos));
130 cerr <<
"Error in PhyloCSF index read\n";
133 index[contig_acc] = make_tuple(shift, plus_len, minus_len);
138 for(
auto& ind : index) {
139 auto& contig_acc = ind.first;
140 auto shift = get<0>(ind.second);
141 auto plus_len = get<1>(ind.second);
142 auto minus_len = get<2>(ind.second);
143 from.seekg(shift,ios_base::beg);
149 size_t data_length = 0;
151 data_length += (scr.second[0].Size()+scr.second[1].Size());
154 out.write(
reinterpret_cast<const char*
>(&data_length),
sizeof data_length);
157 for(
int strand = 0; strand < 2; ++strand)
158 scr.second[strand].Write(
out);
161 size_t shift =
sizeof data_length;
163 auto& contig_acc = scr.first;
165 int slen = (
int)contig_acc.size();
166 out.write(
reinterpret_cast<const char*
>(&slen),
sizeof slen);
167 out.write(contig_acc.c_str(), slen);
169 out.write(
reinterpret_cast<const char*
>(&shift),
sizeof shift);
170 for(
int strand = 0; strand < 2; ++strand) {
172 out.write(
reinterpret_cast<const char*
>(&
len),
sizeof len);
177 cerr <<
"Error in PhyloCSF write\n";
192 for(
auto& cs : scores) {
193 auto& contig_acc = cs.first;
194 for(
int strand = 0; strand < 2; ++strand) {
196 auto scr = cs.second[strand][
i];
TSignedSeqRange ShrinkToRealPointsOnEdited(TSignedSeqRange edited_range) const
TSignedSeqRange MapRangeEditedToOrig(TSignedSeqRange edited_range, bool withextras=true) const
TSignedSeqPos MapEditedToOrig(TSignedSeqPos edited_pos) const
void CompactFullScores(const map< string, array< TFVec, 2 >> &scores)
void Read(CNcbiIstream &from)
SPhyloCSFSlice * CreateSliceForContig(const string &contig_acc) const
map< string, array< SPhyloCSFCompactScore, 2 > > m_contig_scores
void Write(CNcbiOstream &out) const
const_iterator end() const
const_iterator find(const key_type &key) const
std::ofstream out("events_result.xml")
main entry point for tests
int TSignedSeqPos
Type for signed sequence position.
static TThisType GetEmpty(void)
CRange< TSignedSeqPos > TSignedSeqRange
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
unsigned int
A callback function used to compare two keys in a database.
vector< TPhyloCSFScore > TFVec
size_t UpperBound(TSignedSeqPos p) const
void Write(CNcbiOstream &out) const
void Read(CNcbiIstream &from, size_t len)
pair< TSignedSeqPos, TPhyloCSFScore > TElement
size_t LowerBound(TSignedSeqPos p) const
TPhyloCSFScore Score(TSignedSeqPos p) const
vector< TElement > m_scores
TSignedSeqRange CompactRange(int s, TSignedSeqRange edited_range) const
TPhyloCSFScore Score(int s, TSignedSeqPos codon_left) const
const array< SPhyloCSFCompactScore, 2 > * m_scoresp