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

add range option for opening db entry

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@6962 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 8ad7b8ee
Branches
Tags
No related merge requests found
......@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/ArtemisMain.java,v 1.27 2008-01-18 15:50:11 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/ArtemisMain.java,v 1.28 2008-01-21 16:15:39 tjc Exp $
*/
package uk.ac.sanger.artemis.components;
......@@ -52,7 +52,7 @@ import javax.swing.JOptionPane;
* The main window for the Artemis sequence editor.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: ArtemisMain.java,v 1.27 2008-01-18 15:50:11 tjc Exp $
* @version $Id: ArtemisMain.java,v 1.28 2008-01-21 16:15:39 tjc Exp $
**/
public class ArtemisMain extends Splash
......@@ -362,6 +362,7 @@ public class ArtemisMain extends Splash
}
else if(System.getProperty("chado") != null && new_entry_name.indexOf(':')>-1)
{
// open from database e.g. Pfalciparum:Pf3D7_09:95000..150000
Splash.logger4j.info("OPEN ENTRY "+new_entry_name);
getStatusLabel().setText("Connecting ...");
DatabaseEntrySource entry_source = new DatabaseEntrySource();
......
......@@ -44,6 +44,7 @@ import uk.ac.sanger.artemis.util.OutOfRangeException;
import uk.ac.sanger.artemis.io.DatabaseDocumentEntry;
import uk.ac.sanger.artemis.io.InvalidKeyException;
import uk.ac.sanger.artemis.io.EntryInformationException;
import uk.ac.sanger.artemis.io.Range;
/**
*
......@@ -108,7 +109,14 @@ public class DatabaseEntrySource implements EntrySource, Serializable
InputStreamProgressListener progress_listener)
throws OutOfRangeException, NoSequenceException, IOException
{
return makeFromID(null, id, schema, false, progress_listener);
return makeFromID(null, id, schema, false, progress_listener, null);
}
public Entry getEntry(String id, String schema,
InputStreamProgressListener progress_listener, Range range)
throws OutOfRangeException, NoSequenceException, IOException
{
return makeFromID(null, id, schema, false, progress_listener, range);
}
/**
......@@ -251,9 +259,10 @@ public class DatabaseEntrySource implements EntrySource, Serializable
* Thrown if one of the features in the Entry is out of range of
* the Bases object.
*/
protected Entry makeFromID(final Bases bases, final String id,
private Entry makeFromID(final Bases bases, final String id,
final String schema, final boolean read_only,
InputStreamProgressListener progress_listener)
InputStreamProgressListener progress_listener,
final Range range)
throws OutOfRangeException, IOException
{
try
......@@ -266,7 +275,10 @@ public class DatabaseEntrySource implements EntrySource, Serializable
else
{
DatabaseDocument doc = new DatabaseDocument(location, pfield, id,
schema, splitGFFEntry, progress_listener);
schema, splitGFFEntry,
progress_listener);
if(range != null)
doc.setRange(range);
db_entry = new DatabaseDocumentEntry(doc, null);
}
......
......@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/database/DatabaseJPanel.java,v 1.13 2008-01-18 15:54:47 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/database/DatabaseJPanel.java,v 1.14 2008-01-21 16:15:39 tjc Exp $
*/
package uk.ac.sanger.artemis.components.database;
......@@ -34,6 +34,7 @@ import uk.ac.sanger.artemis.util.InputStreamProgressListener;
import uk.ac.sanger.artemis.util.OutOfRangeException;
import uk.ac.sanger.artemis.util.DatabaseDocument;
import uk.ac.sanger.artemis.io.DatabaseDocumentEntry;
import uk.ac.sanger.artemis.io.Range;
import javax.swing.JComponent;
import javax.swing.JTree;
......@@ -167,7 +168,8 @@ public class DatabaseJPanel extends JPanel
* @param entry_source
* @param splash_main
* @param stream_progress_listener
* @param entryName e.g. Pfalciparum:Pf3D7_09
* @param entryName e.g. Pfalciparum:Pf3D7_09 or
* Pfalciparum:Pf3D7_09:20050..40000
* @return
*/
public static EntryEdit show(final DatabaseEntrySource entry_source,
......@@ -184,11 +186,30 @@ public class DatabaseJPanel extends JPanel
userName = userName.substring(5);
DatabaseDocument doc = entry_source.getDatabaseDocument();
Range range = null;
if(entry.length>2)
{
if(entry[2].indexOf("..") > -1)
{
String ranges[] = entry[2].split("\\.\\.");
if(ranges.length == 2)
{
try
{
range = new Range(Integer.parseInt(ranges[0]),
Integer.parseInt(ranges[1]));
}
catch(Exception e){ e.printStackTrace(); }
}
}
}
Feature f = doc.getFeatureByUniquename(entry[1]);
return openEntry(Integer.toString(f.getFeatureId()), entry_source,
splash_main.getCanvas(), splash_main.getStatusLabel(), stream_progress_listener,
false, splash_main, entry[1], userName);
false, splash_main, entry[1], userName, range);
}
/**
......@@ -226,7 +247,7 @@ public class DatabaseJPanel extends JPanel
try
{
openEntry(srcfeatureId, entry_source, srcComponent, status_line, stream_progress_listener,
splitGFFEntry, splash_main, dbDocumentName, userName);
splitGFFEntry, splash_main, dbDocumentName, userName, null);
}
catch(RuntimeException re)
{
......@@ -242,7 +263,7 @@ public class DatabaseJPanel extends JPanel
userName = userName.substring(5);
openEntry(srcfeatureId, entry_source, srcComponent, status_line, stream_progress_listener,
splitGFFEntry, splash_main, dbDocumentName, userName);
splitGFFEntry, splash_main, dbDocumentName, userName, null);
}
srcComponent.setCursor(cdone);
return null;
......@@ -253,7 +274,20 @@ public class DatabaseJPanel extends JPanel
}
/**
*
* @param srcfeatureId
* @param entry_source
* @param srcComponent
* @param status_line
* @param stream_progress_listener
* @param splitGFFEntry
* @param splash_main
* @param dbDocumentName
* @param userName
* @param range range for to retrieve features in
* @return
*/
private static EntryEdit openEntry(
final String srcfeatureId,
final DatabaseEntrySource entry_source,
......@@ -263,15 +297,18 @@ public class DatabaseJPanel extends JPanel
final boolean splitGFFEntry,
final Splash splash_main,
final String dbDocumentName,
final String userName)
final String userName,
final Range range)
{
Cursor cdone = new Cursor(Cursor.DEFAULT_CURSOR);
try
{
if(range != null)
logger4j.info("LOAD FEATURES IN THE RANGE : "+range.toString());
entry_source.setSplitGFF(splitGFFEntry);
final Entry entry = entry_source.getEntry(srcfeatureId, userName,
stream_progress_listener);
stream_progress_listener, range);
DatabaseDocumentEntry db_entry = (DatabaseDocumentEntry) entry
.getEMBLEntry();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment