From 1933431422afc7955684a0bae6c7028a2f8484c8 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 2 Mar 2012 23:00:40 +0000 Subject: [PATCH] (JAL-1052) basic consensus line parsing to rna structure lines --- src/jalview/io/ClustalFile.java | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index 1e198c4..710ef4a 100755 --- a/src/jalview/io/ClustalFile.java +++ b/src/jalview/io/ClustalFile.java @@ -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,9 +156,26 @@ 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()); -- 1.7.10.2