NCBI C++ ToolKit
sequtil_convert_imp.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: sequtil_convert_imp.cpp 72358 2016-05-03 17:12:04Z ivanov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Mati Shomrat
27  *
28  * File Description:
29  *
30  */
31 #include <ncbi_pch.hpp>
32 #include <corelib/ncbistd.hpp>
33 
35 #include <util/range.hpp>
36 
37 #include "sequtil_convert_imp.hpp"
38 #include "sequtil_shared.hpp"
39 #include "sequtil_tables.hpp"
40 
41 #include <stdlib.h>
42 
44 
45 
46 /////////////////////////////////////////////////////////////////////////////
47 //
48 // Conversions
49 
50 // NB: We try to use conversion tables wherever possible, minimizing bit
51 // shifting or any other operation within the main conversion loop.
52 
53 // All conversion functions takes the following parameters:
54 // src - input sequence
55 // pos - starting position in sequence coordinates
56 // length - number of residues to convert
57 // dst - an output container
58 
59 
61 (const char* src,
62  TCoding src_coding,
63  TSeqPos pos,
64  TSeqPos length,
65  char* dst,
66  TCoding dst_coding)
67 {
68  _ASSERT((dst != 0) && (src != 0));
69  _ASSERT(CSeqUtil::GetCodingType(src_coding) ==
70  CSeqUtil::GetCodingType(dst_coding));
71 
72  if ( length == 0 ) {
73  return 0;
74  }
75 
76  // conversion from a coding to itself.
77  if ( src_coding == dst_coding ) {
78  return Subseq(src, src_coding, pos, length, dst);
79  }
80 
81  // all other conversions
82  switch ( src_coding ) {
83 
84  // --- NA conversions
85 
86  // iupacna -> ...
88  switch ( dst_coding ) {
90  return x_ConvertIupacnaTo2na(src, pos, length, dst);
92  return x_ConvertIupacnaTo2naExpand(src, pos, length, dst);
94  return x_ConvertIupacnaTo4na(src, pos, length, dst);
97  return x_ConvertIupacnaTo8na(src, pos, length, dst);
98  default:
99  break;
100  }
101  break;
102 
103  // ncbi2na -> ...
104  case CSeqUtil::e_Ncbi2na:
105  switch ( dst_coding ) {
106  case CSeqUtil::e_Iupacna:
107  return x_Convert2naToIupacna(src, pos, length, dst);
109  return x_Convert2naTo2naExpand(src, pos, length, dst);
110  case CSeqUtil::e_Ncbi4na:
111  return x_Convert2naTo4na(src, pos, length, dst);
113  case CSeqUtil::e_Ncbi8na:
114  return x_Convert2naTo8na(src, pos, length, dst);
115  default:
116  break;
117  }
118  break;
119 
120  // ncbi2na_expand -> ...
122  switch ( dst_coding ) {
123  case CSeqUtil::e_Iupacna:
124  return x_Convert2naExpandToIupacna(src, pos, length, dst);
125  case CSeqUtil::e_Ncbi2na:
126  return x_Convert2naExpandTo2na(src, pos, length, dst);
127  case CSeqUtil::e_Ncbi4na:
128  return x_Convert2naExpandTo4na(src, pos, length, dst);
130  case CSeqUtil::e_Ncbi8na:
131  return x_Convert2naExpandTo8na(src, pos, length, dst);
132  default:
133  break;
134  }
135  break;
136 
137  // ncbi4na -> ...
138  case CSeqUtil::e_Ncbi4na:
139  switch ( dst_coding ) {
140  case CSeqUtil::e_Iupacna:
141  return x_Convert4naToIupacna(src, pos, length, dst);
142  case CSeqUtil::e_Ncbi2na:
143  return x_Convert4naTo2na(src, pos, length, dst);
145  return x_Convert4naTo2naExpand(src, pos, length, dst);
147  case CSeqUtil::e_Ncbi8na:
148  return x_Convert4naTo8na(src, pos, length, dst);
149  default:
150  break;
151  }
152  break;
153 
154  // ncbi8na / ncbi4na_expand -> ...
155  case CSeqUtil::e_Ncbi8na:
157  switch ( dst_coding ) {
158  case CSeqUtil::e_Iupacna:
159  return x_Convert8naToIupacna(src, pos, length, dst);
160  case CSeqUtil::e_Ncbi2na:
161  return x_Convert8naTo2na(src, pos, length, dst);
163  return x_Convert8naTo2naExpand(src, pos, length, dst);
164  case CSeqUtil::e_Ncbi4na:
165  return x_Convert8naTo4na(src, pos, length, dst);
166  case CSeqUtil::e_Ncbi8na:
168  return Subseq(src, src_coding, pos, length, dst);
169  default:
170  break;
171  }
172  break;
173 
174  // --- AA conversions
175 
176  // NB: currently ncbi8aa is the same as ncbistdaa.
177 
178  // iupacaa -> ...
179  case CSeqUtil::e_Iupacaa:
180  switch ( dst_coding ) {
181  case CSeqUtil::e_Ncbieaa:
182  return x_ConvertIupacaaToEaa(src, pos, length, dst);
184  case CSeqUtil::e_Ncbi8aa:
185  return x_ConvertIupacaaToStdaa(src, pos, length, dst);
186  default:
187  break;
188  }
189  break;
190 
191  // ncbieaa -> ...
192  case CSeqUtil::e_Ncbieaa:
193  switch ( dst_coding ) {
194  case CSeqUtil::e_Iupacaa:
195  return x_ConvertEaaToIupacaa(src, pos, length, dst);
197  case CSeqUtil::e_Ncbi8aa:
198  return x_ConvertEaaToStdaa(src, pos, length, dst);
199  default:
200  break;
201  }
202  break;
203 
204  // ncbistdaa / ncbi8aa -> ...
205  case CSeqUtil::e_Ncbi8aa:
207  switch ( dst_coding ) {
208  case CSeqUtil::e_Ncbieaa:
209  return x_ConvertStdaaToEaa(src, pos, length, dst);
210  case CSeqUtil::e_Iupacaa:
211  return x_ConvertStdaaToIupacaa(src, pos, length, dst);
212  case CSeqUtil::e_Ncbi8aa:
214  return Subseq(src, src_coding, pos, length, dst);
215  default:
216  break;
217  }
218  break;
219 
220  default:
221  break;
222  }
223 
224  // We should never reach here
225  NCBI_THROW(CSeqUtilException, eInvalidCoding, "Unknown conversion.");
226 }
227 
228 
229 // --- NA conversions:
230 
231 
232 // from IUPACna to ...
233 //===========================================================================
234 
235 // IUPACna -> IUPACna
236 // This is not a simple copy since we handle conversion of lower to upper
237 // case and conversion of 'U'('u') to 'T'
238 
240 (const char* src,
241  TSeqPos pos,
242  TSeqPos length,
243  char* dst)
244 {
245  // call the shared implementation for converting 1 byte to another byte
246  // given a specific conversion table.
247  // the iupacna to iupacna table converts upper and lower case to upper case
248  // and U (u) to T
249  return convert_1_to_1(src, pos, length, dst,
251 }
252 
253 
254 // IUPACna -> NCBI2na
255 // convert 4 IUPACna characters into a single NCBI2na byte
256 
258 (const char* src,
259  TSeqPos pos,
260  TSeqPos length,
261  char* dst)
262 {
263  // The iupacna to ncbi2na table is constructed such that each row
264  // correspond to an iupacna letter and each column corresponds to
265  // that letter being in one of the 4 possible offsets within the
266  // ncbi2na byte
268 
269  const char* src_i = src + pos;
270  for ( size_t count = length / 4; count; --count ) {
271  *dst =
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];
276  src_i += 4;
277  ++dst;
278  }
279 
280  // Handle overhang
281  if ( length % 4 != 0 ) {
282  *dst = 0x0;
283  for( size_t i = 0; i < (length % 4); ++i, ++src_i ) {
284  *dst |= (char)table[static_cast<Uint1>(*src_i) * 4 + i];
285  }
286  }
287 
288  return length;
289 }
290 
291 
292 // IUPACna -> NCBI2na_expand
293 // convert a single IUPACna character into a single NCBI2na_expand byte.
294 
296 (const char* src,
297  TSeqPos pos,
298  TSeqPos length,
299  char* dst)
300 {
301  // call the shared implementation for converting 1 byte to another byte
302  // given a specific conversion table.
303  // the iupacna to ncbi2na_expand table converts upper and lower case IUPACna
304  // into a single ncbi2na_expand byte.
305  return convert_1_to_1(src, pos, length, dst,
307 }
308 
309 
310 // IUPACna -> NCBI4na
311 // convert 2 IUPACna characters into a single NCBI4na byte
312 
314 (const char* src,
315  TSeqPos pos,
316  TSeqPos length,
317  char* dst)
318 {
319 
320  // The iupacna to ncbi4na table is constructed such that each row
321  // correspond to an iupacna letter and each column corresponds to
322  // that letter being in one of the 2 possible offsets within the
323  // ncbi4na byte
325 
326  const char* src_i = src + pos;
327 
328  for ( size_t count = length / 2; count; --count ) {
329  *dst = table[*src_i * 2] | table[*(src_i + 1) * 2 + 1];
330  src_i += 2;
331  ++dst;
332  }
333 
334  // handle overhang
335  if ( length % 2 != 0 ) {
336  *dst = table[static_cast<Uint1>(*src_i) * 2];
337  }
338 
339  return length;
340 }
341 
342 
343 // IUPACna -> NCBI8na (NCBI4na_expand)
344 // convert a single IUPACna character into a single NCBI8na byte.
345 
347 (const char* src,
348  TSeqPos pos,
349  TSeqPos length,
350  char* dst)
351 {
352  // call the shared implementation for converting 1 byte to another byte
353  // given a specific conversion table.
354  // the iupacna to ncbi8na table converts upper and lower case IUPACna
355  // into a single ncbi8na byte (which is the same as ncbi4na_expand)
356  return convert_1_to_1(src, pos, length, dst,
358 }
359 
360 
361 // from NCBI2na to ...
362 //===========================================================================
363 
364 // NCBI2na -> IUPACna
365 // convert a NCBI2na byte into 4 IUPACna characters.
366 
368 (const char* src,
369  TSeqPos pos,
370  TSeqPos length,
371  char* dst)
372 {
373  return convert_1_to_4(src, pos, length, dst, C2naToIupacna::GetTable());
374 }
375 
376 
377 // NCBI2na -> NCBI2na_expand
378 // convert a NCBI2na byte into 4 NCBI2na_expand characters.
379 
381 (const char* src,
382  TSeqPos pos,
383  TSeqPos length,
384  char* dst)
385 {
386  return convert_1_to_4(src, pos, length, dst, C2naTo2naExpand::GetTable());
387 }
388 
389 
390 // NCBI2na -> NCBI4na
391 // convert a NCBI2na byte into 2 NCBI4na bytes.
392 
394 (const char* src,
395  TSeqPos pos,
396  TSeqPos length,
397  char* dst)
398 {
399  const Uint1* table = C2naTo4na::GetTable(pos % 2 == 0);
400  const Uint2* table2 = reinterpret_cast<const Uint2*>(table);
401 
402  const char* iter = src + (pos / 4);
403 
404  size_t size = length;
405  // NB: branch within the inner loop as devastating consequences
406  // on performance.
407 
408  // we handle two different cases, the first being offsets 0 and 2.
409  // the second are offsets 1 and 3.
410  // for offsets 0,2 we use a 2 column table, where the first column
411  // corresponds to the lower 4 bits of the ncbi2na coding (entry 0)
412  // and the second column corresponds to the upper 4 bits (entry 1).
413  // in this case once we set the initial entry progress is the same.
414  // the overhang for this case is either 0 or 1.
415  // the 1\3 offset is a more complex one. for it we use a 3 column table.
416  // the first column corresponds to the lower 2 bits of the ncbi2na
417  // coding, the second corresponds to the middle 4 bits and the third
418  // correspond to the upper 2 bits.
419  // we handle all cases as offset 3. for offset one we simply handle
420  // the first 4 bits, which will being us to offset 3.
421  // as handling the middle 4 bits or the combination of the 2 lower
422  // ones and 2 upper ones are done differently, we handle 4 letters (8 bits)
423  // at a time, in oredr to prevent branching withing the inner loop.
424  // overhang for this case is 1, 2 or 3.
425 
426  switch ( pos % 4 ) {
427  // --- table entry size for offsets 0,2 is 2
428  case 2:
429  {{
430  *dst = table[static_cast<Uint1>(*iter) * 2 + 1];
431  if ( length == 1 ) {
432  *dst &= (char)0xf0;
433  return length;
434  }
435  size -= 2;
436  ++iter;
437  ++dst;
438  }}
439 
440  // intentional fall through
441  case 0:
442  {{
443  // "trick" the compiler so that each assignment will
444  // be of 2 bytes.
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)];
448  }
449  dst = reinterpret_cast<char*>(dst2);
450  }}
451 
452  // handle overhang
453  if ( (size % 4) != 0 ) {
454  switch ( size % 4 ) {
455  case 1:
456  *dst = table[static_cast<Uint1>(*iter) * 2] & 0xf0;
457  break;
458  case 2:
459  *dst = table[static_cast<Uint1>(*iter) * 2];
460  break;
461  case 3:
462  *dst = table[static_cast<Uint1>(*iter) * 2];
463  ++dst;
464  *dst = table[static_cast<Uint1>(*iter) * 2 + 1] & 0xf0;
465  break;
466  }
467  }
468  break;
469 
470  // --- table entry size for offsets 1,3 is 3
471  case 3:
472  {{
473  if ( length == 1 ) {
474  *dst = table[static_cast<Uint1>(*iter) * 3 + 2];
475  return length;
476  } else {
477  *dst = table[static_cast<Uint1>(*iter) * 3 + 2] |
478  table[static_cast<Uint1>(*(iter + 1)) * 3];
479  ++dst;
480  ++iter;
481  size -= 2;
482  }
483  }}
484  // intentional fall through
485  case 1:
486  {{
487  for ( size_t i = size / 4; i; --i, ++iter ) {
488  *dst = table[static_cast<Uint1>(*iter) * 3 + 1];
489  ++dst;
490  *dst = table[static_cast<Uint1>(*iter) * 3 + 2] |
491  table[static_cast<Uint1>(*(iter + 1)) * 3];
492  ++dst;
493  }
494  }}
495 
496  // handle overhang
497  if ( size % 4 != 0 ) {
498  switch ( size % 4 ) {
499  case 1:
500  *dst = table[static_cast<Uint1>(*iter) * 3 + 1] & 0xF0;
501  break;
502 
503  case 2:
504  *dst = table[static_cast<Uint1>(*iter) * 3 + 1];
505  break;
506 
507  case 3:
508  *dst = table[static_cast<Uint1>(*iter) * 3 + 1];
509  ++dst;
510  *dst = table[static_cast<Uint1>(*iter) * 3 + 2];
511  break;
512  }
513  }
514  break;
515  } // end of switch ( offset )
516 
517  return length;
518 }
519 
520 
521 // NCBI2na -> NCBI8na (NCBI4na_expand)
522 // convert a ncbi2na byte into 4 ncbi4na bytes.
523 
525 (const char* src,
526  TSeqPos pos,
527  TSeqPos length,
528  char* dst)
529 {
530  return convert_1_to_4(src, pos, length, dst, C2naTo8na::GetTable());
531 }
532 
533 
534 // from NCBI2na_expand to ...
535 //===========================================================================
536 
537 // NCBI2na_expand -> IUPACna
538 // convert a single NCBI2na_expand byte into a single IUPACna byte.
539 
541 (const char* src,
542  TSeqPos pos,
543  TSeqPos length,
544  char* dst)
545 {
546  return convert_1_to_1(src, pos, length, dst,
548 }
549 
550 
551 // NCBI2na_expand -> NCBI2na
552 // convert 4 NCBI2na_expand bytes to a single NCBI2na one.
553 
555 (const char* src,
556  TSeqPos pos,
557  TSeqPos length,
558  char* dst)
559 {
560  const char* iter = src + pos;
561 
562  // main loop. pack 4 ncbi2na_expand bytes into a single bye and add it
563  // to the output container
564  for ( size_t i = length / 4; i; --i, ++dst ) {
565  *dst = char((*iter << 6) | (*(iter + 1) << 4) |
566  (*(iter + 2) << 2) | (*(iter + 3)));
567  iter += 4;
568  }
569 
570  switch ( length % 4 ) {
571  case 1:
572  *dst = char(*iter << 6);
573  break;
574  case 2:
575  *dst = char((*iter << 6) | (*(iter + 1) << 4));
576  break;
577  case 3:
578  *dst = char((*iter << 6) | (*(iter + 1) << 4) | (*(iter + 2) << 2));
579  break;
580  }
581 
582  return length;
583 }
584 
585 
586 // NCBI2na_expand -> NCBI4na
587 // convert 2 NCBI2na_expand bytes into a single NCBI4na byte.
588 
590 (const char* src,
591  TSeqPos pos,
592  TSeqPos length,
593  char* dst)
594 {
595  // A simple conversion table that converts a ncbi2na_expand byte
596  // into a "half" ncbi4na byte, based on the position of the
597  // ncbi2na_expand byte within the ncbi4na byte
598  // positions 0 and 1 corresponds to the lower and upper 4 bits in
599  // a ncbi4na byte respectively.
600  static Uint1 table[8] = {
601  // 0 1
602  0x10, 0x01, // A
603  0x20, 0x02, // C
604  0x40, 0x04, // G
605  0x80, 0x08 // T
606  };
607 
608  const char* iter = src + pos;
609 
610  for ( size_t i = length / 2; i; --i, ++dst ) {
611  *dst = table[*iter * 2] | table[*(iter + 1) * 2 + 1];
612  iter += 2;
613  }
614 
615  if ( length % 2 != 0 ) { // == 1
616  *dst = table[*iter * 2];
617  }
618 
619  return length;
620 }
621 
622 
623 // NCBI2na_expand -> NCBI8na (NCBI4na_expand)
624 // convert a single NCBI2na_expand byte into a single NCBI8na one.
625 
627 (const char* src,
628  TSeqPos pos,
629  TSeqPos length,
630  char* dst)
631 {
632  // simple
633  static Uint1 table[4] = {
634  0x01, // A 0 -> 1
635  0x02, // C 1 -> 2
636  0x04, // G 2 -> 4
637  0x08 // T 3 -> 8
638  };
639 
640  return convert_1_to_1(src, pos, length, dst, table);
641 }
642 
643 
644 // from NCBI4na to ...
645 //===========================================================================
646 
647 
648 // NCBI4na -> IUPACna
649 // convert a NCBI4na byte into 2 IUPACna characters.
650 
652 (const char* src,
653  TSeqPos pos,
654  TSeqPos length,
655  char* dst)
656 {
657  return convert_1_to_2(src, pos, length, dst, C4naToIupacna::GetTable());
658 }
659 
660 // NCBI4na -> NCBI2na
661 // convert 2 NCBI4na bytes into a NCBI2na byte.
662 
664 (const char* src,
665  TSeqPos pos,
666  TSeqPos length,
667  char* dst)
668 {
669  Uint1 offset = pos % 2;
671 
672  size_t overhang = length % 4;
673 
674  const char* iter = src + (pos / 2);
675 
676  switch ( offset ) {
677  case 0:
678  // aligned copy
679  {{
680  for ( size_t i = length / 4; i; --i, ++dst ) {
681  *dst =
682  table[static_cast<Uint1>(*iter) * 2] |
683  table[static_cast<Uint1>(*(iter + 1)) * 2 + 1];
684  iter += 2;
685  }
686 
687  // handle overhang
688  if ( overhang != 0 ) {
689  switch ( overhang ) {
690  case 1:
691  // leave just the 2 lower bits
692  *dst = (table[static_cast<Uint1>(*iter) * 2]) & 0xC0;
693  break;
694  case 2:
695  // leave just the 4 lower bits
696  *dst = (table[static_cast<Uint1>(*iter) * 2]) & 0xF0;
697  break;
698  case 3:
699  *dst = (char)(
700  table[static_cast<Uint1>(*iter) * 2] |
701  (table[static_cast<Uint1>(*(iter + 1)) * 2 + 1] & 0xFC));
702  break;
703  }
704  }
705  }}
706  break;
707 
708  case 1:
709  // unaligned copy
710  {{
711  for ( size_t i = length / 4; i; --i, ++dst ) {
712  *dst =
713  table[static_cast<Uint1>(*iter) * 3] |
714  table[static_cast<Uint1>(*(iter + 1)) * 3 + 1] |
715  table[static_cast<Uint1>(*(iter + 2)) * 3 + 2];
716  iter += 2;
717  }
718 
719  // handle overhang
720  if ( overhang != 0 ) {
721  switch ( overhang ) {
722  case 1:
723  *dst = table[static_cast<Uint1>(*iter) * 3] & 0xC0;
724  break;
725  case 2:
726  *dst = (char)(
727  table[static_cast<Uint1>(*iter) * 3] |
728  (table[static_cast<Uint1>(*(iter + 1)) * 3 + 1] & 0xF0));
729  break;
730  case 3:
731  *dst = (char)(
732  table[static_cast<Uint1>(*iter) * 3] |
733  (table[static_cast<Uint1>(*(iter + 1)) * 3 + 1] & 0xFC));
734  break;
735  }
736  }
737  }}
738  break;
739  }
740 
741  return length;
742 }
743 
744 // NCBI4na -> NCBI2na_expand
745 // convert a NCBI4na byte into 2 NCBI2na_expand bytes.
746 
748 (const char* src,
749  TSeqPos pos,
750  TSeqPos length,
751  char* dst)
752 {
753  return convert_1_to_2(src, pos, length, dst,
755 }
756 
757 
758 // NCBI4na -> NCBI8na (NCBI4na_expand)
759 // convert a NCBI2na byte into 4 IUPACna characters.
760 
762 (const char* src,
763  TSeqPos pos,
764  TSeqPos length,
765  char* dst)
766 {
767  return convert_1_to_2(src, pos, length, dst, C4naTo8na::GetTable());
768 }
769 
770 
771 // from NCBI8na (NCBI4na_expand) to ...
772 //===========================================================================
773 
774 // NCBI8na -> IUPACna
775 // convert a single NCBI8na byte into a single IUPACna byte.
776 
778 (const char* src,
779  TSeqPos pos,
780  TSeqPos length,
781  char *dst)
782 {
783  return convert_1_to_1(src, pos, length, dst, C8naToIupacna::GetTable());
784 }
785 
786 
787 // NCBI8na -> NCBI2na
788 // convert 4 NCBI8na bytes into a single NCBI2na byte.
789 
791 (const char* src,
792  TSeqPos pos,
793  TSeqPos length,
794  char *dst)
795 {
796  const Uint1* table = C8naTo2na::GetTable();
797 
798  const char* iter = src + pos;
799 
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];
805  iter += 4;
806  }
807 
808  // Handle overhang
809  if ( (length % 4) != 0 ) {
810  *dst = 0;
811  for( size_t i = 0; i < (length % 4); ++i, ++iter ) {
812  *dst |= (char)table[static_cast<Uint1>(*iter)*4 + i];
813  }
814  }
815 
816  return length;
817 }
818 
819 
820 // NCBI8na -> NCBI2na_expand
821 // convert a single NCBI8na byte into a single NCBI2na_expand byte.
822 
824 (const char* src,
825  TSeqPos pos,
826  TSeqPos length,
827  char *dst)
828 {
829  // simple conversion table
830  static const Uint1 table[16] = {
831  0x03, // gap -> T
832  0x00, // A -> A
833  0x01, // C -> C
834  0x01, // M -> C
835  0x02, // G -> G
836  0x02, // R -> G
837  0x01, // S -> C
838  0x00, // V -> A
839  0x03, // T -> T
840  0x03, // W -> T
841  0x03, // Y -> T
842  0x00, // H -> A
843  0x02, // K -> G
844  0x02, // D -> G
845  0x01, // B -> C
846  0x00 // N -> A
847  };
848 
849  return convert_1_to_1(src, pos, length, dst, table);
850 }
851 
852 
853 // NCBI8na -> NCBI4na
854 // convert 2 NCBI8na bytes into a single NCBI4na byte.
855 
857 (const char* src,
858  TSeqPos pos,
859  TSeqPos length,
860  char *dst)
861 {
862  const char* iter = src + pos;
863 
864  for ( size_t i = length / 2; i; --i, ++dst ) {
865  *dst = char((*iter << 4) | (*(iter + 1)));
866  iter += 2;
867  }
868 
869  if ( (length % 2) != 0 ) {
870  *dst = char((*iter << 4) & 0xf0);
871  }
872 
873  return length;
874 }
875 
876 
877 // AA conversions:
878 
879 // All AA conversions ara a 1 to 1 conversion
880 
881 // from IUPACaa to ...
882 //===========================================================================
883 
884 // IUPACaa -> NCBIeaa
885 
887 (const char* src,
888  TSeqPos pos,
889  TSeqPos length,
890  char *dst)
891 {
892  // they map directly
893  return Subseq(src, CSeqUtil::e_Iupacaa, pos, length, dst);
894 }
895 
896 
897 // IUPACaa -> NCBIstdaa (NCBI8aa)
898 
900 (const char* src,
901  TSeqPos pos,
902  TSeqPos length,
903  char *dst)
904 {
905  return convert_1_to_1(src, pos, length, dst, CIupacaaToStdaa::GetTable());
906 }
907 
908 
909 // from NCBIeaa to ...
910 //===========================================================================
911 
912 // NCBIeaa -> IUPACaa
913 
915 (const char* src,
916  TSeqPos pos,
917  TSeqPos length,
918  char *dst)
919 {
920  return convert_1_to_1(src, pos, length, dst, CEaaToIupacaa::GetTable());
921 }
922 
923 
924 // NCBIeaa -> NCBIstdaa (NCBI8aa)
925 
927 (const char* src,
928  TSeqPos pos,
929  TSeqPos length,
930  char *dst)
931 {
932  return convert_1_to_1(src, pos, length, dst, CEaaToStdaa::GetTable());
933 }
934 
935 
936 // from NCBIstdaa (NCBI8aa) to ...
937 //===========================================================================
938 
939 // NCBIstdaa (NCBI8aa) -> IUPACaa
940 
942 (const char* src,
943  TSeqPos pos,
944  TSeqPos length,
945  char *dst)
946 {
947  return convert_1_to_1(src, pos, length, dst, CStdaaToIupacaa::GetTable());
948 }
949 
950 // NCBIstdaa (NCBI8aa) -> NCBIeaa
951 
953 (const char* src,
954  TSeqPos pos,
955  TSeqPos length,
956  char *dst)
957 {
958  return convert_1_to_1(src, pos, length, dst, CStdaaToEaa::GetTable());
959 }
960 
961 
962 /////////////////////////////////////////////////////////////////////////////
963 //
964 // Subseq - partial sequence
965 
967 (const char* src,
968  TCoding coding,
969  TSeqPos pos,
970  TSeqPos length,
971  char* dst)
972 {
973  SIZE_TYPE converted = 0;
974  char *buf = 0;
975  try {
976  switch ( coding ) {
977 
978  // for packed coding (2na and 4na) first expand, then re-pack
979  case CSeqUtil::e_Ncbi2na:
980  {{
981  buf = new char[length];
982  x_Convert2naTo2naExpand(src, pos, length, buf);
983  converted = x_Convert2naExpandTo2na(buf, 0, length, dst);
984  delete[] buf;
985  buf = 0;
986  }}
987  break;
988 
989  case CSeqUtil::e_Ncbi4na:
990  {{
991  buf = new char[length];
992  x_Convert4naTo8na(src, pos, length, buf);
993  converted = x_Convert8naTo4na(buf, 0, length, dst);
994  delete[] buf;
995  buf = 0;
996  }}
997  break;
998 
999  // iupacna may contain 'U' that needs to be converted to 'T'
1000  case CSeqUtil::e_Iupacna:
1001  {{
1002  converted = convert_1_to_1(src, pos, length, dst,
1004  }}
1005  break;
1006 
1007  // for other ascii codings make sure the output is upper case
1008  case CSeqUtil::e_Iupacaa:
1009  case CSeqUtil::e_Ncbieaa:
1010  {{
1011  const char* iter = src + pos;
1012  const char* end = iter + length;
1013 
1014  for ( ; iter != end; ++iter, ++dst ) {
1015  *dst = (char)toupper((unsigned char)(*iter));
1016  }
1017  converted = length;
1018  }}
1019  break;
1020 
1021  // for the rest of the codings (e.g. 8na, stdaa) copy
1022  // the desired range.
1023  default:
1024  {{
1025  copy(src + pos, src + pos + length, dst);
1026  converted = length;
1027  }}
1028  break;
1029  } // end of switch statement
1030  } catch ( ... ) {
1031  if ( buf != 0 ) {
1032  delete[] buf;
1033  }
1034  throw;
1035  }
1036 
1037  return converted;
1038 }
1039 
1040 
1041 /////////////////////////////////////////////////////////////////////////////
1042 //
1043 // Packing
1044 
1046 (const char* src,
1047  TSeqPos length,
1048  TCoding src_coding,
1049  char* dst,
1050  TCoding& dst_coding)
1051 {
1052  dst_coding = x_HasAmbig(src, src_coding, length) ?
1054 
1055  return Convert(src, src_coding, 0, length, dst, dst_coding);
1056 }
1057 
1058 SIZE_TYPE CSeqConvert_imp::Pack(const char* src, TSeqPos length,
1059  TCoding src_coding, IPackTarget& dst)
1060 {
1061  if (length == 0) {
1062  return 0;
1063  }
1064  bool gaps_ok = dst.GapsOK(CSeqUtil::GetCodingType(src_coding));
1065  const SBestCodings& best_codings = (gaps_ok ? kBestCodingsWithGaps
1067  const TCoding* best_coding = NULL;
1068  switch (src_coding) {
1069  case CSeqUtil::e_Iupacna:
1070  best_coding = best_codings.iupacna;
1071  break;
1072 
1074  return Convert(src, src_coding, 0, length,
1075  dst.NewSegment(CSeqUtil::e_Ncbi2na, length),
1077 
1078  case CSeqUtil::e_Ncbi4na:
1079  best_coding = best_codings.ncbi4na;
1080  break;
1081 
1083  case CSeqUtil::e_Ncbi8na:
1084  best_coding = best_codings.ncbi8na;
1085  break;
1086 
1087  case CSeqUtil::e_Iupacaa:
1088  case CSeqUtil::e_Ncbieaa:
1089  if (gaps_ok) { // no point otherwise
1090  best_coding = best_codings.ncbieaa;
1091  }
1092  break;
1093 
1094  case CSeqUtil::e_Ncbi8aa:
1095  case CSeqUtil::e_Ncbistdaa:
1096  if (gaps_ok) {
1097  best_coding = best_codings.ncbi8aa;
1098  }
1099  break;
1100 
1101  default:
1102  break;
1103  }
1104 
1105  if (best_coding != NULL) {
1106  return CPacker(src_coding, best_coding, gaps_ok, dst)
1107  .Pack(src, length);
1108  } else {
1109  memcpy(dst.NewSegment(src_coding, length), src,
1110  GetBytesNeeded(src_coding, length));
1111  return length;
1112  }
1113 }
1114 
1116  = CSeqUtil::e_Ncbi2na_expand; // never used by best_coding
1117 
1119 {
1122 }
1123 
1125 {
1126  const char* src_end = src + GetBytesNeeded(m_SrcCoding, length);
1127  TCoding prev_type = kNoCoding;
1128 
1129  for (const char* p = src; p < src_end; ++p) {
1130  unsigned char residue;
1131  TCoding curr_type;
1132  do {
1133  residue = static_cast<unsigned char>(*p);
1134  curr_type = m_BestCoding[residue];
1135  } while (curr_type == prev_type && ++p < src_end);
1136 
1137  if (curr_type == CSeqUtil::e_Ncbi4na_expand) {
1138  TCoding type1 = m_BestCoding[(residue >> 4) * 0x11],
1139  type2 = m_BestCoding[(residue & 0x0F) * 0x11];
1140  if (type1 != prev_type) {
1141  x_AddBoundary(TSeqPos((p - src)*2), type1);
1142  }
1143  x_AddBoundary(TSeqPos((p - src)*2 + 1), type2);
1144  prev_type = type2;
1145  } else if (p != src_end) {
1146  _ASSERT(curr_type != kNoCoding);
1147  x_AddBoundary(TSeqPos((p - src) * m_SrcDensity), curr_type);
1148  prev_type = curr_type;
1149  }
1150  }
1151  x_AddBoundary(length, kNoCoding);
1152 
1153  _ASSERT(m_Boundaries.at(0) == 0);
1154 
1155  SArrangement* best_arrangement
1156  = (m_EndingNarrow.cost < m_EndingWide.cost
1157  ? &m_EndingNarrow : &m_EndingWide);
1158 
1159  // XXX - fine-tune 4na/2na boundaries to minimize wastage?
1160 
1161  size_t n = m_Boundaries.size() - 1;
1162  vector<TCoding> coding_vec(n);
1163  SCodings* codings = best_arrangement->codings;
1164  for (size_t i = 0; i < n;
1165  i += codings->current_used, codings = codings->previous) {
1166  _ASSERT(codings != NULL);
1167  memcpy(coding_vec.data() + (n - i - codings->current_used),
1168  codings->current, codings->current_used * sizeof(TCoding));
1169  }
1170  _ASSERT(codings == NULL);
1171 
1172  SIZE_TYPE result = 0;
1173  for (size_t i = 0; i < n; ++i) {
1174  TCoding coding = coding_vec[i];
1175  TSeqPos start = m_Boundaries[i];
1176  while (i < n - 1 && coding_vec[i + 1] == coding) {
1177  ++i; // merge when possible
1178  }
1179 
1180  TSeqPos len = m_Boundaries[i + 1] - start;
1181  char* segment = m_Target.NewSegment(coding, len);
1182  if (coding == CSeqUtil::e_not_set) { // gap
1183  _ASSERT(m_GapsOK);
1184  result += len;
1185  } else {
1186  result += CSeqConvert::Convert(src, m_SrcCoding, start, len,
1187  segment, coding);
1188  }
1189  }
1190 
1191  return result;
1192 }
1193 
1195 {
1196  if (m_Boundaries.empty()) {
1197  _ASSERT(pos == 0);
1198  m_Boundaries.push_back(pos);
1199  m_EndingNarrow.AddCoding(new_coding);
1200  m_EndingWide.AddCoding(m_WideCoding);
1201  m_EndingWide.cost = m_Target.GetOverhead(m_WideCoding);
1202  m_EndingNarrow.cost = m_Target.GetOverhead(new_coding);
1203  return;
1204  }
1205 
1206  TSeqPos last_length = pos - m_Boundaries.back();
1207  _ASSERT(last_length > 0);
1208  m_Boundaries.push_back(pos);
1209 
1210  TCoding last_narrow = m_EndingNarrow.codings->GetLast();
1211  // This always rounds up to full bytes, and as such can slightly
1212  // overestimate the total cost of ncbi4na.
1213  m_EndingNarrow.cost += GetBytesNeeded(last_narrow, last_length);
1214  m_EndingWide.cost += GetBytesNeeded(m_WideCoding, last_length);
1215  if (last_narrow == m_WideCoding) {
1216  _ASSERT(m_EndingNarrow.cost == m_EndingWide.cost);
1217  }
1218 
1219  // _TRACE(static_cast<char>('@' + last_narrow) << last_length << ": ("
1220  // << m_EndingNarrow.cost << ", " << m_EndingWide.cost << ')');
1221 
1222  _ASSERT(new_coding != last_narrow);
1223  if (new_coding == kNoCoding) {
1224  return;
1225  }
1226 
1227  if (new_coding != m_WideCoding
1228  && m_EndingNarrow.cost > m_EndingWide.cost) {
1229  m_EndingNarrow = m_EndingWide;
1230  // _TRACE("N <- W before N'");
1231  }
1232 
1233  SIZE_TYPE alt_wide_cost
1234  = m_EndingNarrow.cost + m_Target.GetOverhead(m_WideCoding);
1235  m_EndingNarrow.cost += m_Target.GetOverhead(new_coding);
1236 
1237  if (m_EndingWide.cost > alt_wide_cost) {
1238  m_EndingWide = m_EndingNarrow;
1239  m_EndingWide.cost = alt_wide_cost;
1240  // _TRACE("W <- N");
1241  } else if (new_coding == m_WideCoding) {
1242  m_EndingNarrow = m_EndingWide;
1243  // _TRACE("N <- W before W");
1244  }
1245  // _TRACE('(' << m_EndingNarrow.cost << ", " << m_EndingWide.cost << ')');
1246 
1247  m_EndingNarrow.AddCoding(new_coding);
1248  m_EndingWide.AddCoding(m_WideCoding);
1249 }
1250 
1253 {
1254  _ASSERT(arr.shared_codings == shared_codings);
1255  if (codings->previous == shared_codings) {
1256  _ASSERT(arr.codings->previous == shared_codings);
1257  codings->current_used = arr.codings->current_used;
1258  memcpy(codings->current, arr.codings->current,
1259  codings->current_used * sizeof(TCoding));
1260  } else {
1261  Reset();
1262  codings = new SCodings(*arr.codings);
1263  shared_codings = arr.shared_codings = codings->previous;
1264  }
1265  cost = arr.cost;
1266  return *this;
1267 }
1268 
1270 {
1271  while (codings != NULL && codings != shared_codings) {
1272  SCodings* previous = codings->previous;
1273  delete codings;
1274  codings = previous;
1275  }
1276 }
1277 
1279 {
1280  if (codings == NULL || codings->current_used == SCodings::kBlockSize) {
1281  SCodings* new_codings = new SCodings;
1282  new_codings->previous = codings;
1283  new_codings->current_used = 0;
1284  codings = new_codings;
1285  }
1286  codings->current[codings->current_used++] = coding;
1287 }
1288 
1291 {
1292  switch (coding) {
1293  case CSeqUtil::e_Iupacna:
1295  case CSeqUtil::e_Ncbi8na: // ignore values >= 16 for now
1296  return CSeqUtil::e_Ncbi4na;
1297 
1299  return CSeqUtil::e_Ncbi2na;
1300 
1301  default:
1302  return coding;
1303  }
1304 }
1305 
1306 
1308 (const char* src,
1309  TCoding src_coding,
1310  size_t length)
1311 {
1312  if ( length == 0 ) {
1313  return false;
1314  }
1315 
1316  switch ( src_coding ) {
1317  case CSeqUtil::e_Iupacna:
1318  return x_HasAmbigIupacna(src, length);
1319 
1320  case CSeqUtil::e_Ncbi4na:
1321  return x_HasAmbigNcbi4na(src, length);
1322 
1324  case CSeqUtil::e_Ncbi8na:
1325  return x_HasAmbigNcbi8na(src, length);
1326 
1327  case CSeqUtil::e_Ncbi2na:
1329  return false;
1330 
1331  default:
1332  break;
1333  }
1334 
1335  return false;
1336 }
1337 
1338 
1339 bool CSeqConvert_imp::x_HasAmbigIupacna(const char* src, size_t length)
1340 {
1341  const bool *not_ambig = CIupacnaAmbig::GetTable();
1342 
1343  const char* end = src + length;
1344 
1345  const char* iter = src;
1346  while ( (iter != end) && (not_ambig[static_cast<Uint1>(*iter)]) ) {
1347  ++iter;
1348  }
1349 
1350  return iter != end;
1351 }
1352 
1353 
1354 bool CSeqConvert_imp::x_HasAmbigNcbi4na(const char* src, size_t length)
1355 {
1356  const bool* not_ambig = CNcbi4naAmbig::GetTable();
1357 
1358  const char* end = src + (length / 2);
1359 
1360  const char* iter = src;
1361  while ( (iter != end) && (not_ambig[static_cast<Uint1>(*iter)]) ) {
1362  ++iter;
1363  }
1364 
1365  if ( (iter == end) && (length % 2) != 0 ) {
1366  return not_ambig[static_cast<Uint1>(*iter | 1) & 0xF1];
1367  }
1368  return iter != end;
1369 }
1370 
1371 
1372 bool CSeqConvert_imp::x_HasAmbigNcbi8na(const char* src, size_t length)
1373 {
1374  const bool *not_ambig = CNcbi8naAmbig::GetTable();
1375 
1376  const char* end = src + length;
1377 
1378  const char* iter = src;
1379  while ( (iter != end) && (not_ambig[static_cast<Uint1>(*iter)]) ) {
1380  ++iter;
1381  }
1382 
1383  return iter != end;
1384 }
1385 
1386 
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)
static TCoding x_GetWideCoding(const TCoding coding)
void x_AddBoundary(TSeqPos pos, TCoding new_coding)
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)
@ e_Ncbi4na_expand
Definition: sequtil.hpp:51
@ e_Ncbi8na
Definition: sequtil.hpp:52
@ e_Iupacna
Definition: sequtil.hpp:47
@ e_Ncbieaa
Definition: sequtil.hpp:57
@ e_not_set
Definition: sequtil.hpp:44
@ e_Ncbi8aa
Definition: sequtil.hpp:56
@ e_Ncbi4na
Definition: sequtil.hpp:50
@ e_Ncbi2na_expand
Definition: sequtil.hpp:49
@ e_Ncbi2na
Definition: sequtil.hpp:48
@ e_Ncbistdaa
Definition: sequtil.hpp:58
@ e_Iupacaa
Definition: sequtil.hpp:55
static ECodingType GetCodingType(TCoding coding)
Definition: sequtil.cpp:44
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
Include a standard set of the NCBI C++ Toolkit most basic headers.
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
uint8_t Uint1
1-byte (8-bit) unsigned integer
Definition: ncbitype.h:99
uint16_t Uint2
2-byte (16-bit) unsigned integer
Definition: ncbitype.h:101
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
char * buf
int i
yy_size_t n
int len
const struct ncbi::grid::netcache::search::fields::SIZE size
int toupper(Uchar c)
Definition: ncbictype.hpp:73
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
int offset
Definition: replacements.h:160
SIZE_TYPE convert_1_to_4(const char *src, TSeqPos pos, TSeqPos length, char *dst, const Uint1 *table)
SIZE_TYPE convert_1_to_2(const char *src, TSeqPos pos, TSeqPos length, char *dst, const Uint1 *table)
SIZE_TYPE GetBytesNeeded(CSeqUtil::TCoding coding, TSeqPos length)
SIZE_TYPE convert_1_to_1(const char *src, TSeqPos pos, TSeqPos length, char *dst, const Uint1 *table)
const SBestCodings kBestCodingsWithoutGaps
const SBestCodings kBestCodingsWithGaps
SArrangement & operator=(SArrangement &arr)
TCoding ncbi8na[256]
TCoding ncbieaa[256]
TCoding ncbi4na[256]
TCoding ncbi8aa[256]
TCoding iupacna[256]
#define _ASSERT
else result
Definition: token2.c:20
Modified on Wed Dec 06 07:15:16 2023 by modify_doxy.py rev. 669887