From 75aa2f504257f5564e3a88c3677905d7c392f24e Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 20 Sep 2021 11:16:44 +0100 Subject: [PATCH] JAL-3829 make sure structure data type reflects actual format identified --- src/jalview/ext/jmol/JmolParser.java | 47 ++++++++++++++++++++++++++++++---- src/mc_view/PDBChain.java | 31 ++++++++++++---------- src/mc_view/PDBfile.java | 4 +-- 3 files changed, 62 insertions(+), 20 deletions(-) diff --git a/src/jalview/ext/jmol/JmolParser.java b/src/jalview/ext/jmol/JmolParser.java index ae8ff7a..18d8e05 100644 --- a/src/jalview/ext/jmol/JmolParser.java +++ b/src/jalview/ext/jmol/JmolParser.java @@ -160,7 +160,31 @@ public class JmolParser extends StructureFile implements JmolStatusListener return validator; } - + PDBEntry.Type jmolFiletype=null; + /** + * resolve a jmol filetype string and update the jmolFiletype field accordingly + * @param jmolIdentifiedFileType + * @return true if filetype was identified as MMCIF, PDB + */ + public boolean updateFileType(String jmolIdentifiedFileType) + { + if (jmolIdentifiedFileType == null + || jmolIdentifiedFileType.trim().equals("")) + { + return false; + } + if ("mmcif".equalsIgnoreCase(jmolIdentifiedFileType)) { + jmolFiletype = PDBEntry.Type.MMCIF; + return true; + } + if ("pdb".equalsIgnoreCase(jmolIdentifiedFileType)) + { + jmolFiletype = PDBEntry.Type.PDB; + return true; + } + return false; + } + public void transformJmolModelToJalview(ModelSet ms) throws IOException { try @@ -171,8 +195,15 @@ public class JmolParser extends StructureFile implements JmolStatusListener List prot = new ArrayList(); PDBChain tmpchain; String pdbId = (String) ms.getInfo(0, "title"); - String isMMCIF = (String) ms.getInfo(0, "fileType"); - + boolean isMMCIF = false; + String jmolFileType_String = (String) ms.getInfo(0, "fileType"); + if (updateFileType(jmolFileType_String)) + { + setStructureFileType(jmolFiletype.toString()); + } + + isMMCIF = PDBEntry.Type.MMCIF.equals(jmolFiletype); + if (pdbId == null) { setId(safeName(getDataName())); @@ -182,7 +213,7 @@ public class JmolParser extends StructureFile implements JmolStatusListener { setId(pdbId); setPDBIdAvailable(true); - alphaFoldModel = alphaFold.search(pdbId) && isMMCIF!=null && isMMCIF.equalsIgnoreCase("mmcif"); + alphaFoldModel = alphaFold.search(pdbId) && isMMCIF; } List significantAtoms = convertSignificantAtoms(ms); @@ -199,7 +230,13 @@ public class JmolParser extends StructureFile implements JmolStatusListener tmpchain.atoms.addElement(tmpatom); } else { - tmpchain = new PDBChain(getId(), tmpatom.chain,isAlphafoldModel()); + String tempFString=null; + if (isAlphafoldModel()) + { + tempFString = "Alphafold Reliability"; + } + + tmpchain = new PDBChain(getId(), tmpatom.chain,tempFString); getChains().add(tmpchain); tmpchain.atoms.addElement(tmpatom); } diff --git a/src/mc_view/PDBChain.java b/src/mc_view/PDBChain.java index 2a813d0..e1c90f3 100755 --- a/src/mc_view/PDBChain.java +++ b/src/mc_view/PDBChain.java @@ -78,11 +78,27 @@ public class PDBChain public String pdbid = ""; - public PDBChain(String thePdbid, String theId, boolean isAlphaFoldModel) + String tfacName = "Temperature Factor"; + + + public PDBChain(String thePdbid, String theId, String tempFactorColumnName) { this.pdbid = thePdbid == null ? thePdbid : thePdbid.toLowerCase(); this.id = theId; - this.alphaFoldModel = isAlphaFoldModel; + 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); } /** @@ -92,8 +108,6 @@ public class PDBChain public Mapping shadowMap; - private boolean alphaFoldModel; - public void setNewlineString(String nl) { newline = nl; @@ -493,11 +507,6 @@ public class PDBChain min = Math.min(min, annots[i].value); resAnnotation.setElementAt(null, i); } - String tfacName = "Temperature Factor"; - if (isAlphaFoldModel()) - { - tfacName = "Alphafold Reliability"; - } AlignmentAnnotation tfactorann = new AlignmentAnnotation( tfacName, tfacName + " for " + pdbid + id, annots, min, max, AlignmentAnnotation.LINE_GRAPH); @@ -509,10 +518,6 @@ public class PDBChain } } - private boolean isAlphaFoldModel() - { - return alphaFoldModel; - } /** * Colour start/end of bonds by charge diff --git a/src/mc_view/PDBfile.java b/src/mc_view/PDBfile.java index 24e0435..0eb14cd 100755 --- a/src/mc_view/PDBfile.java +++ b/src/mc_view/PDBfile.java @@ -154,8 +154,8 @@ public class PDBfile extends StructureFile tmpchain.atoms.addElement(tmpatom); } else { - // PDBfile never handles alphafold models, so false - tmpchain = new PDBChain(getId(), tmpatom.chain, false); + // PDBfile never handles alphafold models + tmpchain = new PDBChain(getId(), tmpatom.chain); getChains().add(tmpchain); tmpchain.atoms.addElement(tmpatom); } -- 1.7.10.2