Skip to main content
  • Research article
  • Open access
  • Published:

Optimal neighborhood indexing for protein similarity search



Similarity inference, one of the main bioinformatics tasks, has to face an exponential growth of the biological data. A classical approach used to cope with this data flow involves heuristics with large seed indexes. In order to speed up this technique, the index can be enhanced by storing additional information to limit the number of random memory accesses. However, this improvement leads to a larger index that may become a bottleneck. In the case of protein similarity search, we propose to decrease the index size by reducing the amino acid alphabet.


The paper presents two main contributions. First, we show that an optimal neighborhood indexing combining an alphabet reduction and a longer neighborhood leads to a reduction of 35% of memory involved into the process, without sacrificing the quality of results nor the computational time. Second, our approach led us to develop a new kind of substitution score matrices and their associated e-value parameters. In contrast to usual matrices, these matrices are rectangular since they compare amino acid groups from different alphabets. We describe the method used for computing those matrices and we provide some typical examples that can be used in such comparisons. Supplementary data can be found on the website


We propose a practical index size reduction of the neighborhood data, that does not negatively affect the performance of large-scale search in protein sequences. Such an index can be used in any study involving large protein data. Moreover, rectangular substitution score matrices and their associated statistical parameters can have applications in any study involving an alphabet reduction.


One fundamental task in bioinformatics concerns large scale comparisons between proteins or families of proteins. It often constitutes the first step before further investigations. A typical comparison, for example, is to query a database with a newly discovered sequence. Observed similarities witness a putative common biological function and direct further studies.

In this paper, we focus on massive protein sequence comparisons: a large database is iteratively compared with relatively short queries (such as newly sequenced data). A possible approach is to use the exact dynamic programming method [1]. For a given similarity model, this method provides optimal alignments within a quadratic computation time. Some optimizations achieve a sub-quadratic complexity [2], but the computation time remains prohibitive for large scale comparisons. Thus, in practice, the full dynamic programming approach is applied to comparison of short sequences.

A successful family of similarity search methods is provided by seed-based heuristics, starting with Fasta [3] and Blast [4] and including specific methods for protein similarities such as Blastp [5]. Seed-based heuristics were recently enhanced by advanced seeding tools like the spaced seeds used in PatternHunter [6] or Yass [7] (see [8] for a recent survey). Authors of this paper also worked on the alliance between advanced seeds techniques and reconfigurable architectures [9].

The main idea of seed-based heuristics is to anchor the detection of similarities using matching short words or short subsequences occurring in both compared sequences. The form of these words or subsequences is provided by a pattern called a seed. A word that respects the seed is called a key. For instance, MVK is one of 203 possible keys for the seed of three consecutive characters on the protein alphabet. Detection of similarities between two strings is done in three stages, as presented in Figure 1:

Figure 1
figure 1

Schematic view of a Blast-like 3-stage algorithm. Representation of the three stages of comparison of a query (vertical) against a database (horizontal): Stage 1: identify seeds, i.e. small patterns occurring in both the query and the database (black diagonals). Stage 2: compute seed extensions and keep only those for which the score verifies at threshold T MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae83eXtfaaa@376F@ (brown diagonals). On the Figure, seeds (a) and (b) are successfully extended. Stage 3: perform a full dynamic programming computation (white squares) on remaining seeds. In this example, only seed (b) leads to a significant alignment.

  • Stage 1: search for keys that occur in both strings,

  • Stage 2: extension of these matching keys with an ungapped alignment, keeping only the alignments with a score greater than a given threshold T MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae83eXtfaaa@376F@ ,

  • Stage 3: full dynamic programming algorithm, applied only to successfully extended matching keys.

In this work, we consider comparisons between a set of protein queries against a large protein database of N amino acids. A common usage of Blast is to index the queries, and then to scan the full database at the runtime. If the size of the query and the database allow it, a full indexation of both leads to advantageous results [10]. In our work, we applied approach used e.g. in Blat [11] where the database is indexed once and each query is successively processed.

To be efficient, the database positions are indexed by seed keys. The usual indexing scheme is shown Figure 2: for each key, a list of all its occurrences is stored. At Stage 1, each query position corresponds to a seed key (or, for the Blastp approach, a set of seed keys that are similar to the query seed key). An index access provides the list of key occurrences in the database, enabling Stage 2. We call such an approach the offset indexing approach. In this case, for each seed position, an offset of log2 N bits is stored. The index size is thus equal to Soffset = N × log2 N bits.

Figure 2
figure 2

Offset indexing. Fragment of an offset index. For each seed key (here composed of three letters), the list of its occurrence positions is stored.

For each query position, each execution of Stage 2 needs to access all the occurrences of the corresponding key. This leads to numerous random memory accesses that are time consuming: memory accesses at random positions are not efficiently cached and require high latencies [12]. A way to reduce the computation time is thus to avoid as far as possible such random memory accesses. For that purpose, it is possible to additionally store, for each key occurrence, its left and right neighborhoods in the sequence, as illustrated in Figure 3. Thus, given a position in the query and its corresponding key, all neighborhoods of this key occurrences in the database are obtained through a single random memory access. For each database position, two neighborhoods are additionally stored. We call this indexing approach the neighborhood indexing approach. The overall index size is then equal to Sneighborhood = N × (log2 N + 2αL) bits, where

