Author: bugman
Date: Thu Jan 22 16:09:34 2015
New Revision: 27267
URL: http://svn.gna.org/viewcvs/relax?rev=27267&view=rev
Log:
Added sanity checks to the Needleman-Wunsch sequence alignment algorithm.
The residues of both sequences are now checked in needleman_wunsch_align() to
make sure that they
are present in the substitution matrix.
Modified:
trunk/lib/sequence_alignment/needleman_wunsch.py
Modified: trunk/lib/sequence_alignment/needleman_wunsch.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/lib/sequence_alignment/needleman_wunsch.py?rev=27267&r1=27266&r2=27267&view=diff
==============================================================================
--- trunk/lib/sequence_alignment/needleman_wunsch.py (original)
+++ trunk/lib/sequence_alignment/needleman_wunsch.py Thu Jan 22 16:09:34 2015
@@ -24,6 +24,10 @@
# Python module imports.
from numpy import float32, int16, zeros
+
+# relax module imports.
+from lib.errors import RelaxError
+
# Default scores.
SCORE_MATCH = 1
@@ -62,6 +66,14 @@
# The sequence lengths.
M = len(sequence1)
N = len(sequence2)
+
+ # Sanity check.
+ for i in range(M):
+ if sequence1[i] not in sub_seq:
+ raise RelaxError("The residue '%s' from the first sequence cannot
be found in the substitution matrix residues '%s'." % (sequence1[i], sub_seq))
+ for j in range(N):
+ if sequence2[j] not in sub_seq:
+ raise RelaxError("The residue '%s' from the second sequence cannot
be found in the substitution matrix residues '%s'." % (sequence2[j], sub_seq))
# Calculate the scoring and traceback matrices.
matrix, traceback_matrix = needleman_wunsch_matrix(sequence1, sequence2,
sub_matrix=sub_matrix, sub_seq=sub_seq, gap_open_penalty=gap_open_penalty,
gap_extend_penalty=gap_extend_penalty)
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits