From: pvtroshin Date: Thu, 28 Apr 2011 10:47:29 +0000 (+0000) Subject: FastaReader build into the datamodel X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=53217f65cb529e859838b528e4ac81a7169e2519;p=jabaws.git FastaReader build into the datamodel git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4045 e3abac25-378b-4346-85de-24260fe3988d --- diff --git a/build.xml b/build.xml index 9b30d3a..fc99421 100644 --- a/build.xml +++ b/build.xml @@ -8,8 +8,8 @@ - - + + diff --git a/datamodel/compbio/data/sequence/FastaReader.java b/datamodel/compbio/data/sequence/FastaReader.java index ed91e93..2e1357f 100644 --- a/datamodel/compbio/data/sequence/FastaReader.java +++ b/datamodel/compbio/data/sequence/FastaReader.java @@ -135,26 +135,24 @@ public class FastaReader implements Iterator { } private static FastaSequence toFastaSequence(final String singleFastaEntry) { - final Scanner sc = new Scanner(singleFastaEntry); - // Use new line delimiter - sc.useDelimiter("\n"); - if (!sc.hasNext()) { + + assert !Util.isEmpty(singleFastaEntry) : "Empty String where FASTA sequence is expected!"; + + int nlineidx = singleFastaEntry.indexOf("\n"); + if (nlineidx < 0) { throw new AssertionError( "The FASTA sequence must contain the header information" + " separated by the new line from the sequence. Given sequence does not appear to " + "contain the header! Given data:\n " + singleFastaEntry); } - String header = sc.next(); + String header = singleFastaEntry.substring(0, nlineidx); + // Get rid of the new line chars (should cover common cases) header = header.replaceAll("\r", ""); - sc.useDelimiter("\\s*"); - final StringBuilder sb = new StringBuilder(); - while (sc.hasNext()) { - sb.append(sc.next()); - } - final String sequence = sb.toString(); + String sequence = singleFastaEntry.substring(nlineidx); + if (Util.isEmpty(sequence)) { throw new AssertionError( "Empty sequences are not allowed! Please make sure the " diff --git a/website/archive/datamodel-1.2.jar b/website/archive/datamodel-1.2.jar new file mode 100644 index 0000000..4c7cffc Binary files /dev/null and b/website/archive/datamodel-1.2.jar differ diff --git a/website/archive/datamodel-src-1.2.jar b/website/archive/datamodel-src-1.2.jar new file mode 100644 index 0000000..6b324de Binary files /dev/null and b/website/archive/datamodel-src-1.2.jar differ