ensure id string doesn't get set to the empty string (bug # 56271) and allow syntheti...
authorjprocter <Jim Procter>
Mon, 12 Oct 2009 12:51:13 +0000 (12:51 +0000)
committerjprocter <Jim Procter>
Mon, 12 Oct 2009 12:51:13 +0000 (12:51 +0000)
src/MCview/PDBfile.java

index 8585c4b..7b6275c 100755 (executable)
@@ -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)