((dst != 0) && (src != 0));
77 if( src_coding == dst_coding ) {
78 return Subseq(src, src_coding, pos, length, dst);
82 switch( src_coding ) {
88 switch( dst_coding ) {
105 switch( dst_coding ) {
122 switch( dst_coding ) {
139 switch( dst_coding ) {
157 switch( dst_coding ) {
168 return Subseq(src, src_coding, pos, length, dst);
180 switch( dst_coding ) {
193 switch( dst_coding ) {
207 switch( dst_coding ) {
214 return Subseq(src, src_coding, pos, length, dst);
269 const char* src_i = src + pos;
272 table[*src_i * 4 ] |
273 table[*(src_i + 1) * 4 + 1] |
274 table[*(src_i + 2) * 4 + 2] |
275 table[*(src_i + 3) * 4 + 3];
281 if( length % 4 != 0 ) {
283 for(
size_t i= 0;
i< (length % 4); ++
i, ++src_i ) {
284*dst |= (char)
table[
static_cast<Uint1>(*src_i) * 4 +
i];
326 const char* src_i = src + pos;
329*dst =
table[*src_i * 2] |
table[*(src_i + 1) * 2 + 1];
335 if( length % 2 != 0 ) {
336*dst =
table[
static_cast<Uint1>(*src_i) * 2];
402 const char* iter = src + (pos / 4);
404 size_t size= length;
430*dst =
table[
static_cast<Uint1>(*iter) * 2 + 1];
445 Uint2* dst2 =
reinterpret_cast<Uint2*
>(dst);
446 for(
size_t i=
size/ 4;
i; --
i, ++dst2, ++iter ) {
447*dst2 = table2[
static_cast<Uint1>(*iter)];
449dst =
reinterpret_cast<char*
>(dst2);
453 if( (
size% 4) != 0 ) {
454 switch(
size% 4 ) {
456*dst =
table[
static_cast<Uint1>(*iter) * 2] & 0xf0;
459*dst =
table[
static_cast<Uint1>(*iter) * 2];
462*dst =
table[
static_cast<Uint1>(*iter) * 2];
464*dst =
table[
static_cast<Uint1>(*iter) * 2 + 1] & 0xf0;
474*dst =
table[
static_cast<Uint1>(*iter) * 3 + 2];
477*dst =
table[
static_cast<Uint1>(*iter) * 3 + 2] |
478 table[
static_cast<Uint1>(*(iter + 1)) * 3];
487 for(
size_t i=
size/ 4;
i; --
i, ++iter ) {
488*dst =
table[
static_cast<Uint1>(*iter) * 3 + 1];
490*dst =
table[
static_cast<Uint1>(*iter) * 3 + 2] |
491 table[
static_cast<Uint1>(*(iter + 1)) * 3];
497 if(
size% 4 != 0 ) {
498 switch(
size% 4 ) {
500*dst =
table[
static_cast<Uint1>(*iter) * 3 + 1] & 0xF0;
504*dst =
table[
static_cast<Uint1>(*iter) * 3 + 1];
508*dst =
table[
static_cast<Uint1>(*iter) * 3 + 1];
510*dst =
table[
static_cast<Uint1>(*iter) * 3 + 2];
560 const char* iter = src + pos;
564 for(
size_t i= length / 4;
i; --
i, ++dst ) {
565*dst = char((*iter << 6) | (*(iter + 1) << 4) |
566(*(iter + 2) << 2) | (*(iter + 3)));
570 switch( length % 4 ) {
572*dst = char(*iter << 6);
575*dst = char((*iter << 6) | (*(iter + 1) << 4));
578*dst = char((*iter << 6) | (*(iter + 1) << 4) | (*(iter + 2) << 2));
608 const char* iter = src + pos;
610 for(
size_t i= length / 2;
i; --
i, ++dst ) {
611*dst =
table[*iter * 2] |
table[*(iter + 1) * 2 + 1];
615 if( length % 2 != 0 ) {
616*dst =
table[*iter * 2];
672 size_toverhang = length % 4;
674 const char* iter = src + (pos / 2);
680 for(
size_t i= length / 4;
i; --
i, ++dst ) {
683 table[
static_cast<Uint1>(*(iter + 1)) * 2 + 1];
688 if( overhang != 0 ) {
689 switch( overhang ) {
692*dst = (
table[
static_cast<Uint1>(*iter) * 2]) & 0xC0;
696*dst = (
table[
static_cast<Uint1>(*iter) * 2]) & 0xF0;
701(
table[
static_cast<Uint1>(*(iter + 1)) * 2 + 1] & 0xFC));
711 for(
size_t i= length / 4;
i; --
i, ++dst ) {
714 table[
static_cast<Uint1>(*(iter + 1)) * 3 + 1] |
715 table[
static_cast<Uint1>(*(iter + 2)) * 3 + 2];
720 if( overhang != 0 ) {
721 switch( overhang ) {
723*dst =
table[
static_cast<Uint1>(*iter) * 3] & 0xC0;
728(
table[
static_cast<Uint1>(*(iter + 1)) * 3 + 1] & 0xF0));
733(
table[
static_cast<Uint1>(*(iter + 1)) * 3 + 1] & 0xFC));
798 const char* iter = src + pos;
800 for(
size_t i= length / 4;
i; --
i, ++dst ) {
801*dst =
table[
static_cast<Uint1>(*iter) * 4] |
802 table[
static_cast<Uint1>(*(iter + 1)) * 4 + 1] |
803 table[
static_cast<Uint1>(*(iter + 2)) * 4 + 2] |
804 table[
static_cast<Uint1>(*(iter + 3)) * 4 + 3];
809 if( (length % 4) != 0 ) {
811 for(
size_t i= 0;
i< (length % 4); ++
i, ++iter ) {
812*dst |= (char)
table[
static_cast<Uint1>(*iter)*4 +
i];
862 const char* iter = src + pos;
864 for(
size_t i= length / 2;
i; --
i, ++dst ) {
865*dst = char((*iter << 4) | (*(iter + 1)));
869 if( (length % 2) != 0 ) {
870*dst = char((*iter << 4) & 0xf0);
981 buf=
new char[length];
991 buf=
new char[length];
1011 const char* iter = src + pos;
1012 const char* end = iter + length;
1014 for( ; iter != end; ++iter, ++dst ) {
1015*dst = (char)
toupper((
unsigned char)(*iter));
1025 copy(src + pos, src + pos + length, dst);
1052dst_coding =
x_HasAmbig(src, src_coding, length) ?
1055 return Convert(src, src_coding, 0, length, dst, dst_coding);
1068 switch(src_coding) {
1070best_coding = best_codings.
iupacna;
1074 return Convert(src, src_coding, 0, length,
1079best_coding = best_codings.
ncbi4na;
1084best_coding = best_codings.
ncbi8na;
1090best_coding = best_codings.
ncbieaa;
1097best_coding = best_codings.
ncbi8aa;
1105 if(best_coding !=
NULL) {
1106 return CPacker(src_coding, best_coding, gaps_ok, dst)
1107.
Pack(src, length);
1109memcpy(dst.
NewSegment(src_coding, length), src,
1126 const char* src_end = src +
GetBytesNeeded(m_SrcCoding, length);
1127 TCodingprev_type = kNoCoding;
1129 for(
const char* p = src; p < src_end; ++p) {
1130 unsigned charresidue;
1133residue =
static_cast<unsigned char>(*p);
1134curr_type = m_BestCoding[residue];
1135}
while(curr_type == prev_type && ++p < src_end);
1138 TCodingtype1 = m_BestCoding[(residue >> 4) * 0x11],
1139type2 = m_BestCoding[(residue & 0x0F) * 0x11];
1140 if(type1 != prev_type) {
1141x_AddBoundary(
TSeqPos((p - src)*2), type1);
1143x_AddBoundary(
TSeqPos((p - src)*2 + 1), type2);
1145}
else if(p != src_end) {
1146 _ASSERT(curr_type != kNoCoding);
1147x_AddBoundary(
TSeqPos((p - src) * m_SrcDensity), curr_type);
1148prev_type = curr_type;
1151x_AddBoundary(length, kNoCoding);
1153 _ASSERT(m_Boundaries.at(0) == 0);
1156= (m_EndingNarrow.cost < m_EndingWide.cost
1157? &m_EndingNarrow : &m_EndingWide);
1161 size_t n= m_Boundaries.size() - 1;
1162vector<TCoding> coding_vec(
n);
1164 for(
size_t i= 0;
i<
n;
1173 for(
size_t i= 0;
i<
n; ++
i) {
1176 while(
i<
n- 1 && coding_vec[
i+ 1] == coding) {
1181 char* segment = m_Target.NewSegment(coding,
len);
1196 if(m_Boundaries.empty()) {
1198m_Boundaries.push_back(pos);
1199m_EndingNarrow.AddCoding(new_coding);
1200m_EndingWide.AddCoding(m_WideCoding);
1201m_EndingWide.cost = m_Target.GetOverhead(m_WideCoding);
1202m_EndingNarrow.cost = m_Target.GetOverhead(new_coding);
1206 TSeqPoslast_length = pos - m_Boundaries.back();
1208m_Boundaries.push_back(pos);
1210 TCodinglast_narrow = m_EndingNarrow.codings->GetLast();
1213m_EndingNarrow.cost +=
GetBytesNeeded(last_narrow, last_length);
1215 if(last_narrow == m_WideCoding) {
1216 _ASSERT(m_EndingNarrow.cost == m_EndingWide.cost);
1222 _ASSERT(new_coding != last_narrow);
1223 if(new_coding == kNoCoding) {
1227 if(new_coding != m_WideCoding
1228&& m_EndingNarrow.cost > m_EndingWide.cost) {
1229m_EndingNarrow = m_EndingWide;
1234= m_EndingNarrow.cost + m_Target.GetOverhead(m_WideCoding);
1235m_EndingNarrow.cost += m_Target.GetOverhead(new_coding);
1237 if(m_EndingWide.cost > alt_wide_cost) {
1238m_EndingWide = m_EndingNarrow;
1239m_EndingWide.cost = alt_wide_cost;
1241}
else if(new_coding == m_WideCoding) {
1242m_EndingNarrow = m_EndingWide;
1247m_EndingNarrow.AddCoding(new_coding);
1248m_EndingWide.AddCoding(m_WideCoding);
1254 _ASSERT(
arr.shared_codings == shared_codings);
1255 if(codings->previous == shared_codings) {
1256 _ASSERT(
arr.codings->previous == shared_codings);
1257codings->current_used =
arr.codings->current_used;
1258memcpy(codings->current,
arr.codings->current,
1259codings->current_used *
sizeof(
TCoding));
1263shared_codings =
arr.shared_codings = codings->previous;
1271 while(codings !=
NULL&& codings != shared_codings) {
1280 if(codings ==
NULL|| codings->current_used == SCodings::kBlockSize) {
1284codings = new_codings;
1286codings->
current[codings->current_used++] = coding;
1312 if( length == 0 ) {
1316 switch( src_coding ) {
1343 const char* end = src + length;
1345 const char* iter = src;
1346 while( (iter != end) && (not_ambig[
static_cast<Uint1>(*iter)]) ) {
1358 const char* end = src + (length / 2);
1360 const char* iter = src;
1361 while( (iter != end) && (not_ambig[
static_cast<Uint1>(*iter)]) ) {
1365 if( (iter == end) && (length % 2) != 0 ) {
1366 returnnot_ambig[
static_cast<Uint1>(*iter | 1) & 0xF1];
1376 const char* end = src + length;
1378 const char* iter = src;
1379 while( (iter != end) && (not_ambig[
static_cast<Uint1>(*iter)]) ) {
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(bool boundry)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(size_t offset)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const bool * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const bool * GetTable(void)
static const bool * GetTable(void)
virtual bool GapsOK(TCodingType coding_type) const =0
virtual char * NewSegment(TCoding coding, TSeqPos length)=0
SIZE_TYPE Pack(const char *src, TSeqPos length)
SArrangement m_EndingWide
static TCoding x_GetWideCoding(const TCoding coding)
void x_AddBoundary(TSeqPos pos, TCoding new_coding)
SArrangement m_EndingNarrow
static const TCoding kNoCoding
static SIZE_TYPE x_ConvertIupacaaToStdaa(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert4naTo8na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_ConvertEaaToIupacaa(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert8naTo4na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_ConvertIupacnaTo8na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert8naTo2naExpand(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert4naTo2naExpand(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_ConvertIupacaaToEaa(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert4naTo2na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_ConvertEaaToStdaa(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert8naToIupacna(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_ConvertIupacnaToIupacna(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert2naTo8na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static bool x_HasAmbig(const char *src, TCoding src_coding, size_t length)
static bool x_HasAmbigNcbi8na(const char *src, size_t length)
static SIZE_TYPE x_ConvertIupacnaTo2na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE Subseq(const SrcCont &src, TCoding coding, TSeqPos pos, TSeqPos length, DstCont &dst)
static SIZE_TYPE x_ConvertStdaaToIupacaa(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert8naTo2na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert2naExpandTo2na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert2naTo4na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static bool x_HasAmbigIupacna(const char *src, size_t length)
static SIZE_TYPE x_Convert2naExpandTo8na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_ConvertStdaaToEaa(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE Convert(const SrcCont &src, TCoding src_coding, TSeqPos pos, TSeqPos length, DstCont &dst, TCoding dst_coding)
static SIZE_TYPE x_Convert2naExpandToIupacna(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert4naToIupacna(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_ConvertIupacnaTo4na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE Pack(const SrcCont &src, TCoding src_coding, DstCont &dst, TCoding &dst_coding, TSeqPos length)
static SIZE_TYPE x_ConvertIupacnaTo2naExpand(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert2naToIupacna(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static bool x_HasAmbigNcbi4na(const char *src, size_t length)
static SIZE_TYPE x_Convert2naTo2naExpand(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE x_Convert2naExpandTo4na(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE Convert(const CTempString &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst, TCoding dst_coding)
static ECodingType GetCodingType(TCoding coding)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
Include a standard set of the NCBI C++ Toolkit most basic headers.
static vector< string > arr
unsigned int TSeqPos
Type for sequence locations and lengths.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
uint8_t Uint1
1-byte (8-bit) unsigned integer
uint16_t Uint2
2-byte (16-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
NCBI_NS_STD::string::size_type SIZE_TYPE
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
const struct ncbi::grid::netcache::search::fields::SIZE size
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
const SBestCodings kBestCodingsWithoutGaps
const SBestCodings kBestCodingsWithGaps
SArrangement & operator=(SArrangement &arr)
SCodings * shared_codings
void AddCoding(TCoding coding)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4