Merge branch 'develop' into develop_m2_8_1_2
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Tue, 18 Jun 2013 16:07:25 +0000 (17:07 +0100)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Tue, 18 Jun 2013 16:07:25 +0000 (17:07 +0100)
29 files changed:
.classpath
.gitignore
THIRDPARTYLIBS
lib/json_simple-1.1.jar [new file with mode: 0644]
src/MCview/PDBViewer.java
src/MCview/PDBfile.java
src/jalview/analysis/Rna.java
src/jalview/analysis/SecStrConsensus.java [new file with mode: 0644]
src/jalview/analysis/StructureFrequency.java
src/jalview/appletgui/AlignFrame.java
src/jalview/bin/Jalview.java
src/jalview/datamodel/AlignmentAnnotation.java
src/jalview/ext/jmol/PDBFileWithJmol.java
src/jalview/ext/paradise/Annotate3D.java
src/jalview/gui/AppVarna.java
src/jalview/gui/AssociatePdbFileWithSeq.java
src/jalview/gui/Desktop.java
src/jalview/gui/MenuChooser.java [new file with mode: 0644]
src/jalview/gui/PopupMenu.java
src/jalview/io/FeaturesFile.java
src/jalview/io/RnamlFile.java
src/jalview/io/StockholmFile.java
src/jalview/io/TCoffeeScoreFile.java
src/jalview/renderer/AnnotationRenderer.java
src/jalview/schemes/ColourSchemeProperty.java
src/jalview/schemes/ResidueProperties.java
src/jalview/ws/jws1/Annotate3D.java
test/jalview/ext/paradise/TestAnnotate3D.java
test/jalview/io/RNAMLfileTest.java [new file with mode: 0644]

index 3ec9da3..8ace199 100644 (file)
@@ -46,6 +46,7 @@
        <classpathentry kind="lib" path="lib/spring-core-3.0.5.RELEASE.jar"/>
        <classpathentry kind="lib" path="lib/spring-web-3.0.5.RELEASE.jar"/>
        <classpathentry kind="lib" path="lib/VARNAv3-9.jar" sourcepath="/Users/jimp/Documents/Jalview/VARNA/VARNAv3-9-src.jar"/>
+       <classpathentry kind="lib" path="lib/json_simple-1.1.jar" sourcepath="/Users/jimp/Downloads/json_simple-1.1-all.zip"/>
        <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
        <classpathentry kind="output" path="classes"/>
index 3407192..9841761 100644 (file)
@@ -2,3 +2,5 @@
 /dist
 /classes
 .externalToolBuilders/Jalview Release indices [Builder].launch
+/.DS_Store
+/.com.apple.timemachine.supported
index bedd23a..57aad05 100644 (file)
@@ -33,7 +33,7 @@ vamsas-client.jar
 wsdl4j.jar
 xercesImpl.jar
 xml-apis.jar
-
+json_simple-1.1.jar : Apache 2.0 license : downloaded from https://code.google.com/p/json-simple/downloads/list (will move to 1.1.1 version when jalview is mavenised and osgi-ised)
 Additional dependencies
 
 examples/javascript/deployJava.js : http://java.com/js/deployJava.js
diff --git a/lib/json_simple-1.1.jar b/lib/json_simple-1.1.jar
new file mode 100644 (file)
index 0000000..f395f41
Binary files /dev/null and b/lib/json_simple-1.1.jar differ
index ccf68bb..c8dbe66 100755 (executable)
@@ -21,14 +21,6 @@ import java.io.*;
 
 import java.awt.event.*;
 import javax.swing.*;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
-
-import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax;
-import fr.orsay.lri.varna.exceptions.ExceptionLoadingFailed;
-import fr.orsay.lri.varna.exceptions.ExceptionPermissionDenied;
-import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses;
 
 import jalview.datamodel.*;
 import jalview.gui.*;
index 4d9d738..829eed7 100755 (executable)
@@ -24,6 +24,7 @@ import java.awt.*;
 
 import jalview.analysis.AlignSeq;
 import jalview.datamodel.*;
+import jalview.ext.jmol.PDBFileWithJmol;
 import jalview.io.FileParse;
 
 public class PDBfile extends jalview.io.AlignFile
@@ -158,7 +159,9 @@ public class PDBfile extends jalview.io.AlignFile
         PDBEntry entry = new PDBEntry();
         entry.setId(id);
         entry.setProperty(new Hashtable());
-        entry.getProperty().put("CHAIN", ((PDBChain)chains.elementAt(i)).id);
+        if (((PDBChain)chains.elementAt(i)).id!=null) {
+          entry.getProperty().put("CHAIN", ((PDBChain)chains.elementAt(i)).id);
+        }
         if (inFile != null)
         {
           entry.setFile(inFile.getAbsolutePath());
@@ -210,6 +213,15 @@ public class PDBfile extends jalview.io.AlignFile
         x.printStackTrace();
         
       };
+      if (prot.size()>0)
+      try {
+        processPdbFileWithJmol(prot);
+      } catch (Exception x)
+      {
+        System.err.println("Exceptions when dealing with RNA in pdb file");
+        x.printStackTrace();
+        
+      };
     } catch (OutOfMemoryError er)
     {
       System.out.println("OUT OF MEMORY LOADING PDB FILE");
@@ -225,8 +237,10 @@ public class PDBfile extends jalview.io.AlignFile
   }
   private void processPdbFileWithJmol(ArrayList<SequenceI> prot) throws Exception
   {
-    // process prot sequence with Jmol to get annotated alignment. 
-    // replaceMatchingSeqsWith(prot, al, AlignSeq.PEP);
+    PDBFileWithJmol jmf = new PDBFileWithJmol(new FileParse(getDataName(),type));
+    Alignment al = new Alignment(jmf.getSeqsAsArray());
+    jmf.addAnnotations(al);
+    replaceMatchingSeqsWith(prot, al, AlignSeq.PEP);
   }
   private void processPdbFileWithAnnotate3d(ArrayList<SequenceI> rna) throws Exception {
 //    System.out.println("this is a PDB format and RNA sequence");
@@ -295,7 +309,9 @@ public class PDBfile extends jalview.io.AlignFile
               ap++;
             }
           }
-          annotations.addAll(inspos, Arrays.asList(sq.getAnnotation()));
+          if (sq.getAnnotation()!=null) {
+            annotations.addAll(inspos, Arrays.asList(sq.getAnnotation()));
+          }
         }
       }
     }
index 1583f84..c5207f7 100644 (file)
  */
 /* Author: Lauren Michelle Lui 
  * Methods are based on RALEE methods http://personalpages.manchester.ac.uk/staff/sam.griffiths-jones/software/ralee/
+ * Additional Author: Jan Engelhart (2011) - Structure consensus and bug fixing
+ * Additional Author: Anne Menard (2012) - Pseudoknot support and secondary structure consensus
  * */
 
 package jalview.analysis;
 
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Stack;
 import java.util.Vector;
 
