X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FStructureFile.java;h=f09538364d2f0c65bc149b5d49883cc43b410a11;hb=d2164f857e0729b86b1e0ffa4c858487f0a3298f;hp=726244380fee785811222d422060d3a2921d0d32;hpb=43ee8686fab13cd6952335ade1382adf3226f7a1;p=jalview.git diff --git a/src/jalview/io/StructureFile.java b/src/jalview/io/StructureFile.java index 7262443..f095383 100644 --- a/src/jalview/io/StructureFile.java +++ b/src/jalview/io/StructureFile.java @@ -1,14 +1,16 @@ package jalview.io; import jalview.analysis.AlignSeq; +import jalview.api.FeatureSettingsModelI; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.DBRefSource; import jalview.datamodel.PDBEntry; +import jalview.datamodel.PDBEntry.Type; import jalview.datamodel.SequenceI; -import jalview.structure.StructureViewSettings; +import jalview.structure.StructureImportSettings; import java.awt.Color; import java.io.IOException; @@ -24,7 +26,8 @@ public abstract class StructureFile extends AlignFile private String id; - private String dbRefType; + private PDBEntry.Type dbRefType; + /** * set to true to add derived sequence annotations (temp factor read from * file, or computed secondary structure) to the alignment @@ -62,10 +65,22 @@ public abstract class StructureFile extends AlignFile this.predictSecondaryStructure = predictSecondaryStructure; this.externalSecondaryStructure = externalSecStr; } - public StructureFile(boolean parseImmediately, String inFile, String type) + + public void xferSettings() + { + this.visibleChainAnnotation = StructureImportSettings + .isVisibleChainAnnotation(); + this.predictSecondaryStructure = StructureImportSettings + .isProcessSecondaryStructure(); + this.externalSecondaryStructure = StructureImportSettings + .isExternalSecondaryStructure(); + + } + + public StructureFile(boolean parseImmediately, String dataObject, String type) throws IOException { - super(parseImmediately, inFile, type); + super(parseImmediately, dataObject, type); } public StructureFile(boolean a, FileParse fp) throws IOException @@ -102,16 +117,13 @@ public abstract class StructureFile extends AlignFile DBRefEntry sourceDBRef = new DBRefEntry(); sourceDBRef.setAccessionId(getId()); sourceDBRef.setSource(DBRefSource.PDB); - sourceDBRef.setStartRes(pdbSequence.getStart()); - sourceDBRef.setEndRes(pdbSequence.getEnd()); - - SequenceI chainseq = pdbSequence.deriveSequence(); - chainseq.setSourceDBRef(sourceDBRef); - chainseq.addPDBId(entry); - chainseq.addDBRef(sourceDBRef); - + // TODO: specify version for 'PDB' database ref if it is read from a file. + // TODO: decide if jalview.io should be creating primary refs! + sourceDBRef.setVersion(""); + pdbSequence.addPDBId(entry); + pdbSequence.addDBRef(sourceDBRef); + SequenceI chainseq = pdbSequence; seqs.addElement(chainseq); - AlignmentAnnotation[] chainannot = chainseq.getAnnotation(); if (chainannot != null && visibleChainAnnotation) @@ -172,8 +184,7 @@ public abstract class StructureFile extends AlignFile @SuppressWarnings("unchecked") protected void replaceAndUpdateChains(List prot, - AlignmentI al, - String pep, boolean b) + AlignmentI al, String pep, boolean b) { List> replaced = AlignSeq .replaceMatchingSeqsWith(seqs, annotations, prot, al, pep, @@ -246,8 +257,7 @@ public abstract class StructureFile extends AlignFile } @SuppressWarnings({ "unchecked", "rawtypes" }) - private void processWithJmolParser(List prot) - throws Exception + private void processWithJmolParser(List prot) throws Exception { try { @@ -255,15 +265,18 @@ public abstract class StructureFile extends AlignFile Class cl = Class.forName("jalview.ext.jmol.JmolParser"); if (cl != null) { - final Constructor constructor = cl -.getConstructor(new Class[] { + final Constructor constructor = cl.getConstructor(new Class[] { boolean.class, boolean.class, boolean.class, FileParse.class }); - final Object[] args = new Object[] { true, true, true, - new FileParse(getDataName(), - type) }; - - StructureViewSettings.setShowSeqFeatures(false); - StructureViewSettings.setPredictSecondaryStructure(true); + final Object[] args = new Object[] { visibleChainAnnotation, + predictSecondaryStructure, externalSecondaryStructure, + new FileParse(getDataName(), type) }; + + StructureImportSettings.setShowSeqFeatures(false); + StructureImportSettings.setVisibleChainAnnotation(false); + StructureImportSettings + .setProcessSecondaryStructure(predictSecondaryStructure); + StructureImportSettings + .setExternalSecondaryStructure(externalSecondaryStructure); Object jmf = constructor.newInstance(args); AlignmentI al = new Alignment((SequenceI[]) cl.getMethod( "getSeqsAsArray", new Class[] {}).invoke(jmf)); @@ -285,13 +298,14 @@ public abstract class StructureFile extends AlignFile } catch (ClassNotFoundException q) { } + StructureImportSettings.setShowSeqFeatures(true); } public PDBChain findChain(String id) throws Exception { for (PDBChain chain : getChains()) { - if (chain.id.equalsIgnoreCase(id)) + if (chain.id.equals(id)) { return chain; } @@ -388,13 +402,33 @@ public abstract class StructureFile extends AlignFile this.chains = chains; } - public String getDbRefType() + public Type getDbRefType() { return dbRefType; } public void setDbRefType(String dbRefType) { + this.dbRefType = Type.valueOf(dbRefType); + } + + public void setDbRefType(Type dbRefType) + { this.dbRefType = dbRefType; } + + /** + * Returns a descriptor for suitable feature display settings with + *
    + *
  • ResNums or insertions features visible
  • + *
  • insertions features coloured red
  • + *
  • ResNum features coloured by label
  • + *
  • Insertions displayed above (on top of) ResNums
  • + *
+ */ + @Override + public FeatureSettingsModelI getFeatureColourScheme() + { + return new PDBFeatureSettings(); + } }