JAL-842; trimming single structures for single sequences added;
authorjanengelhardt <engelhardt87@googlemail.com>
Mon, 11 Jul 2011 01:20:30 +0000 (03:20 +0200)
committerjanengelhardt <engelhardt87@googlemail.com>
Mon, 25 Jul 2011 12:58:34 +0000 (14:58 +0200)
Change-Id: I041c71aafd0081875b948b9978c2411154033408

src/jalview/gui/AppVarna.java
src/jalview/gui/AppVarnaBinding.java

index 012d0d1..5dd65c4 100644 (file)
@@ -38,6 +38,8 @@ import fr.orsay.lri.varna.exceptions.ExceptionNonEqualLength;
 import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses;
 import fr.orsay.lri.varna.interfaces.InterfaceVARNAListener;
 import fr.orsay.lri.varna.models.VARNAConfig;
+import fr.orsay.lri.varna.models.rna.ModeleBaseNucleotide;
+import fr.orsay.lri.varna.models.rna.ModeleStyleBP;
 import fr.orsay.lri.varna.models.rna.RNA;
 
 
@@ -65,8 +67,10 @@ public class AppVarna extends JInternalFrame implements InterfaceVARNAListener//
          } catch (ExceptionFileFormatOrSyntax e3) {
                e3.printStackTrace();
          }
+         rnaList.add(trimRNA(rna1));     
          rnaList.add(rna1);
-         rnaList.add(trimRNA(rna1));
+         rna1.setName("consenus_"+rna1.getName());
+         
          
          vab = new AppVarnaBinding(rnaList);
          //vab = new AppVarnaBinding(seq,struc);
@@ -90,28 +94,47 @@ public class AppVarna extends JInternalFrame implements InterfaceVARNAListener//
   }
   
   public RNA trimRNA(RNA rna){
-         RNA rnaTrim = new RNA(rna.getName()+"_trim");
-         String seq=rna.getSeq();
-         String struc=rna.getStructDBN();
-         String newSeq="";
-         String newStruc="";
-         for(int i=0;i<seq.length();i++){
-                 if(seq.substring(i, i+1).compareTo("-")!=0){
-                         newSeq=newSeq+seq.substring(i, i+1);
-                         newStruc=newStruc+struc.substring(i,i+1);
+         RNA rnaTrim = new RNA("trim_"+rna.getName());
+         try {
+                 rnaTrim.setRNA(rna.getSeq(),rna.getStructDBN());
+         } catch (ExceptionUnmatchedClosingParentheses e2) {
+               e2.printStackTrace();
+         } catch (ExceptionFileFormatOrSyntax e3) {
+               e3.printStackTrace();
+         }
+
+         StringBuffer seq=new StringBuffer(rnaTrim.getSeq());
+         StringBuffer struc=new StringBuffer(rnaTrim.getStructDBN());
+         for(int i=0;i<rnaTrim.getSeq().length();i++){
+                 if(seq.substring(i, i+1).compareTo("-")==0 || seq.substring(i, i+1).compareTo(".")==0){
+                         if(!rnaTrim.findPair(i).isEmpty()){
+                                 System.out.println(rnaTrim.findPair(i));
+                                 int m=rnaTrim.findPair(i).get(1);
+                                 int l=rnaTrim.findPair(i).get(0);
+                                 
+                                 struc.replace(m, m+1, "*");
+                                 struc.replace(l, l+1, "*");
+                         }else{
+                                 struc.replace(i, i+1, "*");
+                         }
                  }
          }
+        
+         String newSeq=rnaTrim.getSeq().replace("-", "");
+         rnaTrim.getSeq().replace(".", "");
+         String newStruc=struc.toString().replace("*", "");
+
          try {
                rnaTrim.setRNA(newSeq,newStruc);
-       } catch (ExceptionUnmatchedClosingParentheses e) {
+         } catch (ExceptionUnmatchedClosingParentheses e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
-       } catch (ExceptionFileFormatOrSyntax e) {
+         } catch (ExceptionFileFormatOrSyntax e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
-       }
-       //System.out.println(newSeq+"\t"+newStruc);
-       return rnaTrim;
+         }
+         
+         return rnaTrim;
   }
 
   public void showPanel(boolean show){
index 092e850..1d2d8fd 100644 (file)
@@ -234,9 +234,9 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
                vp.setPreferredSize(new Dimension(400, 400));
                for(int i=0;i<rnaInList.size();i++){
                        if(i<rnaInList.size()-1){
-                               _rnaList.add(vp.getConfig().clone(),rnaInList.get(i),generateDefaultName());
+                               _rnaList.add(vp.getConfig().clone(),rnaInList.get(i),rnaInList.get(i).getName());
                        }else{
-                               _rnaList.add(vp.getConfig().clone(),rnaInList.get(i),generateDefaultName(),true);
+                               _rnaList.add(vp.getConfig().clone(),rnaInList.get(i),rnaInList.get(i).getName(),true);
                        }
                }