From: gmungoc Date: Wed, 2 Dec 2015 16:43:32 +0000 (+0000) Subject: JAL-1827 added overloaded method for convenience X-Git-Tag: Release_2_10_0~331^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=7a16dc455ffdc4956013aaa4707cc79886b6969a;p=jalview.git JAL-1827 added overloaded method for convenience --- diff --git a/src/jalview/util/Comparison.java b/src/jalview/util/Comparison.java index 95f298b..dfc243d 100644 --- a/src/jalview/util/Comparison.java +++ b/src/jalview/util/Comparison.java @@ -262,9 +262,32 @@ public class Comparison { return false; } + char[][] letters = new char[seqs.length][]; + for (int i = 0; i < seqs.length; i++) + { + char[] sequence = seqs[i].getSequence(); + if (sequence != null) + { + letters[i] = sequence; + } + } + + return areNucleotide(letters); + } + + /** + * Answers true if more than 85% of the sequence residues (ignoring gaps) are + * A, G, C, T or U, else false. This is just a heuristic guess and may give a + * wrong answer (as AGCT are also amino acid codes). + * + * @param letters + * @return + */ + public static final boolean areNucleotide(char[][] letters) + { int ntCount = 0; int aaCount = 0; - for (SequenceI seq : seqs) + for (char[] seq : letters) { if (seq == null) { @@ -272,7 +295,7 @@ public class Comparison } // TODO could possibly make an informed guess just from the first sequence // to save a lengthy calculation - for (char c : seq.getSequence()) + for (char c : seq) { if ('a' <= c && c <= 'z') {