+
+import jalview.analysis.SecStrConsensus.SimpleBP;
 import jalview.datamodel.SequenceFeature;
 
 public class Rna
 {
-  static Hashtable<Integer, Integer> pairHash = new Hashtable();
+       
+       static Hashtable<Integer, Integer> pairHash = new Hashtable();
+       
+  private static final Character[] openingPars = {'(','[','{','<','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; 
+  private static final Character[] closingPars = {')',']','}','>','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; 
+  
+  private static HashSet<Character> openingParsSet = new HashSet<Character>(Arrays.asList(openingPars)); 
+  private static HashSet<Character> closingParsSet = new HashSet<Character>(Arrays.asList(closingPars));
+  private static Hashtable<Character,Character> closingToOpening = new Hashtable<Character,Character>()
+  // Initializing final data structure
+  {
+       private static final long serialVersionUID = 1L;
+       {
+         for(int i=0;i<openingPars.length;i++)
+         {
+                 System.out.println(closingPars[i]+"->"+openingPars[i]);
+                 put(closingPars[i],openingPars[i]);             
+         }
+  }};
+       
+  private static boolean isOpeningParenthesis(char c)
+  {
+         return openingParsSet.contains(c);
+  }
+       
+  private static boolean isClosingParenthesis(char c)
+  {
+         return closingParsSet.contains(c);
+  }
 
+  private static char matchingOpeningParenthesis(char closingParenthesis) throws WUSSParseException
+  {
+         if (!isClosingParenthesis(closingParenthesis))
+         {
+                 throw new WUSSParseException("Querying matching opening parenthesis for non-closing parenthesis character "+closingParenthesis, -1);
+         }
+       
+         return closingToOpening.get(closingParenthesis);
+  }
+  
   /**
    * Based off of RALEE code ralee-get-base-pairs. Keeps track of open bracket
    * positions in "stack" vector. When a close bracket is reached, pair this
@@ -43,69 +89,89 @@ public class Rna
    * @return Array of SequenceFeature; type = RNA helix, begin is open base
    *         pair, end is close base pair
    */
-  public static SequenceFeature[] GetBasePairs(CharSequence line)
-          throws WUSSParseException
+  public static Vector<SimpleBP> GetSimpleBPs(CharSequence line) throws WUSSParseException
   {
-    Stack stack = new Stack();
-    Vector pairs = new Vector();
-
+    System.out.println(line);
+       Hashtable<Character,Stack<Integer>> stacks = new Hashtable<Character,Stack<Integer>>();
+    Vector<SimpleBP> pairs = new Vector<SimpleBP>();
     int i = 0;
     while (i < line.length())
     {
       char base = line.charAt(i);
-
-      if ((base == '<') || (base == '(') || (base == '{') || (base == '[')|| (base == 'A')|| (base == 'B')|| (base == 'C')|| (base == 'D')|| (base == '1')|| (base == 'F')|| (base == 'G')|| (base == '2')|| (base == 'I')|| (base == 'J')|| (base == 'K')|| (base == 'L')|| (base == 'M')|| (base == 'N')|| (base == 'O')|| (base == 'P')|| (base == 'Q')|| (base == 'R')|| (base == 'S')|| (base == 'T')|| (base == 'U')|| (base == 'V')|| (base == 'W')|| (base == 'X')|| (base == 'Y')|| (base == 'Z'))
+     
+      if (isOpeningParenthesis(base))
       {
-        stack.push(i);
+         if (!stacks.containsKey(base)){
+                 stacks.put(base, new Stack<Integer>());
+         }
+        stacks.get(base).push(i);
+       
       }
-      else if ((base == '>') || (base == ')') || (base == '}')|| (base == ']')|| (base == 'a')|| (base == 'b')|| (base == 'c')|| (base == 'd')|| (base == 'e')|| (base == 'f')|| (base == 'g')|| (base == 'h')|| (base == 'i')|| (base == 'j')|| (base == 'k')|| (base == 'l')|| (base == 'm')|| (base == 'n')|| (base == 'o')|| (base == 'p')|| (base == 'q')|| (base == 'r')|| (base == 's')|| (base == 't')|| (base == 'u')|| (base == 'v')|| (base == 'w')|| (base == 'x')|| (base == 'y')|| (base == 'z'))
-      
+      else if (isClosingParenthesis(base))
       {
-
+       
+         char opening = matchingOpeningParenthesis(base);
+         
+         if (!stacks.containsKey(opening)){
+                 throw new WUSSParseException("Mismatched (unseen) closing character "+base, i);
+         }
+         
+        Stack<Integer> stack = stacks.get(opening);
         if (stack.isEmpty())
         {
           // error whilst parsing i'th position. pass back
-          throw new WUSSParseException("Mismatched closing bracket", i);
+                 throw new WUSSParseException("Mismatched closing character "+base, i);
         }
-        Object temp = stack.pop();
-        pairs.addElement(temp);
-        pairs.addElement(i); 
+        int temp = stack.pop();
+        
+        pairs.add(new SimpleBP(temp,i));
       }
-
       i++;
     }
-
-    int numpairs = pairs.size() / 2;
-    SequenceFeature[] outPairs = new SequenceFeature[numpairs];
-
-    // Convert pairs to array
-    for (int p = 0; p < pairs.size(); p += 2)
+    for(char opening: stacks.keySet())
     {
-      int begin = Integer.parseInt(pairs.elementAt(p).toString());
-      int end = Integer.parseInt(pairs.elementAt(p + 1).toString());
-
-      outPairs[p / 2] = new SequenceFeature("RNA helix", "", "", begin,
-              end, "");
-      // pairHash.put(begin, end);
-
+       Stack<Integer> stack = stacks.get(opening);
+       if (!stack.empty())
+       {
+                 throw new WUSSParseException("Mismatched opening character "+opening+" at "+stack.pop(), i);                  
+       }
+    }
+    return pairs;
+  }
+  
+  public static SequenceFeature[] GetBasePairs(CharSequence line) throws WUSSParseException
+  {
+         Vector<SimpleBP> bps = GetSimpleBPs(line);
+         SequenceFeature[] outPairs = new SequenceFeature[bps.size()];
+    for (int p = 0; p < bps.size(); p++)
+    {
+       SimpleBP bp = bps.elementAt(p);
+       outPairs[p] = new SequenceFeature("RNA helix", "", "", bp.getBP5(),bp.getBP3(), "");
     }
-
     return outPairs;
   }
-
+  
+  
+  public static  ArrayList<SimpleBP> GetModeleBP(CharSequence line) throws WUSSParseException
+  {
+         Vector<SimpleBP> bps = GetSimpleBPs(line);
+         return new ArrayList<SimpleBP>(bps);
+  }
+  
+  
   /**
    * Function to get the end position corresponding to a given start position
-   * 
-   * @param indice
-   *          - start position of a base pair
+   * @param indice - start position of a base pair
    * @return - end position of a base pair
    */
-  /*
-   * makes no sense at the moment :( public int findEnd(int indice){ //TODO:
-   * Probably extend this to find the start to a given end? //could be done by
-   * putting everything twice to the hash ArrayList<Integer> pair = new
-   * ArrayList<Integer>(); return pairHash.get(indice); }
-   */
+  /*makes no sense at the moment :(
+  public int findEnd(int indice){
+         //TODO: Probably extend this to find the start to a given end?
+         //could be done by putting everything twice to the hash
+         ArrayList<Integer> pair = new ArrayList<Integer>();
+         return pairHash.get(indice);
+  }*/
+  
 
   /**
    * Figures out which helix each position belongs to and stores the helix
@@ -189,3 +255,4 @@ public class Rna
     }
   }
 }
+
diff --git a/src/jalview/analysis/SecStrConsensus.java b/src/jalview/analysis/SecStrConsensus.java
new file mode 100644 (file)
index 0000000..27c3f7e
--- /dev/null
@@ -0,0 +1,219 @@
+package jalview.analysis;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+
+public class SecStrConsensus {
+ /**
+  * Internal class to represent a simple base-pair.
+  * @author Yawn
+  * [JBPNote: ^^ is that Anne Menard or Ya(w)nn Ponty, I wonder ! ]
+  */
+ public static class SimpleBP{
+  int bp5;
+  int bp3;
+  
+  public SimpleBP()
+  {
+         
+  }
+  public SimpleBP(int i5, int i3)
+  {
+   bp5=i5;
+   bp3=i3;
+  }
+  public void setBP5(int i5)
+  {
+          bp5=i5;
+  }
+  
+  public void setBP3(int i3)
+  {
+          bp3=i3;
+  }
+  
+  public int getBP5()
+  {
+          return bp5;
+  }
+  
+  public int getBP3()
+  {
+          return bp3;
+  }
+  
+  public String toString()
+  {
+         return "("+bp5+","+bp3+")";
+  }
+  
+ }
+ public static int[] extractConsensus(ArrayList<ArrayList<SimpleBP>> bps)
+ {
+  // We do not currently know the length of the alignment
+  // => Estimate it as the biggest index of a base-pair plus one. 
+  int maxlength = 0;
+  for (ArrayList<SimpleBP> strs : bps)
+  {
+   for (SimpleBP bp : strs)
+   {
+       
+    maxlength = Math.max(1+Math.max(bp.bp5, bp.bp3), maxlength);
+
+   }
+  }
+  // Now we have a good estimate for length, allocate and initialize data
+  // to be fed to the dynamic programming procedure.
+  ArrayList<Hashtable<Integer,Double>> seq = new ArrayList<Hashtable<Integer,Double>>();
+  for (int i=0;i<maxlength;i++)
+  { seq.add(new Hashtable<Integer,Double>()); }
+  for (ArrayList<SimpleBP> strs : bps)
+  {
+   for (SimpleBP bp : strs)
+   {
+    int i = bp.bp5;
+    int j = bp.bp3;
+    Hashtable<Integer,Double> h = seq.get(i);
+    if (!h.containsKey(j))
+    {
+     h.put(j, 0.0);
+    }
+    h.put(j, h.get(j)+1.);
+   }
+  }
+  // At this point, seq contains, at each position i, a hashtable which associates,
+  // to each possible end j, the number of time a base-pair (i,j) occurs in the alignment
+  
+  // We can now run the dynamic programming procedure on this data
+  double[][] mat = fillMatrix(seq); 
+  ArrayList<SimpleBP> res = backtrack(mat,seq);
+  
+  // Convert it to an array, ie finalres[i] = j >= 0 iff a base-pair (i,j) is present 
+  // in the consensus, or -1 otherwise
+  int[] finalres = new int[seq.size()];
+  for (int i=0;i<seq.size();i++)
+  { finalres[i] = -1; }
+  for (SimpleBP bp : res)
+  {
+   finalres[bp.bp5] = bp.bp3;
+   finalres[bp.bp3] = bp.bp5;
+  }
+  
+  return finalres;
+ }
+ private static boolean canBasePair(ArrayList<Hashtable<Integer,Double>> seq, int i, int k)
+ {
+  return seq.get(i).containsKey(k);
+ }
+ // Returns the score of a potential base-pair, ie the number of structures in which it is found.
+ private static double basePairScore(ArrayList<Hashtable<Integer,Double>> seq, int i, int k)
+ {
+  return seq.get(i).get(k); 
+ }
+  private static double[][] fillMatrix(ArrayList<Hashtable<Integer,Double>> seq)
+  {
+  int n = seq.size();
+  double[][] tab = new double[n][n];
+  for(int m=1;m<=n;m++)
+  {
+   for(int i=0;i<n-m+1;i++)
+   {
+    int j = i+m-1;
+    tab[i][j] = 0;
+    if (i<j)
+    { 
+     tab[i][j] = Math.max(tab[i][j], tab[i+1][j]); 
+     for (int k=i+1;k<=j;k++)
+     {
+      if (canBasePair(seq,i,k))
+      {
+       double fact1 = 0;
+       if (k>i+1)
+       {
+        fact1 = tab[i+1][k-1];
+       }
+       double fact2 = 0;
+       if (k<j)
+       {
+        fact2 = tab[k+1][j];
+       }
+       tab[i][j] = Math.max(tab[i][j],basePairScore(seq,i,k)+fact1+fact2);
+      } 
+     }
+    }
+   }   
+  }
+   return tab;
+  } 
+  private static  ArrayList<SimpleBP> backtrack(double[][] tab,ArrayList<Hashtable<Integer,Double>> seq)
+  {
+   return backtrack(tab,seq,0,seq.size()-1);
+  }
+  private static ArrayList<SimpleBP> backtrack(double[][] tab,ArrayList<Hashtable<Integer,Double>> seq, int i, int j)
+  {
+   ArrayList<SimpleBP> result = new ArrayList<SimpleBP>();
+   if (i<j)
+  { 
+    ArrayList<Integer> indices = new ArrayList<Integer>();
+    indices.add(-1);
+   for (int k=i+1;k<=j;k++)
+   {
+    indices.add(k);
+   }
+   for (int k : indices)
+    {
+     if (k==-1)
+     {
+      if (tab[i][j] == tab[i+1][j])
+      {
+       result = backtrack(tab, seq, i+1,j);
+      }
+     }
+     else
+     {
+      if (canBasePair(seq,i,k))
+      {
+       double fact1 = 0;
+       if (k>i+1)
+       {
+        fact1 = tab[i+1][k-1];
+       }
+       double fact2 = 0;
+       if (k<j)
+       {
+        fact2 = tab[k+1][j];
+       }
+       if (tab[i][j]==basePairScore(seq,i,k)+fact1+fact2)
+       { 
+        result = backtrack(tab, seq, i+1,k-1);
+        result.addAll(backtrack(tab, seq, k+1,j));
+        result.add(new SimpleBP(i,k));
+       }
+      }       
+     }     
+   }
+  }
+  else if  (i==j)
+  {
+   
+  }
+  else 
+  {
+   
+  }
+   return result;
+  }
+
+
+}
\ No newline at end of file
index 32a4e29..dbba0f4 100644 (file)
@@ -16,7 +16,6 @@
  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-
 package jalview.analysis;
 
 import java.util.*;
@@ -59,15 +58,15 @@ public class StructureFrequency
    */
   public static int findPair(SequenceFeature[] pairs, int indice)
   {
-         System.out.print("indice"+indice+"    ");
+
     for (int i = 0; i < pairs.length; i++)
     {
       if (pairs[i].getBegin() == indice)
-        
+
       {
-         System.out.println(pairs[i].getEnd());
+
         return pairs[i].getEnd();
-        
+
       }
     }
     return -1;
@@ -88,19 +87,11 @@ public class StructureFrequency
           int end, Hashtable[] result, boolean profile,
           AlignmentAnnotation rnaStruc)
   {
-//     System.out.println("longueur="+sequences.length);
-//     for(int l=0;l<=(sequences.length-1);l++){  
-//     System.out.println("sequences "+l+":"+sequences[l].getSequenceAsString());
-//     }
-//     System.out.println("start="+start);
-       System.out.println("end="+end);
-//     System.out.println("result="+result.length);
-//
-//     System.out.println("profile="+profile);
-//     System.out.println("rnaStruc="+rnaStruc);
+
     Hashtable residueHash;
     String maxResidue;
     char[] struc = rnaStruc.getRNAStruc().toCharArray();
+
     SequenceFeature[] rna = rnaStruc._rnasecstr;
     char c, s, cEnd;
     int count = 0, nonGap = 0, i, bpEnd = -1, j, jSize = sequences.length;
@@ -108,7 +99,6 @@ public class StructureFrequency
     int[][] pairs;
     float percentage;
     boolean wooble = true;
-
     for (i = start; i < end; i++) // foreach column
     {
       residueHash = new Hashtable();
@@ -116,11 +106,11 @@ public class StructureFrequency
       values = new int[255];
       pairs = new int[255][255];
       bpEnd = -1;
-      //System.out.println("s="+struc[i]);
+      // System.out.println("s="+struc[i]);
       if (i < struc.length)
       {
         s = struc[i];
-        
+
       }
       else
       {
@@ -140,57 +130,54 @@ public class StructureFrequency
       }
       else
       {
-        
-         
+
         bpEnd = findPair(rna, i);
-       
-        if (bpEnd>-1)
-        {
-        for (j = 0; j < jSize; j++) // foreach row
+
+        if (bpEnd > -1)
         {
-          if (sequences[j] == null)
+          for (j = 0; j < jSize; j++) // foreach row
           {
-            System.err
-                    .println("WARNING: Consensus skipping null sequence - possible race condition.");
-            continue;
-          }
-          c = sequences[j].getCharAt(i);
-          //System.out.println("c="+c);
-          
+            if (sequences[j] == null)
+            {
+              System.err
+                      .println("WARNING: Consensus skipping null sequence - possible race condition.");
+              continue;
+            }
+            c = sequences[j].getCharAt(i);
+            // System.out.println("c="+c);
 
             // standard representation for gaps in sequence and structure
             if (c == '.' || c == ' ')
             {
-              System.err
-                      .println("WARNING: Consensus skipping null sequence - possible race condition.");
+              c = '-';
+            }
+
+            if (c == '-')
+            {
+              values['-']++;
               continue;
             }
             cEnd = sequences[j].getCharAt(bpEnd);
-         
-         
-            System.out.println("pairs ="+c+","+cEnd);
-            if (checkBpType(c, cEnd)==true)
+
+            // System.out.println("pairs ="+c+","+cEnd);
+            if (checkBpType(c, cEnd) == true)
             {
               values['(']++; // H means it's a helix (structured)
               maxResidue = "(";
-              wooble=true;
-              System.out.println("It's a pair wc");
-              
+              wooble = true;
+              // System.out.println("It's a pair wc");
+
             }
-            if (checkBpType(c, cEnd)==false)
+            if (checkBpType(c, cEnd) == false)
             {
-              wooble =false;
+              wooble = false;
               values['[']++; // H means it's a helix (structured)
               maxResidue = "[";
-              System.out.println("It's an pair non canonic");
-              System.out.println(sequences[j].getRNA());
-              System.out.println(rnaStruc.getRNAStruc().charAt(i));
+
             }
-            pairs[c][cEnd]++;  
-           
-          
-               }
+            pairs[c][cEnd]++;
 
+          }
         }
         // nonGap++;
       }
@@ -203,13 +190,13 @@ public class StructureFrequency
 
         residueHash.put(PAIRPROFILE, pairs);
       }
-      if (wooble==true)
+      if (wooble == true)
       {
-      count = values['('];
+        count = values['('];
       }
-      if (wooble==false)
+      if (wooble == false)
       {
-      count = values['['];
+        count = values['['];
       }
       residueHash.put(MAXCOUNT, new Integer(count));
       residueHash.put(MAXRESIDUE, maxResidue);
@@ -225,18 +212,20 @@ public class StructureFrequency
       }
       if (bpEnd > 0)
       {
-       values[')'] = values['('];
+        values[')'] = values['('];
         values[']'] = values['['];
         values['('] = 0;
         values['['] = 0;
         residueHash = new Hashtable();
-        if (wooble==true){
-               System.out.println(maxResidue+","+wooble);
-               maxResidue = ")";
+        if (wooble == true)
+        {
+          // System.out.println(maxResidue+","+wooble);
+          maxResidue = ")";
         }
-        if(wooble==false){
-               System.out.println(maxResidue+","+wooble);
-               maxResidue = "]";
+        if (wooble == false)
+        {
+          // System.out.println(maxResidue+","+wooble);
+          maxResidue = "]";
         }
         if (profile)
         {
@@ -254,6 +243,7 @@ public class StructureFrequency
         residueHash.put(PID_GAPS, new Float(percentage));
 
         result[bpEnd] = residueHash;
+
       }
     }
   }
index 4d574d6..299d1db 100644 (file)
@@ -17,7 +17,6 @@
  */\r
 package jalview.appletgui;\r
 \r
-import jalview.analysis.AAFrequency;\r
 import jalview.analysis.AlignmentSorter;\r
 import jalview.analysis.Conservation;\r
 import jalview.api.SequenceStructureBinding;\r
@@ -92,7 +91,6 @@ import java.util.List;
 import java.util.StringTokenizer;\r
 import java.util.Vector;\r
 \r
-\r
 public class AlignFrame extends EmbmenuFrame implements ActionListener,\r
         ItemListener, KeyListener\r
 {\r
@@ -1027,10 +1025,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {\r
       changeColour(new PurinePyrimidineColourScheme());\r
     }\r
-    else if (source == RNAInteractionColour)\r
-    {\r
-      changeColour(new RNAInteractionColourScheme());\r
-    }\r
+\r
     else if (source == RNAHelixColour)\r
     {\r
       new RNAHelicesColourChooser(viewport, alignPanel);\r
@@ -3262,7 +3257,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     colourMenu.add(buriedColour);\r
     colourMenu.add(nucleotideColour);\r
     colourMenu.add(purinePyrimidineColour);\r
-    colourMenu.add(RNAInteractionColour);\r
+    //    colourMenu.add(RNAInteractionColour);\r
     colourMenu.add(tcoffeeColour);\r
     colourMenu.add(userDefinedColour);\r
     colourMenu.addSeparator();\r
index 94206c2..c3d674b 100755 (executable)
@@ -70,7 +70,11 @@ public class Jalview
       }
     });
   }
-  protected static boolean proteine;
+  /**
+   * Put protein=true for get a protein example
+   */
+  private static boolean protein=false;
+
 
   /**
    * main class for Jalview application
@@ -522,27 +526,14 @@ public class Jalview
     // And the user
     // ////////////////////
   
-    JFrame Typechooser =new JFrame("choose molecule type"); 
-    FlowLayout fl = new FlowLayout();
-    Typechooser.setLayout(fl);
-    Typechooser.setSize(400,400);
-    Typechooser.setDefaultCloseOperation(Typechooser.DISPOSE_ON_CLOSE);
-    JLabel label = new JLabel("What would you open ? ");
-    JButton rnabutton = new JButton("RNA molecule");
-    JButton pbutton = new JButton("Proteine molecule");
-    
-    pbutton.addActionListener(new pbuttonlistener());
-    rnabutton.addActionListener(new rnabuttonlistener());
-    Typechooser.getContentPane().add(label);
-    Typechooser.getContentPane().add(rnabutton);
-    Typechooser.getContentPane().add(pbutton);
-    Typechooser.setVisible(true);
+
     
     
 
     
     if (!headless && file == null && vamsasImport == null
-            && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true) && proteine == true)
+            && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true) && protein == true)
     {
       file = jalview.bin.Cache.getDefault(
               "STARTUP_FILE",
index ea13922..1433f73 100755 (executable)
@@ -18,6 +18,8 @@
 package jalview.datamodel;
 
 import jalview.analysis.Rna;
+import jalview.analysis.SecStrConsensus.SimpleBP;
+
 import jalview.analysis.WUSSParseException;
 
 import java.util.ArrayList;
@@ -55,6 +57,7 @@ public class AlignmentAnnotation
   
   
 
+  public ArrayList<SimpleBP> bps=null;
   /**
    * RNA secondary structure contact positions
    */
