X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFastaFile.java;h=da925e409073de16130bdffb6c93863c891811d7;hb=7e2aa9039133d9e17aef05507fc652542d64a838;hp=8dbfbfd95a9c51bbe9aa5b6d8bd087e1c1e6c473;hpb=ad15cff29620f960119f80176f1fd443da9f6763;p=jalview.git diff --git a/src/jalview/io/FastaFile.java b/src/jalview/io/FastaFile.java index 8dbfbfd..da925e4 100755 --- a/src/jalview/io/FastaFile.java +++ b/src/jalview/io/FastaFile.java @@ -20,9 +20,13 @@ */ package jalview.io; -import java.io.*; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.Annotation; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceI; -import jalview.datamodel.*; +import java.io.IOException; /** * DOCUMENT ME! @@ -51,15 +55,16 @@ public class FastaFile extends AlignFile * * @param inFile * DOCUMENT ME! - * @param type + * @param sourceType * DOCUMENT ME! * * @throws IOException * DOCUMENT ME! */ - public FastaFile(String inFile, String type) throws IOException + public FastaFile(String inFile, DataSourceType sourceType) + throws IOException { - super(inFile, type); + super(inFile, sourceType); } public FastaFile(FileParse source) throws IOException @@ -67,12 +72,18 @@ public class FastaFile extends AlignFile super(source); } + public FastaFile(SequenceI[] seqs) + { + super(seqs); + } + /** * DOCUMENT ME! * * @throws IOException * DOCUMENT ME! */ + @Override public void parse() throws IOException { StringBuffer sb = new StringBuffer(); @@ -169,35 +180,21 @@ public class FastaFile extends AlignFile addProperties(al); for (int i = 0; i < annotations.size(); i++) { - AlignmentAnnotation aa = (AlignmentAnnotation) annotations - .elementAt(i); + AlignmentAnnotation aa = annotations.elementAt(i); aa.setPadGaps(true, al.getGapCharacter()); al.addAnnotation(aa); } } - /** - * DOCUMENT ME! - * - * @param s - * DOCUMENT ME! - * @param len - * DOCUMENT ME! - * @param gaps - * DOCUMENT ME! - * @param displayId - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String print(SequenceI[] s) + @Override + public String print(SequenceI[] s, boolean jvsuffix) { out = new StringBuffer(); int i = 0; while ((i < s.length) && (s[i] != null)) { - out.append(">" + printId(s[i])); + out.append(">" + printId(s[i], jvsuffix)); if (s[i].getDescription() != null) { out.append(" " + s[i].getDescription()); @@ -205,7 +202,8 @@ public class FastaFile extends AlignFile out.append(newline); - int nochunks = (s[i].getLength() / len) + 1; + int nochunks = (s[i].getLength() / len) + + (s[i].getLength() % len > 0 ? 1 : 0); for (int j = 0; j < nochunks; j++) { @@ -228,14 +226,4 @@ public class FastaFile extends AlignFile return out.toString(); } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String print() - { - return print(getSeqsAsArray()); - } }