Figure 3
figure 3

Neighborhood indexing. Fragment of a neighborhood index. For each seed key, the list of its occurrence positions is stored. For each occurrence, its right and left neighborhoods are additionally stored.

  • α is the number of bits for coding a character (amino acid), and

  • L is the length of each neighborhood.

As seen in Figure 4, the main advantage of the neighborhood indexing is that it speeds up the execution time by a factor ranging between 1.5 and 2 over the offset indexing. The actual speed gain depends on the database length and on many implementation and architecture parameters (such as memory and cache sizes, cache strategies and access times) that will not be discussed here. An obvious drawback of the neighborhood indexing is the additional memory it requires to store neighborhoods. Comparing the two indexing schemes, the ratio r between the overall index sizes of the neighborhood indexing and the offset indexing is

Figure 4
figure 4

Time saved by neighborhood indexing compared to offset indexing. Execution time using the offset indexing and the neighborhood indexing for comparing a growing set of queries against a bank of 70·103 proteins.

r = S neighborhood S offset = 1 + 2 α L log 2 N . MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xI8qiVKYPFjYdHaVhbbf9v8qqaqFr0xc9vqFj0dXdbba91qpepeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaGaemOCaiNaeyypa0tcfa4aaSaaaeaacqWGtbWudaWgaaqaaiabb6gaUjabbwgaLjabbMgaPjabbEgaNjabbIgaOjabbkgaIjabb+gaVjabbkhaYjabbIgaOjabb+gaVjabb+gaVjabbsgaKbqabaaabaGaem4uam1aaSbaaeaacqqGVbWBcqqGMbGzcqqGMbGzcqqGZbWCcqqGLbqzcqqG0baDaeqaaaaakiabg2da9iabigdaXiabgUcaRKqbaoaalaaabaGaeGOmaiJaeqySdeMaemitaWeabaWaaCWaaeaacyGGSbaBcqGGVbWBcqGGNbWzdaWgaaqaaiabikdaYaqabaGaemOta4eacaGLUJVaayz+4daaaOGaeiOla4caaa@5DDB@

In common experiments, log2 N is between 20 and 40, αL is between 20 and 200, hence r is between 2 and 21. It is worth mentioning that the log2 N value is often raised to a more practical 32 or 64 bits, reducing the ratio r even more. Storing neighborhoods becomes then relevant with the reduction of memory prices. For instance, the modern technology brings the possibility to get gigabytes of Flash memory in a personal computer for some hundred dollars. It is thus interesting to exploit this storage space as much as possible. It can be used for treating larger databases, but also, as in this work, for speeding up widely used applications.

However, the index size still remains the main limitation. In this paper, we study how the size of a large neighborhood index can be reduced while preserving the result quality. For this purpose, we worked on reducing as much as possible the ratio r. A way for doing this is to reduce the factor αL. We propose to simultaneously increase the neighborhood length (L) and reduce the alphabet size (2·α). We limit the alphabet size by partitioning amino acids into groups. This reduces a by encoding neighborhood characters in less than 5 bits required for coding 20 amino acids. Partitioning the amino acids into 16 groups enables to encode each group using 4 bits, and partitioning into 8, 4 or 2 groups enables to encode each group by 3, 2, and 1 bits respectively. All these reduced alphabets are tested in this paper.

Grouping amino acids was studied in several papers [1316]. Groups can rely on amino acid physical-chemical properties or on a statistical analysis of alignments. For example, the authors of [13] computed correlation coefficients between pairs of amino acids based on the BLOSUM50 matrix and used a greedy algorithm to merge them. A branch-and-bound algorithm for partitioning the amino acids was proposed in [14]. Those papers mainly deal with the construction of reduced alphabets, but none of them studies how the alphabet reduction affects the sensitivity of similarity search, or undertakes a quantitative analysis of the trade-off between search sensitivity and index size for those alphabets. This raises the following problem that is solved in this paper: Can reduced alphabets allow one to decrease the factor αL while preserving the quality of similarity search results?

Results and discussion

The main result of our work is an effective reduction of the index size without deteriorating the quality of the results of similarity search. Moreover, we provide substitution score matrices and e-value parameters to be used with reduced alphabets. Our results are based on the alphabets defined by the amino acids groups proposed by Li and al. (Table 2 of [15]). This choice was motivated by empirical tests showing their relevancy with seeds matching. However, our method can be applied to any other amino acids partitions. The website [17] provides data for all the alphabets reported in [16].

Table 1 Stage two algorithm
Table 2 Memory for neighborhood storage for different alphabets with adapted neighborhood lengths

In the rest of the paper, the original alphabet of 20 amino acids is denoted by Σ20, where each character is encoded by 5 bits. Reduced alphabets Σ16, Σ8, Σ4 and Σ2, respectively of size 16, 8, 4 and 2, have each character encoded by 4, 3, 2 and 1 bits respectively. Those alphabets, taken from Table 2 of [15], are defined by

