2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
28 public class PDBfile extends jalview.io.FileParse {
\r
29 public Vector chains = new Vector();
\r
30 Vector lineArray = new Vector();
\r
32 public PDBfile(String[] lines) {
\r
33 for (int i = 0; i < lines.length; i++)
\r
34 lineArray.addElement(lines[i]);
\r
36 noLines = lineArray.size();
\r
40 public PDBfile(String inFile, String inType) throws IOException {
\r
41 super(inFile, inType);
\r
44 this.lineArray = new Vector();
\r
46 BufferedReader dataIn;
\r
48 if (inType.equals("File")) {
\r
49 dataIn = new BufferedReader(new FileReader(inFile));
\r
51 else if(inType.equals("Paste"))
\r
53 dataIn = new BufferedReader(new StringReader(inFile));
\r
56 URL url = new URL(inFile);
\r
58 dataIn = new BufferedReader(new InputStreamReader(url.openStream()));
\r
61 while ((line = dataIn.readLine()) != null) {
\r
62 lineArray.addElement(line);
\r
65 noLines = lineArray.size();
\r
70 public void parse() {
\r
71 for (int i = 0; i < lineArray.size(); i++) {
\r
72 StringTokenizer str = new StringTokenizer(lineArray.elementAt(i)
\r
75 if (str.hasMoreTokens()) {
\r
76 String inStr = str.nextToken();
\r
78 if (inStr.indexOf("ATOM") != -1) {
\r
80 myAtom tmpatom = new myAtom(str);
\r
82 if (findChain(tmpatom.chain) != null) {
\r
83 // System.out.println("Adding to chain " + tmpatom.chain);
\r
84 findChain(tmpatom.chain).atoms.addElement(tmpatom);
\r
86 PDBChain tmpchain = new PDBChain(tmpatom.chain);
\r
87 chains.addElement(tmpchain);
\r
88 tmpchain.atoms.addElement(tmpatom);
\r
90 } catch (NumberFormatException e) {
\r
91 System.err.println("Caught" + e);
\r
92 System.err.println("Record not added to PDB model:" +
\r
93 lineArray.elementAt(i).toString());
\r
103 public void makeResidueList() {
\r
104 for (int i = 0; i < chains.size(); i++) {
\r
105 ((PDBChain) chains.elementAt(i)).makeResidueList();
\r
109 public void makeCaBondList() {
\r
110 for (int i = 0; i < chains.size(); i++) {
\r
111 ((PDBChain) chains.elementAt(i)).makeCaBondList();
\r
115 public PDBChain findChain(String id) {
\r
116 for (int i = 0; i < chains.size(); i++) {
\r
117 // System.out.println("ID = " + id + " " +((PDBChain)chains.elementAt(i)).id);
\r
118 if (((PDBChain) chains.elementAt(i)).id.equals(id)) {
\r
119 return (PDBChain) chains.elementAt(i);
\r
126 public void setChargeColours() {
\r
127 for (int i = 0; i < chains.size(); i++) {
\r
128 ((PDBChain) chains.elementAt(i)).setChargeColours();
\r
132 public void setHydrophobicityColours() {
\r
133 for (int i = 0; i < chains.size(); i++) {
\r
134 ((PDBChain) chains.elementAt(i)).setHydrophobicityColours();
\r
138 public void colourBySequence()//jalview.gui.SequenceRenderer sr,
\r
139 // jalview.gui.FeatureRenderer fr)
\r
141 for (int i = 0; i < chains.size(); i++) {
\r
142 //((PDBChain)chains.elementAt(i)).colourBySequence(sr,fr);
\r
146 public void setChainColours() {
\r
147 for (int i = 0; i < chains.size(); i++) {
\r
148 ((PDBChain) chains.elementAt(i)).setChainColours();
\r