X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FComparison.java;h=8902e2ce4433aa173361d2c36711af0afc0383c7;hb=e77a693cf000b4ff8a863411acf8c90c6390a061;hp=95f298b82bec574b3a36b8426a94741eead7ecb0;hpb=4d7f98a6dd54d9863ba449ec79dcd95d25ed863d;p=jalview.git diff --git a/src/jalview/util/Comparison.java b/src/jalview/util/Comparison.java index 95f298b..8902e2c 100644 --- a/src/jalview/util/Comparison.java +++ b/src/jalview/util/Comparison.java @@ -262,9 +262,35 @@ public class Comparison { return false; } + char[][] letters = new char[seqs.length][]; + for (int i = 0; i < seqs.length; i++) + { + if (seqs[i] != null) + { + 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 +298,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') {