@@ -73,13 +76,15 @@ public class AlignmentAnnotation
    */
   private void _updateRnaSecStr(CharSequence RNAannot)
   {
-    try
-    {
-      _rnasecstr = Rna.GetBasePairs(RNAannot);
-      invalidrnastruc = -1;
-    } catch (WUSSParseException px)
+    try {
+    _rnasecstr = Rna.GetBasePairs(RNAannot);
+    bps = Rna.GetModeleBP(RNAannot);
+    invalidrnastruc=-1;
+    }
+    catch (WUSSParseException px)
     {
-      invalidrnastruc = px.getProblemPos();
+      // DEBUG System.out.println(px);
+      invalidrnastruc=px.getProblemPos();
     }
     if (invalidrnastruc > -1)
     {
@@ -197,7 +202,11 @@ public class AlignmentAnnotation
       return NO_GRAPH;
     }
   }
-
+    // JBPNote: what does this do ?
+  public void ConcenStru(CharSequence RNAannot) throws WUSSParseException
+  {
+         bps = Rna.GetModeleBP(RNAannot);
+  }
   /**
    * Creates a new AlignmentAnnotation object.
    * 
@@ -254,10 +263,10 @@ public class AlignmentAnnotation
                        || annotations[i].secondaryStructure == 'B'
                        || annotations[i].secondaryStructure == 'C'
                        || annotations[i].secondaryStructure == 'D'
-                       || annotations[i].secondaryStructure == '1'
+                       || annotations[i].secondaryStructure == 'E'
                        || annotations[i].secondaryStructure == 'F'
                        || annotations[i].secondaryStructure == 'G'
-                       || annotations[i].secondaryStructure == '2'
+                       || annotations[i].secondaryStructure == 'H'
                        || annotations[i].secondaryStructure == 'I'
                        || annotations[i].secondaryStructure == 'J'
                        || annotations[i].secondaryStructure == 'K'
@@ -306,8 +315,8 @@ public class AlignmentAnnotation
                 // &&
                 // annotations[i].displayCharacter.charAt(0)==annotations[i].secondaryStructure
                 firstChar != ' '
-                && firstChar != 'H'
-                && firstChar != 'E'
+                && firstChar != '$'
+                && firstChar != 'µ' // JBPNote should explicitly express as unicode number to avoid source code translation problems
                 && firstChar != '('
                 && firstChar != '['
                 && firstChar != '>'
@@ -316,10 +325,10 @@ public class AlignmentAnnotation
                 && firstChar != 'B'
                 && firstChar != 'C'
                 && firstChar != 'D'
-                && firstChar != '1'
+                && firstChar != 'E'
                 && firstChar != 'F'
                 && firstChar != 'G'
-                && firstChar != '2'
+                && firstChar != 'H'
                 && firstChar != 'I'
                 && firstChar != 'J'
                 && firstChar != 'K'
index 1059021..5702558 100644 (file)
@@ -18,6 +18,7 @@
 package jalview.ext.jmol;
 
 import java.io.IOException;
+import java.util.Hashtable;
 import java.util.Map;
 
 import org.jmol.api.JmolStatusListener;
@@ -37,6 +38,7 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceI;
 import jalview.io.AlignFile;
+import jalview.io.FileParse;
 
 /**
  * Import and process PDB files with Jmol
@@ -57,6 +59,12 @@ public class PDBFileWithJmol extends AlignFile implements
   {
     super(inFile, type);
   }
+  
+
+  public PDBFileWithJmol(FileParse fp) throws IOException
+  {
+    super(fp);
+  }
 
   public PDBFileWithJmol()
   {
@@ -164,12 +172,15 @@ public class PDBFileWithJmol extends AlignFile implements
                   pdbe.setFile(getDataName());
                   pdbe.setId(getDataName());
                   sq.addPDBId(pdbe);
+                  pdbe.setProperty(new Hashtable());
+                  pdbe.getProperty().put("CHAIN",""+_lastChainId);
                   seqs.add(sq);
                   if (!(biopoly.isDna() || biopoly.isRna()))
                   {
                     AlignmentAnnotation ann = new AlignmentAnnotation(
                             "Secondary Structure",
                             "Secondary Structure from PDB File", asecstr);
+                    ann.setCalcId(getClass().getName());
                     sq.addAlignmentAnnotation(ann);
                     annotations.add(ann);
                   }
index b0adb45..114de42 100644 (file)
@@ -2,33 +2,186 @@ package jalview.ext.paradise;
 
 import jalview.ws.HttpClientUtils;
 
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.io.Reader;
+import java.io.StringReader;
+import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.http.NameValuePair;
 import org.apache.http.message.BasicNameValuePair;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONStreamAware;
+import org.json.simple.parser.ContentHandler;
+import org.json.simple.parser.ParseException;
 
+/**
+ * simple methods for calling the various paradise RNA tools
+ * 
+ * @author jimp
+ * 
+ *         History: v1.0 revised from original due to refactoring of
+ *         paradise-ubmc.u-strasbg.fr/webservices/annotate3d to
+ *         http://arn-ibmc.in2p3.fr/api/compute/2d?tool=rnaview
+ */
 public class Annotate3D
 {
+  private static String twoDtoolsURL = "http://arn-ibmc.in2p3.fr/api/compute/2d";
+  private static ContentHandler createContentHandler()
+  {
+    ContentHandler ch = new ContentHandler() {
+
+      @Override
+      public void startJSON() throws ParseException, IOException
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      @Override
+      public void endJSON() throws ParseException, IOException
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      @Override
+      public boolean startObject() throws ParseException, IOException
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      @Override
+      public boolean endObject() throws ParseException, IOException
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      @Override
+      public boolean startObjectEntry(String key) throws ParseException,
+              IOException
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
 
-  public static Reader getRNAMLForPDBFileAsString(String pdbfile)
+      @Override
+      public boolean endObjectEntry() throws ParseException, IOException
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      @Override
+      public boolean startArray() throws ParseException, IOException
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      @Override
+      public boolean endArray() throws ParseException, IOException
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      @Override
+      public boolean primitive(Object value) throws ParseException,
+              IOException
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+      
+    };
+    return ch;
+  }
+  public static Iterator<Reader> getRNAMLForPDBFileAsString(String pdbfile)
           throws Exception
   {
     List<NameValuePair> vals = new ArrayList<NameValuePair>();
+    vals.add(new BasicNameValuePair("tool", "rnaview"));
     vals.add(new BasicNameValuePair("data", pdbfile));
-    return HttpClientUtils.doHttpUrlPost(
-            "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d",
-            vals);
+    vals.add(new BasicNameValuePair("output", "rnaml"));
+    return processJsonResponseFor(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals));
+  }
+  public static Iterator<Reader> processJsonResponseFor(Reader respons) throws Exception
+  {
+    org.json.simple.parser.JSONParser jp = new org.json.simple.parser.JSONParser();
+    try {
+      final JSONArray responses = (JSONArray) jp.parse(respons);
+      final Iterator rvals = responses.iterator();
+      return new Iterator<Reader>() 
+        {
+          @Override
+          public boolean hasNext()
+          {
+            return rvals.hasNext();
+          }
+          @Override
+          public Reader next()
+          {
+            JSONObject val=(JSONObject) rvals.next();
+            
+            Object sval = null;
+            try {
+              sval = val.get("2D");
+            } catch (Exception x) {x.printStackTrace();};
+            if (sval==null)
+            {
+              System.err.println("DEVELOPER WARNING: Annotate3d didn't return a '2D' tag in its response. Consider checking output of server. Response was :"+val.toString());
+              
+              sval = "";
+            }
+            return new StringReader((sval instanceof JSONObject) ? ((JSONObject)sval).toString():sval.toString());
+            
+          }@Override
+          public void remove()
+          {
+            throw new Error("Remove: Not implemented");
+            
+          }@Override
+          protected Object clone() throws CloneNotSupportedException
+          {
+            throw new CloneNotSupportedException("Clone: Not implemented");
+          }@Override
+          public boolean equals(Object obj)
+          {
+            return super.equals(obj);
+          }@Override
+          protected void finalize() throws Throwable
+          {
+            while (rvals.hasNext())
+            {
+              rvals.next();
+            }
+            super.finalize();
+          }
+        };
+    } catch (Exception foo)
+    {
+      throw new Exception("Couldn't parse response from Annotate3d server.",foo);
+    }
+    
+    
   }
 
-  public static Reader getRNAMLForPDBId(String pdbid) throws Exception
+  public static Iterator<Reader> getRNAMLForPDBId(String pdbid) throws Exception
   {
     List<NameValuePair> vals = new ArrayList<NameValuePair>();
+    vals.add(new BasicNameValuePair("tool", "rnaview"));
     vals.add(new BasicNameValuePair("pdbid", pdbid));
-    return HttpClientUtils.doHttpUrlPost(
-            "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d",
-            vals);
+    vals.add(new BasicNameValuePair("format", "rnaml"));
+    java.net.URL geturl = new URL(twoDtoolsURL+"?tool=rnaview&output=rnaml&pdbid="+pdbid);
+    return processJsonResponseFor(new InputStreamReader(geturl.openStream()));
   }
 
 }
index 70e68ee..4bff08c 100644 (file)
@@ -75,23 +75,23 @@ public class AppVarna extends JInternalFrame implements
   public AppVarna(String sname, SequenceI seq, String strucseq,
           String struc, String name, AlignmentPanel ap)
   {
-         System.out.println("je suis là (AppVarna!!");
-         System.out.println("1:"+sname);
-         System.out.println("2:"+seq);
-         System.out.println("3:"+strucseq);
-         System.out.println("4:"+struc);
-         System.out.println("5:"+name);
-         System.out.println("6:"+ap);
+
+//       System.out.println("1:"+sname);
+//       System.out.println("2:"+seq);
+//       System.out.println("3:"+strucseq);
+//       System.out.println("4:"+struc);
+//       System.out.println("5:"+name);
+//       System.out.println("6:"+ap);
     this.ap = ap;
     ArrayList<RNA> rnaList = new ArrayList<RNA>();
     RNA rna1 = new RNA(name);
     try
     {
-    System.out.println("ou ici ?");
+
       rna1.setRNA(strucseq, replaceOddGaps(struc));
-      System.out.println("La séquence est :"+rna1.getSeq());
-      System.out.println("La séquence est :"+struc);
-      System.out.println("La séquence est :"+replaceOddGaps(struc).toString());
+//      System.out.println("The sequence is :"+rna1.getSeq());
+//      System.out.println("The sequence is:"+struc);
+//      System.out.println("The sequence is:"+replaceOddGaps(struc).toString());
     } catch (ExceptionUnmatchedClosingParentheses e2)
     {
       e2.printStackTrace();
@@ -120,19 +120,18 @@ public class AppVarna extends JInternalFrame implements
     }
     vab = new AppVarnaBinding(rnaList);
     // vab = new AppVarnaBinding(seq,struc);
-    // System.out.println("Hallo: "+name);
     this.name = sname + " trimmed to " + name;
     initVarna();
    
     ssm = ap.getStructureSelectionManager();
-    System.out.println(ssm.toString());
+    //System.out.println(ssm.toString());
     ssm.addStructureViewerListener(this);
     ssm.addSelectionListener(this);
   }
 
   public void initVarna()
   {
-         System.out.println("initialisation VANRA");
+        
     // vab.setFinishedInit(false);
     varnaPanel = vab.get_varnaPanel();
     setBackground(Color.white);
@@ -147,7 +146,7 @@ public class AppVarna extends JInternalFrame implements
             getBounds().width, getBounds().height);
     this.pack();
     showPanel(true);
-    System.out.println("Sortie initialisation VANRA");
+  
   }
 
   public String replaceOddGaps(String oldStr)
index 979a2e2..4c31ce4 100644 (file)
 package jalview.gui;
 
 import javax.swing.JOptionPane;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
-
-import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax;
-import fr.orsay.lri.varna.exceptions.ExceptionLoadingFailed;
-import fr.orsay.lri.varna.exceptions.ExceptionPermissionDenied;
-import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses;
-
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
 
index db7c32c..b135417 100644 (file)
@@ -1509,6 +1509,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   {
     if (progressPanel != null)
     {
+      synchronized(progressPanel) {
       progressPanel.remove(progbar);
       GridLayout gl = (GridLayout) progressPanel.getLayout();
       gl.setRows(gl.getRows() - 1);
@@ -1517,6 +1518,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
         this.getContentPane().remove(progressPanel);
         progressPanel = null;
       }
+      }
     }
     validate();
   }
@@ -1526,9 +1528,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     fileLoadingCount--;
     if (fileLoadingCount < 1)
     {
-      for (JPanel flp : fileLoadingPanels)
+      while (fileLoadingPanels.size()>0)
       {
-        removeProgressPanel(flp);
+        removeProgressPanel(fileLoadingPanels.remove(0));
       }
       fileLoadingPanels.clear();
       fileLoadingCount = 0;
diff --git a/src/jalview/gui/MenuChooser.java b/src/jalview/gui/MenuChooser.java
new file mode 100644 (file)
index 0000000..2ea7bca
--- /dev/null
@@ -0,0 +1,79 @@
+package jalview.gui;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+public class MenuChooser implements ActionListener
+{
+  public static boolean protein;
+
+  private JFrame choosemenu = new JFrame("Animation");
+
+  private JButton bouton = new JButton("bouton 1");
+
+  private JButton bouton2 = new JButton("bouton 2");
+
+  private JPanel container = new JPanel();
+
+  private JLabel label = new JLabel("Le JLabel");
+
+  public MenuChooser()
+  {
+
+    choosemenu.setSize(300, 300);
+    choosemenu.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+    choosemenu.setLocationRelativeTo(null);
+
+    container.setBackground(Color.white);
+    container.setLayout(new BorderLayout());
+
+    // On ajoute notre Fenetre Ã  la liste des auditeurs de notre Bouton
+    bouton.addActionListener(this);
+    bouton2.addActionListener(this);
+
+    JPanel south = new JPanel();
+    south.add(bouton);
+    south.add(bouton2);
+    container.add(south, BorderLayout.SOUTH);
+
+    // On change la couleur de police
+    label.setForeground(Color.blue);
+    // Et on change l'alignement du texte grâce aux attributs static de la
+    // classe JLabel
+    label.setHorizontalAlignment(JLabel.CENTER);
+
+    container.add(label, BorderLayout.NORTH);
+
+    choosemenu.setContentPane(container);
+    choosemenu.setVisible(true);
+
+  }
+
+  // ...
+
+  // *******************************************************************************
+  // LA VOILAAAAAAAAAAAAAA
+  // *******************************************************************************
+  /**
+   * C'est la méthode qui sera appelée lors d'un clic sur notre bouton
+   */
+  public void actionPerformed(ActionEvent arg0)
+  {
+
+    if (arg0.getSource() == bouton)
+      protein = false;
+    label.setText("RNA menu");
+
+    if (arg0.getSource() == bouton2)
+      label.setText("Protein menu");
+    protein = true;
+  }
+
+}
index 075374a..9c5a222 100644 (file)
@@ -23,14 +23,6 @@ import java.awt.*;
 import java.awt.event.*;
 
 import javax.swing.*;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
-
-import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax;
-import fr.orsay.lri.varna.exceptions.ExceptionLoadingFailed;
-import fr.orsay.lri.varna.exceptions.ExceptionPermissionDenied;
-import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses;
 
 import jalview.analysis.*;
 import jalview.commands.*;
@@ -130,7 +122,11 @@ public class PopupMenu extends JPopupMenu
   JMenu pdbMenu = new JMenu();
 
   JMenuItem pdbFromFile = new JMenuItem();
-
+    // JBPNote: Commented these out - Should add these services via the web services menu system.
+    // JMenuItem ContraFold = new JMenuItem();
+  
+    // JMenuItem RNAFold = new JMenuItem();
+  
   JMenuItem enterPDB = new JMenuItem();
 
   JMenuItem discoverPDB = new JMenuItem();
@@ -470,10 +466,7 @@ public class PopupMenu extends JPopupMenu
         purinePyrimidineColour.setSelected(true);
       }
       
