From e358885b67e52b9a2d78dc849e7ae746eab15e54 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 14 Nov 2018 16:34:09 +0000 Subject: [PATCH] JAL-3032 don't throw Exception to signal chain not found, return null --- src/jalview/ext/jmol/JmolParser.java | 16 ++++++++-------- src/jalview/io/StructureFile.java | 13 ++++++++++--- src/mc_view/PDBfile.java | 16 ++++++++-------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/jalview/ext/jmol/JmolParser.java b/src/jalview/ext/jmol/JmolParser.java index 542b2bc..a9c5f5c 100644 --- a/src/jalview/ext/jmol/JmolParser.java +++ b/src/jalview/ext/jmol/JmolParser.java @@ -172,16 +172,16 @@ public class JmolParser extends StructureFile implements JmolStatusListener List 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); diff --git a/src/jalview/io/StructureFile.java b/src/jalview/io/StructureFile.java index 16ae0a1..084f886 100644 --- a/src/jalview/io/StructureFile.java +++ b/src/jalview/io/StructureFile.java @@ -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() diff --git a/src/mc_view/PDBfile.java b/src/mc_view/PDBfile.java index 0435def..04eda42 100755 --- a/src/mc_view/PDBfile.java +++ b/src/mc_view/PDBfile.java @@ -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); -- 1.7.10.2