Merge branch 'features/JAL-2040_JAL-2137_phyre2' into reviews/features/JAL-2136_phyre...
authorJim Procter <jprocter@issues.jalview.org>
Mon, 23 Jan 2017 15:13:33 +0000 (15:13 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 23 Jan 2017 15:13:33 +0000 (15:13 +0000)
1  2 
src/jalview/ext/jmol/JmolParser.java
src/jalview/io/AnnotationFile.java
src/jalview/structure/StructureSelectionManager.java

Simple merge
@@@ -684,25 -689,45 +689,45 @@@ public class AnnotationFil
    }
  
    public boolean readAnnotationFile(AlignmentI al, ColumnSelection colSel,
 -          String file, String protocol)
 +          String file, DataSourceType sourceType)
    {
+     baseUri = "";
      BufferedReader in = null;
      try
      {
 -      if (protocol.equals(AppletFormatAdapter.FILE))
 +      if (sourceType == DataSourceType.FILE)
        {
          in = new BufferedReader(new FileReader(file));
+         baseUri = new File(file).getParent();
+         if (baseUri == null)
+         {
+           baseUri = "";
+         }
+         else
+         {
+           baseUri += "/";
+         }
        }
 -      else if (protocol.equals(AppletFormatAdapter.URL))
 +      else if (sourceType == DataSourceType.URL)
        {
          URL url = new URL(file);
          in = new BufferedReader(new InputStreamReader(url.openStream()));
+         String bs = url.toExternalForm();
+         baseUri = bs.substring(0, bs.indexOf(url.getHost())
+                 + url.getHost().length());
+         baseUri += url.toURI().getPath();
+         if (baseUri.lastIndexOf("/") > -1)
+         {
+           baseUri = baseUri.substring(0, baseUri.lastIndexOf("/")) + "/";
+         }
        }
 -      else if (protocol.equals(AppletFormatAdapter.PASTE))
 +      else if (sourceType == DataSourceType.PASTE)
        {
          in = new BufferedReader(new StringReader(file));
+         // TODO - support mimencoded PDBs for a paste.. ?
+         baseUri = "";
        }
 -      else if (protocol.equals(AppletFormatAdapter.CLASSLOADER))
 +      else if (sourceType == DataSourceType.CLASSLOADER)
        {
          java.io.InputStream is = getClass().getResourceAsStream("/" + file);
          if (is != null)
@@@ -1376,15 -1355,9 +1376,19 @@@ public class StructureSelectionManage
      return seqmappings;
    }
  
 +  public boolean isMappingForPhyre2Model()
 +  {
 +    return mappingForPhyre2Model;
 +  }
 +
 +  public void setMappingForPhyre2Model(boolean mappingForPhyre2Model)
 +  {
 +    this.mappingForPhyre2Model = mappingForPhyre2Model;
 +  }
 +
+   public static StructureSelectionManager getStructureSelectionManager()
+   {
+     return instances.values().iterator().next();
+   }
  
  }