2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2006 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.datamodel.*;
\r
23 import jalview.schemes.ResidueProperties;
\r
28 import jalview.analysis.AlignSeq;
\r
31 public class PDBChain {
\r
33 public Vector bonds = new Vector();
\r
34 public Vector atoms = new Vector();
\r
35 public Vector residues = new Vector();
\r
37 public Sequence sequence;
\r
38 public boolean isVisible = true;
\r
39 public int pdbstart = 0;
\r
40 public int pdbend = 0;
\r
41 public int seqstart = 0;
\r
42 public int seqend = 0;
\r
44 public PDBChain(String id) {
\r
48 public String print() {
\r
51 for (int i = 0; i < bonds.size(); i++) {
\r
52 tmp = tmp + ((Bond) bonds.elementAt(i)).at1.resName + " " +
\r
53 ((Bond) bonds.elementAt(i)).at1.resNumber + " " + offset +
\r
60 void makeExactMapping(AlignSeq as, Sequence s1)
\r
62 int pdbpos = as.getSeq2Start()-2;
\r
63 int alignpos = s1.getStart() + as.getSeq1Start()-3;
\r
65 for(int i=0; i<as.astr1.length(); i++)
\r
67 if (as.astr1.charAt(i) != '-')
\r
72 if (as.astr2.charAt(i) != '-')
\r
77 if (as.astr1.charAt(i) == as.astr2.charAt(i))
\r
79 Residue res = (Residue) residues.elementAt(pdbpos);
\r
80 Enumeration en = res.atoms.elements();
\r
81 while (en.hasMoreElements())
\r
83 Atom atom = (Atom) en.nextElement();
\r
84 atom.alignmentMapping = alignpos;
\r
92 public void makeCaBondList()
\r
94 for (int i = 0; i < (residues.size() - 1); i++)
\r
96 Residue tmpres = (Residue) residues.elementAt(i);
\r
97 Residue tmpres2 = (Residue) residues.elementAt(i + 1);
\r
98 Atom at1 = tmpres.findAtom("CA");
\r
99 Atom at2 = tmpres2.findAtom("CA");
\r
101 if ((at1 != null) && (at2 != null))
\r
103 if (at1.chain.equals(at2.chain))
\r
105 makeBond(at1, at2);
\r
109 System.out.println("not found "+i);
\r
113 public void makeBond(Atom at1, Atom at2) {
\r
114 float[] start = new float[3];
\r
115 float[] end = new float[3];
\r
125 bonds.addElement(new Bond(start, end, at1, at2));
\r
128 public void makeResidueList() {
\r
130 StringBuffer seq = new StringBuffer();
\r
132 int i, iSize = atoms.size()-1;
\r
133 for (i = 0; i < iSize; i++)
\r
135 Atom tmp = (Atom) atoms.elementAt(i);
\r
136 int resNumber = tmp.resNumber;
\r
137 int res = resNumber;
\r
140 offset = resNumber;
\r
143 Vector resAtoms = new Vector();
\r
145 resAtoms.addElement((Atom) atoms.elementAt(i));
\r
147 resNumber = ((Atom) atoms.elementAt(i)).resNumber;
\r
149 //Add atoms to a vector while the residue number
\r
151 while ((resNumber == res) && (i < atoms.size())) {
\r
152 resAtoms.addElement((Atom) atoms.elementAt(i));
\r
155 if (i < atoms.size()) {
\r
156 resNumber = ((Atom) atoms.elementAt(i)).resNumber;
\r
162 //We need this to keep in step with the outer for i = loop
\r
165 //Make a new Residue object with the new atoms vector
\r
166 residues.addElement(new Residue(resAtoms, resNumber - 1, count));
\r
169 Residue tmpres = (Residue) residues.lastElement();
\r
170 Atom tmpat = (Atom) tmpres.atoms.elementAt(0);
\r
172 // Keep totting up the sequence
\r
173 if (ResidueProperties.getAA3Hash().get(tmpat.resName) == null)
\r
176 // System.err.println("PDBReader:Null aa3Hash for " +
\r
180 seq.append(ResidueProperties.aa[((Integer) ResidueProperties.getAA3Hash()
\r
181 .get(tmpat.resName)).intValue()]);
\r
185 if(id.length()<1 || id.equals(" "))
\r
188 sequence = new Sequence(id, seq.toString(), 1, seq.length());
\r
189 // System.out.println("PDB Sequence is :\nSequence = " + seq);
\r
190 // System.out.println("No of residues = " + residues.size());
\r
193 public void setChargeColours() {
\r
194 for (int i = 0; i < bonds.size(); i++) {
\r
196 Bond b = (Bond) bonds.elementAt(i);
\r
198 if (b.at1.resName.equalsIgnoreCase("ASP") ||
\r
199 b.at1.resName.equalsIgnoreCase("GLU")) {
\r
200 b.startCol = Color.red;
\r
201 } else if (b.at1.resName.equalsIgnoreCase("LYS") ||
\r
202 b.at1.resName.equalsIgnoreCase("ARG")) {
\r
203 b.startCol = Color.blue;
\r
204 } else if (b.at1.resName.equalsIgnoreCase("CYS")) {
\r
205 b.startCol = Color.yellow;
\r
207 //int atno = ((Integer) ResidueProperties.getAA3Hash().get(b.at1.resName.toUpperCase())).intValue();
\r
208 b.startCol = Color.lightGray;
\r
211 if (b.at2.resName.equalsIgnoreCase("ASP") ||
\r
212 b.at2.resName.equalsIgnoreCase("GLU")) {
\r
213 b.endCol = Color.red;
\r
214 } else if (b.at2.resName.equalsIgnoreCase("LYS") ||
\r
215 b.at2.resName.equalsIgnoreCase("ARG")) {
\r
216 b.endCol = Color.blue;
\r
217 } else if (b.at2.resName.equalsIgnoreCase("CYS")) {
\r
218 b.endCol = Color.yellow;
\r
220 //int atno = ((Integer) ResidueProperties.getAA3Hash().get(b.at2.resName.toUpperCase())).intValue();
\r
221 b.endCol = Color.lightGray;
\r
223 } catch (Exception e) {
\r
224 Bond b = (Bond) bonds.elementAt(i);
\r
225 b.startCol = Color.gray;
\r
226 b.endCol = Color.gray;
\r
232 public void setChainColours(jalview.schemes.ColourSchemeI cs)
\r
235 for (int i = 0; i < bonds.size(); i++) {
\r
237 b = (Bond) bonds.elementAt(i);
\r
239 ( (Bond) bonds.elementAt(i)).startCol = cs.findColour(
\r
240 ResidueProperties.aa[ ( (Integer) ResidueProperties.aa3Hash.
\r
241 get(b.at1.resName)).intValue()]
\r
244 b.endCol = cs.findColour(
\r
245 ResidueProperties.aa[ ( (Integer) ResidueProperties.aa3Hash.
\r
246 get(b.at2.resName)).intValue()]
\r
249 } catch (Exception e)
\r
251 b = (Bond) bonds.elementAt(i);
\r
252 b.startCol = Color.gray;
\r
253 b.endCol = Color.gray;
\r
260 public void setChainColours(Color col)
\r
262 for (int i = 0; i < bonds.size(); i++)
\r
264 Bond tmp = (Bond) bonds.elementAt(i);
\r
265 tmp.startCol = col;
\r