JAL-842; Give Varna frames name for window organizer; always display
authorjanengelhardt <engelhardt87@googlemail.com>
Fri, 1 Jul 2011 14:57:01 +0000 (16:57 +0200)
committerjanengelhardt <engelhardt87@googlemail.com>
Mon, 25 Jul 2011 12:58:34 +0000 (14:58 +0200)
the consensus structure and the 'trimmed' structure for a sequence;

Change-Id: If4e9b054455de3c0f43967e27fb399df4c23b751

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

index 7a1e206..012d0d1 100644 (file)
@@ -48,7 +48,7 @@ public class AppVarna extends JInternalFrame implements InterfaceVARNAListener//
 
   VARNAPanel varnaPanel;
   
-  String name;
+  public String name;
   
   /*public AppVarna(){
          vab = new AppVarnaBinding(); 
@@ -60,36 +60,62 @@ public class AppVarna extends JInternalFrame implements InterfaceVARNAListener//
          RNA rna1 = new RNA(name);
          try {
                  rna1.setRNA(seq,struc);
-        } catch (ExceptionUnmatchedClosingParentheses e2) {
+         } catch (ExceptionUnmatchedClosingParentheses e2) {
                e2.printStackTrace();
          } catch (ExceptionFileFormatOrSyntax e3) {
                e3.printStackTrace();
          }
          rnaList.add(rna1);
+         rnaList.add(trimRNA(rna1));
          
          vab = new AppVarnaBinding(rnaList);
          //vab = new AppVarnaBinding(seq,struc);
-         name=this.name;
+         //System.out.println("Hallo: "+name);
+         this.name=name;
          initVarna();    
   }
   
   public void initVarna(){
-         //TODO: Why is it not possible to include varnaPanel in the AppVarna-Jframe?
          //vab.setFinishedInit(false);
          varnaPanel=vab.get_varnaPanel();
          setBackground(Color.white);
+         JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,vab.getListPanel(),varnaPanel);
          getContentPane().setLayout(new BorderLayout());
-         getContentPane().add(varnaPanel, BorderLayout.CENTER);
-         
+         getContentPane().add(split, BorderLayout.CENTER);
+         //getContentPane().add(vab.getTools(), BorderLayout.NORTH);   
          varnaPanel.addVARNAListener(this);
-         jalview.gui.Desktop.addInternalFrame(this,name,getBounds().width, getBounds().height);
+         jalview.gui.Desktop.addInternalFrame(this,"VARNA -"+name,getBounds().width, getBounds().height);
          this.pack();
-         this.setVisible(true);
-         //showPanel(true);
+         showPanel(true);
   }
   
+  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);
+                 }
+         }
+         try {
+               rnaTrim.setRNA(newSeq,newStruc);
+       } catch (ExceptionUnmatchedClosingParentheses e) {
+               // TODO Auto-generated catch block
+               e.printStackTrace();
+       } catch (ExceptionFileFormatOrSyntax e) {
+               // TODO Auto-generated catch block
+               e.printStackTrace();
+       }
+       //System.out.println(newSeq+"\t"+newStruc);
+       return rnaTrim;
+  }
+
   public void showPanel(boolean show){
-         varnaPanel.setVisible(show);
+         this.setVisible(show);
   }
   
   private boolean _started = false;
index 54ca3b3..092e850 100644 (file)
@@ -80,12 +80,12 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
         */
        //private static final long serialVersionUID = -790155708306987257L;
 
-       //private String DEFAULT_SEQUENCE = "CAGCACGACACUAGCAGUCAGUGUCAGACUGCAIACAGCACGACACUAGCAGUCAGUGUCAGACUGCAIACAGCACGACACUAGCAGUCAGUGUCAGACUGCAIA";
-       //private String DEFAULT_STRUCTURE1 = "..(((((...(((((...(((((...(((((.....)))))...))))).....(((((...(((((.....)))))...))))).....)))))...)))))..";
-       //private String DEFAULT_STRUCTURE2 = "..(((((...(((((...(((((........(((((...(((((.....)))))...)))))..................))))).....)))))...)))))..";
+       private String DEFAULT_SEQUENCE = "CAGCACGACACUAGCAGUCAGUGUCAGACUGCAIACAGCACGACACUAGCAGUCAGUGUCAGACUGCAIACAGCACGACACUAGCAGUCAGUGUCAGACUGCAIA";
+       private String DEFAULT_STRUCTURE1 = "..(((((...(((((...(((((...(((((.....)))))...))))).....(((((...(((((.....)))))...))))).....)))))...)))))..";
+       private String DEFAULT_STRUCTURE2 = "..(((((...(((((...(((((........(((((...(((((.....)))))...)))))..................))))).....)))))...)))))..";
        public VARNAPanel vp;
 
-       private JPanel _tools = new JPanel();
+       protected JPanel _tools = new JPanel();
        private JPanel _input = new JPanel();
 
        private JPanel _seqPanel = new JPanel();
@@ -99,7 +99,7 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
        private JButton _deleteButton = new JButton("Delete");
        private JButton _duplicateButton = new JButton("Snapshot");
        
