From 4060c4dbd774eb4937c90e5fe866b3408fb330e8 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 18 Nov 2005 11:36:07 +0000 Subject: [PATCH] Use PDB column format --- src/MCview/Atom.java | 32 ++++++++------------------------ src/MCview/PDBChain.java | 6 ++++-- src/MCview/PDBfile.java | 31 +++++++++++++++++++------------ 3 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/MCview/Atom.java b/src/MCview/Atom.java index e38d7aa..0815dc0 100755 --- a/src/MCview/Atom.java +++ b/src/MCview/Atom.java @@ -37,35 +37,19 @@ public class Atom { public boolean isSelected = false; - public Atom(StringTokenizer str) + public Atom(String str) { - str.nextToken(); // Number, not used in MCview - this.name = str.nextToken(); // Name, not used in MCview + name = str.substring(12,16); - this.resName = str.nextToken(); + resName = str.substring(17,20); - String token1 = str.nextToken(); + chain = str.substring(21,22); - String token2 = str.nextToken(); - - try{ - - this.chain = token1; - resNumber = Integer.parseInt(token2); - - this.x = (float) (new Float(str.nextToken()).floatValue()); - this.y = (float) (new Float(str.nextToken()).floatValue()); - this.z = (float) (new Float(str.nextToken()).floatValue()); - - }catch(NumberFormatException ex) - { - chain = "A"; - resNumber = Integer.parseInt(token1); - this.x = (float) (new Float(token2).floatValue()); - this.y = (float) (new Float(str.nextToken()).floatValue()); - this.z = (float) (new Float(str.nextToken()).floatValue()); - } + resNumber = Integer.parseInt(str.substring(22,26).trim()); + this.x = (float) (new Float(str.substring(30,38).trim()).floatValue()); + this.y = (float) (new Float(str.substring(38,46).trim()).floatValue()); + this.z = (float) (new Float(str.substring(47,55).trim()).floatValue()); } public void setColor(Color col) { diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 9c1d0e0..43c8e9d 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -139,10 +139,12 @@ public class PDBChain { .get(tmpat.resName)).intValue()]; seq = seq + tmpres2; } - } - sequence = new Sequence("PDB_seq", seq, 1, seq.length()); + if(id.length()<1 || id.equals(" ")) + id = "_"; + + sequence = new Sequence(id, seq, 1, seq.length()); // System.out.println("PDB Sequence is :\nSequence = " + seq); // System.out.println("No of residues = " + residues.size()); } diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index d1e4d65..2b22b24 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -29,6 +29,7 @@ import java.awt.Color; public class PDBfile extends jalview.io.FileParse { public Vector chains = new Vector(); Vector lineArray = new Vector(); + String id; public PDBfile(String[] lines) { for (int i = 0; i < lines.length; i++) @@ -68,22 +69,29 @@ public class PDBfile extends jalview.io.FileParse { parse(); } - public void parse() { - for (int i = 0; i < lineArray.size(); i++) { - StringTokenizer str = new StringTokenizer(lineArray.elementAt(i) - .toString()); + public void parse() + { + String line; + for (int i = 0; i < lineArray.size(); i++) + { - if (str.hasMoreTokens()) { - String inStr = str.nextToken(); + line = lineArray.elementAt(i).toString(); - if (inStr.indexOf("ATOM") != -1) { + if (line.indexOf("HEADER") == 0) + { + id = line.substring(62, 67).trim(); + continue; + } + + if (line.indexOf("ATOM") == 0) { try { - Atom tmpatom = new Atom(str); + Atom tmpatom = new Atom(line); - if (findChain(tmpatom.chain) != null) { - // System.out.println("Adding to chain " + tmpatom.chain); + if (findChain(tmpatom.chain) != null) + { findChain(tmpatom.chain).atoms.addElement(tmpatom); - } else { + } else + { PDBChain tmpchain = new PDBChain(tmpatom.chain); chains.addElement(tmpchain); tmpchain.atoms.addElement(tmpatom); @@ -94,7 +102,6 @@ public class PDBfile extends jalview.io.FileParse { lineArray.elementAt(i).toString()); } } - } } makeResidueList(); -- 1.7.10.2