From dee2624d7138c2c54a666fcd69d62e241ab17667 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 12 Oct 2009 12:51:13 +0000 Subject: [PATCH] ensure id string doesn't get set to the empty string (bug # 56271) and allow synthetic pdb files (without id) to be imported gracefully --- src/MCview/PDBfile.java | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index 8585c4b..7b6275c 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -55,7 +55,8 @@ public class PDBfile extends jalview.io.AlignFile public void parse() throws IOException { // TODO set the filename sensibly - id = (inFile == null || inFile.getName().length()==0) ? "PDBFILE" : inFile.getName(); + id = (inFile == null || inFile.getName() == null || inFile.getName() + .length() == 0) ? "PDBFILE" : inFile.getName(); try { chains = new Vector(); @@ -70,11 +71,21 @@ public class PDBfile extends jalview.io.AlignFile { if (line.indexOf("HEADER") == 0) { - // make sure we don't get zero length ID strings - String tid = line.substring(62, 67).trim(); - if (tid.length()>0) + String tid; + if (line.length() > 62) { - id = tid; + if (line.length() > 67) + { + tid = line.substring(62, 67).trim(); + } + else + { + tid = line.substring(62).trim(); + } + if (tid.length() > 0) + { + id = tid; + } } continue; } @@ -143,8 +154,8 @@ public class PDBfile extends jalview.io.AlignFile } dataset.addPDBId(entry); SequenceI chainseq = dataset.deriveSequence(); // PDBChain objects - // maintain reference to - // dataset + // maintain reference to + // dataset seqs.addElement(chainseq); AlignmentAnnotation[] chainannot = chainseq.getAnnotation(); if (chainannot != null) -- 1.7.10.2