Σ 16 = { [ C ] , [ F Y ] , [ W ] , [ M L ] , [ I V ] , [ G ] , [ P ] , [ A ] , [ T ] , [ S ] , [ N ] , [ H ] , [ Q E ] , [ D ] , [ R ] , [ K ] } , Σ 8 = { [ C F Y W ] , [ M L I V ] , [ G ] , [ P ] , [ A T S ] , [ N H ] , [ Q E D ] , [ R K ] } , Σ 4 = { [ C F Y W ] , [ M L I V ] , [ G P A T S ] , [ N H Q E D R K ] } , a n d Σ 2 = { [ C F Y W M L I V ] , [ G P A T S N H Q E D R K ] } . MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xI8qiVKYPFjYdHaVhbbf9v8qqaqFr0xc9vqFj0dXdbba91qpepeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaqbaeaabGWaaaaaaeaacqqHJoWudaWgaaWcbaGaeGymaeJaeGOnaydabeaaaOqaaiabg2da9aqaaiabcUha7jabcUfaBjabdoeadjabc2faDjabcYcaSiabcUfaBjabdAeagjabdMfazjabc2faDjabcYcaSiabcUfaBjabdEfaxjabc2faDjabcYcaSiabcUfaBjabd2eanjabdYeamjabc2faDjabcYcaSiabcUfaBjabdMeajjabdAfawjabc2faDjabcYcaSiabcUfaBjabdEeahjabc2faDjabcYcaSiabcUfaBjabdcfaqjabc2faDjabcYcaSiabcUfaBjabdgeabjabc2faDjabcYcaSaqaaaqaaaqaaiabcUfaBjabdsfaujabc2faDjabcYcaSiabcUfaBjabdofatjabc2faDjabcYcaSiabcUfaBjabd6eaojabc2faDjabcYcaSiabcUfaBjabdIeaijabc2faDjabcYcaSiabcUfaBjabdgfarjabdweafjabc2faDjabcYcaSiabcUfaBjabdseaejabc2faDjabcYcaSiabcUfaBjabdkfasjabc2faDjabcYcaSiabcUfaBjabdUealjabc2faDjabc2ha9jabcYcaSaqaaiabfo6atnaaBaaaleaacqaI4aaoaeqaaaGcbaGaeyypa0dabaGaei4EaSNaei4waSLaem4qamKaemOrayKaemywaKLaem4vaCLaeiyxa0LaeiilaWIaei4waSLaemyta0KaemitaWKaemysaKKaemOvayLaeiyxa0LaeiilaWIaei4waSLaem4raCKaeiyxa0LaeiilaWIaei4waSLaemiuaaLaeiyxa0LaeiilaWIaei4waSLaemyqaeKaemivaqLaem4uamLaeiyxa0LaeiilaWcabaaabaaabaGaei4waSLaemOta4KaemisaGKaeiyxa0LaeiilaWIaei4waSLaemyuaeLaemyrauKaemiraqKaeiyxa0LaeiilaWIaei4waSLaemOuaiLaem4saSKaeiyxa0LaeiyFa0NaeiilaWcabaGaeu4Odm1aaSbaaSqaaiabisda0aqabaaakeaacqGH9aqpaeaacqGG7bWEcqGGBbWwcqWGdbWqcqWGgbGrcqWGzbqwcqWGxbWvcqGGDbqxcqGGSaalcqGGBbWwcqWGnbqtcqWGmbatcqWGjbqscqWGwbGvcqGGDbqxcqGGSaalcqGGBbWwcqWGhbWrcqWGqbaucqWGbbqqcqWGubavcqWGtbWucqGGDbqxcqGGSaalaeaaaeaaaeaacqGGBbWwcqWGobGtcqWGibascqWGrbqucqWGfbqrcqWGebarcqWGsbGucqWGlbWscqGGDbqxcqGG9bqFcqGGSaalcqWGHbqycqWGUbGBcqWGKbazaeaacqqHJoWudaWgaaWcbaGaeGOmaidabeaaaOqaaiabg2da9aqaaiabcUha7jabcUfaBjabdoeadjabdAeagjabdMfazjabdEfaxjabd2eanjabdYeamjabdMeajjabdAfawjabc2faDjabcYcaSaqaaaqaaaqaaiabcUfaBjabdEeahjabdcfaqjabdgeabjabdsfaujabdofatjabd6eaojabdIeaijabdgfarjabdweafjabdseaejabdkfasjabdUealjabc2faDjabc2ha9jabc6caUaaaaaa@0C1A@

The main idea is to represent the neighborhoods of keys stored in the index (see Figure 3) over a reduced alphabet. Consequently, at Stage 2 of the similarity search, amino acid sequences are compared with sequences over the reduced alphabet. By an alignment over Σ × Σ', we understand an alignment between a sequence over Σ and a sequence over Σ'. Thus, in this paper we will consider alignments over Σ20 × Σ20, Σ20 × Σ16, Σ20 × Σ8, Σ20 × Σ4 and Σ20 × Σ2.

In the next sections, we describe how to evaluate the quality of Stage 2 and how a substantial index size reduction can be obtained by using longer neighborhoods on reduced alphabets. As presented in Figure 5, using a reduced alphabet involves several parameters that we study in the following sections. In section Rectangular substitution score matrices, we present substitution score matrices used for alignments over Σ20 × Σ8 and Σ20 × Σ16. We then present the computation of e-value to estimate the significance of alignments over reduced alphabets. The last section, Experimental validation, describes a practical application of reduced alphabets to real biological data.

Figure 5
figure 5

