From 65f339692b3a60a8c8d7681021d127bf12982163 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 1 Sep 2015 17:19:38 +0100 Subject: [PATCH] JAL-1853 refactor clip routine from getSequenceStrings --- src/jalview/datamodel/AlignmentView.java | 49 +++++++++++++++++++----------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/jalview/datamodel/AlignmentView.java b/src/jalview/datamodel/AlignmentView.java index a6f4310..7ccd9cf 100644 --- a/src/jalview/datamodel/AlignmentView.java +++ b/src/jalview/datamodel/AlignmentView.java @@ -515,8 +515,38 @@ public class AlignmentView } /** + * build a string excluding hidden regions from a particular sequence in the + * view + * + * @param c + * @param n + * @return + */ + private String getASequenceString(char c, int n) + { + String sqn; + String fullseq = sequences[n].getSequenceString(c); + if (contigs != null) + { + sqn = ""; + int p = 0; + for (int h = 0; h < contigs.length; h += 3) + { + sqn += fullseq.substring(p, contigs[h + 1]); + p = contigs[h + 1] + contigs[h + 2]; + } + sqn += fullseq.substring(p); + } + else + { + sqn = fullseq; + } + return sqn; + } + + /** * get an array of visible sequence strings for a view on an alignment using - * the given gap character + * the given gap character uses getASequenceString * * @param c * char @@ -527,22 +557,7 @@ public class AlignmentView String[] seqs = new String[sequences.length]; for (int n = 0; n < sequences.length; n++) { - String fullseq = sequences[n].getSequenceString(c); - if (contigs != null) - { - seqs[n] = ""; - int p = 0; - for (int h = 0; h < contigs.length; h += 3) - { - seqs[n] += fullseq.substring(p, contigs[h + 1]); - p = contigs[h + 1] + contigs[h + 2]; - } - seqs[n] += fullseq.substring(p); - } - else - { - seqs[n] = fullseq; - } + seqs[n] = getASequenceString(c, n); } return seqs; } -- 1.7.10.2