-       private JPanel _listPanel = new JPanel();
+       protected JPanel _listPanel = new JPanel();
        private ReorderableJList _sideList = null;
 
 
@@ -131,9 +131,9 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
                initVarna(seq,struc);
        }
        
-       public AppVarnaBinding(ArrayList<RNA> rnalist){
+       public AppVarnaBinding(ArrayList<RNA> rnaList){
                //super("VARNA in Jalview");
-               initVarnaEdit(rnalist);
+               initVarnaEdit(rnaList);
        }
        
        
@@ -195,7 +195,7 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
            DefaultListModel dlm = new DefaultListModel(); 
            
 
-               int marginTools = 40;
+               //int marginTools = 40;
 
            DefaultListSelectionModel m = new DefaultListSelectionModel();
            m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
@@ -215,13 +215,14 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
                                        FullBackup  sel = (FullBackup) _sideList.getSelectedValue();
                                        Mapping map = Mapping.DefaultOutermostMapping(vp.getRNA().getSize(), sel.rna.getSize());
                                        vp.showRNAInterpolated(sel.rna,sel.config,map);
-                                       _seq.setText(sel.rna.getSeq());
-                                       _str.setText(sel.rna.getStructDBN());
+                                       //_seq.setText(sel.rna.getSeq());
+                                       //_str.setText(sel.rna.getStructDBN());
                                }
                        }
            });
-
+           
            _rnaList = new BackupHolder(dlm,_sideList);
+                       
                try {
                        vp = new VARNAPanel("0",".");
                        for(int i=0;i<rnaInList.size();i++){
@@ -232,18 +233,22 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
                } 
                vp.setPreferredSize(new Dimension(400, 400));
                for(int i=0;i<rnaInList.size();i++){
-                       _rnaList.add(vp.getConfig().clone(),rnaInList.get(i),generateDefaultName(),true);
+                       if(i<rnaInList.size()-1){
+                               _rnaList.add(vp.getConfig().clone(),rnaInList.get(i),generateDefaultName());
+                       }else{
+                               _rnaList.add(vp.getConfig().clone(),rnaInList.get(i),generateDefaultName(),true);
+                       }
                }
+
            /*_rnaList.add(vp.getConfig().clone(),_RNA2,generateDefaultName());
            _rnaList.add(vp.getConfig().clone(),_RNA1,generateDefaultName(),true);*/
 
            JScrollPane listScroller = new JScrollPane(_sideList);
            listScroller.setPreferredSize(new Dimension(150, 0));
 
-               //TODO setBackground(_backgroundColor);
                vp.setBackground(_backgroundColor);
-
-
+               
+               /*
                Font textFieldsFont = Font.decode("MonoSpaced-PLAIN-12");
 
                _seqLabel.setHorizontalTextPosition(JLabel.LEFT);
@@ -265,8 +270,7 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
                                }
                        }
                });
-
-
+               
                _seqPanel.setLayout(new BorderLayout());
                _seqPanel.add(_seqLabel, BorderLayout.WEST);
                _seqPanel.add(_seq, BorderLayout.CENTER);
@@ -299,7 +303,8 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
                        public void actionPerformed(ActionEvent e) {
                                        _rnaList.add((VARNAConfig)vp.getConfig().clone(),vp.getRNA().clone(),vp.getRNA().getName()+"-"+DateFormat.getTimeInstance(DateFormat.LONG).format(new Date()),true); 
                        }});
-               
+               goPanel.add(_createButton, BorderLayout.CENTER);
+               */
                JPanel ops = new JPanel();
                ops.setLayout(new GridLayout(1,2));
                ops.add(_deleteButton);
@@ -312,9 +317,9 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
                _listPanel.add(j,BorderLayout.NORTH);
                _listPanel.add(listScroller,BorderLayout.CENTER);
 
-               goPanel.add(_createButton, BorderLayout.CENTER);
-
-               JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,_listPanel,vp);
+               
+               
+               //JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,_listPanel,vp);
                /**TODO
                getContentPane().setLayout(new BorderLayout());
                getContentPane().add(split, BorderLayout.CENTER);
@@ -326,9 +331,17 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
                
                vp.addVARNAListener(this);
        }
+       
+       public JPanel getTools(){
+               return _tools;
+       }
+       
+       public JPanel getListPanel(){
+               return _listPanel;
+       }
 
-
-       /*private void RNAPanelDemoInit() 
+       /*
+       private void RNAPanelDemoInit() 
        {
            DefaultListModel dlm = new DefaultListModel(); 
            
@@ -465,8 +478,8 @@ public class AppVarnaBinding extends jalview.ext.varna.JalviewVarnaBinding imple
                DropTarget dt = new DropTarget(vp, this);
                
                vp.addVARNAListener(this);
-       }*/
-       
+       }
+       */
        public static String generateDefaultName()
        {
                return "User file #"+_nextID++;
index 2ac304b..a4808cf 100644 (file)
@@ -269,6 +269,8 @@ public class PopupMenu extends JPopupMenu
                          break;
                  }
          }
+         
+         SequenceGroup a = aa[0].groupRef;
 
          //TODO: make rnastrucF a bit more nice
          final String rnastrucF=rnastruc;