JAL-1919 refined structure view annotation settings to work for both PDB and mmCIF
[jalview.git] / src / jalview / io / StructureFile.java
index 4ba4c10..7262443 100644 (file)
@@ -8,6 +8,7 @@ import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceI;
+import jalview.structure.StructureViewSettings;
 
 import java.awt.Color;
 import java.io.IOException;
@@ -23,19 +24,20 @@ public abstract class StructureFile extends AlignFile
 
   private String id;
 
+  private String dbRefType;
   /**
    * set to true to add derived sequence annotations (temp factor read from
    * file, or computed secondary structure) to the alignment
    */
   protected boolean visibleChainAnnotation = false;
 
-  /*
+  /**
    * Set true to predict secondary structure (using JMol for protein, Annotate3D
    * for RNA)
    */
-  protected boolean predictSecondaryStructure = true;
+  protected boolean predictSecondaryStructure = false;
 
-  /*
+  /**
    * Set true (with predictSecondaryStructure=true) to predict secondary
    * structure using an external service (currently Annotate3D for RNA only)
    */
@@ -53,6 +55,13 @@ public abstract class StructureFile extends AlignFile
     super(fp);
   }
 
+  public void addSettings(boolean addAlignmentAnnotations,
+          boolean predictSecondaryStructure, boolean externalSecStr)
+  {
+    this.visibleChainAnnotation = addAlignmentAnnotations;
+    this.predictSecondaryStructure = predictSecondaryStructure;
+    this.externalSecondaryStructure = externalSecStr;
+  }
   public StructureFile(boolean parseImmediately, String inFile, String type)
           throws IOException
   {
@@ -75,7 +84,7 @@ public abstract class StructureFile extends AlignFile
     pdbSequence.setName(getId() + "|" + pdbSequence.getName());
     PDBEntry entry = new PDBEntry();
     entry.setId(getId());
-    entry.setType(PDBEntry.Type.PDB);
+    entry.setType(this.dbRefType);
     entry.setProperty(new Hashtable());
     if (chain.id != null)
     {
@@ -247,9 +256,14 @@ public abstract class StructureFile extends AlignFile
       if (cl != null)
       {
         final Constructor constructor = cl
-                .getConstructor(new Class[] { FileParse.class });
-        final Object[] args = new Object[] { new FileParse(getDataName(),
+.getConstructor(new Class[] {
+            boolean.class, boolean.class, boolean.class, FileParse.class });
+        final Object[] args = new Object[] { true, true, true,
+            new FileParse(getDataName(),
                 type) };
+
+        StructureViewSettings.setShowSeqFeatures(false);
+        StructureViewSettings.setPredictSecondaryStructure(true);
         Object jmf = constructor.newInstance(args);
         AlignmentI al = new Alignment((SequenceI[]) cl.getMethod(
                 "getSeqsAsArray", new Class[] {}).invoke(jmf));
@@ -373,4 +387,14 @@ public abstract class StructureFile extends AlignFile
   {
     this.chains = chains;
   }
+
+  public String getDbRefType()
+  {
+    return dbRefType;
+  }
+
+  public void setDbRefType(String dbRefType)
+  {
+    this.dbRefType = dbRefType;
+  }
 }