X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAMSAFile.java;h=e7e6d97bf3b1d74ab9cb982525f1112239e555cd;hb=49cc4c921eac8fd966dfe4fa4b86d00655ea2f67;hp=12a659db8145c4c9d08ada6da9da411f08c50598;hpb=68a0d4900885cec55096d1f266ee15ef6217f754;p=jalview.git diff --git a/src/jalview/io/AMSAFile.java b/src/jalview/io/AMSAFile.java index 12a659d..e7e6d97 100644 --- a/src/jalview/io/AMSAFile.java +++ b/src/jalview/io/AMSAFile.java @@ -1,85 +1,100 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.io; import jalview.datamodel.*; -public class AMSAFile extends jalview.io.FastaFile +public class AMSAFile + extends jalview.io.FastaFile { - AlignmentI al; - /** - * Creates a new AMSAFile object for output. - */ - public AMSAFile(AlignmentI al) - { - this.al = al; - } + AlignmentI al; + /** + * Creates a new AMSAFile object for output. + */ + public AMSAFile(AlignmentI al) + { + this.al = al; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print() + { + super.print(getSeqsAsArray()); - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String print() + AlignmentAnnotation aa; + if (al.getAlignmentAnnotation() != null) { - super.print(getSeqsAsArray()); - AlignmentAnnotation aa; - if (al.getAlignmentAnnotation() != null) + for (int i = 0; i < al.getAlignmentAnnotation().length; i++) { - for (int i = 0; i < al.getAlignmentAnnotation().length; i++) + aa = al.getAlignmentAnnotation()[i]; + + + if (aa.autoCalculated || !aa.visible) { - aa = al.getAlignmentAnnotation()[i]; - if (aa.autoCalculated) - continue; + continue; + } - out.append(">#_" + aa.label); - if (aa.description != null) - out.append(" " + aa.description); + out.append(">#_" + aa.label); + if (aa.description != null) + { + out.append(" " + aa.description); + } - out.append("\n"); + out.append("\n"); - int nochunks = (aa.annotations.length / len) + 1; + int nochunks = Math.min(aa.annotations.length, al.getWidth()) + / len + 1; - for (int j = 0; j < nochunks; j++) + for (int j = 0; j < nochunks; j++) + { + int start = j * len; + int end = start + len; + if (end > aa.annotations.length) { - int start = j * len; - int end = start + len; - if (end > aa.annotations.length) - end = aa.annotations.length; + end = aa.annotations.length; + } - String ch; - for (int k = start; k < end; k++) + String ch; + for (int k = start; k < end; k++) + { + if (aa.annotations[k] == null) + { + ch = " "; + } + else { - if (aa.annotations[k] == null) - ch = " "; - else - ch = aa.annotations[k].displayCharacter; + ch = aa.annotations[k].displayCharacter; + } - out.append(ch); + out.append(ch); - } - out.append("\n"); } + out.append("\n"); } } - return out.toString(); } + return out.toString(); + } }