Parameters involved in alphabet reduction. Once an alphabet and a sensitivity/selectivity ratio are chosen, several parameters are computed. Substitution score matrix and e-value parameters depend only on the alphabet and the model probabilities, whereas the optimal neighborhood size and the threshold depends also on the sensitivity/selectivity level.

Stage 2 algorithm and quality

A detailed description of Stage 2 is given in Algorithm 1 (Table 1). Query and database neighborhoods of a matching key (detected during Stage 1) are compared character by character over L positions. During this comparison that uses substitution score matrices (lines 1 and 1), the highest scores for the left and right neighborhoods are kept (lines 1 and 1). If the sum of the highest scores exceeds a threshold T MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae83eXtfaaa@376F@ , the alignment is kept for Stage 3 (line 1), otherwise it is rejected (line 1). Note that in the offset indexing case, a random memory access is performed in order to retrieve neighborhoods left db and right db (line 1). This is not the case for the neighborhood indexing, as the neighborhoods are stored directly in the index.

The quality of Stage 2 is measured by a trade-off between its sensitivity (ability to extend true alignments) and selectivity (ability to filter out spurious seed hits). Computation of those values is described page 10.

Increasing the threshold T MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae83eXtfaaa@376F@ or decreasing the neighborhood length L makes Stage 2 more selective but less sensitive (faster execution at the price of worse quality results) while decreasing T MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae83eXtfaaa@376F@ or increasing L increases the sensitivity and decreases the selectivity (better quality results at the price of a slower execution).

Reducing the index size by 35% without loss of quality

As shown in Figure 6, the sensitivity/selectivity trade-off follows a convex curve. We propose here to achieve an equivalent trade-off with a reduction of the index size.

Figure 6
figure 6

Sensitivity/selectivity trade-off using different alphabets with a constant neighborhood length. Sensitivity/selectivity trade-off for two neighborhoods of length 11 (other lengths give similar results). When the length is fixed, reduced alphabets provide worse results than the Σ20 × Σ20 alphabet. The curves for alphabets Σ20 × Σ4 and Σ20 × Σ2, not shown, are even worse.

Clearly, for a fixed neighborhood length L (in Figure 6, 16 amino acids), the sensitivity/selectivity trade-off is always better when using the full amino acid alphabets than a reduced alphabet. This is easily explained by the fact that reducing the alphabet size decreases the alignment accuracy. In order to keep up with the sensitivity/selectivity ratio, the neighborhood length L should be increased. In Figure 7, all reduced alphabets, used with increased neighborhood lengths, now perform equivalently (or slightly better) than the full alphabet.

Figure 7
figure 7

Sensitivity/selectivity trade-off using different alphabets with adapted neighborhood lengths. Sensitivity/selectivity trade-off for two neighborhoods with the adapted lengths of Table 2. Now all reduced alphabets are equivalent (or slightly better, due to integer rounding of the neighborhood lengths) than the original alphabet Σ20 × Σ20.

Figure 8 shows the dependency, for different reduced alphabets, between the number of bits needed to store both neighborhoods (X axis) and the selectivity (Y axis), for an equivalent quality (fixed sensitivity). Those results are obtained with the use of special substitution score matrices, adapted to reduced alphabets, that are presented in the next section. Our main result is that for any given selectivity, using any of the reduced alphabets for storing neighborhoods leads to a smaller αL factor than for the Σ20 alphabet. Therefore, for a fixed memory usage, the sensitivity/selectivity trade-off is always better with a reduced alphabet than with the full Σ20 alphabet.

Figure 8
figure 8

Memory for neighborhood storage for different alphabets at a fixed sensitivity. Memory space needed to achieve a sensitivity close to 0.95. The same quality can be achieved with 64 bits (2 neighborhoods of 32 amino acids encoded in 1 bit, sensitivity of 0.9499, selectivity of 0.0112) instead of 110 bits (2 neighborhoods of 11 amino acids encoded in 5 bits, sensitivity of 0.9500, selectivity of 0.0111). All reduced rectangular alphabets lead to smaller index sizes than the regular Σ20 × Σ20 alphabet.

In practice, this result enables a reduction of the index size without any sacrifice in running time or in result quality. Table 2 shows the memory requirements for different alphabets. We obtain a practical reduction of 42% of the factor αL using the reduced alphabet Σ2 instead of Σ20. The ratio r on the overall index size is then reduced by 35%.

Rectangular substitution score matrices

We designed a method for computing substitution score matrices for any pair of possibly reduced amino acid alphabets. As this method is based on the original programs of [18], we call such matrices RE BLOSUM for Rectangular BLOSUM matrices. The RE BLOSUM matrices for alphabets Σ20 × Σ20 are the original BLOSUM matrices. Tables 3, 4, 5 and 6 present RE BLOSUM matrices for alignments over alphabets Σ20 × Σ16, Σ20 × Σ8, Σ20 × Σ4 and Σ20 × Σ2 respectively.

Table 3 RE BLOSUM 62 matrix for alphabet Σ20 × Σ16
Table 4 RE BLOSUM 62 matrix for alphabet Σ20 × Σ8
Table 5 RE BLOSUM 62 matrix for alphabet Σ20 × Σ4
Table 6 RE BLOSUM 62 matrix for alphabet Σ20 × Σ2

Such matrices can be applied in any method reducing the amino acid alphabets by residue grouping. As one may be interested in using any other pair of alphabets, we additionally propose a web interface [17]. This web interface computes RE BLOSUM matrices for other alphabets listed in [16] and for any custom alphabets provided by the user.

