Merge remote-tracking branch 'origin/features/JAL-1705_ensembl' into
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 5 Jan 2016 13:09:44 +0000 (13:09 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 5 Jan 2016 13:09:44 +0000 (13:09 +0000)
features/JAL-653_JAL-1766_htslib_refseqsupport

1  2 
src/jalview/gui/SequenceFetcher.java
src/jalview/io/FileParse.java

@@@ -54,8 -54,6 +54,6 @@@ import javax.swing.JTextArea
  import javax.swing.SwingConstants;
  import javax.swing.tree.DefaultMutableTreeNode;
  
- import com.stevesoft.pat.Regex;
  public class SequenceFetcher extends JPanel implements Runnable
  {
    JLabel dbeg = new JLabel();
        resetDialog();
        return;
      }
+     // TODO: Refactor to GUI independent code and write tests.
      // indicate if successive sources should be merged into one alignment.
      boolean addToLast = false;
      ArrayList<String> aresultq = new ArrayList<String>(), presultTitle = new ArrayList<String>();
                  DBRefEntry dbr = new DBRefEntry(), found[] = null;
                  dbr.setSource(proxy.getDbSource());
                  dbr.setVersion(null);
-                 if (proxy.getAccessionValidator() != null)
-                 {
-                   Regex vgr = proxy.getAccessionValidator();
-                   vgr.search(q);
-                   if (vgr.numSubs() > 0)
-                   {
-                     dbr.setAccessionId(vgr.stringMatched(1));
-                   }
-                   else
-                   {
-                     dbr.setAccessionId(vgr.stringMatched());
-                   }
-                 }
-                 else
-                 {
-                   dbr.setAccessionId(q);
-                 }
+                 String accId = DBRefUtils.processQueryToAccessionFor(proxy,
+                         q);
+                 dbr.setAccessionId(accId);
                  boolean rfound = false;
                  for (int r = 0; r < rs.length; r++)
                  {
  
    AlignmentI parseResult(String result, String title)
    {
 -    String format = new IdentifyFile().Identify(result, "Paste");
 +    String format = new IdentifyFile().identify(result, "Paste");
      AlignmentI sequences = null;
      if (FormatAdapter.isValidFormat(format))
      {
@@@ -274,6 -274,30 +274,30 @@@ public class FilePars
    }
  
    /**
+    * not for general use, creates a fileParse object for an existing reader with
+    * configurable values for the origin and the type of the source
+    */
+   public FileParse(BufferedReader source, String originString,
+           String typeString)
+   {
+     type = typeString;
+     error = false;
+     inFile = null;
+     dataName = originString;
+     dataIn = source;
+     try
+     {
+       if (dataIn.markSupported())
+       {
+         dataIn.mark(READAHEAD_LIMIT);
+       }
+     } catch (IOException q)
+     {
+     }
+   }
+   /**
     * Create a datasource for input to Jalview. See AppletFormatAdapter for the
     * types of sources that are handled.
     * 
    }
  
    /**
 -   * rewinds the datasource the beginning.
 +   * Rewinds the datasource to the marked point if possible
 +   * 
 +   * @param bytesRead
     * 
     */
 -  public void reset() throws IOException
 +  public void reset(int bytesRead) throws IOException
    {
 +    if (bytesRead >= READAHEAD_LIMIT)
 +    {
 +      System.err.println(String.format(
 +              "File reset error: read %d bytes but reset limit is %d",
 +              bytesRead, READAHEAD_LIMIT));
 +    }
      if (dataIn != null && !error)
      {
        dataIn.reset();