From ff303328d18feb9948a816ff95aa86bc724b0570 Mon Sep 17 00:00:00 2001 From: tjc <tjc@ee4ac58c-ac51-4696-9907-e4b3aa274f04> Date: Tue, 3 Aug 2004 16:31:53 +0000 Subject: [PATCH] -R git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@1763 ee4ac58c-ac51-4696-9907-e4b3aa274f04 --- uk/ac/sanger/artemis/editor/Annotation.java | 59 ++++++++++--- uk/ac/sanger/artemis/editor/BigPane.java | 7 +- .../artemis/editor/DataCollectionPane.java | 87 +++++++++++++------ .../artemis/editor/DataViewInternalFrame.java | 21 +++-- .../sanger/artemis/editor/FastaTextPane.java | 68 ++++++++++++++- uk/ac/sanger/artemis/editor/HitInfo.java | 80 ++++++++++++++++- 6 files changed, 270 insertions(+), 52 deletions(-) diff --git a/uk/ac/sanger/artemis/editor/Annotation.java b/uk/ac/sanger/artemis/editor/Annotation.java index 6d7978d25..d0c8bb3f7 100644 --- a/uk/ac/sanger/artemis/editor/Annotation.java +++ b/uk/ac/sanger/artemis/editor/Annotation.java @@ -24,7 +24,9 @@ package uk.ac.sanger.artemis.editor; + import java.util.StringTokenizer; +import javax.swing.border.*; import javax.swing.event.*; import javax.swing.text.html.*; import javax.swing.text.DefaultStyledDocument; @@ -248,6 +250,29 @@ public class Annotation extends JEditorPane } + protected void setUpSRSFrame(URL url, String search) + throws IOException + { + if(BigPane.srsFrame == null) + { + BigPane.setUpSRSFrame((2*desktop.getHeight())/3,desktop); + Border loweredbevel = BorderFactory.createLoweredBevelBorder(); + Border raisedbevel = BorderFactory.createRaisedBevelBorder(); + Border compound = BorderFactory.createCompoundBorder(raisedbevel,loweredbevel); + + JTextField statusField = new JTextField(); + statusField.setBorder(compound); + statusField.setEditable(false); + BigPane.srsFrame.getContentPane().add(statusField, BorderLayout.SOUTH); + } + + Annotation edPane = new Annotation(url); + JScrollPane jsp = new JScrollPane(edPane); + JTabbedPane jtab = (JTabbedPane)BigPane.srsFrame.getContentPane().getComponent(0); + jtab.insertTab(search, null,jsp,null,0); + BigPane.srsFrame.setVisible(true); + } + /** * * Method to handle hyper link events. @@ -256,7 +281,7 @@ public class Annotation extends JEditorPane */ public void hyperlinkUpdate(HyperlinkEvent event) { - if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) + if(event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { setCursor(cbusy); try @@ -273,15 +298,7 @@ public class Annotation extends JEditorPane if(desktop != null) { if(BigPane.srsTabPane.isSelected()) - { - if(BigPane.srsFrame == null) - BigPane.setUpSRSFrame((2*desktop.getHeight())/3,desktop); - Annotation edPane = new Annotation(url); - JScrollPane jsp = new JScrollPane(edPane); - JTabbedPane jtab = (JTabbedPane)BigPane.srsFrame.getContentPane().getComponent(0); - jtab.insertTab(search, null,jsp,null,0); - BigPane.srsFrame.setVisible(true); - } + setUpSRSFrame(url,search); if(BigPane.srsWin.isSelected()) { @@ -315,12 +332,34 @@ public class Annotation extends JEditorPane { setCursor(cdone); ioe.printStackTrace(); + // ("Can't follow link to " + // event.getURL().toExternalForm() ); } setCursor(cdone); } + else if(event.getEventType() == HyperlinkEvent.EventType.ENTERED) + { + try + { + JTextField statusField = (JTextField)BigPane.srsFrame.getContentPane().getComponent(1); + statusField.setText(event.getDescription()); + } + catch(Exception exp){} + + } + else if(event.getEventType() == HyperlinkEvent.EventType.EXITED) + { + try + { + JTextField statusField = (JTextField)BigPane.srsFrame.getContentPane().getComponent(1); + statusField.setText(""); + } + catch(Exception exp){} + + } + } diff --git a/uk/ac/sanger/artemis/editor/BigPane.java b/uk/ac/sanger/artemis/editor/BigPane.java index 4928ae894..c47fc874c 100644 --- a/uk/ac/sanger/artemis/editor/BigPane.java +++ b/uk/ac/sanger/artemis/editor/BigPane.java @@ -102,8 +102,8 @@ public class BigPane extends JFrame JMenu srsMenu = new JMenu("Show SRS in"); optionMenu.add(srsMenu); - srsBrowser = new JCheckBoxMenuItem("External Broser",false); - srsTabPane = new JCheckBoxMenuItem("Tabbed Pane",true); + srsBrowser = new JCheckBoxMenuItem("Browser",false); + srsTabPane = new JCheckBoxMenuItem("Tab Pane",true); srsWin = new JCheckBoxMenuItem("New Window",false); srsMenu.add(srsBrowser); @@ -165,7 +165,8 @@ public class BigPane extends JFrame public void actionPerformed(ActionEvent e) { int select = jtab.getSelectedIndex(); - jtab.removeTabAt(select); + if(select > -1) + jtab.removeTabAt(select); } }); diff --git a/uk/ac/sanger/artemis/editor/DataCollectionPane.java b/uk/ac/sanger/artemis/editor/DataCollectionPane.java index f91b942c1..d17cd0090 100644 --- a/uk/ac/sanger/artemis/editor/DataCollectionPane.java +++ b/uk/ac/sanger/artemis/editor/DataCollectionPane.java @@ -25,6 +25,7 @@ package uk.ac.sanger.artemis.editor; import javax.swing.*; +import javax.swing.border.Border; import java.util.StringTokenizer; import java.io.BufferedReader; @@ -47,7 +48,7 @@ import java.util.Hashtable; public class DataCollectionPane extends JScrollPane { - public DataCollectionPane(Vector hitInfoCollection, String dataFile, + public DataCollectionPane(String dataFile, final FastaTextPane fastaTextPane, final Annotation ann, final JDesktopPane desktop) { @@ -60,6 +61,8 @@ public class DataCollectionPane extends JScrollPane scrollPanel.add(bdown); Hashtable goHash = new Hashtable(); + Vector hitInfoCollection = fastaTextPane.getHitCollection(); + Enumeration hitEnum = hitInfoCollection.elements(); while(hitEnum.hasMoreElements()) { @@ -190,34 +193,9 @@ public class DataCollectionPane extends JScrollPane try { URL url = new URL("http://"+srscmd); - if(BigPane.srsTabPane.isSelected()) - { - if(BigPane.srsFrame == null) - { - BigPane.setUpSRSFrame((2*desktop.getHeight())/3,desktop); -// int hgt = (2*desktop.getHeight())/3; -// BigPane.srsFrame = new JInternalFrame("SRS", -// true, //resizable -// true, //closable -// true, //maximizable -// true);//iconifiable -// JTabbedPane jtab = new JTabbedPane(); -// BigPane.srsFrame.getContentPane().add(jtab); -// BigPane.srsFrame.setLocation(0,0); -// BigPane.srsFrame.setSize(800,hgt); - -// JMenuBar menuBar = new JMenuBar(); -// menuBar.add(new CommonMenu(BigPane.srsFrame)); -// BigPane.srsFrame.setJMenuBar(menuBar); -// desktop.add(BigPane.srsFrame); - } - Annotation edPane = new Annotation(url); - JScrollPane jsp = new JScrollPane(edPane); - JTabbedPane jtab = (JTabbedPane)BigPane.srsFrame.getContentPane().getComponent(0); - jtab.insertTab(search,null,jsp,null,0); - BigPane.srsFrame.setVisible(true); - } + if(BigPane.srsTabPane.isSelected()) + setUpSRSFrame(url,search,desktop); if(BigPane.srsWin.isSelected()) { @@ -239,6 +217,14 @@ public class DataCollectionPane extends JScrollPane desktop.add(jif); } } + catch(java.net.ConnectException connect) + { + JOptionPane.showMessageDialog(DataCollectionPane.this, + "Cannot retrieve "+search+ + "\nConnection failed to:\nhttp://"+srscmd, + "Connection Error", + JOptionPane.WARNING_MESSAGE); + } catch(Exception exp) { exp.printStackTrace(); @@ -275,6 +261,27 @@ public class DataCollectionPane extends JScrollPane { String go_cmd = "http://www.godatabase.org/cgi-bin/amigo/go.cgi?query=GO%3A"+go_id; BrowserControl.displayURL(go_cmd); + + if(BigPane.srsTabPane.isSelected()) + { + try + { + setUpSRSFrame(new URL(go_cmd),go_id,desktop); + } + catch(java.net.ConnectException connect) + { + JOptionPane.showMessageDialog(DataCollectionPane.this, + "Cannot retrieve "+go_id+ + "\nConnection failed to:\n"+go_cmd, + "Connection Error", + JOptionPane.WARNING_MESSAGE); + } + catch(Exception exp) + { + exp.printStackTrace(); + } + } + } }); bacross.add(Box.createHorizontalStrut(10)); @@ -295,6 +302,30 @@ public class DataCollectionPane extends JScrollPane } + protected void setUpSRSFrame(URL url, String search, JDesktopPane desktop) + throws IOException + { + if(BigPane.srsFrame == null) + { + BigPane.setUpSRSFrame((2*desktop.getHeight())/3,desktop); + Border loweredbevel = BorderFactory.createLoweredBevelBorder(); + Border raisedbevel = BorderFactory.createRaisedBevelBorder(); + Border compound = BorderFactory.createCompoundBorder(raisedbevel,loweredbevel); + + JTextField statusField = new JTextField(); + statusField.setBorder(compound); + statusField.setEditable(false); + BigPane.srsFrame.getContentPane().add(statusField, BorderLayout.SOUTH); + } + + Annotation edPane = new Annotation(url); + JScrollPane jsp = new JScrollPane(edPane); + JTabbedPane jtab = (JTabbedPane)BigPane.srsFrame.getContentPane().getComponent(0); + jtab.insertTab(search, null,jsp,null,0); + BigPane.srsFrame.setVisible(true); + } + + protected static void getzCall(HitInfo hit, boolean ortholog) { String env[] = { "PATH=/usr/local/pubseq/bin/" }; diff --git a/uk/ac/sanger/artemis/editor/DataViewInternalFrame.java b/uk/ac/sanger/artemis/editor/DataViewInternalFrame.java index 90a8b5a85..665a1953f 100644 --- a/uk/ac/sanger/artemis/editor/DataViewInternalFrame.java +++ b/uk/ac/sanger/artemis/editor/DataViewInternalFrame.java @@ -43,8 +43,6 @@ public class DataViewInternalFrame extends JInternalFrame true);//iconifiable Annotation ann = new Annotation(desktop); - JPanel dataPanel = (JPanel)getContentPane(); - dataPanel.setLayout(new BorderLayout()); StringBuffer annFormat = new StringBuffer(); @@ -56,15 +54,28 @@ public class DataViewInternalFrame extends JInternalFrame annFormat.append("/"+fastaPane.getFormat()+"_file=\""+ dataFile[i]+"\"\n"); // add data pane - Vector hits = fastaPane.getHitCollection(); DataCollectionPane dataPane = - new DataCollectionPane(hits, dataFile[i], fastaPane, ann, desktop); + new DataCollectionPane(dataFile[i], fastaPane, ann, desktop); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, fastaPane,dataPane); split.setDividerLocation(150); tabPane.add(fastaPane.getFormat(),split); + + JInternalFrame jif = new JInternalFrame("Viewer", + true, //resizable + true, //closable + true, //maximizable + true);//iconifiable + DBViewer dbview = new DBViewer(fastaPane); + JScrollPane dbviewScroll = new JScrollPane(dbview); + dbviewScroll.setPreferredSize(new Dimension(500,200)); + jif.getContentPane().add(dbviewScroll); + jif.setLocation(0,0); + jif.setSize(500,300); + jif.setVisible(true); + desktop.add(jif); } // add annotator text pane @@ -75,7 +86,7 @@ public class DataViewInternalFrame extends JInternalFrame JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, annotationScroll,tabPane); split.setDividerLocation(250); - dataPanel.add(split); + getContentPane().add(split); setVisible(true); } diff --git a/uk/ac/sanger/artemis/editor/FastaTextPane.java b/uk/ac/sanger/artemis/editor/FastaTextPane.java index ef0e9a0d8..38c48a37a 100644 --- a/uk/ac/sanger/artemis/editor/FastaTextPane.java +++ b/uk/ac/sanger/artemis/editor/FastaTextPane.java @@ -155,11 +155,13 @@ public class FastaTextPane extends JScrollPane streamReader = new InputStreamReader(getInputStream(dataFile)); buffReader = new BufferedReader(streamReader); + String qlen = null; String line = null; int textPosition = 0; int len = 0; HitInfo hit = null; int ind1 = 0; + int endQuery = 0; while( (line = buffReader.readLine()) != null) { @@ -198,6 +200,8 @@ public class FastaTextPane extends JScrollPane hit = getHitInfo(currentID,hitInfoCollection); hit.setStartPosition(textPosition); + if(qlen != null) + hit.setQueryLength(Integer.parseInt(qlen)); String going = ""; ind = line.indexOf("GO:"); @@ -205,18 +209,51 @@ public class FastaTextPane extends JScrollPane going = line.substring(ind+3); String nextLine = null; - buffReader.mark(210); +// buffReader.mark(210); + +// get GO numbers while((nextLine = buffReader.readLine()).indexOf("Length") == -1) { + len += nextLine.length()+1; + sbuff.append(nextLine+"\n"); if(going.equals("") && ((ind = nextLine.indexOf("GO:")) > -1)) going = nextLine.substring(ind+3); else if(!going.equals("")) going = going.concat(nextLine); } - - buffReader.reset(); + if(!going.equals("")) - hit.setGO(going); + hit.setGO(going); + + if(nextLine != null) + { + len += nextLine.length()+1; + sbuff.append(nextLine+"\n"); + if( (ind1 = nextLine.indexOf(" Length = ")) > -1) + hit.setLength(nextLine.substring(ind1+11)); + } + +// get query start + while(!(nextLine = buffReader.readLine()).startsWith("Query: ")) + { + len += nextLine.length()+1; + sbuff.append(nextLine+"\n"); + } + + if(nextLine != null) + { + len += nextLine.length()+1; + sbuff.append(nextLine+"\n"); + if(nextLine.startsWith("Query:")) + { + ind1 = nextLine.indexOf(" ",8); + int start = Integer.parseInt(nextLine.substring(7,ind1).trim()); + hit.setQueryStart(start); + hit.setQueryEnd(Integer.parseInt(nextLine.substring(nextLine.lastIndexOf(" ")).trim())); + } + } + +// buffReader.reset(); } else if( (ind1 = line.indexOf("Identities = ")) > -1) { @@ -226,6 +263,29 @@ public class FastaTextPane extends JScrollPane } else if( (ind1 = line.indexOf(" Length = ")) > -1) hit.setLength(line.substring(ind1+11)); + else if(line.startsWith("Query: ")) + hit.setQueryEnd(Integer.parseInt(line.substring(line.lastIndexOf(" ")).trim())); + else if(line.startsWith("Query=")) + { + int ind2 = 0; + ind1 = line.indexOf(" letters)"); + if(ind1 == -1) + { + String nextLine = null; + while((nextLine = buffReader.readLine()).indexOf(" letters)") < -1) + { + len += nextLine.length()+1; + sbuff.append(nextLine+"\n"); + } + line = nextLine; + ind1 = nextLine.indexOf(" letters)"); + ind2 = nextLine.indexOf("("); + } + else + ind2 = line.indexOf("("); + + qlen = line.substring(ind2+1,ind1).trim(); + } textPosition += len; } diff --git a/uk/ac/sanger/artemis/editor/HitInfo.java b/uk/ac/sanger/artemis/editor/HitInfo.java index f1c3959e1..c8f84a56c 100644 --- a/uk/ac/sanger/artemis/editor/HitInfo.java +++ b/uk/ac/sanger/artemis/editor/HitInfo.java @@ -49,6 +49,9 @@ public class HitInfo private String desc = null; /** Sequence length */ private String length = null; + /** Query length */ + private int queryLength = 0; + /** */ private String opt = null; private String zscore = null; @@ -71,10 +74,13 @@ public class HitInfo private int startPosition = 0; /** end position of this hit in the results output */ private int endPosition = 0; - /** collection of GO terms */ private Vector go; - + /** query hit start point */ + private int startQuery; + /** query hit end point */ + private int endQuery; + public HitInfo(String header, String format) { header = header.trim(); @@ -168,6 +174,53 @@ public class HitInfo } + + /** + * + * Get the start position for the query sequence in the alignment. + * @return startQuery + * + */ + protected int getQueryStart() + { + return startQuery; + } + + /** + * + * Get the end position for the query sequence in the alignment. + * @return endQuery + * + */ + protected int getQueryEnd() + { + return endQuery; + } + + + /** + * + * Set the start position for the query sequence in the alignment. + * @param startQuery startQuery + * + */ + protected void setQueryStart(int startQuery) + { + this.startQuery = startQuery; + } + + /** + * + * Set the end position for the query sequence in the alignment. + * @param endQuery endQuery + * + */ + protected void setQueryEnd(int endQuery) + { + this.endQuery = endQuery; + } + + /** * * Set the start position of the alignment in the @@ -192,6 +245,29 @@ public class HitInfo this.endPosition = endPosition; } + /** + * + * Set the query sequence length. + * @param queryLength query sequence length. + * + */ + protected void setQueryLength(int queryLength) + { + this.queryLength = queryLength; + } + + /** + * + * Get the query sequence length. + * @return query sequence length. + * + */ + protected int getQueryLength() + { + return queryLength; + } + + /** * * Set the sequence length. -- GitLab