Parameters for e-value computation

The e-value, or expected value, provides the expected number of alignments with a given score, when comparing a text T and a query Q of length |T | and |Q| respectively. Local alignment methods like Blast sort results by increasing e-value, thus reflecting their decreasing significance. In the Blast algorithm, the e-value of an alignment is obtained bye-value = K·|Q| · |T| · e-λs,

where s is the score of the alignment obtained with substitution matrices. Parameters λ and K are two constants that fit the Gumbel law, computed using methods described in [19]. Table 7 provides those parameters for several RE BLOSUM substitution matrices.

Table 7 Gumbel law parameters λ and K for different alphabets, obtained with the corresponding RE BLOSUM score matrices.

Experimental validation

In a model where the Stage 2 alignments are ungapped, using reduced alphabets and alignments on longer neighborhoods can however affect the result quality. Indeed, the longer the neighborhoods are, the bigger is the chance to meet a gap in the sequences. More generally, the probabilities distributions used in theoretical sensitivity and selectivity computations do not truly reflect the nature of the biological sequences.

We thus validated our approach with large-scale tests on biological sequences. We set a database to be the hard-masked human chromosome 21 (UCSC Release hg18) translated according to the six possible reading frames. The query set was a set of seven archea and bacteria proteomes derived from a study of mitochondrial diseases. This set was selected for is interest toward the detection of potential insertions of mitochondrial genes in the human genome. Moreover, testing out our approach comparing such distant species represents one of the hardest application case. Indeed more typical homology searches on closer sequences is easier. Tests on such homology searches could have hidden potential issue on our approach.

The database contained 12 700 507 amino acids whereas the query was composed by 5 321 439 amino acids. Using the ssearch method [20], 650 alignments were obtained between the database and the query (maximal e-value: 10-3). This set of exhaustive optimum alignments was sufficient to validate our method in comparison with results obtained using different alphabets. The seed used in Stage 1 was a subset seed (see [21]), as in [9]. For the neighborhood indexing, we indexed the database using each of the alphabets Σ20, Σ16, Σ8, Σ4 and Σ2. We selected the neighborhood length to have a theoretical sensitivity close to 0.95 and a theoretical selectivity close to 0.01. Theoretical sensitivity and selectivity are defined according distributions presented on page 10.

This leads to indexing 2 × 11 characters for Σ20, 2 × 12 characters for Σ16, 2 × 14 characters on Σ8, 2 × 19 characters for Σ4, and 2 × 32 characters for Σ2 (Figure 7). The database index sizes are reported in Table 9. Using alphabet Σ2 instead of Σ20 reduces the overall index size: the ratio r goes from r20 = 5.58 to only r2 = 3.67, that is a 35% reduction. The initial assumption of ungapped alignments in the Stage 2 can be wrong with a neighborhood length of 2 × 32. Thus one could prefer to use the alphabet Σ4 with 2 × 19 characters, giving a 25% reduction of the overall index size (r4 = 4.17).

Table 8 Practical results for different alphabets – Quality estimations
Table 9 Practical results for different alphabets – Memory requirements

As shown in Table 8, each of the reduced alphabets yields a practical full sensitivity, as all the 650 alignments are found in each test. Moreover, the practical selectivity, close to 10-3, is here better than the theoretical one (0.01).


We proposed a method for reducing the index size when storing neighborhoods of seed keys in protein databases. This approach is based on reducing the alphabet of indexed data while using a longer neighborhood. We save 35% of the index size without any modification on the result quality assuming an ungapped alignment model. We provided optimal lengths for selected alphabets.

Furthermore, the proposed method requires unusual substitutions score matrices that are called RE BLOSUM, for rectangular BLOSUM matrices. These matrices provide substitution scores between letters from different alphabets. We extended the computation of traditional BLOSUM matrices in order to compute RE BLOSUM matrices, and adapted the computation of λ and K parameters for e-value estimation to reduced alphabets. We provided RE BLOSUM matrices and their corresponding λ and K values for selected alphabets. Other matrices and parameters can be obtained from the website [17].


In this section, we describe the methods we used to compute the sensitivity and selectivity of similarity search on reduced alphabets as well as the neighborhood length. We further describe the computation of RE BLOSUM substitution score matrices and of the e-value parameter. Moreover, we explain how the threshold T MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae83eXtfaaa@376F@ is computed at Stage 2 depending on the e-value specified by the user. Finally, we describe how we estimated the time gain of the the neighborhood indexing over the offset indexing.

Selectivity and sensitivity computation

The sensitivity of Stage 2 is defined by the ratio of retained "true alignments" (a "true alignment" is an alignment known to be relevant, according to a model or to a reference set like the BLOCKS database):