-      else if (sg.cs instanceof RNAInteractionColourScheme)
-      {
-        RNAInteractionColour.setSelected(true);
-      }
+   
       /*
        * else if (sg.cs instanceof CovariationColourScheme) {
        * covariationColour.setSelected(true); }
@@ -1066,6 +1059,32 @@ public class PopupMenu extends JPopupMenu
         pdbFromFile_actionPerformed();
       }
     });
+//    RNAFold.setText("From RNA Fold with predict2D");
+//    RNAFold.addActionListener(new ActionListener()
+//    {
+//      public void actionPerformed(ActionEvent e)
+//      {
+//       try {
+//                     RNAFold_actionPerformed();
+//             } catch (Exception e1) {
+//                     // TODO Auto-generated catch block
+//                     e1.printStackTrace();
+//             }
+//      }   
+//    });
+//    ContraFold.setText("From Contra Fold with predict2D");
+//    ContraFold.addActionListener(new ActionListener()
+//    {
+//      public void actionPerformed(ActionEvent e)
+//      {
+//       try {
+//                     ContraFold_actionPerformed();
+//             } catch (Exception e1) {
+//                     // TODO Auto-generated catch block
+//                     e1.printStackTrace();
+//             }
+//      }   
+//    });
     enterPDB.setText("Enter PDB Id");
     enterPDB.addActionListener(new ActionListener()
     {
@@ -1142,7 +1161,8 @@ public class PopupMenu extends JPopupMenu
     colourMenu.add(buriedColour);
     colourMenu.add(nucleotideMenuItem);
     if (ap.getAlignment().isNucleotide()) {
-      colourMenu.add(RNAInteractionColour);
+       // JBPNote - commented since the colourscheme isn't functional
+       //  colourMenu.add(RNAInteractionColour);
        colourMenu.add(purinePyrimidineColour);
     }
     // colourMenu.add(covariationColour);
@@ -1178,6 +1198,9 @@ public class PopupMenu extends JPopupMenu
     editMenu.add(lowerCase);
     editMenu.add(toggle);
     pdbMenu.add(pdbFromFile);
+    // JBPNote: These shouldn't be added here - should appear in a generic 'apply web service to this sequence menu'
+    //    pdbMenu.add(RNAFold);
+    //    pdbMenu.add(ContraFold);
     pdbMenu.add(enterPDB);
     pdbMenu.add(discoverPDB);
     jMenu1.add(groupName);
@@ -1307,15 +1330,7 @@ public class PopupMenu extends JPopupMenu
               }
             });
     
-    RNAInteractionColour.setText("RNA Interaction type");
-    RNAInteractionColour
-            .addActionListener(new java.awt.event.ActionListener()
-            {
-              public void actionPerformed(ActionEvent e)
-              {
-                RNAInteractionColour_actionPerformed();
-              }
-            });
+   
     /*
      * covariationColour.addActionListener(new java.awt.event.ActionListener() {
      * public void actionPerformed(ActionEvent e) {
@@ -1503,11 +1518,7 @@ public class PopupMenu extends JPopupMenu
     refresh();
   }
 
-  protected void RNAInteractionColour_actionPerformed()
-  {
-    getGroup().cs = new RNAInteractionColourScheme();
-    refresh();
-  }
+
   /*
    * protected void covariationColour_actionPerformed() { getGroup().cs = new
    * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
@@ -1982,7 +1993,18 @@ public class PopupMenu extends JPopupMenu
     }
 
   }
-
+    // JBNote: commented out - these won't be instantiated here...!  
+//  public void RNAFold_actionPerformed() throws Exception
+//  {
+//       Predict2D P2D = new Predict2D();
+//       P2D.getStructure2DFromRNAFold("toto");
+//  }
+//  
+//  public void ContraFold_actionPerformed() throws Exception
+//  {
+//       Predict2D P2D = new Predict2D();
+//       P2D.getStructure2DFromContraFold("toto");
+//  }
   public void enterPDB_actionPerformed()
   {
     String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
index ea7ac70..5faf334 100755 (executable)
@@ -129,7 +129,7 @@ public class FeaturesFile extends AlignFile
   }
 
   /**
-   * /** Parse GFF or sequence features file
+   * Parse GFF or sequence features file
    * 
    * @param align
    *          - alignment/dataset containing sequences that are to be annotated
@@ -606,7 +606,6 @@ public class FeaturesFile extends AlignFile
       resetMatcher();
     } catch (Exception ex)
     {
-      System.out.println(line);
       System.out.println("Error parsing feature file: " + ex + "\n" + line);
       ex.printStackTrace(System.err);
       resetMatcher();
index 122e6e1..7b89909 100644 (file)
  */
 package jalview.io;
 
-import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.Annotation;
-import jalview.datamodel.Sequence;
-import jalview.datamodel.SequenceI;
-
 import java.io.BufferedReader;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
 
+import jalview.analysis.SecStrConsensus.SimpleBP;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+
 import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax;
 import fr.orsay.lri.varna.exceptions.ExceptionLoadingFailed;
 import fr.orsay.lri.varna.exceptions.ExceptionPermissionDenied;
@@ -58,20 +59,6 @@ public class RnamlFile extends AlignFile
 
   }
 
-  // public RnamlFile(BufferedReader r) throws IOException,
-  // ExceptionFileFormatOrSyntax, ParserConfigurationException, SAXException,
-  // ExceptionPermissionDenied, ExceptionLoadingFailed
-  // {
-  // super();
-  // parse(r);
-  // // sets the index of each sequence in the alignment
-  // for( int i=0,c=seqs.size(); i<c; i++ ) {
-  // seqs.get(i).setIndex(i);
-  // }
-  //
-  //
-  // }
-
   public BufferedReader CreateReader() throws FileNotFoundException
   {
     FileReader fr = null;
@@ -81,13 +68,30 @@ public class RnamlFile extends AlignFile
     return r;
   }
 
