From: jprocter Date: Mon, 2 Nov 2009 13:25:48 +0000 (+0000) Subject: gracefully cope with non-standard nucleotide or amino acid symbols in pairwise alignment. X-Git-Tag: Jalview_2_4_0b2~5 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3293a3287aa25f50577baae4f2373710895bdca2;p=jalview.git gracefully cope with non-standard nucleotide or amino acid symbols in pairwise alignment. --- diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 49be7f9..999dd07 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -113,6 +113,8 @@ public class AlignSeq String type; + private int[] charToInt; + /** * Creates a new AlignSeq object. * @@ -380,11 +382,13 @@ public class AlignSeq if (type.equals(AlignSeq.PEP)) { intToStr = pep; + charToInt = ResidueProperties.aaIndex; defInt = 23; } else if (type.equals(AlignSeq.DNA)) { intToStr = dna; + charToInt = ResidueProperties.nucleotideIndex; defInt = 4; } else @@ -821,7 +825,6 @@ public class AlignSeq public int[] stringToInt(String s, String type) { int[] seq1 = new int[s.length()]; - for (int i = 0; i < s.length(); i++) { // String ss = s.substring(i, i + 1).toUpperCase(); @@ -834,33 +837,15 @@ public class AlignSeq try { - if (type.equals("pep")) - { - seq1[i] = ResidueProperties.aaIndex[c]; - if (seq1[i] > 23) - { - seq1[i] = 23; - } - } - else if (type.equals("dna")) + seq1[i] = charToInt[c]; // set accordingly from setType + if (seq1[i]<0 || seq1[i] > defInt) // set from setType: 23 for peptides, or 4 for NA. { - seq1[i] = ResidueProperties.nucleotideIndex[c]; - if (seq1[i] > 4) - { - seq1[i] = 4; - } + seq1[i] = defInt; } } catch (Exception e) { - if (type.equals("dna")) - { - seq1[i] = 4; - } - else - { - seq1[i] = 23; - } + seq1[i] = defInt; } }