Merge branch 'develop' into features/filetypeEnum
[jalview.git] / src / jalview / io / AppletFormatAdapter.java
index 0c99d26..04d68e8 100755 (executable)
@@ -26,7 +26,9 @@ import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
+import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SequenceI;
+import jalview.ext.jmol.JmolParser;
 import jalview.structure.StructureImportSettings;
 
 import java.io.File;
@@ -191,9 +193,32 @@ public class AppletFormatAdapter
     {
       if (fileFormat == FileFormat.PDB || fileFormat == FileFormat.MMCif)
       {
-        StructureImportSettings.addSettings(annotFromStructure,
-                localSecondaryStruct, serviceSecondaryStruct);
-        alignFile = fileFormat.getAlignmentFile(inFile, sourceType);
+        // TODO obtain config value from preference settings.
+        // Set value to 'true' to test PDB processing with Jmol: JAL-1213
+        boolean isParseWithJMOL = StructureImportSettings
+                .getDefaultPDBFileParser().equalsIgnoreCase(
+                        StructureImportSettings.StructureParser.JMOL_PARSER
+                                .toString());
+        if (isParseWithJMOL)
+        {
+          StructureImportSettings.addSettings(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct);
+          alignFile = new JmolParser(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct, inFile,
+                  sourceType);
+        }
+        else
+        {
+          StructureImportSettings.addSettings(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct);
+          StructureImportSettings.setShowSeqFeatures(true);
+          alignFile = new MCview.PDBfile(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct, inFile,
+                  sourceType);
+        }
+        ((StructureFile) alignFile)
+                .setDbRefType(fileFormat == FileFormat.PDB ? Type.PDB
+                        : Type.MMCIF);
       }
       else
       {
@@ -276,9 +301,22 @@ public class AppletFormatAdapter
     {
       if (format == FileFormat.PDB || format == FileFormat.MMCif)
       {
-        StructureImportSettings.addSettings(annotFromStructure,
-                localSecondaryStruct, serviceSecondaryStruct);
-        alignFile = format.getAlignmentFile(source);
+        // TODO obtain config value from preference settings
+        boolean isParseWithJMOL = false;
+        if (isParseWithJMOL)
+        {
+          StructureImportSettings.addSettings(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct);
+          alignFile = new JmolParser(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct, source);
+        }
+        else
+        {
+          StructureImportSettings.setShowSeqFeatures(true);
+          alignFile = new MCview.PDBfile(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct, source);
+        }
+        ((StructureFile) alignFile).setDbRefType(Type.PDB);
       }
       else
       {