1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625
|
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2026, Knut Reinert, FU Berlin
// Copyright (c) 2013 NVIDIA Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: David Weese <david.weese@fu-berlin.de>
// ==========================================================================
#ifndef SEQAN_HEADER_INDEX_BASE_H
#define SEQAN_HEADER_INDEX_BASE_H
//#define SEQAN_TEST_INDEX
namespace seqan2
{
// ============================================================================
// Forwards
// ============================================================================
// suffix array construction specs
struct Skew3;
struct Skew7;
struct LarssonSadakane;
struct ManberMyers;
struct SAQSort;
struct QGramAlg;
// inverse suffix array construction specs
template <typename TParallel>
struct FromSortedSa{};
// lcp table construction algorithms
struct Kasai;
struct KasaiOriginal; // original, but more space-consuming algorithm
// enhanced suffix array construction algorithms
struct Childtab;
struct Bwt;
// ============================================================================
// Concepts
// ============================================================================
/*!
* @concept StringIndexConcept
* @brief An index that can be traversed top-down.
* @headerfile <seqan/index.h>
*
* @signature StringIndexConcept<T>
*/
SEQAN_CONCEPT(StringIndexConcept, (TIndex))
{
// typedef typename Iterator<TIndex, TopDown<> >::Type TTopDownIterator;
typedef typename VertexDescriptor<TIndex>::Type TVertexDescriptor;
typedef String<int> TPropertyMap;
TIndex index;
TPropertyMap pm;
SEQAN_CONCEPT_USAGE(StringIndexConcept)
{
// property map interface
resizeVertexMap(pm, index);
// iteration
// TTopDownIterator iter = begin(index, TopDown<>());
}
};
/*!
* @concept StringTreeConcept
* @brief An index that can be traversed top-down as a tree.
* @headerfile <seqan/index.h>
*
* @signature StringTreeConcept<T>
*/
SEQAN_CONCEPT_REFINE(StringTreeConcept, (TIndex), (StringIndexConcept)) {};
/*!
* @concept StringTrieConcept
* @brief An index that can be traversed top-down as a trie.
* @headerfile <seqan/index.h>
*
* @signature StringTrieConcept<T>
*/
SEQAN_CONCEPT_REFINE(StringTrieConcept, (TIndex), (StringIndexConcept)) {};
/*!
* @defgroup IndexFindAlgorithm Index Find Algorithm
* @brief Tag to specify the index search algorithm.
*
* These tags can be used to specify the @link Finder#find @endlink algorithm for @link
* Index @endlink based substring searches.
*
* @see Finder
*
* @tag IndexFindAlgorithm#FinderSTree
* @brief Suffix tree search.
*
* Exact string matching using a suffix tree.
*
* @tag IndexFindAlgorithm#PizzaChiliFinder
* @brief Finds an occurrence in a @link PizzaChiliIndex @endlink index.
*
* The actual algorithm used for searching depends on the @link PizzaChiliIndexTags @endlink used.
*
* @tag IndexFindAlgorithm#QGramFindLookup
* @brief q-gram search. Finds q-grams in a @link IndexQGram @endlink index using the hash table.
*
* @tag IndexFindAlgorithm#FinderLcpe
* @brief Binary search using lcp values.
*
*
* Exact string matching using a suffix array binary search and a lcp-interval tree.
*
* @tag IndexFindAlgorithm#FinderMlr
* @brief Binary search with mlr-heuristic.
*
* Exact string matching using a suffix array binary search with the mlr-heuristic.
*/
// finder tags
struct FinderMlr_; // simple Suffix Array finder with mlr-heuristic
struct FinderLcpe_; // Suffix Array finder using an enhanced LCP-Table
struct FinderSTree_; // Suffix Array finder using an enhanced LCP-Table
typedef Tag<FinderMlr_> const FinderMlr;
typedef Tag<FinderLcpe_> const FinderLcpe;
typedef Tag<FinderSTree_> const FinderSTree;
template <typename TSpec = void>
struct IndexEsa {};
// ----------------------------------------------------------------------------
// Metafunction DefaultIndexSpec
// ----------------------------------------------------------------------------
/*!
* @mfn Index#DefaultIndexSpec
* @headerfile <seqan/index.h>
* @brief Default @link Index @endlink specialization type.
*
* @signature DefaultIndexSpec<TText>::Type;
*
* @tparam TText The given text type.
*
* @return TReturn Currently the return type is @link IndexEsa @endlink.
*
* @section Examples
*
* The following will define <tt>TIndex</tt> to be of type @link IndexEsa @endlink, because the
* default index type for @link String @endlink or @link StringSet @endlink is @link IndexEsa @endlink.
*
* @code{.cpp}
* typedef DefaultIndexSpec<String<Dna> >::Type TIndex;
* @endcode
*/
template < typename TObject >
struct DefaultIndexSpec {
typedef IndexEsa<> Type;
};
// ----------------------------------------------------------------------------
// Metafunction DefaultIndexStringSpec
// ----------------------------------------------------------------------------
//NOTE(esiragusa): Deprecated in favor of StringSpec.
/*!
* @mfn Index#DefaultIndexStringSpec
* @headerfile <seqan/index.h>
* @brief Default @link String @endlink specialization type of the @link Fibre
* @endlink of an @link Index @endlink.
* @deprecated Deprecated in favor of StringSpec.
*
* @signature DefaultIndexStringSpec<TIndex>::Type;
*
* @tparam TIndex An @link Index @endlink Type.
*
* @return TReturn If the underlying text is a @link String @endlink or a set of
* Strings (see @link StringSet @endlink) the String's spec.
* type is returned.
*
* @section Remarks
*
* Most of the @link Index @endlink fibres are strings. The @link String
* @endlink specialization type is chosen by this meta-function.
*/
template <typename TObject>
struct DefaultIndexStringSpec : StringSpec<TObject> {};
//////////////////////////////////////////////////////////////////////////////
template <
typename TObject,
typename TSpec = typename DefaultIndexSpec<TObject>::Type >
class Index;
/*!
* @class Index
* @headerfile <seqan/index.h>
* @brief Indices are data structures which contain preprocessing data of a fixed text (or set of texts). In combination
* with a @link Finder @endlink or an @link VSTreeIterator @endlink it allows fast dictionary look-up and advanced computations.
*
* @signature class Index<TText[, TSpec]>;
*
* @tparam TSpec The index type.
* @tparam TText The text type. Types: @link String @endlink, @link StringSet @endlink
*
*
* An index contains various arrays or objects, also called fibres (see @link Fibre @endlink).
* These fibres are created on demand depending on the requirements of an algorithm. To force the fibre creation you can
* use the function @link Index#indexCreate @endlink.
* The list of fibres is available in @link Fibre @endlink
*
* @section Examples
*
* The following code shows how to search for exact matches between the reference "tobeornottobe" and the
* pattern "to" with the means of a Finder.
*
* @include demos/dox/index/finder.cpp
*
* The result is as follows
*
* @include demos/dox/index/finder.cpp.stdout
*
* This code shows how an index can be used with iterators to achieve a pre-order tree like traversal
* in DFS of the text "tobeornottobe". In order to do so a Top-Down History iterator is used.
*
* @include demos/dox/index/iterator.cpp
*
* The result is as follows
*
* @include demos/dox/index/iterator.cpp.stdout
*
* Note that you can also use specialized iterators such as:
*
* @code{.cpp}
* Iterator<TIndex, TopDown<ParentLinks<PreOrder> > >::Type
* @endcode
*
* or
*
* @code{.cpp}
* Iterator<TIndex, TopDown<ParentLinks<PostOrder> > >::Type
* @endcode
*
* You can achieve a post-order traversal like this:
*
* @snippet demos/dox/index/iterator_short.cpp iteration
*
* The result is as follows
*
* @include demos/dox/index/iterator_short.cpp.stdout
*/
template <typename TObject, typename TSpec>
struct Host< Index<TObject, TSpec> > {
typedef TObject Type;
};
template <typename TObject, typename TSpec>
struct Spec< Index<TObject, TSpec> > {
typedef TSpec Type;
};
/*!
* @mfn Fibre
* @headerfile <seqan/index.h>
* @brief Type of a specific container member (fibre).
*
* @signature Fibre<TObject, TSpec>::Type;
*
* @tparam TSpec Tag to specify the fibre. Types: @link IndexEsaFibres @endlink, @link FMIndexFibres @endlink, @link
* QGramIndexFibres @endlink, @link WOTDIndexFibres @endlink, @link WaveletTreeFibres @endlink, @link
* RightArrayBinaryTreeFibres @endlink, @link RankDictionaryFibres @endlink, @link
* SentinelRankDictionaryFibres @endlink
* @tparam TObject The container type. Types: @link Index @endlink, @link RankDictionary @endlink, @link SparseString
* @endlink, @link CompressedSA @endlink
*
* @return Type Fibre type.
*
* @section Naming
*
* Some containers, such as the @link Index @endlink or the @link RankDictionary @endlink, can be seen as a collection
* of tables. However, each table alone is just a collection of information. They only become powerful if used
* together. Therefore, a more appropriate label for the tables is fibre, like the fibres of a rope.
*
* In addition, sometimes a fibre can be a single value and calling it a table would be misleading.
*/
// meta function to get the type of a bundle fibre
template < typename TIndex, typename TSpec >
struct Fibre {
typedef String< typename Size<TIndex>::Type > Type;
};
template < typename TIndex, typename TSpec >
struct Fibre<TIndex const, TSpec> {
typedef typename Fibre<TIndex, TSpec>::Type const Type;
};
struct FibreRecord {
unsigned id;
void* ptr;
bool owner;
};
// less function to search in sorted list for fibre id
struct FibreLess: public std::function<bool(FibreRecord, unsigned)>
{ // functor for operator>
inline bool operator()(FibreRecord const & _Left, unsigned const Right_) const
{ // apply operator> to operands
return (_Left.id < Right_);
}
};
//////////////////////////////////////////////////////////////////////////////
/*!
* @mfn Index#DefaultIndexCreator
* @headerfile <seqan/index.h>
* @note Advanced functionality, not commonly used.
* @brief Default algorithm to create a demanded and not yet existing @link Fibre @endlink.
*
* @signature DefaultIndexCreator<TIndex, TFibre>::Type;
*
* @tparam TIndex An @link Index @endlink Type.
* @tparam TFibre A tag specifying the fibre (e.g. @link IndexEsaFibres#EsaSA
* @endlink).
*
* @return Type A tag specifying the default algorithm to create the fibre with.
*/
template < typename TIndex, typename TFibre >
struct DefaultIndexCreator {
typedef Default Type;
};
//////////////////////////////////////////////////////////////////////////////
template <
typename TSA,
typename TText,
typename TAlgSpec >
struct SACreatorRandomAccess_
{
typedef typename AllowsFastRandomAccess<TSA>::Type TRandomSA;
typedef typename AllowsFastRandomAccess<TText>::Type TRandomText;
typedef typename And<TRandomText,TRandomSA>::Type Type;
};
template <
typename TLCP,
typename TText,
typename TSA,
typename TAlgSpec >
struct LcpCreatorRandomAccess_
{
typedef typename AllowsFastRandomAccess<TText>::Type TRandomText;
typedef typename AllowsFastRandomAccess<TLCP>::Type TRandomLCP;
typedef typename AllowsFastRandomAccess<TSA>::Type TRandomSA;
typedef typename And<TRandomLCP, typename And<TRandomText,TRandomSA>::Type>::Type Type;
};
//////////////////////////////////////////////////////////////////////////////
/*
template < typename TSpec = void >
truct Bundle {
typedef std::vector<FibreRecord> TFibreRecords;
TFibreRecords fibres;
};
template < typename TBundleSpec, typename TFibreSpec >
inline FibreRecord& getRecord(Bundle<TBundleSpec> &bundle, TFibreSpec const) {
unsigned id = (unsigned)ClassIdentifier_<TFibreSpec>::getID();
typename Bundle<TBundleSpec>::TFibreRecords::iterator first = lower_bound(bundle.fibres.begin(), bundle.fibres.end(), id, FibreLess());
if (!first->id != id) {
FibreRecord rec;
rec.id = id;
rec.ptr = NULL;
rec.owner = true;
bundle.fibres.insert(first, rec);
} else
return *first;
}
template < typename TBundleSpec, typename TFibreSpec >
inline typename Fibre<Bundle<TBundleSpec>, TFibreSpec>::Type & getFibre(Bundle<TBundleSpec> &bundle, TFibreSpec const) {
typedef typename Fibre<Bundle<TBundleSpec>, TFibreSpec>::Type Type;
unsigned id = (unsigned)ClassIdentifier_<TFibreSpec>::getID();
FibreRecord &rec = getRecord(bundle, TFibreSpec());
if (!rec.ptr)
rec.ptr = new Type();
return *reinterpret_cast<Type*>(rec.ptr);
}
template < typename TBundleSpec, typename TFibreSpec >
inline typename Fibre<Bundle<TBundleSpec>, TFibreSpec>::Type const & getFibre(Bundle<TBundleSpec> const &bundle, TFibreSpec const) {
typedef typename Fibre<Bundle<TBundleSpec>, TFibreSpec>::Type Type;
unsigned id = (unsigned)ClassIdentifier_<TFibreSpec>::getID();
FibreRecord &rec = getRecord(bundle, TFibreSpec());
return *reinterpret_cast<Type*>(rec.ptr);
}
*/
//////////////////////////////////////////////////////////////////////////////
// various fibre specs for enhanced suffix arrays
struct FibreText_; // Original text. Can be a String or a StringSet
struct FibreRawText_; // Concatenation of the strings above
struct FibreSA_; // suffix array (of raw text with virtual $-delimiters) with Pair entries
struct FibreRawSA_; // suffix array with integer entries
struct FibreIsa_; // inverse suffix array.
struct FibreSae_; // suffix array reordered in a b-tree
struct FibreLcp_; // lcp table of raw text
struct FibreLcpe_; // lcp interval tree
struct FibreChildtab_; // childtab (Kurtz et al.) of raw text
struct FibreBwt_; // burrows wheeler table of raw text
typedef Tag<FibreText_> const FibreText;
typedef Tag<FibreRawText_> const FibreRawText;
typedef Tag<FibreSA_> const FibreSA;
typedef Tag<FibreRawSA_> const FibreRawSA;
typedef Tag<FibreIsa_> const FibreIsa;
typedef Tag<FibreSae_> const FibreSae;
typedef Tag<FibreLcp_> const FibreLcp;
typedef Tag<FibreLcpe_> const FibreLcpe;
typedef Tag<FibreChildtab_> const FibreChildtab;
typedef Tag<FibreBwt_> const FibreBwt;
//////////////////////////////////////////////////////////////////////////////
/*!
* @mfn SAValue
* @headerfile <seqan/index.h>
* @brief The default alphabet type of a suffix array, i.e. the type to store a
* position of a string or string set.
*
* @signature SAValue<TObject>::Type;
*
* @tparam TObject A string, string set, or index type. Types: @link String @endlink, @link StringSet @endlink,
* @link Index @endlink
* @return TReturn A type to store a position.If <tt>TObject</tt> is a @link String @endlink, it is a single integer
* value. By default this is the @link Size @endlink type of <tt>TObject</tt>.If <tt>TObject</tt> is a
* @link StringSet @endlink, it could be a single integer too (called global position, see @link
* ConcatDirectStringSet @endlink) or a @link Pair @endlink (called local position, see
* @link OwnerStringSet @endlink). Currently SeqAn defaults to a local position for @link StringSet
* @endlink classes (index_base.h).
*
* SAValue is the return type of various functions, e.g. @link Finder#position @endlink for the Index @link Finder @endlink
* class, @link VSTreeIterator#getOccurrence @endlink, @link VSTreeIterator#getOccurrences @endlink, @link IndexQGram#getOccurrences
* @endlink etc. You should always use the type of this meta-function to store the return values. If you want to write
* algorithms for both variants (local and global positions) you should use the functions @link TextConcept#posLocalize @endlink,
* @link TextConcept#posGlobalize @endlink, @link TextConcept#getSeqNo @endlink and @link TextConcept#getSeqOffset @endlink.
*
* @note If <tt>TObject</tt> is an @link Index @endlink, @link Position @endlink returns the same value as <tt>SAValue</tt>.
* You can change the position type of an index by overloading <tt>SAValue</tt>, not @link Position @endlink.
*
* @section Examples
*
* The following code snippet demonstrates the usage of @link SAValue @endlink.
* @code{.cpp}
* template < typename TString, typename TSpec >
* struct SAValue< StringSet<TString, TSpec> > {
* typedef Pair<
* typename Size< StringSet<TString, TSpec> >::Type,
* typename SAValue<TString>::Type,
* Pack
* > Type;
* };
* @endcode
* @see orderOccurrences
*/
template <typename TObject>
struct SAValue:
Position<TObject> {};
template <typename TObject>
struct SAValue<TObject const>:
SAValue<TObject> {};
// to speed up sequence number computation
// we use a pair of seqNo and localPosition
template <typename TString, typename TSpec>
struct SAValue<StringSet<TString, TSpec> > :
StringSetPosition<StringSet<TString, TSpec> > {};
/*
template < typename TString, typename TSpec >
struct SAValue< StringSet<TString, TSpec> > {
typedef Pair<
typename Size< StringSet<TString, TSpec> >::Type,
typename SAValue<TString>::Type,
BitPacked<2,30> // max. 4 sequences
> Type; // max. 2^30 characters each
};
*/
template < typename TText, typename TSpec >
struct SAValue< Index<TText, TSpec> >:
SAValue<TText> {};
template <typename TText, typename TSpec>
struct StringSpec<Index<TText, TSpec> > : StringSpec<TText> {};
//////////////////////////////////////////////////////////////////////////////
// value and size type of an index
template < typename TText, typename TSpec >
struct Value< Index<TText, TSpec> > {
typedef typename Value<
typename Fibre< Index<TText, TSpec>, FibreRawText>::Type
>::Type Type;
};
/*!
* @mfn Index#Size
* @headerfile <seqan/index.h>
* @brief Returns the size type of an Index.
*
* @signature Size<TIndex>::Type;
*
* @tparam TIndex The Index specialization.
*
* @return Type The resulting size type of the index.
*/
template < typename TText, typename TSpec >
struct Size< Index<TText, TSpec> > {
typedef typename LengthSum<TText>::Type Type;
};
template < typename TText, typename TSpec >
struct Position< Index<TText, TSpec> >:
SAValue< Index<TText, TSpec> > {};
//////////////////////////////////////////////////////////////////////////////
// infix of an index
template < typename TText, typename TSpec >
struct Infix< Index<TText, TSpec> >:
InfixOnValue<TText> {};
template < typename TText, typename TSpec >
struct Infix< Index<TText, TSpec> const >:
InfixOnValue<TText> {};
//////////////////////////////////////////////////////////////////////////////
// default table type
template < typename TObject, typename TSpec, typename TFibre >
struct Fibre< Index<TObject, TSpec>, Tag<TFibre> const > {
typedef String<
typename Size< Index<TObject, TSpec> >::Type,
typename StringSpec< Index<TObject, TSpec> >::Type
> Type;
};
//////////////////////////////////////////////////////////////////////////////
// original text
template < typename TText, typename TSpec >
struct Fibre< Index<TText, TSpec>, FibreText> {
typedef TText Type;
};
//////////////////////////////////////////////////////////////////////////////
// type of the text member
template <typename TText, typename TSpec>
struct Member<Index<TText, TSpec>, FibreText>
{
typedef Holder<typename Fibre<Index<TText, TSpec>, FibreText>::Type> Type;
};
//////////////////////////////////////////////////////////////////////////////
// concatenated text
template < typename TText, typename TSpec >
struct Fibre< Index<TText, TSpec>, FibreRawText> {
typedef typename Concatenator<TText>::Type Type;
};
//////////////////////////////////////////////////////////////////////////////
// suffix array type
template < typename TText, typename TSpec >
struct Fibre< Index<TText, TSpec>, FibreSA> {
typedef String<
typename SAValue< Index<TText, TSpec> >::Type,
typename StringSpec< Index<TText, TSpec> >::Type
> Type;
};
//////////////////////////////////////////////////////////////////////////////
// lcp type
template <typename TText, typename TSSetSpec, typename TSpec>
struct Fibre<Index<StringSet<TText, TSSetSpec>, TSpec>, FibreLcp>
{
typedef String<
typename Size<TText>::Type,
typename StringSpec<Index<StringSet<TText, TSSetSpec>, TSpec> >::Type
> Type;
};
//////////////////////////////////////////////////////////////////////////////
// globalize functor
template <typename InType, typename TLimitsString, typename Result = typename Value<TLimitsString>::Type>
struct FunctorGlobalize : public std::function<Result(InType)>
{
TLimitsString const * limits;
FunctorGlobalize() : limits() {}
FunctorGlobalize(TLimitsString const &_limits) : limits(&_limits) {}
inline Result operator()(InType const &x) const
{
return posGlobalize(x, *limits);
}
};
template <typename InType, typename Result>
struct FunctorGlobalize<InType, Nothing, Result> : public std::function<InType(InType)>
{
FunctorGlobalize() {}
FunctorGlobalize(Nothing const &) {}
inline InType operator()(InType const &x) const
{
return x;
}
};
//////////////////////////////////////////////////////////////////////////////
// raw suffix array contains integer offsets relative to raw text
/*
template < typename TString, typename TSpec >
struct Fibre< Index<TString, TSpec>, FibreRawSA>:
public Fibre< Index<TString, TSpec> const, FibreSA> {};
template < typename TString, typename TSSetSpec, typename TSpec >
struct Fibre< Index<StringSet<TString, TSSetSpec>, TSpec>, FibreRawSA>
{
typedef Index< StringSet<TString, TSSetSpec>, TSpec> TIndex;
typedef ModifiedString<
typename Fibre<TIndex, FibreSA>::Type,
ModView< FunctorGlobalize<
typename Value< typename Fibre<TIndex, FibreSA>::Type >::Type,
typename StringSetLimits<TString>::Type >
>
> Type;
};
*/
template < typename TText, typename TSpec >
struct Fibre< Index<TText, TSpec>, FibreRawSA>
{
typedef Index<TText, TSpec> TIndex;
typedef ModifiedString<
typename Fibre<TIndex, FibreSA>::Type,
ModView< FunctorGlobalize<
typename Value< typename Fibre<TIndex, FibreSA>::Type >::Type,
typename StringSetLimits<TText>::Type >
>
> Type;
};
//////////////////////////////////////////////////////////////////////////////
// default burrows-wheeler table
template < typename TText, typename TSpec >
struct Fibre< Index<TText, TSpec>, FibreBwt> {
typedef String <
typename Value< Index<TText, TSpec> >::Type,
typename StringSpec< Index<TText, TSpec> >::Type
> Type;
};
//////////////////////////////////////////////////////////////////////////////
// default fibre creators
template < typename TText, typename TSpec >
struct DefaultIndexCreator<Index<TText, TSpec>, FibreSA> {
typedef Skew7 Type; // standard suffix array creator is skew7
};
template < typename TText, typename TSpec >
struct DefaultIndexCreator<Index<TText, TSpec>, FibreIsa> {
typedef FromSortedSa<Serial> Type;
};
template < typename TText, typename TSpec >
struct DefaultIndexCreator<Index<TText, TSpec>, FibreLcp> {
typedef Kasai Type;
};
template < typename TText, typename TSpec >
struct DefaultIndexCreator<Index<TText, TSpec>, FibreBwt> {
typedef Bwt Type;
};
template < typename TText, typename TSpec >
struct DefaultIndexCreator<Index<TText, TSpec>, FibreChildtab> {
typedef Childtab Type;
};
template <typename TText, typename TSpec>
inline typename Member<Index<TText, TSpec>, FibreText>::Type &
_dataHost(Index<TText, TSpec> & index) {
return index.text;
}
template <typename TText, typename TSpec>
inline typename Member<Index<TText, TSpec> const, FibreText>::Type &
_dataHost(Index<TText, TSpec> const &index) {
return index.text;
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn Index#getFibre
* @headerfile <seqan/index.h>
* @brief Returns a specific fibre of a container.
*
* @signature TFibre getFibre(index, fibreTag);
*
* @param[in] index The container holding the fibre.
* @param[in] fibreTag A tag that identifies the @link Fibre @endlink. Types: @link IndexEsaFibres Index Esa Fibres
* @endlink, @link FMIndexFibres FM Index Fibres @endlink, @link WOTDIndexFibres Index Wotd Fibres @endlink,
* and @link QGramIndexFibres Index QGram Fibres @endlink.
*
* @return TFibre A reference to the @link Fibre @endlink object.
*
* @section Examples
*
* The following example shows how to search for a pattern in a string.
*
* @include demos/dox/index/getOccurrences_getFrequency_range_getFibre.cpp
*
* The output is as follows:
*
* @include demos/dox/index/getOccurrences_getFrequency_range_getFibre.cpp.stdout
*
* @see Fibre
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreText>::Type &
getFibre(Index<TText, TSpec> &index, FibreText) {
return value(index.text);
}
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreText>::Type &
getFibre(Index<TText, TSpec> const &index, FibreText) {
return value(index.text);
}
//////////////////////////////////////////////////////////////////////////////
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreRawText>::Type &
getFibre(Index<TText, TSpec> &index, FibreRawText) {
return concat(getFibre(index, FibreText()));
}
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreRawText>::Type &
getFibre(Index<TText, TSpec> const &index, FibreRawText) {
return concat(getFibre(index, FibreText()));
}
//////////////////////////////////////////////////////////////////////////////
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreSA>::Type &
getFibre(Index<TText, TSpec> &index, FibreSA) {
return index.sa;
}
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreSA>::Type &
getFibre(Index<TText, TSpec> const &index, FibreSA) {
return index.sa;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreIsa>::Type &
getFibre(Index<TText, TSpec> &index, FibreIsa) {
return index.isa;
}
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreIsa>::Type &
getFibre(Index<TText, TSpec> const &index, FibreIsa) {
return index.isa;
}
//////////////////////////////////////////////////////////////////////////////
/*
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreRawSA>::Type const &
getFibre(Index<TText, TSpec> &index, FibreRawSA) {
return indexSA(index);
}
template <typename TString, typename TSSetSpec, typename TSpec>
inline typename Fibre<Index<StringSet<TString, TSSetSpec>, TSpec>, FibreRawSA>::Type
getFibre(Index<StringSet<TString, TSSetSpec>, TSpec> &index, FibreRawSA)
{
typedef Index< StringSet<TString, TSSetSpec>, TSpec> TIndex;
typedef FunctorGlobalize<
typename Value< typename Fibre<TIndex, FibreSA>::Type >::Type,
typename StringSetLimits<StringSet<TString, TSSetSpec> >::Type
> TFunctor;
typedef ModifiedString<
typename Fibre<Index<StringSet<TString, TSSetSpec>, TSpec>, FibreSA>::Type,
ModView< TFunctor >
> ModString;
return ModString(indexSA(index), TFunctor(stringSetLimits(indexText(index))));
}
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreRawSA>::Type
getFibre(Index<TText, TSpec> &index, FibreRawSA)
{
typedef Index<TText, TSpec> TIndex;
typedef FunctorGlobalize<
typename Value< typename Fibre<TIndex, FibreSA>::Type >::Type,
typename StringSetLimits<TText>::Type
> TFunctor;
typedef ModifiedString<
typename Fibre<Index<TText, TSpec>, FibreSA>::Type,
ModView< TFunctor >
> ModString;
return ModString(indexSA(index), TFunctor(stringSetLimits(indexText(index))));
}
//////////////////////////////////////////////////////////////////////////////
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreLcp>::Type &
getFibre(Index<TText, TSpec> &index, FibreLcp) {
return index.lcp;
}
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreLcp>::Type &
getFibre(Index<TText, TSpec> const &index, FibreLcp) {
return index.lcp;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreLcpe>::Type &
getFibre(Index<TText, TSpec> &index, FibreLcpe) {
return index.lcpe;
}
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreLcpe>::Type &
getFibre(Index<TText, TSpec> const &index, FibreLcpe) {
return index.lcpe;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreChildtab>::Type &
getFibre(Index<TText, TSpec> &index, FibreChildtab) {
return index.childtab;
}
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreChildtab>::Type &
getFibre(Index<TText, TSpec> const &index, FibreChildtab) {
return index.childtab;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreBwt>::Type &
getFibre(Index<TText, TSpec> &index, FibreBwt) {
return index.bwt;
}
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreBwt>::Type &
getFibre(Index<TText, TSpec> const &index, FibreBwt) {
return index.bwt;
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn Index#length
* @headerfile <seqan/index.h>
* @brief Returns the number of characters in the underlying text of the index.
*
* @signature TSize length(index);
*
* @param[in] index An index of a text.
*
* @return TSize Returns the number of characters in the raw underlying text of the
* index with TSize being the result of the @link Size @endlink meta-function
* of @link Index @endlink.
*
* @section Examples
*
* The following example shows how to count characters of an index, determine the number of sequences involved and how
* to search for a pattern.
*
* @include demos/dox/index/length_countSequences.cpp
*
* The output is as follows:
*
* @include demos/dox/index/length_countSequences.cpp.stdout
*/
template <typename TText, typename TSpec>
inline typename Size<Index<TText, TSpec> >::Type
length(Index<TText, TSpec> const &index) {
return length(indexRawText(index));
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn Index#countSequences
* @headerfile <seqan/index.h>
* @brief Return the number of sequences in an index' underlying text.
*
* @signature TSize countSequences(index);
*
* @param[in] index The index to return the number of sequences of.
*
* @return TSize The number of sequences in the index' underlying text with TSize being the result @link Size @endlink.
*
* @section Examples
*
* The following example shows how to count characters of an index, determine the number of sequences involved and how
* to search for a pattern.
*
* @include demos/dox/index/length_countSequences.cpp
*
* The output is as follows:
*
* @code{.output}
* The text has 25 characters and consists of 2 sequences.
* Hit at position: < 1 , 2 >
* Hit at position: < 0 , 0 >
* @endcode
*/
template <typename TText, typename TSpec>
inline typename Size<TText>::Type
countSequences(Index<TText, TSpec> const &index) {
return countSequences(indexText(index));
}
//////////////////////////////////////////////////////////////////////////////
// TODO(singer): Since this is a public function it should be documented
template <typename TText, typename TSpec>
struct GetSequenceByNo< Index<TText, TSpec> >
{
typedef typename GetSequenceByNo<TText>::Type Type;
};
template <typename TText, typename TSpec>
struct GetSequenceByNo< Index<TText, TSpec> const>
{
typedef typename GetSequenceByNo<TText const>::Type Type;
};
//////////////////////////////////////////////////////////////////////////////
// TODO(singer): Since this is a public function it should be documented
template <typename TSeqNo, typename TText, typename TSpec>
inline typename GetSequenceByNo< Index<TText, TSpec> >::Type
getSequenceByNo(TSeqNo seqNo, Index<TText, TSpec> &index)
{
return getSequenceByNo(seqNo, indexText(index));
}
template <typename TSeqNo, typename TText, typename TSpec>
inline typename GetSequenceByNo< Index<TText, TSpec> const>::Type
getSequenceByNo(TSeqNo seqNo, Index<TText, TSpec> const &index)
{
return getSequenceByNo(seqNo, indexText(index));
}
//////////////////////////////////////////////////////////////////////////////
// TODO(singer): Since this is a public function it should be documented
template <typename TSeqNo, typename TText, typename TSpec>
inline typename Size<Index<TText, TSpec> >::Type
sequenceLength(TSeqNo seqNo, Index<TText, TSpec> const &index) {
return sequenceLength(seqNo, indexText(index));
}
//////////////////////////////////////////////////////////////////////////////
// TODO(singer): Since this is a public function it should be documented
template <typename TPos, typename TText, typename TSpec>
inline typename Size<Index<TText, TSpec> >::Type
suffixLength(TPos pos, Index<TText, TSpec> const &index)
{
return length(indexText(index)) - pos;
}
template <typename TPos, typename TString, typename TSSetSpec, typename TSpec>
inline typename Size<Index<StringSet<TString, TSSetSpec>, TSpec> >::Type
suffixLength(TPos pos, Index<StringSet<TString, TSSetSpec>, TSpec> const &index)
{
typename StringSetLimits<StringSet<TString, TSSetSpec> >::Type const &limits = stringSetLimits(index);
return sequenceLength(getSeqNo(pos, limits), index) - getSeqOffset(pos, limits);
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#textAt
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>value(indexText(..), ..)</tt>.
*
* @signature TValue textAt(position, index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
* @param[in] position A position in the fibre on which the value should be accessed.
*
* @return TValue A reference or proxy to the value in the text.
*/
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex, FibreRawText>::Type>::Type
textAt(TPos i, TIndex &index) {
return value(getFibre(index, FibreRawText()), i);
}
template <typename TPos, typename TString, typename TSSetSpec, typename TSpec>
inline typename Reference<typename Fibre< Index< StringSet<TString, TSSetSpec>, TSpec>, FibreRawText>::Type>::Type
textAt(TPos i, Index< StringSet<TString, TSSetSpec>, TSpec> &index) {
return value(getFibre(index, FibreRawText()), posGlobalize(i, stringSetLimits(index)));
}
template <typename TPos, typename TString, typename TSSetSpec, typename TSpec>
inline typename Reference<typename Fibre< Index< StringSet<TString, TSSetSpec>, TSpec> const, FibreRawText>::Type>::Type
textAt(TPos i, Index< StringSet<TString, TSSetSpec>, TSpec> const &index) {
return value(getFibre(index, FibreRawText()), posGlobalize(i, stringSetLimits(index)));
}
template <typename TPos, typename TString, typename TSpec>
inline typename Reference<typename Fibre< Index< StringSet<TString, Owner<Default> >, TSpec>, FibreRawText>::Type>::Type
textAt(TPos i, Index< StringSet<TString, Owner<Default> >, TSpec> &index) {
Pair <
typename Size< StringSet<TString, Owner<Default> > >::Type,
typename Size< TString >::Type > locPos;
posLocalize(locPos, i, stringSetLimits(index));
return value(value(getFibre(index, FibreText()), getValueI1(locPos)), getValueI2(locPos));
}
template <typename TPos, typename TString, typename TSpec>
inline typename Reference<typename Fibre< Index< StringSet<TString, Owner<Default> >, TSpec> const, FibreRawText>::Type>::Type
textAt(TPos i, Index< StringSet<TString, Owner<Default> >, TSpec> const &index) {
Pair <
typename Size< StringSet<TString, Owner<Default> > >::Type,
typename Size< TString >::Type > locPos;
posLocalize(locPos, i, stringSetLimits(index));
return value(value(getFibre(index, FibreText()), getValueI1(locPos)), getValueI2(locPos));
}
//////////////////////////////////////////////////////////////////////////////
// infix
template <typename TText, typename TSpec, typename TPosBegin, typename TPosEnd>
inline typename InfixOnValue<TText>::Type
infix(Index<TText, TSpec> &index, TPosBegin pos_begin, TPosEnd pos_end)
{
return infix(indexText(index), pos_begin, pos_end);
}
template <typename TText, typename TSpec, typename TPosBegin, typename TPosEnd>
inline typename InfixOnValue<TText>::Type
infix(Index<TText, TSpec> const &index, TPosBegin pos_begin, TPosEnd pos_end)
{
return infix(indexText(index), pos_begin, pos_end);
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn Index#rawtextAt
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>value(indexRawText(..), ..)</tt>.
*
* @signature TValue rawtextAt(position, index);
*
* @param[in] index The @link Index @endlink object. Types: @link Index @endlink
* @param[in] position A position in the array on which the value should be accessed.
*
* @return TValue A reference or proxy to the value. The type is the result if the meta-function @link Reference
* @endlink.
*
* @note The result of this function when used on an Index<TText, FMIndex<TOccSpec, Compress> > is not
* defined.
*/
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex, FibreRawText>::Type>::Type rawtextAt(TPos i, TIndex &index) {
return value(getFibre(index, FibreRawText()), i);
}
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex const, FibreRawText>::Type>::Type rawtextAt(TPos i, TIndex const &index) {
return value(getFibre(index, FibreRawText()), i);
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#saAt
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>value(indexSA(..), ..)</tt>.
*
* @signature TValue saAt(position, index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
* @param[in] position A position in the array on which the value should be accessed.
*
* @return TValue A reference or proxy to the value in the suffix array.
*/
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex, FibreSA>::Type>::Type saAt(TPos i, TIndex &index) {
return value(getFibre(index, FibreSA()), i);
}
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex const, FibreSA>::Type>::Type saAt(TPos i, TIndex const &index) {
return value(getFibre(index, FibreSA()), i);
}
//////////////////////////////////////////////////////////////////////////////
// TODO(weese): I disabled the doc, as we don't want to encourage users to use it
/*
* @fn IndexEsa#rawsaAt
* @headerfile <seqan/index.h>
* @note Advanced functionality, not commonly used.
* @brief Shortcut for <tt>value(indexRawSA(..), ..)</tt>.
*
* @signature TValue rawsaAt(position, index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
* @param[in] position A position in the array on which the value should be accessed.
*
* @return TValue A reference or proxy to the value. To be more precise, a reference to a position
* containing a value of type @link SAValue @endlink is returned (or a proxy).
*/
template <typename TPos, typename TIndex>
inline typename Value<typename Fibre<TIndex const, FibreRawSA>::Type>::Type rawsaAt(TPos i, TIndex const &index) {
return posGlobalize(saAt(i, index), stringSetLimits(indexText(index)));
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#isaAt
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>value(indexIsa(..), ..)</tt>.
*
* @signature TValue isaAt(position, index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
* @param[in] position A position in the array on which the value should be accessed.
*
* @return TValue A reference or proxy to the value in the inverse suffix array.
*/
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex, FibreIsa>::Type>::Type isaAt(TPos i, TIndex &index) {
return value(getFibre(index, FibreIsa()), i);
}
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex const, FibreIsa>::Type>::Type isaAt(TPos i, TIndex const &index) {
return value(getFibre(index, FibreIsa()), i);
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#lcpAt
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>value(indexLcp(..), ..)</tt>.
*
* @signature TValue lcpAt(position, index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
* @param[in] position A position in the array on which the value should be accessed.
*
* @return TValue A reference or proxy to the value.
*/
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex, FibreLcp>::Type>::Type lcpAt(TPos i, TIndex &index) {
return value(getFibre(index, FibreLcp()), i);
}
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex const, FibreLcp>::Type>::Type lcpAt(TPos i, TIndex const &index) {
return value(getFibre(index, FibreLcp()), i);
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#lcpeAt
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>value(indexLcpe(..), ..)</tt>.
*
* @signature TValue lcpeAt(position, index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
* @param[in] position A position in the array on which the value should be accessed.
*
* @return TValue A reference or proxy to the value.
*/
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex, FibreLcpe>::Type>::Type lcpeAt(TPos i, TIndex &index) {
return value(getFibre(index, FibreLcpe()), i);
}
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex const, FibreLcpe>::Type>::Type lcpeAt(TPos i, TIndex const &index) {
return value(getFibre(index, FibreLcpe()), i);
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#childAt
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>value(indexChildtab(..), ..)</tt>.
*
* @signature TValue childAt(position, index);
*
* @param[in] position A position in the array on which the value should be accessed.
* @param[in] index The @link IndexEsa @endlink object holding the fibre.
*
* @return TValue A reference or proxy to the value.
*/
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex, FibreChildtab>::Type>::Type childAt(TPos i, TIndex &index) {
return value(getFibre(index, FibreChildtab()), i);
}
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex const, FibreChildtab>::Type>::Type childAt(TPos i, TIndex const &index) {
return value(getFibre(index, FibreChildtab()), i);
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#bwtAt
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>value(indexBwt(..), ..)</tt>.
*
* @signature TValue bwtAt(position, index);
*
* @param[in] index The @link IndexEsa @endlink object holding the fibre.
* @param[in] position A position in the array on which the value should be accessed.
*
* @return TValue A reference or proxy to the value.
*/
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex, FibreBwt>::Type>::Type bwtAt(TPos i, TIndex &index) {
return value(getFibre(index, FibreBwt()), i);
}
template <typename TPos, typename TIndex>
inline typename Reference<typename Fibre<TIndex const, FibreBwt>::Type>::Type bwtAt(TPos i, TIndex const &index) {
return value(getFibre(index, FibreBwt()), i);
}
//////////////////////////////////////////////////////////////////////////////
template <typename TIndex, typename TPos, typename TSize>
inline typename SAValue<TIndex>::Type toSuffixPosition(TIndex &, TPos i, TSize) {
return i;
}
template <typename TIndex, typename TPos, typename TSize>
inline typename SAValue<TIndex const>::Type toSuffixPosition(TIndex const &, TPos i, TSize) {
return i;
}
//////////////////////////////////////////////////////////////////////////////
// interface for infinity/invalid values
template <typename TValue>
inline void _setSizeInval(TValue &v) {
v = std::numeric_limits<TValue>::max();
}
template <typename TValue>
inline bool _isSizeInval(TValue const &v) {
//IOREV _notio_
return v == std::numeric_limits<TValue>::max();
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn Index#indexText
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>getFibre(.., EsaText)</tt>.
*
* @signature TFibre indexText(index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
*
* @return TFibre A reference to the text of the index.
*
* @note The result of this function when used on an <tt>Index<TText, FMIndex<TOccSpec, CompressText> >
* is not defined.
*
* @section Examples
*
* The following code shows how the BWT of a text can be computed.
*
* @include demos/dox/index/textAt_indexText_saAt_indexRequire.cpp
*
* The output is as follows:
*
* @include demos/dox/index/textAt_indexText_saAt_indexRequire.cpp.stdout
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreText>::Type & indexText(Index<TText, TSpec> &index) { return getFibre(index, FibreText()); }
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreText>::Type & indexText(Index<TText, TSpec> const &index) { return getFibre(index, FibreText()); }
//////////////////////////////////////////////////////////////////////////////
template <typename TText, typename TSpec>
inline typename StringSetLimits<TText const>::Type
stringSetLimits(Index<TText, TSpec> &) {
return Nothing();
}
template <typename TText, typename TSpec>
inline typename StringSetLimits<TText const>::Type
stringSetLimits(Index<TText, TSpec> const &) {
return Nothing();
}
template <typename TString, typename TSSetSpec, typename TSpec>
inline typename StringSetLimits< StringSet<TString, TSSetSpec> const >::Type &
stringSetLimits(Index<StringSet<TString, TSSetSpec>, TSpec> &index) {
return stringSetLimits(indexText(index));
}
template <typename TString, typename TSSetSpec, typename TSpec>
inline typename StringSetLimits< StringSet<TString, TSSetSpec> const >::Type &
stringSetLimits(Index<StringSet<TString, TSSetSpec>, TSpec> const &index) {
return stringSetLimits(indexText(index));
}
template <typename TString, typename TSSetSpec, typename TSpec>
inline typename StringSetLimits< StringSet<TString, TSSetSpec> const >::Type &
stringSetLimits(Index<StringSet<TString, TSSetSpec> const, TSpec> &index) {
return stringSetLimits(indexText(index));
}
template <typename TString, typename TSSetSpec, typename TSpec>
inline typename StringSetLimits< StringSet<TString, TSSetSpec> const >::Type &
stringSetLimits(Index<StringSet<TString, TSSetSpec> const, TSpec> const &index) {
return stringSetLimits(indexText(index));
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn Index#indexRawText
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>$getFibre(.., FibreRawText)</tt>.
*
* @signature TFibre indexRawText(position, index);
*
* @param[in] position A position in the array on which the value should be accessed.
* @param[in] index The @link Index @endlink object.
*
* @return TFibre A reference or proxy to the value.
*/
template <typename TText, typename TSpec>
inline
typename Fibre<Index<TText, TSpec>, FibreRawText>::Type &
indexRawText(Index<TText, TSpec> &index)
{
return getFibre(index, FibreRawText());
}
template <typename TText, typename TSpec>
inline
typename Fibre<Index<TText, TSpec> const, FibreRawText>::Type &
indexRawText(Index<TText, TSpec> const &index)
{
return getFibre(index, FibreRawText());
}
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#indexSA
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>getFibre(.., EsaSA)</tt>.
*
* @signature TSA indexSA(index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
*
* @return TSA A reference to the @link IndexEsaFibres#EsaSA @endlink fibre (suffix array).
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreSA>::Type & indexSA(Index<TText, TSpec> &index) { return getFibre(index, FibreSA()); }
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreSA>::Type & indexSA(Index<TText, TSpec> const &index) { return getFibre(index, FibreSA()); }
//////////////////////////////////////////////////////////////////////////////
// NOTE(esiragusa): indexRawSA() is internal and must stay invisible in the doc.
/*
* @fn IndexEsa#indexRawSA
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>getFibre(.., EsaRawSA)</tt>.
*
* @signature TSA indexRawSA(index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
*
* @return TSA A reference to the @link IndexEsaFibres#EsaRawSA @endlink fibre (suffix array).
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreRawSA>::Type indexRawSA(Index<TText, TSpec> &index) { return getFibre(index, FibreRawSA()); }
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreRawSA>::Type indexRawSA(Index<TText, TSpec> const &index) { return getFibre(index, FibreRawSA()); }
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#indexIsa
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>getFibre(.., EsaIsa)</tt>.
*
* @signature TIsa indexIsa(index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
*
* @return TIsa A reference to the inverse suffix array fibre.
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreIsa>::Type & indexIsa(Index<TText, TSpec> &index) { return getFibre(index, FibreIsa()); }
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreIsa>::Type & indexIsa(Index<TText, TSpec> const &index) { return getFibre(index, FibreIsa()); }
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#indexLcp
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>getFibre(.., EsaLcp)</tt>.
*
* @signature TLcp indexLcp(index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
*
* @return TLcp A reference to the @link IndexEsaFibres#EsaLcp @endlink fibre (lcp table).
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreLcp>::Type & indexLcp(Index<TText, TSpec> &index) { return getFibre(index, FibreLcp()); }
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreLcp>::Type & indexLcp(Index<TText, TSpec> const &index) { return getFibre(index, FibreLcp()); }
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#indexLcpe
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>getFibre(.., EsaLcpe)</tt>.
*
* @signature TLcpe indexLcpe(index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
*
* @return TLcpe A reference to the @link IndexEsaFibres#EsaLcpe @endlink fibre (enhanced lcp table).
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreLcpe>::Type & indexLcpe(Index<TText, TSpec> &index) { return getFibre(index, FibreLcpe()); }
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreLcpe>::Type & indexLcpe(Index<TText, TSpec> const &index) { return getFibre(index, FibreLcpe()); }
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#indexBwt
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>getFibre(.., EsaBwt)</tt>.
*
* @signature TBwt indexBwt(index);
*
* @param[in] index The @link IndexEsa @endlink object holding the fibre.
*
* @return TBwt A reference to the @link IndexEsaFibres#EsaBwt @endlink fibre (Burrows-Wheeler table).
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreBwt>::Type & indexBwt(Index<TText, TSpec> &index) { return getFibre(index, FibreBwt()); }
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreBwt>::Type & indexBwt(Index<TText, TSpec> const &index) { return getFibre(index, FibreBwt()); }
//////////////////////////////////////////////////////////////////////////////
/*!
* @fn IndexEsa#indexChildtab
* @headerfile <seqan/index.h>
* @brief Shortcut for <tt>getFibre(.., EsaChildtab)</tt>.
*
* @signature TChildTab indexChildtab(index);
*
* @param[in] index The @link Index @endlink object holding the fibre.
*
* @return TChildTab A reference to the @link IndexEsaFibres#EsaChildtab @endlink fibre (child table).
*/
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec>, FibreChildtab>::Type & indexChildtab(Index<TText, TSpec> &index) { return getFibre(index, FibreChildtab()); }
template <typename TText, typename TSpec>
inline typename Fibre<Index<TText, TSpec> const, FibreChildtab>::Type & indexChildtab(Index<TText, TSpec> const &index) { return getFibre(index, FibreChildtab()); }
// ----------------------------------------------------------------------------
// Function open
// ----------------------------------------------------------------------------
/*!
* @fn Index#open
* @headerfile <seqan/index.h>
* @brief This functions opens an index from disk.
*
* @signature bool open(index, fileName[, mode]);
*
* @param[in,out] index The index to be opened.
* @param[in] fileName C-style character string containing the file name.
* @param[in] mode The combination of flags defining how the file should be opened.To open a file read-only, write-only or
* to read and write use <tt>OPEN_RDONLY</tt>, <tt>OPEN_WRONLY</tt>, or <tt>OPEN_RDWR</tt>.To create or
* overwrite a file add <tt>OPEN_CREATE</tt>.To append a file if existing add <tt>OPEN_APPEND</tt>.To
* circumvent problems, files are always opened in binary mode.
* Default: <tt>OPEN_RDWR | OPEN_CREATE | OPEN_APPEND</tt>.
*
* @return bool <tt>true</tt> on success and <tt>false</tt> otherwise.
*
* @section Examples
*
* The following code shows how the function @link Index#open @endlink is used with indices.
*
* @include demos/dox/index/open_save.cpp
*
* The output is as follows:
*
* @include demos/dox/index/open_save.cpp.stdout
*/
// ----------------------------------------------------------------------------
// Function save
// ----------------------------------------------------------------------------
/*!
* @fn Index#save
* @headerfile <seqan/index.h>
* @brief This functions saves an index to disk.
*
* @signature bool save(index, fileName[, mode]);
*
* @param[in,out] index The index to be opened.
* @param[in] fileName C-style character string containing the file name.
* @param[in] mode The combination of flags defining how the file should be opened.To open a file read-only, write-only or
* to read and write use <tt>OPEN_RDONLY</tt>, <tt>OPEN_WRONLY</tt>, or <tt>OPEN_RDWR</tt>.To create or
* overwrite a file add <tt>OPEN_CREATE</tt>.To append a file if existing add <tt>OPEN_APPEND</tt>.To
* circumvent problems, files are always opened in binary mode.
* Default: <tt>OPEN_RDWR | OPEN_CREATE | OPEN_APPEND</tt>.
*
* @return bool <tt>true</tt> on success and <tt>false</tt> otherwise.
*
* @section Examples
*
* The following code shows how the function @link Index#save @endlink is used with indices.
*
* @include demos/dox/index/open_save.cpp
*
* The output is as follows:
*
* @include demos/dox/index/open_save.cpp.stdout
*/
}
#endif
|