Merge branch 'apifix/JAL-1926_JAL-2106' into develop
[jalview.git] / src / jalview / ext / jmol / JmolParser.java
index c9243ed..0cbeef6 100644 (file)
@@ -22,12 +22,11 @@ package jalview.ext.jmol;
 
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
-import jalview.datamodel.DBRefSource;
 import jalview.datamodel.SequenceI;
 import jalview.io.FileParse;
 import jalview.io.StructureFile;
 import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureViewSettings;
+import jalview.structure.StructureImportSettings;
 import jalview.util.MessageManager;
 
 import java.io.IOException;
@@ -64,14 +63,12 @@ public class JmolParser extends StructureFile implements JmolStatusListener
           throws IOException
   {
     super(inFile, type);
-    // addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr);
   }
 
   public JmolParser(boolean addAlignmentAnnotations, boolean predictSecStr,
           boolean externalSecStr, FileParse fp) throws IOException
   {
     super(fp);
-    // addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr);
   }
 
   public JmolParser()
@@ -89,15 +86,6 @@ public class JmolParser extends StructureFile implements JmolStatusListener
   @Override
   public void parse() throws IOException
   {
-    String dataName = getDataName();
-    if (dataName.endsWith(".cif"))
-    {
-      setDbRefType(DBRefSource.MMCIF);
-    }
-    else
-    {
-      setDbRefType(DBRefSource.PDB);
-    }
     setChains(new Vector<PDBChain>());
     Viewer jmolModel = getJmolData();
     jmolModel.openReader(getDataName(), getDataName(), getReader());
@@ -167,12 +155,14 @@ public class JmolParser extends StructureFile implements JmolStatusListener
         }
         lastID = tmpatom.resNumIns.trim();
       }
+      xferSettings();
+
       makeResidueList();
       makeCaBondList();
 
       if (getId() == null)
       {
-        setId(inFile.getName());
+        setId(safeName(getDataName()));
       }
       for (PDBChain chain : getChains())
       {
@@ -186,7 +176,7 @@ public class JmolParser extends StructureFile implements JmolStatusListener
           prot.add(chainseq);
         }
 
-        if (StructureViewSettings.isPredictSecondaryStructure())
+        if (StructureImportSettings.isProcessSecondaryStructure())
         {
           createAnnotation(chainseq, chain, ms.at);
         }
@@ -206,6 +196,12 @@ public class JmolParser extends StructureFile implements JmolStatusListener
     List<Atom> significantAtoms = new ArrayList<Atom>();
     for (org.jmol.modelset.Atom atom : ms.at)
     {
+      // System.out.println("Seq Id : " + atom.getSeqID());
+      // System.out.println("To String : " + atom.toString());
+      if (!StructureImportSettings.isProcessHETATMs() && atom.isHetero())
+      {
+        continue;
+      }
       if (atom.getAtomName().equalsIgnoreCase("CA")
               || atom.getAtomName().equalsIgnoreCase("P"))
       {
@@ -220,7 +216,7 @@ public class JmolParser extends StructureFile implements JmolStatusListener
         curAtom.occupancy = ms.occupancies != null ? ms.occupancies[atom
                 .getIndex()] : Float.valueOf(atom.getOccupancy100());
         curAtom.resNumIns = "" + curAtom.resNumber + curAtom.insCode;
-        // curAtom.tfactor = atom.group.;
+        curAtom.tfactor = atom.getBfactor100() / 100f;
         curAtom.type = 0;
         significantAtoms.add(curAtom);
       }
@@ -277,9 +273,15 @@ public class JmolParser extends StructureFile implements JmolStatusListener
     {
       if (secstr[p] >= 'A' && secstr[p] <= 'z')
       {
+        try
+        {
         asecstr[p] = new Annotation(String.valueOf(secstr[p]), null,
                 secstrcode[p], Float.NaN);
         ssFound = true;
+        } catch (Exception e)
+        {
+          // e.printStackTrace();
+        }
       }
     }
 
@@ -560,4 +562,14 @@ public class JmolParser extends StructureFile implements JmolStatusListener
     this.predictSecondaryStructure = predictSecondaryStructure;
   }
 
+  public boolean isVisibleChainAnnotation()
+  {
+    return visibleChainAnnotation;
+  }
+
+  public void setVisibleChainAnnotation(boolean visibleChainAnnotation)
+  {
+    this.visibleChainAnnotation = visibleChainAnnotation;
+  }
+
 }