develop merge
[jalview.git] / src / jalview / io / AppletFormatAdapter.java
index e34093d..65fd72f 100755 (executable)
@@ -26,6 +26,7 @@ import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
+import jalview.structure.StructureViewSettings;
 import jalview.util.MessageManager;
 
 import java.io.File;
@@ -86,7 +87,7 @@ public class AppletFormatAdapter
   public static final String[] READABLE_FORMATS = new String[] { "BLC",
       "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH", "PDB",
       "JnetFile", "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC,
-      IdentifyFile.FeaturesFile, "HTML" };
+      IdentifyFile.FeaturesFile, "HTML", "mmCIF" };
 
   /**
    * List of readable format file extensions by application in order
@@ -95,7 +96,7 @@ public class AppletFormatAdapter
   public static final String[] READABLE_EXTENSIONS = new String[] {
       "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
       "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, JSONFile.FILE_EXT,
-      ".gff2,gff3", "jar,jvp", HtmlFile.FILE_EXT };
+      ".gff2,gff3", "jar,jvp", HtmlFile.FILE_EXT, "cif" };
 
   /**
    * List of readable formats by application in order corresponding to
@@ -104,7 +105,7 @@ public class AppletFormatAdapter
   public static final String[] READABLE_FNAMES = new String[] { "Fasta",
       "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Stockholm", "RNAML",
       PhylipFile.FILE_DESC, JSONFile.FILE_DESC, IdentifyFile.FeaturesFile,
-      "Jalview", HtmlFile.FILE_DESC };
+      "Jalview", HtmlFile.FILE_DESC, "mmCIF" };
 
   /**
    * List of valid format strings for use by callers of the formatSequences
@@ -277,10 +278,31 @@ public class AppletFormatAdapter
       }
       else if (format.equals("PDB"))
       {
-        alignFile = new MCview.PDBfile(annotFromStructure,
+        // TODO obtain config value from preference settings.
+        // Set value to 'true' to test PDB processing with Jmol: JAL-1213
+        boolean isParseWithJMOL = false;
+        if (isParseWithJMOL)
+        {
+          StructureViewSettings.addSettings(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct);
+          alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct, inFile,
+                  type);
+        }
+        else
+        {
+          StructureViewSettings.setShowSeqFeatures(true);
+          alignFile = new MCview.PDBfile(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct, inFile,
+                  type);
+        }
+      }
+      else if (format.equals("mmCIF"))
+      {
+        StructureViewSettings.addSettings(annotFromStructure,
+                localSecondaryStruct, serviceSecondaryStruct);
+        alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
                 localSecondaryStruct, serviceSecondaryStruct, inFile, type);
-        // Uncomment to test Jmol data based PDB processing: JAL-1213
-        // afile = new jalview.ext.jmol.PDBFileWithJmol(inFile, type);
       }
       else if (format.equals("STH"))
       {
@@ -308,7 +330,7 @@ public class AppletFormatAdapter
       }
       else if (format.equals(IdentifyFile.FeaturesFile))
       {
-        alignFile = new FeaturesFile(true, inFile, type);
+        alignFile = new FeaturesFile(inFile, type);
       }
       return buildAlignmentFrom(alignFile);
     } catch (Exception e)
@@ -407,7 +429,27 @@ public class AppletFormatAdapter
       }
       else if (format.equals("PDB"))
       {
-        alignFile = new MCview.PDBfile(annotFromStructure,
+        // TODO obtain config value from preference settings
+        boolean isParseWithJMOL = false;
+        if (isParseWithJMOL)
+        {
+          StructureViewSettings.addSettings(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct);
+          alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct, source);
+        }
+        else
+        {
+          StructureViewSettings.setShowSeqFeatures(true);
+          alignFile = new MCview.PDBfile(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct, source);
+        }
+      }
+      else if (format.equals("mmCIF"))
+      {
+        StructureViewSettings.addSettings(annotFromStructure,
+                localSecondaryStruct, serviceSecondaryStruct);
+        alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
                 localSecondaryStruct, serviceSecondaryStruct, source);
       }
       else if (format.equals("STH"))
@@ -428,8 +470,7 @@ public class AppletFormatAdapter
       }
       else if (format.equals(IdentifyFile.FeaturesFile))
       {
-        // enforce 'parseImmediately' here:
-        alignFile = new FeaturesFile(true, inFile, type);
+        alignFile = new FeaturesFile(inFile, type);
       }
       else if (format.equals(JSONFile.FILE_DESC))
       {