JAL-3032 don't throw Exception to signal chain not found, return null
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 14 Nov 2018 16:34:09 +0000 (16:34 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 14 Nov 2018 16:34:09 +0000 (16:34 +0000)
src/jalview/ext/jmol/JmolParser.java
src/jalview/io/StructureFile.java
src/mc_view/PDBfile.java

index 542b2bc..a9c5f5c 100644 (file)
@@ -172,16 +172,16 @@ public class JmolParser extends StructureFile implements JmolStatusListener
       List<Atom> significantAtoms = convertSignificantAtoms(ms);
       for (Atom tmpatom : significantAtoms)
       {
-        try
+        if (tmpatom.resNumIns.trim().equals(lastID))
+        {
+          // phosphorylated protein - seen both CA and P..
+          continue;
+        }
+        tmpchain = findChain(tmpatom.chain);
+        if (tmpchain != null)
         {
-          tmpchain = findChain(tmpatom.chain);
-          if (tmpatom.resNumIns.trim().equals(lastID))
-          {
-            // phosphorylated protein - seen both CA and P..
-            continue;
-          }
           tmpchain.atoms.addElement(tmpatom);
-        } catch (Exception e)
+        } else
         {
           tmpchain = new PDBChain(getId(), tmpatom.chain);
           getChains().add(tmpchain);
index 16ae0a1..084f886 100644 (file)
@@ -341,8 +341,15 @@ public abstract class StructureFile extends AlignFile
     }
     StructureImportSettings.setShowSeqFeatures(true);
   }
-
-  public PDBChain findChain(String id) throws Exception
+  
+  /**
+   * Answers the first PDBChain found matching the given id, or null if none 
+   * is found
+   * 
+   * @param id
+   * @return
+   */
+  public PDBChain findChain(String id)
   {
     for (PDBChain chain : getChains())
     {
@@ -351,7 +358,7 @@ public abstract class StructureFile extends AlignFile
         return chain;
       }
     }
-    throw new Exception("PDB chain not Found!");
+    return null;
   }
 
   public void makeResidueList()
index 0435def..04eda42 100755 (executable)
@@ -143,16 +143,16 @@ public class PDBfile extends StructureFile
           }
 
           Atom tmpatom = new Atom(line);
-          try
+          if (tmpatom.resNumIns.trim().equals(lastID))
+          {
+            // phosphorylated protein - seen both CA and P..
+            continue;
+          }
+          tmpchain = findChain(tmpatom.chain);
+          if (tmpchain != null)
           {
-            tmpchain = findChain(tmpatom.chain);
-            if (tmpatom.resNumIns.trim().equals(lastID))
-            {
-              // phosphorylated protein - seen both CA and P..
-              continue;
-            }
             tmpchain.atoms.addElement(tmpatom);
-          } catch (Exception e)
+          } else
           {
             tmpchain = new PDBChain(getId(), tmpatom.chain);
             getChains().add(tmpchain);