+  /*
+   * (non-Javadoc)
+   * 
+   * @see jalview.io.AlignFile#parse()
+   */
   public void parse() throws IOException
   {
-    result = null;
+    if (System.getProperty("java.version").indexOf("1.6") > -1
+            || System.getProperty("java.version").indexOf("1.5") > -1)
+    {
+      // patch for 'This parser does not support specification "null" version
+      // "null"' error
+      // this hack ensures we get a properly updated SAXParserFactory on older
+      // JVMs
+      // thanks to Stefan Birkner over at https://coderwall.com/p/kqsrrw
+      System.setProperty("javax.xml.parsers.SAXParserFactory",
+              "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
+    }
+    // rather than lose exception semantics whilst parsing RNAML with VARNA we
+    // wrap the routine and catch all exceptions before passing them up the
+    // chain as an IOException
     try
     {
-      result = RNAFactory.loadSecStrRNAML(getReader());
-
+      _parse();
     } catch (ExceptionPermissionDenied pdx)
     {
       errormessage = "Couldn't access datasource (" + pdx.getMessage()
@@ -102,62 +106,94 @@ public class RnamlFile extends AlignFile
     {
       errormessage = "Invalid RNAML file (" + iff.getMessage() + ")";
       throw new IOException(iff);
+    } catch (Exception x)
+    {
+      error = true;
+      errormessage = "Problem parsing data as RNAML (" + x.getMessage()
+              + ")";
+      throw new IOException("Couldn't parse the datasource as RNAML", x);
     }
+  }
+
+  @SuppressWarnings("unchecked")
+  public void _parse() throws FileNotFoundException,
+          ExceptionPermissionDenied, ExceptionLoadingFailed,
+          ExceptionFileFormatOrSyntax
+  {
 
+    result = RNAFactory.loadSecStrRNAML(getReader());
+
+    ArrayList<ArrayList> allarray = new ArrayList();
+    ArrayList<ArrayList<SimpleBP>> BP = new ArrayList();
+    ArrayList strucinarray = new ArrayList();
     SequenceI[] seqs = new SequenceI[result.size()];
 
     for (int i = 0; i < result.size(); i++)
     {
-      // DEBUG System.err.println("RNAML entry "+i);
+
       RNA current = result.get(i);
-      String seq = current.getSeq();
-      // DEBUG System.err.println(seq);
       String rna = current.getStructDBN(true);
-      // DEBUG System.err.println(rna);
-
+      String seq = current.getSeq();
       int begin = 1;
-      int end = seq.length(); // TODO: compute non-gapped length for sequence
+      int end = seq.length();
 
       id = current.getName();
       seqs[i] = new Sequence(id, seq, begin, end);
 
+      seqs[i].setEnd(seqs[i].findPosition(seqs[i].getLength()));
       String[] annot = new String[rna.length()];
       Annotation[] ann = new Annotation[rna.length()];
 
       for (int j = 0; j < rna.length(); j++)
       {
-        annot[j] = rna.substring(j, j + 1);
+        annot[j] = "" + rna.charAt(j);
 
       }
-
       for (int k = 0; k < rna.length(); k++)
       {
         ann[k] = new Annotation(annot[k], "",
                 jalview.schemes.ResidueProperties.getRNASecStrucState(
                         annot[k]).charAt(0), 0f);
-
       }
+
       AlignmentAnnotation align = new AlignmentAnnotation("Sec. str.",
               current.getID(), ann);
 
       seqs[i].addAlignmentAnnotation(align);
       seqs[i].setRNA(result.get(i));
+
+      allarray.add(strucinarray);
+
       annotations.addElement(align);
+      BP.add(align.bps);
+
     }
+
     setSeqs(seqs);
   }
 
   public static String print(SequenceI[] s)
   {
-    // TODO: implement RNAML export option
     return "not yet implemented";
   }
 
   public String print()
   {
+    System.out.print("print :");
     return print(getSeqsAsArray());
   }
 
+  public ArrayList getRNA()
+  {
+    return result;
+  }
+
+  // public static void main(String[] args) {
+  // Pattern p= Pattern.compile("(.+)[.][^.]+");
+  // Matcher m = p.matcher("toto.xml.zip");
+  // System.out.println(m.matches());
+  // System.out.println(m.group(1));
+  // }
   /**
    * make a friendly ID string.
    * 
index d730c9c..4d8f136 100644 (file)
  */\r
 package jalview.io;\r
 \r
+import jalview.datamodel.AlignmentI;\r
 import jalview.datamodel.AlignmentAnnotation;\r
 import jalview.datamodel.AlignmentI;\r
 import jalview.datamodel.Annotation;\r
 import jalview.datamodel.DBRefEntry;\r
+import jalview.datamodel.Mapping;\r
 import jalview.datamodel.Sequence;\r
 import jalview.datamodel.SequenceFeature;\r
 import jalview.datamodel.SequenceI;\r
@@ -70,8 +72,6 @@ public class StockholmFile extends AlignFile
 
   AlignmentI al;
 \r
-  public String id;\r
-\r
   public StockholmFile()\r
   {\r
   }\r
@@ -98,11 +98,13 @@ public class StockholmFile extends AlignFile
   {\r
     super.initData();\r
   }\r
-\r
   /**\r
-   * Parse a file in Stockholm format using VARNA\r
+   * Parse a file in Stockholm format into Jalview's data model using VARNA\r
+   * \r
+   * @throws IOException\r
+   *           If there is an error with the input file\r
    */\r
-  public void _parse_withVARNA(java.io.File inFile) throws IOException\r
+  public void parse_with_VARNA(java.io.File inFile) throws IOException\r
   {\r
     FileReader fr = null;\r
     fr = new FileReader(inFile);\r
@@ -121,6 +123,7 @@ public class StockholmFile extends AlignFile
     // DEBUG System.out.println("this is the secondary scructure:"\r
     // +result.size());\r
     SequenceI[] seqs = new SequenceI[result.size()];\r
+    String id=null;\r
     for (int i = 0; i < result.size(); i++)\r
     {\r
       // DEBUG System.err.println("Processing i'th sequence in Stockholm file")\r
@@ -170,68 +173,70 @@ public class StockholmFile extends AlignFile
    */\r
   public void parse() throws IOException\r
   {\r
-    StringBuffer treeString = new StringBuffer();\r
-    String treeName = null;\r
-    // --------------- Variable Definitions -------------------\r
-    String line;\r
-    String version;\r
+      StringBuffer treeString = new StringBuffer();\r
+      String treeName = null;\r
+      // --------------- Variable Definitions -------------------\r
+      String line;\r
+      String version;\r
     // String id;\r
-    Hashtable seqAnn = new Hashtable(); // Sequence related annotations\r
-    Hashtable seqs = new Hashtable();\r
-    Regex p, r, rend, s, x;\r
-\r
-    // Temporary line for processing RNA annotation\r
-    // String RNAannot = "";\r
+      Hashtable seqAnn = new Hashtable(); // Sequence related annotations\r
+      Hashtable seqs = new Hashtable();\r
+      Regex p, r, rend, s, x;\r
+      // Temporary line for processing RNA annotation\r
+      // String RNAannot = "";\r
 \r
-    // ------------------ Parsing File ----------------------\r
-    // First, we have to check that this file has STOCKHOLM format, i.e. the\r
-    // first line must match\r
-    r = new Regex("# STOCKHOLM ([\\d\\.]+)");\r
-    if (!r.search(nextLine()))\r
-    {\r
-      throw new IOException(\r
-              "This file is not in valid STOCKHOLM format: First line does not contain '# STOCKHOLM'");\r
-    }\r
-    else\r
-    {\r
-      version = r.stringMatched(1);\r
-      // logger.debug("Stockholm version: " + version);\r
-    }\r
-\r
-    // We define some Regexes here that will be used regularily later\r
-    rend = new Regex("^\\s*\\/\\/"); // Find the end of an alignment\r
-    p = new Regex("(\\S+)\\/(\\d+)\\-(\\d+)"); // split sequence id in\r
-    // id/from/to\r
-    s = new Regex("(\\S+)\\s+(\\S*)\\s+(.*)"); // Parses annotation subtype\r
-    r = new Regex("#=(G[FSRC]?)\\s+(.*)"); // Finds any annotation line\r
-    x = new Regex("(\\S+)\\s+(\\S+)"); // split id from sequence\r
+      // ------------------ Parsing File ----------------------\r
+      // First, we have to check that this file has STOCKHOLM format, i.e. the\r
+      // first line must match\r
+      \r
+  \r
+               r = new Regex("# STOCKHOLM ([\\d\\.]+)");\r
+               if (!r.search(nextLine()))\r
+               {\r
+                       throw new IOException(\r
+                                       "This file is not in valid STOCKHOLM format: First line does not contain '# STOCKHOLM'");\r
+               }\r
+               else\r
+               {\r
+                       version = r.stringMatched(1);\r
+               \r
+                       // logger.debug("Stockholm version: " + version);\r
+               }\r
 \r
-    // Convert all bracket types to parentheses (necessary for passing to VARNA)\r
-    Regex openparen = new Regex("(<|\\[)", "(");\r
-    Regex closeparen = new Regex("(>|\\])", ")");\r
+               // We define some Regexes here that will be used regularily later\r
+               rend = new Regex("^\\s*\\/\\/"); // Find the end of an alignment\r
+               p = new Regex("(\\S+)\\/(\\d+)\\-(\\d+)"); // split sequence id in\r
+               // id/from/to\r
+               s = new Regex("(\\S+)\\s+(\\S*)\\s+(.*)"); // Parses annotation subtype\r
+               r = new Regex("#=(G[FSRC]?)\\s+(.*)"); // Finds any annotation line\r
+               x = new Regex("(\\S+)\\s+(\\S+)"); // split id from sequence\r
 \r
-    // Detect if file is RNA by looking for bracket types\r
-    Regex detectbrackets = new Regex("(<|>|\\[|\\]|\\(|\\))");\r
+               // Convert all bracket types to parentheses (necessary for passing to VARNA)\r
+               Regex openparen = new Regex("(<|\\[)", "(");\r
+               Regex closeparen = new Regex("(>|\\])", ")");\r
 \r
-    rend.optimize();\r
-    p.optimize();\r
-    s.optimize();\r
-    r.optimize();\r
-    x.optimize();\r
-    openparen.optimize();\r
-    closeparen.optimize();\r
+               // Detect if file is RNA by looking for bracket types\r
+               Regex detectbrackets = new Regex("(<|>|\\[|\\]|\\(|\\))");\r
 \r
-    while ((line = nextLine()) != null)\r
-    {\r
-      if (line.length() == 0)\r
-      {\r
-        continue;\r
-      }\r
-      if (rend.search(line))\r
-      {\r
-        // End of the alignment, pass stuff back\r
+               rend.optimize();\r
+           p.optimize();\r
+           s.optimize();\r
+           r.optimize();\r
+           x.optimize();\r
+           openparen.optimize();\r
+           closeparen.optimize();\r
+       \r
+           while ((line = nextLine()) != null)\r
+           {\r
+             if (line.length() == 0)\r
+             {\r
+               continue;\r
+             }\r
+             if (rend.search(line))\r
+             {\r
+               // End of the alignment, pass stuff back\r
         this.noSeqs = seqs.size();\r
-\r
+       \r
         String seqdb,dbsource = null;\r
         Regex pf = new Regex("PF[0-9]{5}(.*)"); // Finds AC for Pfam\r
         Regex rf = new Regex("RF[0-9]{5}(.*)"); // Finds AC for Rfam\r
@@ -248,60 +253,59 @@ public class StockholmFile extends AlignFile
             dbsource = "RFAM";\r
           }\r
         }\r
-        // logger.debug("Number of sequences: " + this.noSeqs);\r
-        Enumeration accs = seqs.keys();\r
-        while (accs.hasMoreElements())\r
-        {\r
-          String acc = (String) accs.nextElement();\r
-          // logger.debug("Processing sequence " + acc);\r
-          String seq = (String) seqs.remove(acc);\r
-          if (maxLength < seq.length())\r
-          {\r
-            maxLength = seq.length();\r
-          }\r
-          int start = 1;\r
-          int end = -1;\r
-          String sid = acc;\r
-          /*\r
+               // logger.debug("Number of sequences: " + this.noSeqs);\r
+               Enumeration accs = seqs.keys();\r
+               while (accs.hasMoreElements())\r
+               {\r
+                 String acc = (String) accs.nextElement();\r
+                 // logger.debug("Processing sequence " + acc);\r
+                 String seq = (String) seqs.remove(acc);\r
+                 if (maxLength < seq.length())\r
+                 {\r
+                   maxLength = seq.length();\r
+                 }\r
+                 int start = 1;\r
+                 int end = -1;\r
+                 String sid = acc;\r
+                 /*\r
            * Retrieve hash of annotations for this accession Associate\r
            * Annotation with accession\r
-           */\r
-          Hashtable accAnnotations = null;\r
-\r
-          if (seqAnn != null && seqAnn.containsKey(acc))\r
-          {\r
-            accAnnotations = (Hashtable) seqAnn.remove(acc);\r
-            // TODO: add structures to sequence\r
-          }\r
-\r
-          // Split accession in id and from/to\r
-          if (p.search(acc))\r
-          {\r
-            sid = p.stringMatched(1);\r
-            start = Integer.parseInt(p.stringMatched(2));\r
-            end = Integer.parseInt(p.stringMatched(3));\r
-          }\r
-          // logger.debug(sid + ", " + start + ", " + end);\r
-\r
-          Sequence seqO = new Sequence(sid, seq, start, end);\r
-          // Add Description (if any)\r
-          if (accAnnotations != null && accAnnotations.containsKey("DE"))\r
-          {\r
-            String desc = (String) accAnnotations.get("DE");\r
-            seqO.setDescription((desc == null) ? "" : desc);\r
-          }\r
-\r
-          // Add DB References (if any)\r
-          if (accAnnotations != null && accAnnotations.containsKey("DR"))\r
-          {\r
-            String dbr = (String) accAnnotations.get("DR");\r
-            if (dbr != null && dbr.indexOf(";") > -1)\r
-            {\r
-              String src = dbr.substring(0, dbr.indexOf(";"));\r
-              String acn = dbr.substring(dbr.indexOf(";") + 1);\r
-              jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn);\r
-            }\r
-          }\r
+                  */\r
+                 Hashtable accAnnotations = null;\r
+       \r
+                 if (seqAnn != null && seqAnn.containsKey(acc))\r
+                 {\r
+                   accAnnotations = (Hashtable) seqAnn.remove(acc);\r
+                   //TODO: add structures to sequence\r
+                 }\r
+       \r
+                 // Split accession in id and from/to\r
+                 if (p.search(acc))\r
+                 {\r
+                   sid = p.stringMatched(1);\r
+                   start = Integer.parseInt(p.stringMatched(2));\r
+                   end = Integer.parseInt(p.stringMatched(3));\r
+                 }\r
+                 // logger.debug(sid + ", " + start + ", " + end);\r
+       \r
+                 Sequence seqO = new Sequence(sid, seq, start, end);\r
+                 // Add Description (if any)\r
+                 if (accAnnotations != null && accAnnotations.containsKey("DE"))\r
+                 {\r
+                   String desc = (String) accAnnotations.get("DE");\r
+                   seqO.setDescription((desc == null) ? "" : desc);\r
+                 }\r
+                 // Add DB References (if any)\r
+                 if (accAnnotations != null && accAnnotations.containsKey("DR"))\r
+                 {\r
+                   String dbr = (String) accAnnotations.get("DR");\r
+                   if (dbr != null && dbr.indexOf(";") > -1)\r
+                   {\r
+                     String src = dbr.substring(0, dbr.indexOf(";"));\r
+                     String acn = dbr.substring(dbr.indexOf(";") + 1);\r
+                     jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn);\r
+                   }\r
+                 }        \r
 \r
           if (accAnnotations != null && accAnnotations.containsKey("AC"))\r
           {\r
@@ -309,39 +313,39 @@ public class StockholmFile extends AlignFile
             {\r
               String dbr = (String) accAnnotations.get("AC");\r
               if (dbr != null)\r
-              {\r
+                 {\r
                 // we could get very clever here - but for now - just try to guess accession type from source of alignment plus structure of accession\r
                 guessDatabaseFor(seqO, dbr, dbsource);\r
-                \r
-              }\r
-            } \r
+                         \r
+                           }\r
+                 }\r
             // else - do what ?  add the data anyway and prompt the user to specify what references these are ?\r
           }\r
-\r
-          Hashtable features = null;\r
-          // We need to adjust the positions of all features to account for gaps\r
-          try\r
-          {\r
-            features = (Hashtable) accAnnotations.remove("features");\r
-          } catch (java.lang.NullPointerException e)\r
-          {\r
-            // loggerwarn("Getting Features for " + acc + ": " +\r
-            // e.getMessage());\r
-            // continue;\r
-          }\r
-          // if we have features\r
-          if (features != null)\r
-          {\r
-            int posmap[] = seqO.findPositionMap();\r
-            Enumeration i = features.keys();\r
-            while (i.hasMoreElements())\r
-            {\r
-              // TODO: parse out secondary structure annotation as annotation\r
-              // row\r
-              // TODO: parse out scores as annotation row\r
-              // TODO: map coding region to core jalview feature types\r
-              String type = i.nextElement().toString();\r
-              Hashtable content = (Hashtable) features.remove(type);\r
+               \r
+                 Hashtable features = null;\r
+                 // We need to adjust the positions of all features to account for gaps\r
+                 try\r
+                 {\r
+                   features = (Hashtable) accAnnotations.remove("features");\r
+                 } catch (java.lang.NullPointerException e)\r
+                 {\r
+                   // loggerwarn("Getting Features for " + acc + ": " +\r
+                   // e.getMessage());\r
+                   // continue;\r
+                 }\r
+                 // if we have features\r
+                 if (features != null)\r
+                 {\r
+                   int posmap[] = seqO.findPositionMap();\r
+                   Enumeration i = features.keys();\r
+                   while (i.hasMoreElements())\r
+                   {\r
+                     // TODO: parse out secondary structure annotation as annotation\r
+                     // row\r
+                     // TODO: parse out scores as annotation row\r
+                     // TODO: map coding region to core jalview feature types\r
+                     String type = i.nextElement().toString();\r
+                     Hashtable content = (Hashtable) features.remove(type);\r
 \r
               // add alignment annotation for this feature\r
               String key = type2id(type);\r
@@ -360,300 +364,304 @@ public class StockholmFile extends AlignFile
                 }\r
               }\r
 \r
-              Enumeration j = content.keys();\r
-              while (j.hasMoreElements())\r
-              {\r
-                String desc = j.nextElement().toString();\r
-                String ns = content.get(desc).toString();\r
-                char[] byChar = ns.toCharArray();\r
-                for (int k = 0; k < byChar.length; k++)\r
-                {\r
-                  char c = byChar[k];\r
-                  if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM\r
-                  // uses\r
-                  // '.'\r
-                  // for\r
-                  // feature\r
-                  // background\r
-                  {\r
-                    int new_pos = posmap[k]; // look up nearest seqeunce\r
-                    // position to this column\r
-                    SequenceFeature feat = new SequenceFeature(type, desc,\r
-                            new_pos, new_pos, 0f, null);\r
-\r
-                    seqO.addSequenceFeature(feat);\r
-                  }\r
-                }\r
-              }\r
-\r
-            }\r
-\r
-          }\r
-          // garbage collect\r
-\r
-          // logger.debug("Adding seq " + acc + " from " + start + " to " + end\r
-          // + ": " + seq);\r
-          this.seqs.addElement(seqO);\r
-        }\r
-        return; // finished parsing this segment of source\r
-      }\r
-      else if (!r.search(line))\r
-      {\r
-        // System.err.println("Found sequence line: " + line);\r
-\r
-        // Split sequence in sequence and accession parts\r
-        if (!x.search(line))\r
-        {\r
-          // logger.error("Could not parse sequence line: " + line);\r
-          throw new IOException("Could not parse sequence line: " + line);\r
-        }\r
-        String ns = (String) seqs.get(x.stringMatched(1));\r
-        if (ns == null)\r
-        {\r
-          ns = "";\r
-        }\r
-        ns += x.stringMatched(2);\r
-\r
-        seqs.put(x.stringMatched(1), ns);\r
-      }\r
-      else\r
-      {\r
-        String annType = r.stringMatched(1);\r
-        String annContent = r.stringMatched(2);\r
-\r
-        // System.err.println("type:" + annType + " content: " + annContent);\r
-\r
-        if (annType.equals("GF"))\r
-        {\r
-          /*\r
-           * Generic per-File annotation, free text Magic features: #=GF NH\r
-           * <tree in New Hampshire eXtended format> #=GF TN <Unique identifier\r
-           * for the next tree> Pfam descriptions: 7. DESCRIPTION OF FIELDS\r
-           * \r
-           * Compulsory fields: ------------------\r
-           * \r
-           * AC Accession number: Accession number in form PFxxxxx.version or\r
-           * PBxxxxxx. ID Identification: One word name for family. DE\r
-           * Definition: Short description of family. AU Author: Authors of the\r
-           * entry. SE Source of seed: The source suggesting the seed members\r
-           * belong to one family. GA Gathering method: Search threshold to\r
-           * build the full alignment. TC Trusted Cutoff: Lowest sequence score\r
-           * and domain score of match in the full alignment. NC Noise Cutoff:\r
-           * Highest sequence score and domain score of match not in full\r
-           * alignment. TP Type: Type of family -- presently Family, Domain,\r
-           * Motif or Repeat. SQ Sequence: Number of sequences in alignment. AM\r
-           * Alignment Method The order ls and fs hits are aligned to the model\r
-           * to build the full align. // End of alignment.\r
-           * \r
-           * Optional fields: ----------------\r
-           * \r
-           * DC Database Comment: Comment about database reference. DR Database\r
-           * Reference: Reference to external database. RC Reference Comment:\r
-           * Comment about literature reference. RN Reference Number: Reference\r
-           * Number. RM Reference Medline: Eight digit medline UI number. RT\r
-           * Reference Title: Reference Title. RA Reference Author: Reference\r
-           * Author RL Reference Location: Journal location. PI Previous\r
-           * identifier: Record of all previous ID lines. KW Keywords: Keywords.\r
-           * CC Comment: Comments. NE Pfam accession: Indicates a nested domain.\r
-           * NL Location: Location of nested domains - sequence ID, start and\r
-           * end of insert.\r
-           * \r
-           * Obsolete fields: ----------- AL Alignment method of seed: The\r
-           * method used to align the seed members.\r
-           */\r
-          // Let's save the annotations, maybe we'll be able to do something\r
-          // with them later...\r
-          Regex an = new Regex("(\\w+)\\s*(.*)");\r
-          if (an.search(annContent))\r
-          {\r
-            if (an.stringMatched(1).equals("NH"))\r
-            {\r
-              treeString.append(an.stringMatched(2));\r
-            }\r
-            else if (an.stringMatched(1).equals("TN"))\r
-            {\r
-              if (treeString.length() > 0)\r
-              {\r
-                if (treeName == null)\r
-                {\r
-                  treeName = "Tree " + (getTreeCount() + 1);\r
-                }\r
-                addNewickTree(treeName, treeString.toString());\r
-              }\r
-              treeName = an.stringMatched(2);\r
-              treeString = new StringBuffer();\r
-            }\r
-            setAlignmentProperty(an.stringMatched(1), an.stringMatched(2));\r
-          }\r
-        }\r
-        else if (annType.equals("GS"))\r
-        {\r
-          // Generic per-Sequence annotation, free text\r
-          /*\r
-           * Pfam uses these features: Feature Description ---------------------\r
-           * ----------- AC <accession> ACcession number DE <freetext>\r
-           * DEscription DR <db>; <accession>; Database Reference OS <organism>\r
-           * OrganiSm (species) OC <clade> Organism Classification (clade, etc.)\r
-           * LO <look> Look (Color, etc.)\r
-           */\r
-          if (s.search(annContent))\r
-          {\r
-            String acc = s.stringMatched(1);\r
-            String type = s.stringMatched(2);\r
-            String content = s.stringMatched(3);\r
-            // TODO: store DR in a vector.\r
-            // TODO: store AC according to generic file db annotation.\r
-            Hashtable ann;\r
-            if (seqAnn.containsKey(acc))\r
-            {\r
-              ann = (Hashtable) seqAnn.get(acc);\r
-            }\r
-            else\r
-            {\r
-              ann = new Hashtable();\r
-            }\r
-            ann.put(type, content);\r
-            seqAnn.put(acc, ann);\r
-          }\r
-          else\r
-          {\r
-            throw new IOException("Error parsing " + line);\r
-          }\r
-        }\r
-        else if (annType.equals("GC"))\r
-        {\r
-          // Generic per-Column annotation, exactly 1 char per column\r
-          // always need a label.\r
-          if (x.search(annContent))\r
-          {\r
-            // parse out and create alignment annotation directly.\r
-            parseAnnotationRow(annotations, x.stringMatched(1),\r
-                    x.stringMatched(2));\r
-          }\r
-        }\r
-        else if (annType.equals("GR"))\r
-        {\r
-          // Generic per-Sequence AND per-Column markup, exactly 1 char per\r
-          // column\r
-          /*\r
-           * Feature Description Markup letters ------- -----------\r
-           * -------------- SS Secondary Structure [HGIEBTSCX] SA Surface\r
-           * Accessibility [0-9X] (0=0%-10%; ...; 9=90%-100%) TM TransMembrane\r
-           * [Mio] PP Posterior Probability [0-9*] (0=0.00-0.05; 1=0.05-0.15;\r
-           * *=0.95-1.00) LI LIgand binding [*] AS Active Site [*] IN INtron (in\r
-           * or after) [0-2]\r
-           */\r
-          if (s.search(annContent))\r
-          {\r
-            String acc = s.stringMatched(1);\r
-            String type = s.stringMatched(2);\r
-            String seq = new String(s.stringMatched(3));\r
-            String description = null;\r
-            // Check for additional information about the current annotation\r
-            // We use a simple string tokenizer here for speed\r
-            StringTokenizer sep = new StringTokenizer(seq, " \t");\r
-            description = sep.nextToken();\r
-            if (sep.hasMoreTokens())\r
-            {\r
-              seq = sep.nextToken();\r
-            }\r
-            else\r
-            {\r
-              seq = description;\r
-              description = new String();\r
-            }\r
-            // sequence id with from-to fields\r
-\r
-            Hashtable ann;\r
-            // Get an object with all the annotations for this sequence\r
-            if (seqAnn.containsKey(acc))\r
-            {\r
-              // logger.debug("Found annotations for " + acc);\r
-              ann = (Hashtable) seqAnn.get(acc);\r
-            }\r
-            else\r
-            {\r
-              // logger.debug("Creating new annotations holder for " + acc);\r
-              ann = new Hashtable();\r
-              seqAnn.put(acc, ann);\r
-            }\r
+                     Enumeration j = content.keys();\r
+                     while (j.hasMoreElements())\r
+                     {\r
+                       String desc = j.nextElement().toString();\r
+                       String ns = content.get(desc).toString();\r
+                       char[] byChar = ns.toCharArray();\r
+                       for (int k = 0; k < byChar.length; k++)\r
+                       {\r
+                         char c = byChar[k];\r
+                         if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM\r
+                         // uses\r
+                         // '.'\r
+                         // for\r
+                         // feature\r
+                         // background\r
+                         {\r
+                           int new_pos = posmap[k]; // look up nearest seqeunce\r
+                           // position to this column\r
+                           SequenceFeature feat = new SequenceFeature(type, desc,\r
+                                   new_pos, new_pos, 0f, null);\r
+       \r
+                           seqO.addSequenceFeature(feat);\r
+                         }\r
+                       }\r
+                     }\r
+       \r
+                   }\r
+       \r
+                 }\r
+                 // garbage collect\r
+       \r
+                 // logger.debug("Adding seq " + acc + " from " + start + " to " + end\r
+                 // + ": " + seq);\r
+                 this.seqs.addElement(seqO);\r
+               }\r
+               return; // finished parsing this segment of source\r
+             }\r
+             else if (!r.search(line))\r
+             {\r
+               // System.err.println("Found sequence line: " + line);\r
+       \r
+               // Split sequence in sequence and accession parts\r
+               if (!x.search(line))\r
+               {\r
+                 // logger.error("Could not parse sequence line: " + line);\r
+                 throw new IOException("Could not parse sequence line: " + line);\r
+               }\r
+               String ns = (String) seqs.get(x.stringMatched(1));\r
+               if (ns == null)\r
+               {\r
+                 ns = "";\r
+               }\r
+               ns += x.stringMatched(2);\r
+       \r
+               seqs.put(x.stringMatched(1), ns);\r
+             }\r
+             else\r
+             {\r
+               String annType = r.stringMatched(1);\r
+               String annContent = r.stringMatched(2);\r
+       \r
+               // System.err.println("type:" + annType + " content: " + annContent);\r
+       \r
+               if (annType.equals("GF"))\r
+               {\r
+                 /*\r
+                  * Generic per-File annotation, free text Magic features: #=GF NH\r
+                  * <tree in New Hampshire eXtended format> #=GF TN <Unique identifier\r
+                  * for the next tree> Pfam descriptions: 7. DESCRIPTION OF FIELDS\r
+                  * \r
+                  * Compulsory fields: ------------------\r
+                  * \r
+                  * AC Accession number: Accession number in form PFxxxxx.version or\r
+                  * PBxxxxxx. ID Identification: One word name for family. DE\r
+                  * Definition: Short description of family. AU Author: Authors of the\r
+                  * entry. SE Source of seed: The source suggesting the seed members\r
+                  * belong to one family. GA Gathering method: Search threshold to\r
+                  * build the full alignment. TC Trusted Cutoff: Lowest sequence score\r
+                  * and domain score of match in the full alignment. NC Noise Cutoff:\r
+                  * Highest sequence score and domain score of match not in full\r
+                  * alignment. TP Type: Type of family -- presently Family, Domain,\r
+                  * Motif or Repeat. SQ Sequence: Number of sequences in alignment. AM\r
+                  * Alignment Method The order ls and fs hits are aligned to the model\r
+                  * to build the full align. // End of alignment.\r
+                  * \r
+                  * Optional fields: ----------------\r
+                  * \r
+                  * DC Database Comment: Comment about database reference. DR Database\r
+                  * Reference: Reference to external database. RC Reference Comment:\r
+                  * Comment about literature reference. RN Reference Number: Reference\r
+                  * Number. RM Reference Medline: Eight digit medline UI number. RT\r
+                  * Reference Title: Reference Title. RA Reference Author: Reference\r
+                  * Author RL Reference Location: Journal location. PI Previous\r
+                  * identifier: Record of all previous ID lines. KW Keywords: Keywords.\r
+                  * CC Comment: Comments. NE Pfam accession: Indicates a nested domain.\r
+                  * NL Location: Location of nested domains - sequence ID, start and\r
+                  * end of insert.\r
+                  * \r
+                  * Obsolete fields: ----------- AL Alignment method of seed: The\r
+                  * method used to align the seed members.\r
+                  */\r
+                 // Let's save the annotations, maybe we'll be able to do something\r
+                 // with them later...\r
+                 Regex an = new Regex("(\\w+)\\s*(.*)");\r
+                 if (an.search(annContent))\r
+                 {\r
+                   if (an.stringMatched(1).equals("NH"))\r
+                   {\r
+                     treeString.append(an.stringMatched(2));\r
+                   }\r
+                   else if (an.stringMatched(1).equals("TN"))\r
+                   {\r
+                     if (treeString.length() > 0)\r
+                     {\r
+                       if (treeName == null)\r
+                       {\r
+                         treeName = "Tree " + (getTreeCount() + 1);\r
+                       }\r
+                       addNewickTree(treeName, treeString.toString());\r
+                     }\r
+                     treeName = an.stringMatched(2);\r
+                     treeString = new StringBuffer();\r
+                   }\r
+                   setAlignmentProperty(an.stringMatched(1), an.stringMatched(2));\r
+                 }\r
+               }\r
+               else if (annType.equals("GS"))\r
+               {\r
+                 // Generic per-Sequence annotation, free text\r
+                 /*\r
+                  * Pfam uses these features: Feature Description ---------------------\r
+                  * ----------- AC <accession> ACcession number DE <freetext>\r
+                  * DEscription DR <db>; <accession>; Database Reference OS <organism>\r
+                  * OrganiSm (species) OC <clade> Organism Classification (clade, etc.)\r
+                  * LO <look> Look (Color, etc.)\r
+                  */\r
+                 if (s.search(annContent))\r
+                 {\r
+                   String acc = s.stringMatched(1);\r
+                   String type = s.stringMatched(2);\r
+                   String content = s.stringMatched(3);\r
+                   // TODO: store DR in a vector.\r
+                   // TODO: store AC according to generic file db annotation.\r
+                   Hashtable ann;\r
+                   if (seqAnn.containsKey(acc))\r
+                   {\r
+                     ann = (Hashtable) seqAnn.get(acc);\r
+                   }\r
+                   else\r
+                   {\r
+                     ann = new Hashtable();\r
+                   }\r
+                   ann.put(type, content);\r
+                   seqAnn.put(acc, ann);\r
+                 }\r
+                 else\r
+                 {\r
+                   throw new IOException("Error parsing " + line);\r
+                 }\r
+               }\r
+               else if (annType.equals("GC"))\r
+               {\r
+                 // Generic per-Column annotation, exactly 1 char per column\r
+                 // always need a label.\r
+                 if (x.search(annContent))\r
+                 {\r
+                   // parse out and create alignment annotation directly.\r
+                   parseAnnotationRow(annotations, x.stringMatched(1),\r
+                           x.stringMatched(2));\r
+                 }\r
+               }\r
+               else if (annType.equals("GR"))\r
+               {\r
+                 // Generic per-Sequence AND per-Column markup, exactly 1 char per\r
+                 // column\r
+                 /*\r
+                  * Feature Description Markup letters ------- -----------\r
+                  * -------------- SS Secondary Structure [HGIEBTSCX] SA Surface\r
+                  * Accessibility [0-9X] (0=0%-10%; ...; 9=90%-100%) TM TransMembrane\r
+                  * [Mio] PP Posterior Probability [0-9*] (0=0.00-0.05; 1=0.05-0.15;\r
+                  * *=0.95-1.00) LI LIgand binding [*] AS Active Site [*] IN INtron (in\r
+                  * or after) [0-2]\r
+                  */\r
+                 if (s.search(annContent))\r
+                 {\r
+                   String acc = s.stringMatched(1);\r
+                   String type = s.stringMatched(2);\r
+                   String seq = new String(s.stringMatched(3));\r
+                   String description = null;\r
+                   // Check for additional information about the current annotation\r
+                   // We use a simple string tokenizer here for speed\r
+                   StringTokenizer sep = new StringTokenizer(seq, " \t");\r
+                   description = sep.nextToken();\r
+                   if (sep.hasMoreTokens())\r
+                   {\r
+                     seq = sep.nextToken();\r
+                   }\r
+                   else\r
+                   {\r
+                     seq = description;\r
+                     description = new String();\r
+                   }\r
+                   // sequence id with from-to fields\r
+       \r
+                   Hashtable ann;\r
+                   // Get an object with all the annotations for this sequence\r
+                   if (seqAnn.containsKey(acc))\r
+                   {\r
+                     // logger.debug("Found annotations for " + acc);\r
+                     ann = (Hashtable) seqAnn.get(acc);\r
+                   }\r
+                   else\r
+                   {\r
+                     // logger.debug("Creating new annotations holder for " + acc);\r
+                     ann = new Hashtable();\r
+                     seqAnn.put(acc, ann);\r
+                   }\r
             // TODO test structure, call parseAnnotationRow with vector from\r
             // hashtable for specific sequence\r
-            Hashtable features;\r
-            // Get an object with all the content for an annotation\r
-            if (ann.containsKey("features"))\r
-            {\r
-              // logger.debug("Found features for " + acc);\r
-              features = (Hashtable) ann.get("features");\r
-            }\r
-            else\r
-            {\r
-              // logger.debug("Creating new features holder for " + acc);\r
-              features = new Hashtable();\r
-              ann.put("features", features);\r
-            }\r
-\r
-            Hashtable content;\r
-            if (features.containsKey(this.id2type(type)))\r
-            {\r
-              // logger.debug("Found content for " + this.id2type(type));\r
-              content = (Hashtable) features.get(this.id2type(type));\r
-            }\r
-            else\r
-            {\r
-              // logger.debug("Creating new content holder for " +\r
-              // this.id2type(type));\r
-              content = new Hashtable();\r
-              features.put(this.id2type(type), content);\r
-            }\r
-            String ns = (String) content.get(description);\r
-            if (ns == null)\r
-            {\r
-              ns = "";\r
-            }\r
-            ns += seq;\r
-            content.put(description, ns);\r
-            Hashtable strucAnn;\r
-            if (seqAnn.containsKey(acc))\r
-            {\r
-              strucAnn = (Hashtable) seqAnn.get(acc);\r
-            }\r
-            else\r
-            {\r
-              strucAnn = new Hashtable();\r
-            }\r
-\r
-            Vector newStruc = new Vector();\r
-            parseAnnotationRow(newStruc, type, ns);\r
-            strucAnn.put(type, newStruc);\r
-            seqAnn.put(acc, strucAnn);\r
-          }\r
-          else\r
-          {\r
-            System.err\r
-                    .println("Warning - couldn't parse sequence annotation row line:\n"\r
-                            + line);\r
-            // throw new IOException("Error parsing " + line);\r
-          }\r
-        }\r
-        else\r
-        {\r
-          throw new IOException("Unknown annotation detected: " + annType\r
-                  + " " + annContent);\r
-        }\r
-      }\r
-    }\r
-    if (treeString.length() > 0)\r
-    {\r
-      if (treeName == null)\r
-      {\r
-        treeName = "Tree " + (1 + getTreeCount());\r
-      }\r
-      addNewickTree(treeName, treeString.toString());\r
-    }\r
-  }\r
+                   Hashtable features;\r
+                   // Get an object with all the content for an annotation\r
+                   if (ann.containsKey("features"))\r
+                   {\r
+                     // logger.debug("Found features for " + acc);\r
+                     features = (Hashtable) ann.get("features");\r
+                   }\r
+                   else\r
+                   {\r
+                     // logger.debug("Creating new features holder for " + acc);\r
+                     features = new Hashtable();\r
+                     ann.put("features", features);\r
+                   }\r
+       \r
+                   Hashtable content;\r
+                   if (features.containsKey(this.id2type(type)))\r
+                   {\r
+                     // logger.debug("Found content for " + this.id2type(type));\r
+                     content = (Hashtable) features.get(this.id2type(type));\r
+                   }\r
+                   else\r
+                   {\r
+                     // logger.debug("Creating new content holder for " +\r
+                     // this.id2type(type));\r
+                     content = new Hashtable();\r
+                     features.put(this.id2type(type), content);\r
+                   }\r
+                   String ns = (String) content.get(description);\r
+                   if (ns == null)\r
+                   {\r
+                     ns = "";\r
+                   }\r
+                   ns += seq;\r
+                   content.put(description, ns);\r
+       \r
+//                 if(type.equals("SS")){\r
+                       Hashtable strucAnn;\r
+                       if (seqAnn.containsKey(acc))\r
+                       {\r
+                         strucAnn = (Hashtable) seqAnn.get(acc);\r
+                       }\r
+                       else\r
+                       {\r
+                         strucAnn = new Hashtable();\r
+                       }\r
+                       \r
+                       Vector newStruc=new Vector();\r
+                       parseAnnotationRow(newStruc, type,ns);\r
+                       \r
+                       strucAnn.put(type, newStruc);\r
+                       seqAnn.put(acc, strucAnn);\r
+                    }\r
+//               }\r
+                       else\r
+                       {\r
+                                               System.err\r
+                                               .println("Warning - couldn't parse sequence annotation row line:\n"\r
+                                               + line);\r
+                       // throw new IOException("Error parsing " + line);\r
+                       }\r
+                       }\r
+                       else\r
+                       {\r
+                       throw new IOException("Unknown annotation detected: " + annType\r
+                               + " " + annContent);\r
+                       }\r
+                       }\r
+               }\r
+               if (treeString.length() > 0)\r
+               {\r
+               if (treeName == null)\r
+               {\r
+                       treeName = "Tree " + (1 + getTreeCount());\r
+               }\r
+               addNewickTree(treeName, treeString.toString());\r
+               }\r
+       }\r
 \r
