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
21 import jalview.io.AppletFormatAdapter;
\r
22 import jalview.datamodel.*;
\r
29 import java.awt.Color;
\r
32 public class PDBfile extends jalview.io.AlignFile {
\r
33 public Vector chains;
\r
36 public PDBfile(String inFile, String inType) throws IOException
\r
38 super(inFile, inType);
\r
41 public String print()
\r
46 public void parse() throws IOException
\r
48 chains = new Vector();
\r
52 boolean modelFlag = false;
\r
53 boolean terFlag = false;
\r
57 while((line = nextLine())!=null)
\r
59 if (line.indexOf("HEADER") == 0)
\r
61 id = line.substring(62, 67).trim();
\r
65 if(line.indexOf("MODEL")==0)
\r
68 if(line.indexOf("TER")==0)
\r
71 if(modelFlag && line.indexOf("ENDMDL")==0)
\r
74 if ( line.indexOf("ATOM")==0
\r
75 || (line.indexOf("HETATM")==0 && !terFlag)
\r
81 //Jalview is only interested in CA bonds????
\r
82 if (!line.substring(12, 15).trim().equals("CA"))
\r
87 Atom tmpatom = new Atom(line);
\r
88 tmpchain = findChain(tmpatom.chain);
\r
89 if (tmpchain != null)
\r
91 tmpchain.atoms.addElement(tmpatom);
\r
95 tmpchain = new PDBChain(tmpatom.chain);
\r
96 chains.addElement(tmpchain);
\r
97 tmpchain.atoms.addElement(tmpatom);
\r
106 for (int i = 0; i < chains.size(); i++)
\r
108 SequenceI seq = ( (PDBChain) chains.elementAt(i)).
\r
110 seq.setName(id + "|" + seq.getName());
\r
111 Sequence dataset = new Sequence(seq.
\r
113 seq.getSequence().toString(), seq.getStart(), seq.getEnd());
\r
115 PDBEntry entry = new PDBEntry();
\r
117 entry.setFile(inFile.getAbsolutePath());
\r
119 seq.setDatasetSequence(dataset);
\r
120 dataset.addPDBId(entry);
\r
122 getSeqs().addElement(seq);
\r
126 public void makeResidueList() {
\r
127 for (int i = 0; i < chains.size(); i++) {
\r
128 ((PDBChain) chains.elementAt(i)).makeResidueList();
\r
132 public void makeCaBondList() {
\r
133 for (int i = 0; i < chains.size(); i++) {
\r
134 ((PDBChain) chains.elementAt(i)).makeCaBondList();
\r
138 public PDBChain findChain(String id) {
\r
139 for (int i = 0; i < chains.size(); i++) {
\r
140 if (((PDBChain) chains.elementAt(i)).id.equals(id)) {
\r
141 return (PDBChain) chains.elementAt(i);
\r
148 public void setChargeColours() {
\r
149 for (int i = 0; i < chains.size(); i++) {
\r
150 ((PDBChain) chains.elementAt(i)).setChargeColours();
\r
154 public void setColours(jalview.schemes.ColourSchemeI cs) {
\r
155 for (int i = 0; i < chains.size(); i++) {
\r
156 ((PDBChain) chains.elementAt(i)).setChainColours(cs);
\r
160 public void setChainColours()
\r
162 for (int i = 0; i < chains.size(); i++)
\r
164 ((PDBChain) chains.elementAt(i)).setChainColours(
\r
165 Color.getHSBColor(1.0f / (float)i, .4f, 1.0f)
\r