64 const char* begin = src + (pos / 4);
65 const char* end = src + ((pos + length - 1) / 4) + 1;
66 const char* iter = end;
68 size_t offset = (pos + length - 1) % 4;
72 for ( ; iter != begin; ++dst ) {
78 for (
size_t count = length / 4; count; --count, ++dst ) {
86 if ( length % 4 != 0 ) {
87 *dst =
table[
static_cast<Uint1>(*iter) * 2 + 1];
88 if ( iter != begin ) {
90 *dst |= (char)
table[
static_cast<Uint1>(*iter) * 2];
96 *dst &= char(0xFF << ((4 - (length % 4)) % 4) * 2);
108 size_t start_offset = (pos + length - 1) % 2;
112 const char* begin = src + (pos / 2);
113 const char* end = src + ((pos + length - 1) / 2) + 1;
114 const char* iter = end;
116 switch ( start_offset ) {
120 for ( ; iter != begin; ++dst ) {
124 if ( length % 2 != 0 ) {
132 for (
size_t count = length / 2; count; --count, ++dst ) {
134 *dst = char((
static_cast<Uint1>(*iter) & 0xF0) |
135 (
static_cast<Uint1>(*(iter - 1)) & 0x0F));
138 if ( length % 2 != 0 ) {
140 *dst = char(
static_cast<Uint1>(*iter) & 0xF0);
150 template <
typename SrcCont,
typename DstCont>
159 if ( src.empty() || (length == 0) ) {
167 pos, length, &*dst.begin());
179 return s_Reverse(src, src_coding, pos, length, dst);
184 (
const vector<char>& src,
191 return s_Reverse(src, coding,pos, length, dst);
202 _ASSERT((dst != 0) && (src != 0));
204 switch ( src_coding ) {
215 reverse_copy(src + pos, src + pos + length, dst);
227 template <
typename SrcCont,
typename DstCont>
236 if ( src.empty() || (length == 0) ) {
244 pos, length, &*dst.begin());
261 (
const vector<char>& src,
278 const char* iter = src + (pos / 4);
279 const char* end = src + ((pos + length - 1) / 4) + 1;
281 if ( pos % 4 == 0 ) {
282 for ( ; iter != end; ++iter, ++dst ) {
283 *dst = char(~(*iter));
286 if ( length % 4 != 0 ) {
287 *(--dst) &=
char(0xFF << (8 - (length % 4) * 2));
292 for (
size_t count = length / 4; count; --count, ++dst, ++iter ) {
295 table[
static_cast<Uint1>(*(iter + 1)) * 2 + 1] );
299 if ( length % 4 != 0 ) {
300 *dst = (char)
table[
static_cast<Uint1>(*iter) * 2];
301 if ( ++iter != end ) {
302 *dst |= (char)
table[
static_cast<Uint1>(*iter) * 2 + 1];
307 *dst &= char(0xFF << ((4 - (length % 4)) % 4) * 2);
319 const char* end = src + pos + length;
320 const char* iter = src + pos;
322 for ( ; iter != end; ++iter, ++dst ) {
323 *dst = char(3 -
static_cast<Uint1>(*iter));
336 const char* iter = src + (pos / 2);
337 const char* end = src + (pos + length - 1) / 2 + 1;
344 for ( ; iter != end; ++iter, ++dst ) {
345 *dst = (char)
table[
static_cast<Uint1>(*iter)];
348 if ( length % 2 != 0 ) {
356 for (
size_t count = length / 2; count; --count, ++iter, ++dst ) {
359 table[
static_cast<Uint1>(*(iter + 1)) * 2 + 1] );
362 if ( length % 2 != 0 ) {
363 *dst = (char)
table[
static_cast<Uint1>(*iter) * 2];
380 _ASSERT((dst != 0) && (src != 0));
382 switch ( src_coding ) {
404 "There is no complement for the specified coding.");
411 template <
typename SrcCont,
typename DstCont>
420 if ( src.empty() || (length == 0) ) {
428 pos, length, &*dst.begin());
445 (
const vector<char>& src,
462 size_t offset = (pos + length - 1) % 4;
465 const char* begin = src + (pos / 4);
466 const char* iter = src + (pos + length - 1) / 4 + 1;
472 for (
size_t count = length / 4; count; --count, ++dst, --iter ) {
475 table[
static_cast<Uint1>(*(iter - 1)) * 2 + 1];
479 if ( length % 4 != 0 ) {
481 if ( iter != begin ) {
483 *dst |= (char)
table[
static_cast<Uint1>(*iter) * 2 + 1];
490 for ( ; iter != begin; ++dst ) {
497 *dst &= char(0xFF << ((4 - (length % 4)) % 4) * 2);
509 const char* begin = src + pos;
510 const char* iter = src + pos + length;
512 for ( ; iter != begin; ++dst ) {
513 *dst = char(3 -
static_cast<Uint1>(*--iter));
526 const char* begin = src + (pos / 2);
527 const char* iter = src + ((pos + length - 1) / 2) + 1;
529 size_t offset = (pos + length - 1) % 2;
536 for (
size_t count = length / 2; count; --count, --iter, ++dst ) {
539 table[
static_cast<Uint1>(*(iter - 1)) * 2 + 1];
542 if ( length % 2 != 0 ) {
550 for ( ; iter != begin; ++dst ) {
554 if ( length % 2 != 0 ) {
572 _ASSERT((dst != 0) && (src != 0));
574 switch ( src_coding ) {
597 "There is no complement for the specified coding.");
603 template <
typename SrcCont>
611 if ( src.empty() || (length == 0) ) {
649 char*
first = src + pos;
654 temp = char(3 - *
first);
660 copy(src + pos, src + pos + length, src);
672 char*
buf =
new char[length];
689 char*
buf =
new char[length];
709 switch ( src_coding ) {
731 "There is no complement for the specified coding.");
static const Uint1 * GetTable(size_t offset)
static const Uint1 * GetTable(size_t offset)
static const Uint1 * GetTable(size_t offset)
static const Uint1 * GetTable(size_t offset)
static const Uint1 * GetTable(size_t offset)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static SIZE_TYPE Convert(const CTempString &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst, TCoding dst_coding)
static SIZE_TYPE Reverse(const string &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst)
static SIZE_TYPE ReverseComplement(const string &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst)
static SIZE_TYPE Complement(const string &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst)
Include a standard set of the NCBI C++ Toolkit most basic headers.
The NCBI C++ standard methods for dealing with std::string.
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
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
#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
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
static SIZE_TYPE s_Ncbi2naRevCmp(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE s_Ncbi2naExpandRevCmp(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE s_4naReverse(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE s_Ncbi4naRevCmp(const char *src, TSeqPos pos, TSeqPos length, char *dst)
SIZE_TYPE s_ReverseComplement(const SrcCont &src, CSeqUtil::TCoding src_coding, TSeqPos pos, TSeqPos length, DstCont &dst)
static SIZE_TYPE s_Ncbi2naComplement(const char *src, TSeqPos pos, TSeqPos length, char *dst)
static SIZE_TYPE s_2naReverse(const char *src, TSeqPos pos, TSeqPos length, char *dst)
SIZE_TYPE s_Complement(const SrcCont &src, CSeqUtil::TCoding src_coding, TSeqPos pos, TSeqPos length, DstCont &dst)
static SIZE_TYPE s_Ncbi2naExpandComplement(const char *src, TSeqPos pos, TSeqPos length, char *dst)
SIZE_TYPE s_Reverse(const SrcCont &src, CSeqUtil::TCoding src_coding, TSeqPos pos, TSeqPos length, DstCont &dst)
static SIZE_TYPE s_Ncbi4naComplement(const char *src, TSeqPos pos, TSeqPos length, char *dst)
SIZE_TYPE copy_1_to_1_reverse(const char *src, TSeqPos pos, TSeqPos length, char *dst, const Uint1 *table)
SIZE_TYPE convert_1_to_1(const char *src, TSeqPos pos, TSeqPos length, char *dst, const Uint1 *table)
SIZE_TYPE revcmp(char *buf, TSeqPos pos, TSeqPos length, const Uint1 *table)
bool OutOfRange(TSeqPos pos, const C &container, CSeqUtil::TCoding coding)
void ResizeDst(C &container, CSeqUtil::TCoding coding, TSeqPos length)
void AdjustLength(C &container, CSeqUtil::TCoding coding, TSeqPos pos, TSeqPos &length)