Skip to content
Snippets Groups Projects
Commit eb9dd4ff authored by tjc's avatar tjc
Browse files

split seq selection on org and sofa type

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@2911 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 5d4959e0
No related branches found
No related tags found
No related merge requests found
...@@ -28,10 +28,6 @@ import javax.swing.*; ...@@ -28,10 +28,6 @@ import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeSelectionModel; import javax.swing.tree.TreeSelectionModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Cursor;
import java.awt.Container; import java.awt.Container;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.net.*; import java.net.*;
...@@ -189,7 +185,7 @@ public class DatabaseEntrySource implements EntrySource ...@@ -189,7 +185,7 @@ public class DatabaseEntrySource implements EntrySource
DatabaseDocument doc = new DatabaseDocument(location); DatabaseDocument doc = new DatabaseDocument(location);
entries = doc.getDatabaseEntries(); entries = doc.getDatabaseEntries();
Vector organism = doc.getOrganism(); Vector organism = doc.getOrganism();
DefaultMutableTreeNode top = DefaultMutableTreeNode top =
new DefaultMutableTreeNode("PSU Organism List"); new DefaultMutableTreeNode("PSU Organism List");
...@@ -206,12 +202,19 @@ public class DatabaseEntrySource implements EntrySource ...@@ -206,12 +202,19 @@ public class DatabaseEntrySource implements EntrySource
* @return node that is currently selected * @return node that is currently selected
* *
*/ */
protected DefaultMutableTreeNode getSelectedNode(JTree tree) protected String getSelectedNode(JTree tree)
{ {
TreePath path = tree.getLeadSelectionPath(); TreePath path = tree.getLeadSelectionPath();
if(path == null) if(path == null)
return null; return null;
return (DefaultMutableTreeNode)path.getLastPathComponent();
DefaultMutableTreeNode seq_node = (DefaultMutableTreeNode)path.getLastPathComponent();
DefaultMutableTreeNode type_node = (DefaultMutableTreeNode)seq_node.getParent();
DefaultMutableTreeNode org_node = (DefaultMutableTreeNode)type_node.getParent();
return (String)org_node.getUserObject() + " - " +
(String)type_node.getUserObject() + " - " +
(String)seq_node.getUserObject();
} }
/** /**
...@@ -228,6 +231,7 @@ public class DatabaseEntrySource implements EntrySource ...@@ -228,6 +231,7 @@ public class DatabaseEntrySource implements EntrySource
Enumeration enum_org = org.elements(); Enumeration enum_org = org.elements();
DefaultMutableTreeNode org_node; DefaultMutableTreeNode org_node;
DefaultMutableTreeNode seq_node; DefaultMutableTreeNode seq_node;
DefaultMutableTreeNode typ_node;
while(enum_org.hasMoreElements()) while(enum_org.hasMoreElements())
{ {
...@@ -235,14 +239,31 @@ public class DatabaseEntrySource implements EntrySource ...@@ -235,14 +239,31 @@ public class DatabaseEntrySource implements EntrySource
org_node = new DefaultMutableTreeNode(name); org_node = new DefaultMutableTreeNode(name);
top.add(org_node); top.add(org_node);
Hashtable seq_type_node = new Hashtable();
Enumeration enum_seq = organism.keys(); Enumeration enum_seq = organism.keys();
while(enum_seq.hasMoreElements()) while(enum_seq.hasMoreElements())
{ {
String seq_name = (String)enum_seq.nextElement(); String seq_name = (String)enum_seq.nextElement();
if(seq_name.startsWith(name)) if(seq_name.startsWith(name))
{ {
int ind1 = seq_name.indexOf( "- ");
int ind2 = seq_name.lastIndexOf("- ");
String type = seq_name.substring(ind1+2,ind2).trim();
seq_name = seq_name.substring(ind2+2).trim();
if(!seq_type_node.containsKey(type))
{
typ_node = new DefaultMutableTreeNode(type);
seq_type_node.put(type,typ_node);
org_node.add(typ_node);
}
else
typ_node= (DefaultMutableTreeNode)seq_type_node.get(type);
seq_node = new DefaultMutableTreeNode(seq_name); seq_node = new DefaultMutableTreeNode(seq_name);
org_node.add(seq_node); typ_node.add(seq_node);
} }
} }
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/DatabaseJFrame.java,v 1.3 2005-06-01 15:07:31 tjc Exp $ * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/DatabaseJFrame.java,v 1.4 2005-06-18 07:01:16 tjc Exp $
*/ */
package uk.ac.sanger.artemis.components; package uk.ac.sanger.artemis.components;
...@@ -115,11 +115,8 @@ public class DatabaseJFrame extends JFrame ...@@ -115,11 +115,8 @@ public class DatabaseJFrame extends JFrame
Cursor cbusy = new Cursor(Cursor.WAIT_CURSOR); Cursor cbusy = new Cursor(Cursor.WAIT_CURSOR);
Cursor cdone = new Cursor(Cursor.DEFAULT_CURSOR); Cursor cdone = new Cursor(Cursor.DEFAULT_CURSOR);
DefaultMutableTreeNode node = entry_source.getSelectedNode(tree); String node_name = entry_source.getSelectedNode(tree);
if(node == null || !node.isLeaf()) String id = entry_source.getEntryID(node_name);
return;
String id = entry_source.getEntryID((String)node.getUserObject());
if(id != null) if(id != null)
getEntryEditFromDatabase(id, entry_source, tree, art_main); getEntryEditFromDatabase(id, entry_source, tree, art_main);
} }
......
...@@ -189,6 +189,13 @@ public class DatabaseDocument extends Document ...@@ -189,6 +189,13 @@ public class DatabaseDocument extends Document
return null; return null;
} }
/**
*
* Given a parent (chromosome, contig, supercontig) retrieve the features
* in the form of a GFF stream.
*
*/
private String getGFF(Connection conn, String parentFeatureID) private String getGFF(Connection conn, String parentFeatureID)
throws java.sql.SQLException throws java.sql.SQLException
{ {
...@@ -338,13 +345,7 @@ public class DatabaseDocument extends Document ...@@ -338,13 +345,7 @@ public class DatabaseDocument extends Document
while(rs.next()) while(rs.next())
cvterm_id.add(rs.getString("type_id")); cvterm_id.add(rs.getString("type_id"));
// String sql = "select cvterm.cvterm_id, cvterm.name FROM cvterm, cv "+ sql = new String("SELECT abbreviation, name, feature_id, type_id FROM organism, feature WHERE (");
// "WHERE cv.cv_id = cvterm.cv_id and cvterm.name = 'chromosome'";
// ResultSet rs = st.executeQuery(sql);
// rs.next();
// String cvterm_id = rs.getString("cvterm_id");
sql = new String("SELECT abbreviation, name, feature_id FROM organism, feature WHERE (");
for(int i=0; i<cvterm_id.size(); i++) for(int i=0; i<cvterm_id.size(); i++)
{ {
...@@ -356,16 +357,15 @@ public class DatabaseDocument extends Document ...@@ -356,16 +357,15 @@ public class DatabaseDocument extends Document
sql = sql + ") " + " and organism.organism_id=feature.organism_id "+ sql = sql + ") " + " and organism.organism_id=feature.organism_id "+
"ORDER BY abbreviation, name"; "ORDER BY abbreviation, name";
// sql = new String("SELECT abbreviation, name, feature_id FROM organism, feature WHERE type_id = '"+
// cvterm_id+"' and organism.organism_id=feature.organism_id "+
// "ORDER BY abbreviation, name");
appendToLogFile(sql,sqlLog); appendToLogFile(sql,sqlLog);
rs = st.executeQuery(sql); rs = st.executeQuery(sql);
while(rs.next()) while(rs.next())
{ {
String org = rs.getString("abbreviation"); String org = rs.getString("abbreviation");
db.put(org+" - "+rs.getString("name"), rs.getString("feature_id")); String typeName = getCvtermName(conn,rs.getLong("type_id"));
db.put(org+" - "+typeName+" - "+rs.getString("name"),
rs.getString("feature_id"));
if(!organism.contains(org)) if(!organism.contains(org))
organism.add(org); organism.add(org);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment