note to callers of adjustPanelHeight
[jalview.git] / src / MCview / PDBfile.java
index c671ec2..3df320c 100755 (executable)
@@ -55,7 +55,7 @@ public class PDBfile extends jalview.io.AlignFile
   public void parse() throws IOException
   {
     // TODO set the filename sensibly
-    id = (inFile == null) ? "PDBFILE" : inFile.getName();
+    id = (inFile == null || inFile.getName()==null || inFile.getName().length()==0) ? "PDBFILE" : inFile.getName();
     try
     {
       chains = new Vector();
@@ -64,18 +64,25 @@ public class PDBfile extends jalview.io.AlignFile
       String line;
       boolean modelFlag = false;
       boolean terFlag = false;
+      String lastID="";
 
       int index = 0;
+      String atomnam=null;
       while ((line = nextLine()) != null)
       {
         if (line.indexOf("HEADER") == 0)
         {
           if (line.length()>62)
           {
+            String tid;
             if (line.length()>67) {
-              id = line.substring(62, 67).trim();
+              tid = line.substring(62, 67).trim();
             } else {
-              id=line.substring(62).trim();
+              tid=line.substring(62).trim();
+            }
+            if (tid.length()>0)
+            {
+              id = tid;
             }
             continue;
           }
@@ -105,7 +112,8 @@ public class PDBfile extends jalview.io.AlignFile
           terFlag = false;
 
           // Jalview is only interested in CA bonds????
-          if (!line.substring(12, 15).trim().equals("CA"))
+          atomnam = line.substring(12, 15).trim();
+          if (!atomnam.equals("CA") && !atomnam.equals("P"))
           {
             continue;
           }
@@ -114,6 +122,11 @@ public class PDBfile extends jalview.io.AlignFile
           tmpchain = findChain(tmpatom.chain);
           if (tmpchain != null)
           {
+            if (tmpatom.resNumIns.trim().equals(lastID))
+            {
+              //  phosphorylated protein - seen both CA and P..
+              continue;
+            }
             tmpchain.atoms.addElement(tmpatom);
           }
           else
@@ -122,6 +135,7 @@ public class PDBfile extends jalview.io.AlignFile
             chains.addElement(tmpchain);
             tmpchain.atoms.addElement(tmpatom);
           }
+          lastID = tmpatom.resNumIns.trim();
         }
         index++;
       }