sensitivity = # successfully extended true alignments # true alignments , MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xI8qiVKYPFjYdHaVhbbf9v8qqaqFr0xc9vqFj0dXdbba91qpepeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaGaee4CamNaeeyzauMaeeOBa4Maee4CamNaeeyAaKMaeeiDaqNaeeyAaKMaeeODayNaeeyAaKMaeeiDaqNaeeyEaKNaeyypa0tcfa4aaSaaaeaacqqGJaWicqqGGaaicqqGZbWCcqqG1bqDcqqGJbWycqqGJbWycqqGLbqzcqqGZbWCcqqGZbWCcqqGMbGzcqqG1bqDcqqGSbaBcqqGSbaBcqqG5bqEcqqGGaaicqqGLbqzcqqG4baEcqqG0baDcqqGLbqzcqqGUbGBcqqGKbazcqqGLbqzcqqGKbazcqqGGaaicqqG0baDcqqGYbGCcqqG1bqDcqqGLbqzcqqGGaaicqqGHbqycqqGSbaBcqqGPbqAcqqGNbWzcqqGUbGBcqqGTbqBcqqGLbqzcqqGUbGBcqqG0baDcqqGZbWCaeaacqqGJaWicqqGGaaicqqG0baDcqqGYbGCcqqG1bqDcqqGLbqzcqqGGaaicqqGHbqycqqGSbaBcqqGPbqAcqqGNbWzcqqGUbGBcqqGTbqBcqqGLbqzcqqGUbGBcqqG0baDcqqGZbWCaaGaeiilaWcaaa@8652@

The selectivity is defined as the ratio of retained "random alignments" (a "random alignment" means an alignment of randomly chosen amino acid pairs drawn according to an appropriate probability distribution):

selectivity = # successfully extended random alignments # random alignments . MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xI8qiVKYPFjYdHaVhbbf9v8qqaqFr0xc9vqFj0dXdbba91qpepeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaGaee4CamNaeeyzauMaeeiBaWMaeeyzauMaee4yamMaeeiDaqNaeeyAaKMaeeODayNaeeyAaKMaeeiDaqNaeeyEaKNaeyypa0tcfa4aaSaaaeaacqqGJaWicqqGGaaicqqGZbWCcqqG1bqDcqqGJbWycqqGJbWycqqGLbqzcqqGZbWCcqqGZbWCcqqGMbGzcqqG1bqDcqqGSbaBcqqGSbaBcqqG5bqEcqqGGaaicqqGLbqzcqqG4baEcqqG0baDcqqGLbqzcqqGUbGBcqqGKbazcqqGLbqzcqqGKbazcqqGGaaicqqGYbGCcqqGHbqycqqGUbGBcqqGKbazcqqGVbWBcqqGTbqBcqqGGaaicqqGHbqycqqGSbaBcqqGPbqAcqqGNbWzcqqGUbGBcqqGTbqBcqqGLbqzcqqGUbGBcqqG0baDcqqGZbWCaeaacqqGJaWicqqGGaaicqqGYbGCcqqGHbqycqqGUbGBcqqGKbazcqqGVbWBcqqGTbqBcqqGGaaicqqGHbqycqqGSbaBcqqGPbqAcqqGNbWzcqqGUbGBcqqGTbqBcqqGLbqzcqqGUbGBcqqG0baDcqqGZbWCaaGaeiOla4caaa@8B4A@

Note that here we focus on the behavior of Stage 2 and do not take into consideration the sensitivity/selectivity of Stage 1. In particular, in the above fractions we consider only alignments that extend a hit presumably reported at Stage 1.

The sensitivity and the selectivity of Stage 2 rely on three parameters: the alphabet choice, the neighborhood length, and the score threshold T MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae83eXtfaaa@376F@ . Given these three parameters, we applied a dynamic programming algorithm to compute the probability for the filter to retain an alignment drawn according to a given amino acid pair distribution. Applied to distributions of "true" and "random" alignments (foreground and background distributions, respectively), the algorithm gives a theoretical estimation of the sensitivity and the selectivity of the filter. The two distributions were the Bernoulli models (namely the expected and the observed probabilities, see below), obtained with the BLOSUM programs on the BLOCKS protein database when processing the BLOSUM-62 matrix.

In our Algorithm 1, two neighborhoods (left and right) are processed. We thus consider the sum of two maximal scores, reached in the left and right neighborhoods. The probability that this sum reaches a given threshold T MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae83eXtfaaa@376F@ at least once is computed as follows. First, we compute the probability for each neighborhood independently to reach any given maximal score s (s ≥ 0) within the neighborhood length. Then, these two independent discrete distributions are combined to compute the T MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae83eXtfaaa@376F@ threshold requirement.

For our experiments, we calibrated the neighborhoods lengths to have a sensibility close to 0.95 and a selectivity close to 0.01, and computed related thresholds values (available of the RE BLOSUM website).

Computing RE BLOSUM matrices

There are several substitution score matrices for the regular Σ20 × Σ20 alphabet, and the most common of them are matrices from the BLOSUM family [22] (BLOcks SUbstitution Matrix). They are built from the BLOCKS database of ungapped multiple alignments [23]. For a given identity level X and two amino acids i and j, the BLOSUM X score Bi, jare log-likelihoods of amino acid pair frequencies:

B i , j = log ( q i , j p i p j ) , MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xI8qiVKYPFjYdHaVhbbf9v8qqaqFr0xc9vqFj0dXdbba91qpepeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaGaemOqai0aaSbaaSqaaiabdMgaPjabcYcaSiabdQgaQbqabaGccqGH9aqpcyGGSbaBcqGGVbWBcqGGNbWzdaqadaqcfayaamaalaaabaGaemyCae3aaSbaaeaacqWGPbqAcqGGSaalcqWGQbGAaeqaaaqaaiabdchaWnaaBaaabaGaemyAaKgabeaacqGHflY1cqWGWbaCdaWgaaqaaiabdQgaQbqabaaaaaGccaGLOaGaayzkaaGaeiilaWcaaa@466D@

