# Computing Percent Identity between DNA / Amino Acid Sequence

What are some tools where I can input a pair of DNA sequences (or alternatively a pair of Amino Acid Sequences) and compute a percent similarity identity metric between them?

Is BLAST the right algorithm for this or something else?

The context is that a certain patent protects all sequences at least 90% or more identity to a given sequence. I wanted to test some candidate sequences and verify the percent identity metric.

Below I post a patent-snippet where they actually define their identity metric.

tBLASTn, BLASTx and tBLASTx can be used.

It is clearly illustrated here.

If you have just two sequences you need not do a search against the database. You can simply align them using Smith-Waterman or Needleman-Wunsch algorithms, as David mentioned. However, you still need to translate your DNA to protein before doing the alignment. Again, as pointed out by David, with protein alignments you do usually not use identity. Scoring matrices like PAM or BLOSUM are used to calculate similarity.

If you want to compare two specific sequences that you already have, then BLAST itself is not the program you need. BLAST is a program that uses heuristics for rapid searching of a large database for sequences similar to a query sequence. Each of the highest scoring sequences obtained is ‘finished’ for presentation by running an implementation of quite different older and slower dynamic-programming algorithm, which is non-heuristic.

There is an option at the BLAST implementation at NCBI for just comparing two sequences, but this seems strange as one may as well just use the dynamic-programming alignment algorithm. Furthermore the output is not what you want as it scores a local alignment, whereas what your patent specifies is a global alignment (see below).

So for pairwise comparison of two sequences one normally uses a program that implements the Smith and Waterman dynamic programming algorithm for local alignment (only the regions of best similarity are compared) or the Needleman and Wunsch algorithm for global alignment (the whole of both sequences are compared). From your patent specification you clearly want a global alignment and a value for percentage identity.

You can find free web implementations of both of them at the EBI website (among other places) where the program ‘Needle’ performs the global alignment you require. Alternatively, there is an implementation of the Needleman and Wunsch algorithm at NBCI, tucked misleadingly into the BLAST suite.

I do see one theoretical problem with these programs in relation to the patent, although this may not matter in practice. The patent says that “The optimal alignment is the alignment in which the percentage identity is the highest possible”. But these programs try to find the ‘best’ alignment not on the basis of the highest identity score, but on the basis of the highest similarity score. This is done by using one of a number of emperical scoring matrices that encompass the likelihood of particular amino acid substitutions. For example a match between similar amino acids (e.g. Glu/Asp) may give a score of 4, compared with a perfect match score of 5. Moreover, a perfect match for an amino acid like Trp scores much higher than one for Gly. (More info on this and these terms can be found in the Wikipedia Sequence Alignment entry or in the BLAST Glossary.)

Now you would expect that the ‘best’ sequence alignment obtained by optimizing for similarity in this way would also give the best identity score. This is quite likely for sequences of 90% identity or higher, but there is no reason it should necessarily be the case. In theory to get the highest identity score you should use a scoring matrix in which all perfect matches scored the same, and all mismatches zero. This is possible using an implementation of Needleman and Wunsch that allows you to use your own comparison matrix, e.g. this online EMBOSS-Explorer implementation. The problem is what score to give the perfect match (the average of match scores?), as this has to fit with the scoring penalties for mismatches. Or perhaps you should drop the mismatch penalty altogether, as you are only interested in the highest identity.

My advice would be to go for the Needleman and Wunsch algorithm, accept the defaults, and check you get the same score with different implementations. If your lawyers want anything more, I can offer a consultancy ;-).

• BLAST does implement Smith-Watermann. The OP would still need to "translate" the DNA to compare it with the protein sequence. Commented Jun 21, 2016 at 14:40
• @curious_cat if you have just two sequences then you can directly use Smith-Waterman or Needleman-Wunsch depending on what you really intend to do. With protein sequence you don't usually work with "identity"; you use scoring matrices like PAM or BLOSUM. In any case, the DNA has to be translated to protein in order to be compared with the other protein sequence. Commented Jun 21, 2016 at 17:59
• @David The lawyers apparently tried to think this through. See the edit in my answer. I post a snippet from the patent. It tries to address the question about how to score gaps. Now the question is how to get a score that matches this lawery-definition. Will BLAST out-of-the-box work to give a score matching their definition? They do recommend BLAST. Commented Jun 22, 2016 at 12:04
• @curious_cat —Aaah. You mean identity. It seems counter-intuitive in plain English to talk about 90% identity, but that's the tech usage to distinguish it from "similarity" where you use a matrix of scores for different amino acid combinations. I'll do a test of my own and report back. Commented Jun 22, 2016 at 12:41
• @David Thank you very much. I started a related thread here: biology.stackexchange.com/questions/48294/… Would love your comments on that if you can! Commented Jun 22, 2016 at 16:49