X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2FMCview%2FPDBChain.java;h=3cf73d1e8d466673432fc9f8596a86f6015670b9;hb=001bbb88f11b8a6cb2fb67aa30a64fe15ae454fb;hp=4bfe2559558fc7d7c75ca3c99a10c58a6b524b23;hpb=588042b69abf8e60bcc950b24c283933c7dd422f;p=jalview.git diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 4bfe255..3cf73d1 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -34,11 +34,12 @@ public class PDBChain { public Vector residues = new Vector(); public int offset; public Sequence sequence; - public boolean isVisible = false; + public boolean isVisible = true; public int pdbstart = 0; public int pdbend = 0; public int seqstart = 0; public int seqend = 0; + public int [] seqMapping; //public DrawableSequence ds; public PDBChain(String id) { @@ -57,22 +58,26 @@ public class PDBChain { return tmp; } - public void makeCaBondList() { - for (int i = 0; i < (residues.size() - 1); i++) { + public void makeCaBondList() + { + for (int i = 0; i < (residues.size() - 1); i++) + { Residue tmpres = (Residue) residues.elementAt(i); Residue tmpres2 = (Residue) residues.elementAt(i + 1); - myAtom at1 = tmpres.findAtom("CA"); - myAtom at2 = tmpres2.findAtom("CA"); + Atom at1 = tmpres.findAtom("CA"); + Atom at2 = tmpres2.findAtom("CA"); - if ((at1 != null) && (at2 != null)) { - if (at1.chain.equals(at2.chain)) { + if ((at1 != null) && (at2 != null)) + { + if (at1.chain.equals(at2.chain)) + { makeBond(at1, at2); } } } } - public void makeBond(myAtom at1, myAtom at2) { + public void makeBond(Atom at1, Atom at2) { float[] start = new float[3]; float[] end = new float[3]; @@ -89,11 +94,12 @@ public class PDBChain { public void makeResidueList() { int count = 0; - String seq = ""; + StringBuffer seq = new StringBuffer(); - for (int i = 0; i < atoms.size(); i++) { - myAtom tmp = (myAtom) atoms.elementAt(i); - String resName = tmp.resName; + int i, iSize = atoms.size()-1; + for (i = 0; i < iSize; i++) + { + Atom tmp = (Atom) atoms.elementAt(i); int resNumber = tmp.resNumber; int res = resNumber; @@ -103,18 +109,18 @@ public class PDBChain { Vector resAtoms = new Vector(); - resAtoms.addElement((myAtom) atoms.elementAt(i)); + resAtoms.addElement((Atom) atoms.elementAt(i)); i++; - resNumber = ((myAtom) atoms.elementAt(i)).resNumber; + resNumber = ((Atom) atoms.elementAt(i)).resNumber; //Add atoms to a vector while the residue number //remains the same while ((resNumber == res) && (i < atoms.size())) { - resAtoms.addElement((myAtom) atoms.elementAt(i)); + resAtoms.addElement((Atom) atoms.elementAt(i)); i++; if (i < atoms.size()) { - resNumber = ((myAtom) atoms.elementAt(i)).resNumber; + resNumber = ((Atom) atoms.elementAt(i)).resNumber; } else { resNumber++; } @@ -128,24 +134,27 @@ public class PDBChain { count++; Residue tmpres = (Residue) residues.lastElement(); - myAtom tmpat = (myAtom) tmpres.atoms.elementAt(0); + Atom tmpat = (Atom) tmpres.atoms.elementAt(0); // Keep totting up the sequence - if (ResidueProperties.getAA3Hash().get(tmpat.resName) == null) { - System.err.println("PDBReader:Null aa3Hash for " + - tmpat.resName); + if (ResidueProperties.getAA3Hash().get(tmpat.resName) == null) + { + seq.append("X") ; + // System.err.println("PDBReader:Null aa3Hash for " + + // tmpat.resName); } else { - String tmpres2 = ResidueProperties.aa[((Integer) ResidueProperties.getAA3Hash() - .get(tmpat.resName)).intValue()]; - seq = seq + tmpres2; - } - // System.out.println(tmpat.resName + " " + tmpres2); + seq.append(ResidueProperties.aa[((Integer) ResidueProperties.getAA3Hash() + .get(tmpat.resName)).intValue()]); + } } - sequence = new Sequence("PDB_seq", seq, 1, seq.length()); - System.out.println("PDB Sequence is :\nSequence = " + seq); - System.out.println("No of residues = " + residues.size()); + if(id.length()<1 || id.equals(" ")) + id = "_"; + + sequence = new Sequence(id, seq.toString(), 1, seq.length()); + // System.out.println("PDB Sequence is :\nSequence = " + seq); + // System.out.println("No of residues = " + residues.size()); } public void setChargeColours() { @@ -162,7 +171,7 @@ public class PDBChain { } else if (b.at1.resName.toUpperCase().equals("CYS")) { b.startCol = Color.yellow; } else { - int atno = ((Integer) ResidueProperties.getAA3Hash().get(b.at1.resName.toUpperCase())).intValue(); + //int atno = ((Integer) ResidueProperties.getAA3Hash().get(b.at1.resName.toUpperCase())).intValue(); b.startCol = Color.lightGray; } @@ -175,7 +184,7 @@ public class PDBChain { } else if (b.at2.resName.toUpperCase().equals("CYS")) { b.endCol = Color.yellow; } else { - int atno = ((Integer) ResidueProperties.getAA3Hash().get(b.at2.resName.toUpperCase())).intValue(); + //int atno = ((Integer) ResidueProperties.getAA3Hash().get(b.at2.resName.toUpperCase())).intValue(); b.endCol = Color.lightGray; } } catch (Exception e) { @@ -230,54 +239,15 @@ public class PDBChain { } } - public void colourBySequence(jalview.gui.AlignViewport av, Sequence seq) { - jalview.gui.SequenceRenderer sr = new jalview.gui.SequenceRenderer(av); - - for (int i = 0; i < bonds.size(); i++) { - Bond tmp = (Bond) bonds.elementAt(i); - - try { - if ((tmp.at1.resNumber >= ((offset + pdbstart) - 1)) && - (tmp.at1.resNumber <= ((offset + pdbend) - 1))) { - int pos = seqstart + - (tmp.at1.resNumber - pdbstart - offset); - int index = seq.findIndex(pos); - - tmp.startCol = sr.getResidueBoxColour(av.getGlobalColourScheme(), - seq, index); - } else { - tmp.startCol = Color.gray; - } - - if ((tmp.at2.resNumber >= ((offset + pdbstart) - 1)) && - (tmp.at2.resNumber <= ((pdbend + offset) - 1))) { - int pos = seqstart + - (tmp.at2.resNumber - pdbstart - offset); - int index = seq.findIndex(pos); - tmp.endCol = sr.getResidueBoxColour(av.getGlobalColourScheme(), - seq, index); - } else { - tmp.endCol = Color.gray; - } - } catch (Exception e) { - tmp.startCol = Color.lightGray; - tmp.endCol = Color.lightGray; - } - } - } - public void setChainColours() { - for (int i = 0; i < bonds.size(); i++) { + public void setChainColours(Color col) + { + for (int i = 0; i < bonds.size(); i++) + { Bond tmp = (Bond) bonds.elementAt(i); - - try { - tmp.startCol = (Color) ResidueProperties.getChainColours().get(id); - tmp.endCol = (Color) ResidueProperties.getChainColours().get(id); - } catch (Exception e) { - tmp.startCol = Color.lightGray; - tmp.endCol = Color.lightGray; - } + tmp.startCol = col; + tmp.endCol = col; } } }