X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFastaFile.java;h=8972a932c75aa8b7b7cb7f3d92a80e077734434c;hb=0e2054d29bc49351f000d478659dc3c4371b251c;hp=3b748558c83b097dd28d89122150a3ccb82f8e0c;hpb=797df64fa2a0a30773d0f48f5494d4155e5a8be3;p=jalview.git diff --git a/src/jalview/io/FastaFile.java b/src/jalview/io/FastaFile.java index 3b74855..8972a93 100755 --- a/src/jalview/io/FastaFile.java +++ b/src/jalview/io/FastaFile.java @@ -1,24 +1,26 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) - * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview 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 3 of the License, or (at your option) any later version. - * + * * Jalview 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 Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.io; import java.io.*; + import jalview.datamodel.*; /** @@ -75,14 +77,14 @@ public class FastaFile extends AlignFile StringBuffer sb = new StringBuffer(); boolean firstLine = true; - String line; + String line,uline; Sequence seq = null; boolean annotation = false; - while ((line = nextLine()) != null) + while ((uline = nextLine()) != null) { - line = line.trim(); + line = uline.trim(); if (line.length() > 0) { if (line.charAt(0) == '>') @@ -91,17 +93,7 @@ public class FastaFile extends AlignFile { if (annotation) { - Annotation[] anots = new Annotation[sb.length()]; - String anotString = sb.toString(); - for (int i = 0; i < sb.length(); i++) - { - anots[i] = new Annotation(anotString.substring(i, i + 1), - null, ' ', 0); - } - AlignmentAnnotation aa = new AlignmentAnnotation(seq - .getName().substring(2), seq.getDescription(), anots); - - annotations.addElement(aa); + annotations.addElement(makeAnnotation(seq, sb)); } } else @@ -131,24 +123,14 @@ public class FastaFile extends AlignFile } else { - sb.append(line); + sb.append(annotation ? uline : line); } } } if (annotation) { - Annotation[] anots = new Annotation[sb.length()]; - String anotString = sb.toString(); - for (int i = 0; i < sb.length(); i++) - { - anots[i] = new Annotation(anotString.substring(i, i + 1), null, - ' ', 0); - } - AlignmentAnnotation aa = new AlignmentAnnotation(seq.getName() - .substring(2), seq.getDescription(), anots); - - annotations.addElement(aa); + annotations.addElement(makeAnnotation(seq, sb)); } else if (!firstLine) @@ -157,7 +139,23 @@ public class FastaFile extends AlignFile seqs.addElement(seq); } } - + private AlignmentAnnotation makeAnnotation(SequenceI seq, StringBuffer sb) + { + Annotation[] anots = new Annotation[sb.length()]; + char cb; + for (int i=0;i