X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FClustalFile.java;h=8c0cac1e2344a91074d40c570f1b8b9669c4d9e7;hb=3eef76298c55f3def21eed2516b5ace4405bed0a;hp=4c700eda262e76f742cc7b233bdc69dfc9610856;hpb=8a6fa9ea9900d0f106529c3f6283e7f9d76dd2cb;p=jalview.git diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index 4c700ed..8c0cac1 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.6) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * 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 * * This file is part of Jalview. * @@ -49,7 +49,9 @@ public class ClustalFile extends AlignFile { int i = 0; boolean flag = false; - + boolean rna=false; + boolean top=false; + StringBuffer pssecstr=new StringBuffer(),consstr=new StringBuffer(); Vector headers = new Vector(); Hashtable seqhash = new Hashtable(); StringBuffer tempseq; @@ -60,6 +62,10 @@ public class ClustalFile extends AlignFile { while ((line = nextLine()) != null) { + if (line.length()==0) + { + top=true; + } if (line.indexOf(" ") != 0) { str = new StringTokenizer(line, " "); @@ -95,6 +101,7 @@ public class ClustalFile extends AlignFile { tempseq.append(str.nextToken()); } + top=false; } } } @@ -102,6 +109,16 @@ public class ClustalFile extends AlignFile { flag = true; } + } else { + if (line.matches("\\s+(-|\\.|\\(|\\[|\\]|\\))+")) + { + if (top) + { + pssecstr.append(line.trim()); + } else { + consstr.append(line.trim()); + } + } } } } catch (IOException e) @@ -139,17 +156,35 @@ public class ClustalFile extends AlignFile + headers.elementAt(i)); } } + AlignmentAnnotation lastssa=null; + if (pssecstr.length()==maxLength) + { + Vector ss=new Vector(); + AlignmentAnnotation ssa=lastssa=StockholmFile.parseAnnotationRow(ss, "secondary structure", pssecstr.toString()); + ssa.label="Secondary Structure"; + annotations.addElement(ssa); + } + if (consstr.length()==maxLength) + { + Vector ss=new Vector(); + AlignmentAnnotation ssa=StockholmFile.parseAnnotationRow(ss, "secondary structure", consstr.toString()); + ssa.label="Consensus Secondary Structure"; + if (lastssa==null || !lastssa.getRNAStruc().equals(ssa.getRNAStruc().replace('-', '.'))) + { + annotations.addElement(ssa); + } + } } } - public String print() { return print(getSeqsAsArray()); + // TODO: locaRNA style aln output } public String print(SequenceI[] s) { - StringBuffer out = new StringBuffer("CLUSTAL\n\n"); + StringBuffer out = new StringBuffer("CLUSTAL"+newline+newline); int max = 0; int maxid = 0; @@ -207,11 +242,11 @@ public class ClustalFile extends AlignFile } } - out.append("\n"); + out.append(newline); j++; } - out.append("\n"); + out.append(newline); } return out.toString();