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
26 import java.awt.Color;
\r
29 public class PDBfile extends jalview.io.FileParse {
\r
30 public Vector chains = new Vector();
\r
31 Vector lineArray = new Vector();
\r
34 public PDBfile(String[] lines) {
\r
35 for (int i = 0; i < lines.length; i++)
\r
36 lineArray.addElement(lines[i]);
\r
38 noLines = lineArray.size();
\r
42 public PDBfile(String inFile, String inType) throws IOException {
\r
43 super(inFile, inType);
\r
46 this.lineArray = new Vector();
\r
48 BufferedReader dataIn;
\r
50 if (inType.equals("File")) {
\r
51 dataIn = new BufferedReader(new FileReader(inFile));
\r
53 else if(inType.equals("Paste"))
\r
55 dataIn = new BufferedReader(new StringReader(inFile));
\r
58 URL url = new URL(inFile);
\r
60 dataIn = new BufferedReader(new InputStreamReader(url.openStream()));
\r
63 while ((line = dataIn.readLine()) != null) {
\r
64 lineArray.addElement(line);
\r
67 noLines = lineArray.size();
\r
77 boolean modelFlag = false;
\r
78 boolean terFlag = false;
\r
81 for (int i = 0; i < lineArray.size(); i++)
\r
84 line = lineArray.elementAt(i).toString();
\r
87 if (line.indexOf("HEADER") == 0)
\r
89 id = line.substring(62, 67).trim();
\r
93 if(line.indexOf("MODEL")==0)
\r
96 if(line.indexOf("TER")==0)
\r
99 if(modelFlag && line.indexOf("ENDMDL")==0)
\r
102 if ( line.indexOf("ATOM")==0
\r
103 || (line.indexOf("HETATM")==0 && !terFlag)
\r
109 //Jalview is only interested in CA bonds????
\r
110 if (!line.substring(12, 15).trim().equals("CA"))
\r
115 Atom tmpatom = new Atom(line);
\r
117 tmpchain = findChain(tmpatom.chain);
\r
118 if (tmpchain != null)
\r
120 tmpchain.atoms.addElement(tmpatom);
\r
124 tmpchain = new PDBChain(tmpatom.chain);
\r
125 chains.addElement(tmpchain);
\r
126 tmpchain.atoms.addElement(tmpatom);
\r
136 public void makeResidueList() {
\r
137 for (int i = 0; i < chains.size(); i++) {
\r
138 ((PDBChain) chains.elementAt(i)).makeResidueList();
\r
142 public void makeCaBondList() {
\r
143 for (int i = 0; i < chains.size(); i++) {
\r
144 ((PDBChain) chains.elementAt(i)).makeCaBondList();
\r
148 public PDBChain findChain(String id) {
\r
149 for (int i = 0; i < chains.size(); i++) {
\r
150 if (((PDBChain) chains.elementAt(i)).id.equals(id)) {
\r
151 return (PDBChain) chains.elementAt(i);
\r
158 public void setChargeColours() {
\r
159 for (int i = 0; i < chains.size(); i++) {
\r
160 ((PDBChain) chains.elementAt(i)).setChargeColours();
\r
164 public void setColours(jalview.schemes.ColourSchemeI cs) {
\r
165 for (int i = 0; i < chains.size(); i++) {
\r
166 ((PDBChain) chains.elementAt(i)).setChainColours(cs);
\r
170 public void setChainColours()
\r
172 for (int i = 0; i < chains.size(); i++)
\r
174 ((PDBChain) chains.elementAt(i)).setChainColours(
\r
175 Color.getHSBColor(1.0f / (float)i, .4f, 1.0f)
\r