where p i · p j is the expected probability of aligning i against j, and qi, jis the observed probability of the same event in a subset of alignments of the BLOCKS database that have at least × percent of identity. (Note that the computation of qi, jtakes into account different contributions provided by alignments with different identity levels.)

In our case, sequences over diferent alphabets are compared and we then have to adapt the matrix computation to compute appropriate rectangular matrices. For this purpose, the original data file (BLOCKS database version 5) was downloaded and the original programs of [18] (downloaded from [24]) were modified in order to take into account the reduced alphabet on "one side" of the matrix and compute new log-likelihood scores. Given two alphabets Σ and Σ', we compute such matrices for several identity levels X, using the log-likelihood of groups of amino acid pair frequencies:

B I , J = log ( q I , J p I p J ) , MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xI8qiVKYPFjYdHaVhbbf9v8qqaqFr0xc9vqFj0dXdbba91qpepeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaGaemOqai0aaSbaaSqaaiabdMeajjabcYcaSiabdQeakbqabaGccqGH9aqpcyGGSbaBcqGGVbWBcqGGNbWzdaqadaqcfayaamaalaaabaGaemyCae3aaSbaaeaacqWGjbqscqGGSaalcqWGkbGsaeqaaaqaaiabdchaWnaaBaaabaGaemysaKeabeaacqGHflY1cqWGWbaCdaWgaaqaaiabdQeakbqabaaaaaGccaGLOaGaayzkaaGaeiilaWcaaa@44ED@

where p I ·p J is the expected frequency of aligning any amino acids from group I Σ against any other amino acid from group J Σ', and qI, Jis the observed frequency of the same event in a subset of alignments of the BLOCKS database that have at least × percent of identity. The recent paper [25] discovered flaws in the original BLOSUM implementation, but shows that a corrected program does not improve (and even in some cases decreases) the results quality. Therefore, we did not take the proposed modifications into account.

The website [17] proposes a selection of RE BLOSUM matrices for several alphabets, as well as an interface to compute RE BLOSUM matrices for any alphabet and identity level specified by the user.

Prototype for estimating the time gain of offset indexing over neighborhood indexing

For comparing the execution time between offset indexing and neighborhood indexing, a C MathType@MTEF@5@5@+=feaagaart1ev2aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacPC6xNi=xH8viVGI8Gi=hEeeu0xXdbba9frFj0xb9qqpG0dXdb9aspeI8k8fiI+fsY=rqGqVepae9pg0db9vqaiVgFr0xfr=xfr=xc9adbaqaaeGaciGaaiaabeqaaeqabiWaaaGcbaWenfgDOvwBHrxAJfwnHbqeg0uy0HwzTfgDPnwy1aaceaGae8NaXpeaaa@374D@ prototype was created. In the case of the offset indexing, the index stores positions of all seeds in an unique integer array. For each seed key, a pointer provides the first occurrence in this array. In the case of the neighborhood indexing, the index uses a (unique) structure array instead of an integer array. For each key occurrence, the structure contains the key position together with two neighborhoods.

