JAL-2164 bugfix to convert insCodes of '\000' to ' ' in JmolParser, this fixes the...
[jalview.git] / src / jalview / ext / jmol / JmolParser.java
index 7056f0f..ea969ff 100644 (file)
@@ -209,7 +209,8 @@ public class JmolParser extends StructureFile implements JmolStatusListener
         Atom curAtom = new Atom(atom.x, atom.y, atom.z);
         curAtom.atomIndex = atom.getIndex();
         curAtom.chain = atom.getChainIDStr();
-        curAtom.insCode = atom.group.getInsertionCode();
+        curAtom.insCode = atom.group.getInsertionCode() == '\000' ? ' '
+                : atom.group.getInsertionCode();
         curAtom.name = atom.getAtomName();
         curAtom.number = atom.getAtomNumber();
         curAtom.resName = atom.getGroup3(true);
@@ -219,7 +220,12 @@ public class JmolParser extends StructureFile implements JmolStatusListener
         curAtom.resNumIns = "" + curAtom.resNumber + curAtom.insCode;
         curAtom.tfactor = atom.getBfactor100() / 100f;
         curAtom.type = 0;
-        significantAtoms.add(curAtom);
+        // significantAtoms.add(curAtom);
+        // ignore atoms from subsequent models
+        if (!significantAtoms.contains(curAtom))
+        {
+          significantAtoms.add(curAtom);
+        }
         prevAtom = atom;
       }
     }
@@ -230,6 +236,8 @@ public class JmolParser extends StructureFile implements JmolStatusListener
           org.jmol.modelset.Atom prevAtom,
           HashMap<String, org.jmol.modelset.Atom> chainTerMap)
   {
+    // System.out.println("Atom: " + curAtom.getAtomNumber()
+    // + "   Last atom index " + curAtom.group.lastAtomIndex);
     if (chainTerMap == null || prevAtom == null)
     {
       return true;