X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFastaFile.java;h=d8890afe8909831decb9e7f68bf011c2db726073;hb=b2f9a8d7bce642ff4011bc6d49e02bb0569fbb11;hp=b8e001a02fc2de75edaa3e286d9bb4dfe60704cb;hpb=e601d78bc7762386f570e346a803684c43a66ff1;p=jalview.git diff --git a/src/jalview/io/FastaFile.java b/src/jalview/io/FastaFile.java index b8e001a..d8890af 100755 --- a/src/jalview/io/FastaFile.java +++ b/src/jalview/io/FastaFile.java @@ -1,19 +1,20 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) - * Copyright (C) 2010 J Procter, AM Waterhouse, 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; @@ -75,14 +76,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 +92,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 +122,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 +138,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