-  /**\r
+/**\r
    * Demangle an accession string and guess the originating sequence database for a given sequence\r
    * @param seqO sequence to be annotated\r
    * @param dbr Accession string for sequence\r
@@ -736,12 +744,12 @@ public class StockholmFile extends AlignFile
       for (DBRefEntry d:dbrs)\r
       {\r
         jalview.util.MapList mp = new jalview.util.MapList(new int[] { seqO.getStart(),seqO.getEnd()},new int[] { st,en},1,1);\r
-        jalview.datamodel.Mapping mping = new jalview.datamodel.Mapping(mp);\r
+        jalview.datamodel.Mapping mping = new Mapping(mp);\r
         d.setMap(mping);\r
       }\r
     }\r
   }\r
-  \r
+\r
   protected static AlignmentAnnotation parseAnnotationRow(\r
           Vector annotation, String label, String annots)\r
   {\r
@@ -758,12 +766,12 @@ public class StockholmFile extends AlignFile
     convert2 = closeparen.replaceAll(convert1);\r
     annots = convert2;\r
 \r
-    String type = label;
-    if (label.contains("_cons"))
-    {
-      type = (label.indexOf("_cons") == label.length() - 5) ? label
-            .substring(0, label.length() - 5) : label;\r
-    }
+    String type = label;\r
+    if (label.contains("_cons"))\r
+    {\r
+      type = (label.indexOf("_cons") == label.length() - 5) ? label\r
+              .substring(0, label.length() - 5) : label;\r
+    }\r
     boolean ss = false;\r
     type = id2type(type);\r
     if (type.equals("secondary structure"))\r
@@ -1072,7 +1080,7 @@ public class StockholmFile extends AlignFile
             + id);\r
     return id;\r
   }\r
-  \r
+\r
   protected static String type2id(String type)\r
   {\r
     String key = null;\r
@@ -1093,7 +1101,7 @@ public class StockholmFile extends AlignFile
     System.err.println("Warning : Unknown Stockholm annotation type: "\r
             + type);\r
     return key;\r
-  }\r
+  }
   /**\r
    * make a friendly ID string.\r
    * \r
@@ -1112,4 +1120,4 @@ public class StockholmFile extends AlignFile
     dataName = dataName.substring(1, e).trim();\r
     return dataName;\r
   }\r
-}
\ No newline at end of file
+}\r
index ad5f52a..c020d99 100644 (file)
@@ -86,9 +86,7 @@ import java.util.regex.Pattern;
  * @author Paolo Di Tommaso
  * 
  */