Tests reported in Figure 4 were run on a 2 GHz PC with an AMD Opteron processor. The database size was selected so that the index fits into the main memory (4 GB) but not into the L1/L2 cache (1 MB). In those tests, the neighborhood indexing performs almost twice as fast as the offset indexing.


  1. Smith T, Waterman M: Identification of common molecular subsequences. Journal of Molecular Biology 1981., 147(195–197):

  2. Crochemore M, Landau G, Ziv-Ukelson M: A Sub-quadratic Sequence Alignment Algorithm for Unrestricted Cost Matrices. Symposium On Discrete Algorithms (SODA 02) 2002, 679–688.

    Google Scholar 

  3. Lipman D, Pearson W: Improved tools for biological sequence comparison. Proc Natl Acad Sci USA 1988, 85: 2444–2448. 10.1073/pnas.85.8.2444

    Article  PubMed Central  PubMed  Google Scholar 

  4. Altschul S, Gish W, Miller W, Myers W, Lipman D: Basic local alignment search tool. Journal of Molecular Biology 1990, 215(3):403–410.

    Article  CAS  PubMed  Google Scholar 

  5. Altschul S, Madden T, Schäffer A, Zhang J, Zhang Z, Miller W, Lipman D: Gapped BLAST and PSI-BLAST: a new generation of protein database search programs. Nucleic Acids Research 1997, 25(17):3389–3402. 10.1093/nar/25.17.3389

    Article  PubMed Central  CAS  PubMed  Google Scholar 

  6. Li M, Ma B, Kisman D, Tromp J: PatternHunter II: Highly Sensitive and Fast Homology Search. Journal of Bioinformatics and Computational Biology 2004, 2(3):417–439. [(early version in GIW 2003)]. 10.1142/S0219720004000661

    Article  CAS  PubMed  Google Scholar 

  7. Noé L, Kucherov G: YASS: enhancing the sensitivity of DNA similarity search. Nucleic Acids Research 2005, 33: W540-W543. 10.1093/nar/gki478

    Article  PubMed Central  PubMed  Google Scholar 

  8. Brown DG: Bioinformatics Algorithms: Techniques and Applications. In A survey of seeding for sequence alignment. Wiley-Interscience (I. Mandoiu, A. Zelikovsky); 2008:126–152.

    Google Scholar 

  9. Peterlongo P, Noé L, Lavenier D, Georges G, Jacques J, Kucherov G, Giraud M: Protein similarity search with subset seeds on a dedicated reconfigurable hardware. Parallel Biocomputing Conference (PBC 07), Volume 4967 of Lecture Notes in Computer Science (LNCS) 2007.

    Google Scholar 

  10. Nguyen VH, Lavenier D: Speeding up Subset Seed Algorithm for Intensive Protein Sequence Comparison. 6th International Conference on research, innovation and vision for the future 2008.

    Google Scholar 

  11. Kent WJ: BLAT-the BLAST-like alignment tool. Genome Res 2002, 12(4):656–664.

    Article  PubMed Central  CAS  PubMed  Google Scholar 

  12. Hennessy JL, Patterson DA: Computer Architecture, A Quantitative Approach. Morgan Kaufmann; 2006.

    Google Scholar 

  13. Murphy L, Wallqvist A, Ronald L: Simplified amino acid alphabets for protein fold recognition and implications for folding. Protein Engineering 2000, 13(3):149–152. 10.1093/protein/13.3.149

    Article  CAS  PubMed  Google Scholar 

  14. Cannata N, Toppo S, Romualdi C, Valle G: Simplifying amino acid alphabets by means of a branch and algorithm and substitution matrices. Bioinformatic 2002, 18(8):1102–1108. 10.1093/bioinformatics/18.8.1102

    Article  CAS  Google Scholar 

  15. Li T, Fan K, Wang J, Wang W: Reduction of protein sequence complexity by residue grouping. Protein Engineering 2003, 16(5):323–330. 10.1093/protein/gzg044

    Article  CAS  PubMed  Google Scholar 

  16. Edgar R: Local homology recognition and distance measures in linear time using compressed amino acid alphabets. Nucleic Acids Research 2004, 32: 380–385. 10.1093/nar/gkh180

    Article  PubMed Central  CAS  PubMed  Google Scholar 

  17. ReBLOSUM:: Rectangular BLOSUM Matrices[]

  18. Henikoff J, Henikoff S: Amino Acid Substitution Matrices form Protein Blocks. Proc Natl Acad Sci USA 1992, 89: 10915–10919. 10.1073/pnas.89.22.10915

    Article  PubMed Central  CAS  PubMed  Google Scholar 

  19. Karlin S, Altschul SF: Methods for assessing the statistical significance of molecular sequence features by using general scoring schemes. Proc Natl Acad Sci USA 1990, 87(6):2264–2268. 10.1073/pnas.87.6.2264

    Article  PubMed Central  CAS  PubMed  Google Scholar 

  20. Lipman D, Pearson W: Rapid and Sensitive Protein Similarity Searches. Science 1985, 227: 1435–1441. 10.1126/science.2983426

    Article  CAS  PubMed  Google Scholar 

  21. Roytberg M, Gambin A, Noé L, Lasota S, Furletova E, Szczurek E, Kucherov G: Efficient seeding techniques for protein similarity search. Bioinformatics Research and Development, Proceedings of the 2nd International Conference BIRD 2008, Vienna (Austria), July 7–9, 2008, of Communications in Computer and Information Science, Springer Verlag 2008, 13: 466–478.

    Google Scholar 

  22. Henikoff S, Henikoff J: Amino acid substitution matrices from protein blocks. Proc Natl Acad Sci USA 1992, 89: 10915–10919. 10.1073/pnas.89.22.10915

    Article  PubMed Central  CAS  PubMed  Google Scholar 

  23. Henikoff S, Henikoff J: Automated assembly of protein blocks for database searching. Nucleic Acids Res 1991, 19(23):6565–6572. 10.1093/nar/19.23.6565

    Article  PubMed Central  CAS  PubMed  Google Scholar 

  24. Blosum database[]

  25. Styczynski MP, Jensen KL, Rigoutsos I, Stephanopoulos G: BLOSUM62 miscalculations improve search performance. Nat Biotech 2008, 26(3):274–275. 10.1038/nbt0308-274

    Article  CAS  Google Scholar 

Download references


This work was supported by the INRIA ARC grant "Flash" (Seed Optimization and Indexing of Genomic Databases).

Author information

Authors and Affiliations


Corresponding author

Correspondence to Pierre Peterlongo.

Additional information

Authors' contributions

All authors conceived the study. VHN created and tested the prototype estimating the time gain using a neighborhood index. LN and MG computed RE BLOSUM matrices and optimal neighborhood lengths using different alphabets and created the web interface. PP performed tests on biological sequences and drafted the manuscript. DL and GK proposed the setup of the work and participated in its coordination. All authors read and approved the final manuscript.

Authors’ original submitted files for images

Rights and permissions

This article is published under license to BioMed Central Ltd. This is an Open Access article distributed under the terms of the Creative Commons Attribution License (, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

Reprints and permissions

About this article

Cite this article

Peterlongo, P., Noé, L., Lavenier, D. et al. Optimal neighborhood indexing for protein similarity search. BMC Bioinformatics 9, 534 (2008).

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI: