/*
* 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));
}
}
}