X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fmc_view%2FPDBChain.java;h=e854247babf9d96984f7d84ce84b2c1629c7275c;hb=refs%2Fheads%2Ftask%2FJAL-4059_updateJmolandSwingJS;hp=a3c8bee12febbe2395f5f84323f0c563d4be38e5;hpb=1b98f7d9d004823a57b9e1c4e476123c2ea4a898;p=jalview.git diff --git a/src/mc_view/PDBChain.java b/src/mc_view/PDBChain.java index a3c8bee..e854247 100755 --- a/src/mc_view/PDBChain.java +++ b/src/mc_view/PDBChain.java @@ -20,6 +20,11 @@ */ package mc_view; +import java.awt.Color; +import java.util.List; +import java.util.Locale; +import java.util.Vector; + import jalview.analysis.AlignSeq; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; @@ -33,10 +38,6 @@ import jalview.structure.StructureImportSettings; import jalview.structure.StructureMapping; import jalview.util.Comparison; -import java.awt.Color; -import java.util.List; -import java.util.Vector; - public class PDBChain { public static final String RESNUM_FEATURE = "RESNUM"; @@ -78,10 +79,30 @@ public class PDBChain public String pdbid = ""; - public PDBChain(String thePdbid, String theId) + String tfacName = "Temperature Factor"; + + public PDBChain(String thePdbid, String theId, + String tempFactorColumnName) { - this.pdbid = thePdbid == null ? thePdbid : thePdbid.toLowerCase(); + this.pdbid = thePdbid == null ? thePdbid + : thePdbid.toLowerCase(Locale.ROOT); this.id = theId; + if (tempFactorColumnName != null && tempFactorColumnName.length() > 0) + { + tfacName = tempFactorColumnName; + } + } + + /** + * import chain data assuming Temperature Factor is in the Temperature Factor + * column + * + * @param thePdbid + * @param theId + */ + public PDBChain(String thePdbid, String theId) + { + this(thePdbid, theId, null); } /** @@ -193,8 +214,8 @@ public class PDBChain } char seqchar = ds.getCharAt(seqpos - ds.getStart()); - boolean sameResidue = Comparison.isSameResidue( - seqchar, strchar, false); + boolean sameResidue = Comparison.isSameResidue(seqchar, strchar, + false); if (sameResidue) { for (Atom atom : res.atoms) @@ -212,10 +233,18 @@ public class PDBChain * @param seq * @param status * The Status of the transferred annotation + * + * @param altPDBID + * the group id for the features on the destination sequence (e.g. + * the official accession ID) */ - public void transferRESNUMFeatures(SequenceI seq, - String status) + public void transferRESNUMFeatures(SequenceI seq, String status, + String altPDBID) { + if (altPDBID == null) + { + altPDBID = pdbid; + } SequenceI sq = seq; while (sq != null && sq.getDatasetSequence() != null) { @@ -243,12 +272,13 @@ public class PDBChain if (feature.getFeatureGroup() != null && feature.getFeatureGroup().equals(pdbid)) { - int newBegin = 1 + residues.elementAt(feature.getBegin() - offset).atoms - .elementAt(0).alignmentMapping; + int newBegin = 1 + + residues.elementAt(feature.getBegin() - offset).atoms + .elementAt(0).alignmentMapping; int newEnd = 1 + residues.elementAt(feature.getEnd() - offset).atoms .elementAt(0).alignmentMapping; SequenceFeature tx = new SequenceFeature(feature, newBegin, newEnd, - feature.getFeatureGroup(), feature.getScore()); + altPDBID, feature.getScore()); tx.setStatus(status + ((tx.getStatus() == null || tx.getStatus().length() == 0) ? "" @@ -393,8 +423,8 @@ public class PDBChain { String desc = currAtom.resName + ":" + currAtom.resNumIns + " " + pdbid + id; - SequenceFeature sf = new SequenceFeature("INSERTION", desc, offset - + count - 1, offset + count - 1, "PDB_INS"); + SequenceFeature sf = new SequenceFeature("INSERTION", desc, + offset + count - 1, offset + count - 1, "PDB_INS"); resFeatures.addElement(sf); residues.lastElement().atoms.addAll(resAtoms); } @@ -406,12 +436,12 @@ public class PDBChain Residue tmpres = residues.lastElement(); Atom tmpat = tmpres.atoms.get(0); // Make A new SequenceFeature for the current residue numbering - String desc = tmpat.resName - + ":" + tmpat.resNumIns + " " + pdbid + id; + String desc = tmpat.resName + ":" + tmpat.resNumIns + " " + pdbid + + id; SequenceFeature sf = new SequenceFeature(RESNUM_FEATURE, desc, offset + count, offset + count, pdbid); resFeatures.addElement(sf); - resAnnotation.addElement(new Annotation(tmpat.tfactor)); + resAnnotation.addElement(new Annotation((float) tmpat.tfactor)); // Keep totting up the sequence if ((symbol = ResidueProperties.getAA3Hash() @@ -490,10 +520,12 @@ public class PDBChain min = Math.min(min, annots[i].value); resAnnotation.setElementAt(null, i); } + AlignmentAnnotation tfactorann = new AlignmentAnnotation(tfacName, + tfacName + " for " + pdbid + id, annots, min, max, + AlignmentAnnotation.LINE_GRAPH); + + tfactorann.setCalcId(getClass().getName()); - AlignmentAnnotation tfactorann = new AlignmentAnnotation( - "Temperature Factor", "Temperature Factor for " + pdbid + id, - annots, min, max, AlignmentAnnotation.LINE_GRAPH); tfactorann.setSequenceRef(sequence); sequence.addAlignmentAnnotation(tfactorann); } @@ -615,8 +647,10 @@ public class PDBChain for (AlignmentAnnotation ana : shadow.getAnnotation()) { - List transfer = sq - .getAlignmentAnnotations(ana.getCalcId(), ana.label); + // match on calcId, label and description so annotations from + // different structures are preserved + List transfer = sq.getAlignmentAnnotations( + ana.getCalcId(), ana.label, ana.description); if (transfer == null || transfer.size() == 0) { ana = new AlignmentAnnotation(ana); @@ -636,8 +670,11 @@ public class PDBChain { for (AlignmentAnnotation ana : sequence.getAnnotation()) { + // match on calcId, label and description so annotations from + // different structures are preserved List transfer = dsq - .getAlignmentAnnotations(ana.getCalcId(), ana.label); + .getAlignmentAnnotations(ana.getCalcId(), ana.label, + ana.description); if (transfer == null || transfer.size() == 0) { ana = new AlignmentAnnotation(ana); @@ -657,8 +694,8 @@ public class PDBChain // Useful for debugging mappings - adds annotation for mapped position float min = -1, max = 0; Annotation[] an = new Annotation[sq.getEnd() - sq.getStart() + 1]; - for (int i = sq.getStart(), j = sq - .getEnd(), k = 0; i <= j; i++, k++) + for (int i = sq.getStart(), j = sq.getEnd(), + k = 0; i <= j; i++, k++) { int prn = mapping.getPDBResNum(k + 1);