-public class TCoffeeScoreFile extends AlignFile
-{
-
+public class TCoffeeScoreFile extends AlignFile {
   public TCoffeeScoreFile(String inFile, String type) throws IOException
   {
     super(inFile, type);
index 23726df..6d00118 100644 (file)
@@ -174,7 +174,7 @@ public class AnnotationRenderer
   private boolean canClip=false;
 
   
-  public void drawNotCanonicalAnnot(Graphics g, Color nonCanColor, Annotation[] row_annotations,
+  public void drawPseudoNode(Graphics g, Color nonCanColor, Annotation[] row_annotations,
           int lastSSX, int x, int y, int iconOffset, int startRes,
           int column, boolean validRes, boolean validEnd)
   {
@@ -184,7 +184,7 @@ public class AnnotationRenderer
     int sCol = (lastSSX / charWidth) + startRes;
     int x1 = lastSSX;
     int x2 = (x * charWidth);
-    Regex closeparen = new Regex("}|]|<|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z");
+    Regex closeparen = new Regex("}|]|<|[a-z]");
     
     String dc = (column == 0 || row_annotations[column - 1] == null) ? ""
             : row_annotations[column - 1].displayCharacter;
@@ -364,6 +364,7 @@ public class AnnotationRenderer
     updateFromAwtRenderPanel(annotPanel, av);
     fm = g.getFontMetrics();
     AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
+    int temp = 0;
     if (aa==null)
     {
       return false;
@@ -626,267 +627,50 @@ public class AnnotationRenderer
                
              }
            }
-           if (ss == 'A')
+           if (ss >=65)
            {
+                 // System.out.println("ss="+ss);
              // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('a') > -1)
+             if (row_annotations[column].displayCharacter.indexOf(ss+32) > -1)
              {
-               ss = 'a';
+            
+               ss = (char) (ss+32);
               
                
              }
            }
+
            
-           if (ss == 'B')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('b') > -1)
-             {
-               ss = 'b';
-               
-             }
-           }
-           
-           if (ss == 'C')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('c') > -1)
-             {
-               ss = 'c';
-               
-             }
-           }
-           if (ss == 'D')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('d') > -1)
-             {
-               ss = 'd';
-               
-             }
-           }
-           if (ss == '1')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('e') > -1)
-             {
-               ss = 'e';
-               
-             }
-           }
-           if (ss == 'F')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('f') > -1)
-             {
-               ss = 'f';
-               
-             }
-           }
-           if (ss == 'G')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('g') > -1)
-             {
-               ss = 'g';
-               
-             }
-           }
-           if (ss == '2')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('h') > -1)
-             {
-               ss = 'h';
-               
-             }
-           }
-           if (ss == 'I')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('i') > -1)
-             {
-               ss = 'i';
-               
-             }
-           }
-           if (ss == 'J')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('j') > -1)
-             {
-               ss = 'j';
-               
-             }
-           }
-           if (ss == 'K')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('k') > -1)
-             {
-               ss = 'k';
-               
-             }
-           }
-           if (ss == 'L')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('l') > -1)
-             {
-               ss = 'l';
-               
-             }
-           }
-           if (ss == 'M')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('m') > -1)
-             {
-               ss = 'm';
-               
-             }
-           }
-           if (ss == 'N')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('n') > -1)
-             {
-               ss = 'n';
-               
-             }
-           }
-           if (ss == 'O')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('o') > -1)
-             {
-               ss = 'o';
-               
-             }
-           }
-           if (ss == 'P')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('p') > -1)
-             {
-               ss = 'p';
-               
-             }
-           }
-           if (ss == 'Q')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('q') > -1)
-             {
-               ss = 'q';
-               
-             }
-           }
-           if (ss == 'R')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('r') > -1)
-             {
-               ss = 'r';
-               
-             }
-           }
-           if (ss == 'S')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('s') > -1)
-             {
-               ss = 's';
-               
-             }
-           }
-           if (ss == 'T')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('t') > -1)
-             {
-               ss = 't';
-               
-             }
-           }
-           if (ss == 'U')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('u') > -1)
-             {
-               ss = 'u';
-               
-             }
-           }
-           if (ss == 'V')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('v') > -1)
-             {
-               ss = 'v';
-               
-             }
-           }
-           if (ss == 'W')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('w') > -1)
-             {
-               ss = 'w';
-               
-             }
-           }
-           if (ss == 'X')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('x') > -1)
-             {
-               ss = 'x';
-               
-             }
-           }
-           if (ss == 'Y')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('y') > -1)
-             {
-               ss = 'y';
-               
-             }
-           }
-           if (ss == 'Z')
-           {
-             // distinguish between forward/backward base-pairing
-             if (row_annotations[column].displayCharacter.indexOf('z') > -1)
-             {
-               ss = 'z';
-               
-             }
-           }
           if (!validRes || (ss != lastSS))
           {
+                 
+     
             if (x > -1)
             {
+        
+               
+              int nb_annot=x-temp;
+              //System.out.println("\t type :"+lastSS+"\t x :"+x+"\t nbre annot :"+nb_annot);
               switch (lastSS)
               {
-              case 'H':
-                drawHelixAnnot(g, row_annotations, lastSSX, x, y,
-                        iconOffset, startRes, column, validRes, validEnd);
+              
+              case '$':
+                drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
+                        column, validRes, validEnd);
                 break;
 
-              case 'E':
-                drawSheetAnnot(g, row_annotations, lastSSX, x, y,
-                        iconOffset, startRes, column, validRes, validEnd);
+              case 'µ':
+                drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
+                        column, validRes, validEnd);
                 break;
 
               case '(': // Stem case for RNA secondary structure
               case ')': // and opposite direction
+                 
+                 
                 drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
                         column, validRes, validEnd);
-//              case 'S': // Stem case for RNA secondary structure
-//              case 's': // and opposite direction
-//                drawStemAnnot(g, row_annotations, lastSSX, x, y,
-//                        iconOffset, startRes, column, validRes, validEnd);
+                temp=x;
                 break;
               case '{':
               case '}':
@@ -902,13 +686,13 @@ public class AnnotationRenderer
               case 'c':
               case 'D':
               case 'd':
-              case '1':
+              case 'E':
               case 'e':
               case 'F':
               case 'f':
               case 'G':
               case 'g':
-              case '2':
+              case 'H':
               case 'h':
               case 'I':
               case 'i':
@@ -946,16 +730,17 @@ public class AnnotationRenderer
               case 'y':
               case 'Z':
               case 'z':
-                 //System.out.println(lastSS);
+                 
                  Color nonCanColor= getNotCanonicalColor(lastSS);
-                 drawNotCanonicalAnnot(g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes,
+                 drawPseudoNode(g, nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes,
                           column, validRes, validEnd);
+                 temp=x;
                  break;
               default:
                 g.setColor(Color.gray);
                 g.fillRect(lastSSX, y + 6 + iconOffset, (x * charWidth)
                         - lastSSX, 2);
-
+                temp=x;
                 break;
               }
             }
@@ -1001,19 +786,21 @@ public class AnnotationRenderer
       {
         switch (lastSS)
         {
-        case 'H':
-          drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
-                  startRes, column, validRes, validEnd);
+        case '$':
+          drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
+                  column, validRes, validEnd);
           break;
 
-        case 'E':
-          drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
-                  startRes, column, validRes, validEnd);
+        case 'µ':
+          drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
+                  column, validRes, validEnd);
           break;
         case 's':
         case 'S': // Stem case for RNA secondary structure
-          drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
-                  startRes, column, validRes, validEnd);
+               
+          drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
+                  column, validRes, validEnd);
+          
           break;
         case '{':
         case '}':
@@ -1029,13 +816,13 @@ public class AnnotationRenderer
         case 'c':
         case 'D':
         case 'd':
-        case '1':
+        case 'E':
         case 'e':
         case 'F':
         case 'f':
         case 'G':
         case 'g':
-        case '2':
+        case 'H':
         case 'h':
         case 'I':
         case 'i':
@@ -1072,13 +859,16 @@ public class AnnotationRenderer
         case 'Z':
         case 'z':
                //System.out.println(lastSS);
+               
           Color nonCanColor = getNotCanonicalColor(lastSS);
