X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2FMCview%2FPDBChain.java;h=2eaf8a3d8ffe210147491569cd8b2d724fad5fec;hb=d423f22792e47dbc800ae220a58677f988971d06;hp=0715b6abd2e8ac892fbd166856e9256b31631e2f;hpb=dbbe146185027d9cb041a83645985a6b1a26cb75;p=jalview.git diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 0715b6a..2eaf8a3 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -1,286 +1,468 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ -package MCview; - -import jalview.datamodel.*; - -import jalview.schemes.ResidueProperties; - -import java.awt.*; - -import java.util.*; -import jalview.analysis.AlignSeq; - - -public class PDBChain { - public String id; - public Vector bonds = new Vector(); - public Vector atoms = new Vector(); - public Vector residues = new Vector(); - public int offset; - public Sequence sequence; - public boolean isVisible = true; - public int pdbstart = 0; - public int pdbend = 0; - public int seqstart = 0; - public int seqend = 0; - - public PDBChain(String id) { - this.id = id; - } - - public String print() { - String tmp = ""; - - for (int i = 0; i < bonds.size(); i++) { - tmp = tmp + ((Bond) bonds.elementAt(i)).at1.resName + " " + - ((Bond) bonds.elementAt(i)).at1.resNumber + " " + offset + - "\n"; - } - - return tmp; - } - - void makeExactMapping(AlignSeq as, Sequence s1) - { - int pdbpos = as.getSeq2Start()-2; - int alignpos = s1.getStart() + as.getSeq1Start()-3; - - for(int i=0; i (float) 1.0) { - red = (float) 1.0; - } - - if (red < (float) 0.0) { - red = (float) 0.0; - } - - b.startCol = new Color(red, (float) 0.0, (float) 1.0 - red); - atno = ((Integer) AA3Hash.get(b.at2.resName.toUpperCase())).intValue(); - - red = ((float) hyd[atno] - hydmin) / (hydmax - hydmin); - - if (red > (float) 1.0) { - red = (float) 1.0; - } - - if (red < (float) 0.0) { - red = (float) 0.0; - } - - b.endCol = new Color(red, (float) 0.2, (float) 1.0 - red); - } catch (Exception e) { - Bond b = (Bond) bonds.elementAt(i); - b.startCol = Color.gray; - b.endCol = Color.gray; - } - } - } - - - - public void setChainColours(Color col) - { - for (int i = 0; i < bonds.size(); i++) - { - Bond tmp = (Bond) bonds.elementAt(i); - tmp.startCol = col; - tmp.endCol = col; - } - } -} +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) + * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + */ +package MCview; + +import java.util.*; + +import java.awt.*; + +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.schemes.*; +import jalview.structure.StructureMapping; + +public class PDBChain +{ + /** + * SequenceFeature group for PDB File features added to sequences + */ + private static final String PDBFILEFEATURE = "PDBFile"; + + private static final String IEASTATUS = "IEA:jalview"; + + public String id; + + public Vector bonds = new Vector(); + + public Vector atoms = new Vector(); + + public Vector residues = new Vector(); + + public int offset; + + public Sequence sequence; + + public boolean isVisible = true; + + public int pdbstart = 0; + + public int pdbend = 0; + + public int seqstart = 0; + + public int seqend = 0; + + public String pdbid = ""; + + public PDBChain(String pdbid, String id) + { + this.pdbid = pdbid.toLowerCase(); + this.id = id; + } + + public String print() + { + String tmp = ""; + + for (int i = 0; i < bonds.size(); i++) + { + tmp = tmp + ((Bond) bonds.elementAt(i)).at1.resName + " " + + ((Bond) bonds.elementAt(i)).at1.resNumber + " " + offset + + "\n"; + } + + return tmp; + } + + public void makeExactMapping(AlignSeq as, SequenceI s1) + { + int pdbpos = as.getSeq2Start() - 2; + int alignpos = s1.getStart() + as.getSeq1Start() - 3; + + for (int i = 0; i < as.astr1.length(); i++) + { + if (as.astr1.charAt(i) != '-') + { + alignpos++; + } + + if (as.astr2.charAt(i) != '-') + { + pdbpos++; + } + + if (as.astr1.charAt(i) == as.astr2.charAt(i)) + { + Residue res = (Residue) residues.elementAt(pdbpos); + Enumeration en = res.atoms.elements(); + while (en.hasMoreElements()) + { + Atom atom = (Atom) en.nextElement(); + atom.alignmentMapping = alignpos; + } + } + } + } + + /** + * copy over the RESNUM seqfeatures from the internal chain sequence to the + * mapped sequence + * + * @param seq + * @param status + * The Status of the transferred annotation + * @return the features added to sq (or its dataset) + */ + public SequenceFeature[] transferRESNUMFeatures(SequenceI seq, + String status) + { + SequenceI sq = seq; + while (sq != null && sq.getDatasetSequence() != null) + { + sq = sq.getDatasetSequence(); + if (sq == sequence) + { + return null; + } + } + /** + * Remove any existing features for this chain if they exist ? + * SequenceFeature[] seqsfeatures=seq.getSequenceFeatures(); int + * totfeat=seqsfeatures.length; // Remove any features for this exact chain + * ? for (int i=0; i k) + { + min = k; + } + else if (max < k) + { + max = k; + } + } + } + sq + .addAlignmentAnnotation(new AlignmentAnnotation("PDB.RESNUM", + "PDB Residue Numbering for " + this.pdbid + ":" + + this.id, an, (float) min, (float) max, + AlignmentAnnotation.LINE_GRAPH)); + } + } +}