JAL-1759 correct conversion of Jmol Chain.chainId (int) to string +
[jalview.git] / src / jalview / ext / jmol / PDBFileWithJmol.java
index 2f117d3..3b6f0c2 100644 (file)
@@ -144,7 +144,9 @@ public class PDBFileWithJmol extends AlignFile implements
         modelIndex++;
         for (BioPolymer bp : ((BioModel) model).bioPolymers)
         {
-          int _lastChainId = 0;
+          int lastChainId = 0; // int value of character e.g. 65 for A
+          String lastChainIdAlpha = "";
+
           int[] groups = bp.getLeadAtomIndices();
           char seq[] = new char[groups.length], secstr[] = new char[groups.length], secstrcode[] = new char[groups.length];
           int groupc = 0, len = 0, firstrnum = 1, lastrnum = 0;
@@ -152,7 +154,7 @@ public class PDBFileWithJmol extends AlignFile implements
           do
           {
             if (groupc >= groups.length
-                    || ms.at[groups[groupc]].group.chain.chainID != _lastChainId)
+                    || ms.at[groups[groupc]].group.chain.chainID != lastChainId)
             {
               /*
                * on change of chain (or at end), construct the sequence and
@@ -181,14 +183,14 @@ public class PDBFileWithJmol extends AlignFile implements
                 String modelTitle = (String) ms
                         .getInfo(modelIndex, "title");
                 SequenceI sq = new Sequence("" + getDataName() + "|"
-                        + modelTitle + "|" + _lastChainId, newseq,
+                        + modelTitle + "|" + lastChainIdAlpha, newseq,
                         firstrnum, lastrnum);
                 PDBEntry pdbe = new PDBEntry();
                 pdbe.setFile(getDataName());
                 pdbe.setId(getDataName());
                 pdbe.setProperty(new Hashtable());
                 // pdbe.getProperty().put("CHAIN", "" + _lastChainId);
-                pdbe.setChainCode(String.valueOf(_lastChainId));
+                pdbe.setChainCode(lastChainIdAlpha);
                 sq.addPDBId(pdbe);
                 // JAL-1533
                 // Need to put the number of models for this polymer somewhere
@@ -199,9 +201,9 @@ public class PDBFileWithJmol extends AlignFile implements
                 {
                   String mt = modelTitle == null ? getDataName()
                           : modelTitle;
-                  if (_lastChainId >= ' ')
+                  if (lastChainId >= ' ')
                   {
-                    mt += _lastChainId;
+                    mt += lastChainIdAlpha;
                   }
                   AlignmentAnnotation ann = new AlignmentAnnotation(
                           "Secondary Structure", "Secondary Structure for "
@@ -226,7 +228,8 @@ public class PDBFileWithJmol extends AlignFile implements
               if (len == 0)
               {
                 firstrnum = group.getResno();
-                _lastChainId = group.chain.chainID;
+                lastChainId = group.chain.chainID;
+                lastChainIdAlpha = group.chain.getIDStr();
               }
               else
               {