-         drawNotCanonicalAnnot(g,nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes,
+         drawPseudoNode(g,nonCanColor, row_annotations, lastSSX, x, y, iconOffset, startRes,
                     column, validRes, validEnd);
+       
          break;
+         
         default:
-          drawGlyphLine(g, row_annotations, lastSSX, x, y, iconOffset,
-                  startRes, column, validRes, validEnd);
+          drawGlyphLine(g, row_annotations, lastSSX, x, y, iconOffset, startRes,
+                  column, validRes, validEnd);
           break;
         }
       }
@@ -1102,6 +892,7 @@ public class AnnotationRenderer
               {
                 aa[gg].visible = false;
               }
+
               if (aa[gg].graphMax > groupmax)
               {
                 groupmax = aa[gg].graphMax;
@@ -1116,8 +907,8 @@ public class AnnotationRenderer
             {
               if (aa[gg].graphGroup == row.graphGroup)
               {
-                drawLineGraph(g, aa[gg], aa[gg].annotations, startRes,
-                        endRes, y, groupmin, groupmax, row.graphHeight);
+                drawLineGraph(g, aa[gg], aa[gg].annotations, startRes, endRes, y, groupmin,
+                        groupmax, row.graphHeight);
               }
             }
 
@@ -1125,14 +916,14 @@ public class AnnotationRenderer
           }
           else
           {
-            drawLineGraph(g, row, row_annotations, startRes, endRes, y,
-                    row.graphMin, row.graphMax, row.graphHeight);
+            drawLineGraph(g, row, row_annotations, startRes, endRes, y, row.graphMin,
+                    row.graphMax, row.graphHeight);
           }
         }
         else if (row.graph == AlignmentAnnotation.BAR_GRAPH)
         {
-          drawBarGraph(g, row, row_annotations, startRes, endRes,
-                  row.graphMin, row.graphMax, y);
+          drawBarGraph(g, row, row_annotations, startRes, endRes, row.graphMin,
+                  row.graphMax, y);
         }
       }
     } else {
@@ -1185,17 +976,18 @@ public class AnnotationRenderer
   
   private  Color sdNOTCANONICAL_COLOUR;
 
-  public void drawGlyphLine(Graphics g, Annotation[] row, int lastSSX,
-          int x, int y, int iconOffset, int startRes, int column,
-          boolean validRes, boolean validEnd)
+  public void drawGlyphLine(Graphics g, Annotation[] row,
+          int lastSSX, int x, int y, int iconOffset, int startRes,
+          int column, boolean validRes, boolean validEnd)
   {
     g.setColor(GLYPHLINE_COLOR);
     g.fillRect(lastSSX, y + 6 + iconOffset, (x * charWidth) - lastSSX, 2);
   }
 
-  public void drawSheetAnnot(Graphics g, Annotation[] row, int lastSSX,
-          int x, int y, int iconOffset, int startRes, int column,
-          boolean validRes, boolean validEnd)
+  public void drawSheetAnnot(Graphics g, Annotation[] row,
+
+          int lastSSX, int x, int y, int iconOffset, int startRes,
+          int column, boolean validRes, boolean validEnd)
   {
     g.setColor(SHEET_COLOUR);
 
@@ -1573,122 +1365,122 @@ public class AnnotationRenderer
       {
          case '{':  
              case '}':
-                 return Color.cyan;
+                 return new Color(255,125,5);
                 
              case '[':
              case ']':
-                 return Color.green;
+                 return new Color(245,115,10);
                 
              case '>':
              case '<':
-                 return Color.magenta;
+                 return new Color(235,135,15);
                  
              case 'A':
              case 'a':
-                 return Color.orange;
+                 return new Color(225,105,20);
                
              case 'B':
              case 'b':
-                 return Color.pink;
+                 return new Color(215,145,30);
                  
              case 'C':
              case 'c':
-                 return Color.red;
+                 return new Color(205,95,35);
                 
              case 'D':
              case 'd':
-                 return Color.yellow;
+                 return new Color(195,155,45);
                  
-             case '1':
+             case 'E':
              case 'e':
-                 return Color.black;
+                 return new Color(185,85,55);
                 
              case 'F':
              case 'f':
-                 return Color.darkGray;
+                 return new Color(175,165,65);
                 
              case 'G':
              case 'g':
-                 return Color.gray;
+                 return new Color(170,75,75);
                
-             case '2':
+             case 'H':
              case 'h':
-                 return Color.lightGray;
+                 return new Color(160,175,85);
                  
              case 'I':
              case 'i':
-                 return Color.white;
+                 return new Color(150,65,95);
                 
              case 'J':
              case 'j':
-                 return Color.cyan;
+                 return new Color(140,185,105);
                  
              case 'K':
              case 'k':
-                 return Color.magenta;
+                 return new Color(130,55,110);
                
              case 'L':
              case 'l':
-                 return Color.orange;
+                 return new Color(120,195,120);
        
              case 'M':
              case 'm':
-                 return Color.red;
+                 return new Color(110,45,130);
                
              case 'N':
              case 'n':
-                 return Color.yellow;
+                 return new Color(100,205,140);
                  
              case 'O':
              case 'o':
-                 return Color.pink;
+                 return new Color(90,35,150);
                
              case 'P':
              case 'p':
-                 return Color.black;
+                 return new Color(85,215,160);
                
              case 'Q':
              case 'q':
-                 return Color.blue;
+                 return new Color(75,25,170);
        
              case 'R':
              case 'r':
-                 return Color.cyan;
+                 return new Color(65,225,180);
        
              case 'S':
              case 's':
-                 return Color.magenta;
+                 return new Color(55,15,185);
                
              case 'T':
              case 't':
-                 return Color.darkGray;
+                 return new Color(45,235,195);
                 
              case 'U':
              case 'u':
-                 return Color.yellow;
+                 return new Color(35,5,205);
                  
              case 'V':
              case 'v':
-                 return Color.blue;
+                 return new Color(25,245,215);
                 
              case 'W':
              case 'w':
-                 return Color.orange;
+                 return new Color(15,0,225);
                  
              case 'X':
              case 'x':
-                 return Color.magenta;
+                 return new Color(10,255,235);
                 
              case 'Y':
              case 'y':
-                 return Color.blue;
+                 return new Color(5,150,245);
                  
              case 'Z':
              case 'z':
-                 return Color.blue;
+                 return new Color(0,80,255);
                 
        default :
-               System.out.println("This is not a interaction");
+               System.out.println("This is not a interaction : "+lastss);
                return null;
                
       }
index 4132f32..f748c96 100755 (executable)
@@ -246,10 +246,7 @@ public class ColourSchemeProperty
     {
       index = TCOFFEE;
     }
-    else if (cs instanceof RNAInteractionColourScheme)
-    {
-      index = RNAINTERACTION;
-    }
+   
     
     
     /*
@@ -504,14 +501,12 @@ public class ColourSchemeProperty
       cs = new TCoffeeColourScheme(coll);
       break;
       
-    case RNAINTERACTION:
-        cs = new RNAInteractionColourScheme();
-        break;
+
       
     // case COVARIATION:
     // cs = new CovariationColourScheme(annotation);
 
-      // break;
+    // break;
 
     case USER_DEFINED:
       Color[] col = new Color[24];
index d360995..c131e76 100755 (executable)
@@ -1606,7 +1606,7 @@ public class ResidueProperties
   public static Hashtable toRNAssState;
   static
   {
-    toRNAssState = new Hashtable();
+       toRNAssState = new Hashtable<String,String>();
     toRNAssState.put(")", "(");
     toRNAssState.put("(", "(");
     toRNAssState.put("]", "[");
@@ -1623,14 +1623,14 @@ public class ResidueProperties
     toRNAssState.put("c", "C");
     toRNAssState.put("D", "D");
     toRNAssState.put("d", "D");
-    toRNAssState.put("1", "1");
-    toRNAssState.put("e", "1");
+    toRNAssState.put("E", "E");
+    toRNAssState.put("e", "E");
     toRNAssState.put("F", "F");
     toRNAssState.put("f", "F");
     toRNAssState.put("G", "G");
     toRNAssState.put("g", "G");
-    toRNAssState.put("2", "2");
-    toRNAssState.put("h", "2");
+    toRNAssState.put("H", "H");
+    toRNAssState.put("h", "H");
     toRNAssState.put("I", "I");
     toRNAssState.put("i", "I");
     toRNAssState.put("J", "J");
index a30a9a1..e90b2d2 100644 (file)
@@ -31,6 +31,7 @@ import java.io.Reader;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLEncoder;
+import java.util.Iterator;
 
 public class Annotate3D
 {
@@ -76,12 +77,21 @@ public class Annotate3D
           sb.append(cbuff[i]);
         }
       }
-
-      FileParse fp = new InputStreamParser(
-              jalview.ext.paradise.Annotate3D.getRNAMLForPDBFileAsString(sb
-                      .toString()), source.getDataName());
-      AlignmentI nal = new FormatAdapter().readFromFile(fp, "RNAML");
-      return nal;
+      Iterator<Reader> r = jalview.ext.paradise.Annotate3D
+              .getRNAMLForPDBFileAsString(sb.toString());
+      AlignmentI al=null;
+      while (r.hasNext())
+      {
+        FileParse fp = new InputStreamParser(r.next(), source.getDataName());
+        AlignmentI nal = new FormatAdapter().readFromFile(fp, "RNAML");
+        if (al==null)
+        {
+          al = nal;
+        } else {
+          al.append(nal);
+        }
+      }
+      return al;
     } catch (Throwable x)
     {
       if (x instanceof IOException)
index 1ed46f4..702d9ad 100644 (file)
@@ -10,6 +10,8 @@ import jalview.io.FormatAdapter;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.Reader;
+import java.util.Iterator;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -24,13 +26,17 @@ public class TestAnnotate3D
   @Test
   public void testIdVsContent() throws Exception
   {
-    BufferedReader id = (BufferedReader) Annotate3D
+    Iterator<Reader> ids = Annotate3D
             .getRNAMLForPDBId("2GIS");
-    assertTrue("Didn't retrieve 2GIS by id.", id != null);
-    BufferedReader file = (BufferedReader) Annotate3D
+    assertTrue("Didn't retrieve 2GIS by id.", ids != null);
+    Iterator<Reader> files = Annotate3D
             .getRNAMLForPDBFileAsString(FileUtil.readFileToString(new File(
                     "examples/2GIS.pdb")));
-    assertTrue("Didn't retrieve using examples/2GIS.pdb.", file != null);
+    assertTrue("Didn't retrieve using examples/2GIS.pdb.", files != null);
+    int i=0;
+    while (ids.hasNext() && files.hasNext())
+    {
+      BufferedReader file=new BufferedReader(files.next()), id=new BufferedReader(ids.next());
     String iline, fline;
     do
     {
@@ -40,12 +46,13 @@ public class TestAnnotate3D
         System.out.println(iline);
       if (fline != null)
         System.out.println(fline);
-
-      assertTrue("Results differ for ID and file upload based retrieval",
+      // next assert fails for latest RNAview - because the XMLID entries change between file and ID based RNAML generation.
+      assertTrue("Results differ for ID and file upload based retrieval (chain entry "+(++i)+")",
               ((iline == fline && iline == null) || (iline != null
                       && fline != null && iline.equals(fline))));
 
     } while (iline != null);
+    }
   }
 
   /**
@@ -62,39 +69,46 @@ public class TestAnnotate3D
     StringBuffer sb = new StringBuffer();
     // Comment - should add new FileParse constructor like new FileParse(Reader
     // ..). for direct reading
-    BufferedReader br = new BufferedReader(
-            Annotate3D.getRNAMLForPDBFileAsString(FileUtil
-                    .readFileToString(new File("examples/2GIS.pdb"))));
-    String line;
-    while ((line = br.readLine()) != null)
+    Iterator<Reader> readers = Annotate3D
+            .getRNAMLForPDBFileAsString(FileUtil.readFileToString(new File(
+                    "examples/2GIS.pdb")));
+    int r=0;
+    while (readers.hasNext())
     {
-      sb.append(line + "\n");
-    }
-    assertTrue("No data returned by Annotate3D", sb.length() > 0);
-    AlignmentI al = new FormatAdapter().readFile(sb.toString(),
-            FormatAdapter.PASTE, "RNAML");
+      System.out.println("Testing RNAML input number "+(++r));
+      BufferedReader br = new BufferedReader(readers.next());
+      String line;
+      while ((line = br.readLine()) != null)
+      {
+        sb.append(line + "\n");
+      }
+      assertTrue("No data returned by Annotate3D", sb.length() > 0);
+      AlignmentI al = new FormatAdapter().readFile(sb.toString(),
+              FormatAdapter.PASTE, "RNAML");
 
-    assertTrue("No alignment returned.", al != null);
-    assertTrue("No sequences in returned alignment.", al.getHeight() > 0);
-    for (SequenceI sq : al.getSequences())
-    {
+      assertTrue("No alignment returned.", al != null);
+      assertTrue("No sequences in returned alignment.", al.getHeight() > 0);
+      for (SequenceI sq : al.getSequences())
       {
-        SequenceI struseq = null;
-        String sq_ = new String(sq.getSequence()).toLowerCase();
-        for (SequenceI _struseq : pdbf.getSeqsAsArray())
         {
-          if (new String(_struseq.getSequence()).toLowerCase().equals(sq_))
+          SequenceI struseq = null;
+          String sq_ = new String(sq.getSequence()).toLowerCase();
+          for (SequenceI _struseq : pdbf.getSeqsAsArray())
           {
-            struseq = _struseq;
-            break;
+            if (new String(_struseq.getSequence()).toLowerCase()
+                    .equals(sq_))
+            {
+              struseq = _struseq;
+              break;
+            }
+          }
+          if (struseq == null)
+          {
+            Assert.fail("Couldn't find this sequence in original input:\n"
+                    + new FastaFile().print(new SequenceI[]
+                    { sq }) + "\n\nOriginal input:\n"
+                    + new FastaFile().print(pdbf.getSeqsAsArray()) + "\n");
           }
-        }
-        if (struseq == null)
-        {
-          Assert.fail("Couldn't find this sequence in original input:\n"
-                  + new FastaFile().print(new SequenceI[]
-                  { sq }) + "\n\nOriginal input:\n"
-                  + new FastaFile().print(pdbf.getSeqsAsArray()) + "\n");
         }
       }
     }
diff --git a/test/jalview/io/RNAMLfileTest.java b/test/jalview/io/RNAMLfileTest.java
new file mode 100644 (file)
index 0000000..282914b
--- /dev/null
@@ -0,0 +1,31 @@
+package jalview.io;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class RNAMLfileTest
+{
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception
+  {
+  }
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception
+  {
+  }
+
+  @Test
+  public void testRnamlToStockholmIO()
+  {
+    StockholmFileTest.testFileIOwithFormat(new File("examples/rna-alignment.xml"),"STH");
+    
+  }
+
+}