X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FClustalFile.java;h=6c35ca1bd3f45b40817ae8062aa3b0e120d10458;hb=3d0101179759ef157b088ea135423cd909512d9f;hp=3102f9c6fad4e8185cb6b92228da860385c65f97;hpb=ab43013b7e357b84b4abade0dba949668dfb2a0e;p=jalview.git diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index 3102f9c..6c35ca1 100755 --- a/src/jalview/io/ClustalFile.java +++ b/src/jalview/io/ClustalFile.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,11 +20,15 @@ */ package jalview.io; -import java.io.*; -import java.util.*; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceI; +import jalview.util.Format; -import jalview.datamodel.*; -import jalview.util.*; +import java.io.IOException; +import java.util.Hashtable; +import java.util.StringTokenizer; +import java.util.Vector; public class ClustalFile extends AlignFile { @@ -33,9 +37,10 @@ public class ClustalFile extends AlignFile { } - public ClustalFile(String inFile, String type) throws IOException + public ClustalFile(String inFile, DataSourceType sourceType) + throws IOException { - super(inFile, type); + super(inFile, sourceType); } public ClustalFile(FileParse source) throws IOException @@ -43,18 +48,21 @@ public class ClustalFile extends AlignFile super(source); } + @Override public void initData() { super.initData(); } + @Override public void parse() throws IOException { int i = 0; boolean flag = false; boolean rna = false; boolean top = false; - StringBuffer pssecstr = new StringBuffer(), consstr = new StringBuffer(); + StringBuffer pssecstr = new StringBuffer(), + consstr = new StringBuffer(); Vector headers = new Vector(); Hashtable seqhash = new Hashtable(); StringBuffer tempseq; @@ -151,16 +159,15 @@ public class ClustalFile extends AlignFile } Sequence newSeq = parseId(headers.elementAt(i).toString()); - newSeq.setSequence(seqhash.get(headers.elementAt(i).toString()) - .toString()); + newSeq.setSequence( + seqhash.get(headers.elementAt(i).toString()).toString()); seqs.addElement(newSeq); } else { - System.err - .println("Clustal File Reader: Can't find sequence for " - + headers.elementAt(i)); + System.err.println("Clustal File Reader: Can't find sequence for " + + headers.elementAt(i)); } } AlignmentAnnotation lastssa = null; @@ -179,9 +186,8 @@ public class ClustalFile extends AlignFile AlignmentAnnotation ssa = StockholmFile.parseAnnotationRow(ss, "secondary structure", consstr.toString()); ssa.label = "Consensus Secondary Structure"; - if (lastssa == null - || !lastssa.getRNAStruc().equals( - ssa.getRNAStruc().replace('-', '.'))) + if (lastssa == null || !lastssa.getRNAStruc() + .equals(ssa.getRNAStruc().replace('-', '.'))) { annotations.addElement(ssa); } @@ -189,13 +195,8 @@ public class ClustalFile extends AlignFile } } - public String print() - { - return print(getSeqsAsArray()); - // TODO: locaRNA style aln output - } - - public String print(SequenceI[] s) + @Override + public String print(SequenceI[] s, boolean jvsuffix) { StringBuffer out = new StringBuffer("CLUSTAL" + newline + newline); @@ -206,7 +207,7 @@ public class ClustalFile extends AlignFile while ((i < s.length) && (s[i] != null)) { - String tmp = printId(s[i]); + String tmp = printId(s[i], jvsuffix); if (s[i].getSequence().length > max) { @@ -229,7 +230,7 @@ public class ClustalFile extends AlignFile maxid++; int len = 60; - int nochunks = (max / len) + 1; + int nochunks = (max / len) + (max % len > 0 ? 1 : 0); for (i = 0; i < nochunks; i++) { @@ -237,7 +238,8 @@ public class ClustalFile extends AlignFile while ((j < s.length) && (s[j] != null)) { - out.append(new Format("%-" + maxid + "s").form(printId(s[j]) + " ")); + out.append(new Format("%-" + maxid + "s") + .form(printId(s[j], jvsuffix) + " ")); int start = i * len; int end = start + len;