\r
public boolean isSelected = false;\r
\r
- public Atom(StringTokenizer str)\r
+ public Atom(String str)\r
{\r
- str.nextToken(); // Number, not used in MCview\r
- this.name = str.nextToken(); // Name, not used in MCview\r
+ name = str.substring(12,16);\r
\r
- this.resName = str.nextToken();\r
+ resName = str.substring(17,20);\r
\r
- String token1 = str.nextToken();\r
+ chain = str.substring(21,22);\r
\r
- String token2 = str.nextToken();\r
-\r
- try{\r
-\r
- this.chain = token1;\r
- resNumber = Integer.parseInt(token2);\r
-\r
- this.x = (float) (new Float(str.nextToken()).floatValue());\r
- this.y = (float) (new Float(str.nextToken()).floatValue());\r
- this.z = (float) (new Float(str.nextToken()).floatValue());\r
-\r
- }catch(NumberFormatException ex)\r
- {\r
- chain = "A";\r
- resNumber = Integer.parseInt(token1);\r
- this.x = (float) (new Float(token2).floatValue());\r
- this.y = (float) (new Float(str.nextToken()).floatValue());\r
- this.z = (float) (new Float(str.nextToken()).floatValue());\r
- }\r
+ resNumber = Integer.parseInt(str.substring(22,26).trim());\r
\r
+ this.x = (float) (new Float(str.substring(30,38).trim()).floatValue());\r
+ this.y = (float) (new Float(str.substring(38,46).trim()).floatValue());\r
+ this.z = (float) (new Float(str.substring(47,55).trim()).floatValue());\r
}\r
\r
public void setColor(Color col) {\r
.get(tmpat.resName)).intValue()];\r
seq = seq + tmpres2;\r
}\r
-\r
}\r
\r
- sequence = new Sequence("PDB_seq", seq, 1, seq.length());\r
+ if(id.length()<1 || id.equals(" "))\r
+ id = "_";\r
+\r
+ sequence = new Sequence(id, seq, 1, seq.length());\r
// System.out.println("PDB Sequence is :\nSequence = " + seq);\r
// System.out.println("No of residues = " + residues.size());\r
}\r
public class PDBfile extends jalview.io.FileParse {\r
public Vector chains = new Vector();\r
Vector lineArray = new Vector();\r
+ String id;\r
\r
public PDBfile(String[] lines) {\r
for (int i = 0; i < lines.length; i++)\r
parse();\r
}\r
\r
- public void parse() {\r
- for (int i = 0; i < lineArray.size(); i++) {\r
- StringTokenizer str = new StringTokenizer(lineArray.elementAt(i)\r
- .toString());\r
+ public void parse()\r
+ {\r
+ String line;\r
+ for (int i = 0; i < lineArray.size(); i++)\r
+ {\r
\r
- if (str.hasMoreTokens()) {\r
- String inStr = str.nextToken();\r
+ line = lineArray.elementAt(i).toString();\r
\r
- if (inStr.indexOf("ATOM") != -1) {\r
+ if (line.indexOf("HEADER") == 0)\r
+ {\r
+ id = line.substring(62, 67).trim();\r
+ continue;\r
+ }\r
+\r
+ if (line.indexOf("ATOM") == 0) {\r
try {\r
- Atom tmpatom = new Atom(str);\r
+ Atom tmpatom = new Atom(line);\r
\r
- if (findChain(tmpatom.chain) != null) {\r
- // System.out.println("Adding to chain " + tmpatom.chain);\r
+ if (findChain(tmpatom.chain) != null)\r
+ {\r
findChain(tmpatom.chain).atoms.addElement(tmpatom);\r
- } else {\r
+ } else\r
+ {\r
PDBChain tmpchain = new PDBChain(tmpatom.chain);\r
chains.addElement(tmpchain);\r
tmpchain.atoms.addElement(tmpatom);\r
lineArray.elementAt(i).toString());\r
}\r
}\r
- }\r
}\r
\r
makeResidueList();\r