X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FStructureFile.java;h=d39ab387b90a466a297d9dce3120f46b957d467a;hb=7d67fb613ec026dc9a265e351e7fab542e3f1d61;hp=152a2c0529e7d658fbd6b140af933c9778abcd2b;hpb=02e38bb826828ab2991584cf4b737c0138cb6c44;p=jalview.git diff --git a/src/jalview/io/StructureFile.java b/src/jalview/io/StructureFile.java index 152a2c0..d39ab38 100644 --- a/src/jalview/io/StructureFile.java +++ b/src/jalview/io/StructureFile.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.io; import jalview.analysis.AlignSeq; @@ -15,7 +35,6 @@ import jalview.structure.StructureImportSettings; import java.awt.Color; import java.io.IOException; import java.lang.reflect.Constructor; -import java.util.Hashtable; import java.util.List; import java.util.Vector; @@ -26,6 +45,11 @@ public abstract class StructureFile extends AlignFile private String id; + public enum StructureFileType + { + PDB, MMCIF, MMTF + }; + private PDBEntry.Type dbRefType; /** @@ -48,6 +72,8 @@ public abstract class StructureFile extends AlignFile private Vector chains; + private boolean pdbIdAvailable; + public StructureFile(String inFile, DataSourceType sourceType) throws IOException { @@ -93,18 +119,16 @@ public abstract class StructureFile extends AlignFile { } - @SuppressWarnings("rawtypes") protected SequenceI postProcessChain(PDBChain chain) { SequenceI pdbSequence = chain.sequence; pdbSequence.setName(getId() + "|" + pdbSequence.getName()); PDBEntry entry = new PDBEntry(); entry.setId(getId()); - entry.setType(this.dbRefType); - entry.setProperty(new Hashtable()); + entry.setType(getStructureFileType()); if (chain.id != null) { - entry.setChainCode(String.valueOf(chain.id)); + entry.setChainCode(chain.id); } if (inFile != null) { @@ -118,7 +142,9 @@ public abstract class StructureFile extends AlignFile DBRefEntry sourceDBRef = new DBRefEntry(); sourceDBRef.setAccessionId(getId()); sourceDBRef.setSource(DBRefSource.PDB); - pdbSequence.setSourceDBRef(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; @@ -136,6 +162,26 @@ public abstract class StructureFile extends AlignFile return chainseq; } + /** + * filetype of structure file - default is PDB + */ + String structureFileType = PDBEntry.Type.PDB.toString(); + + protected void setStructureFileType(String structureFileType) + { + this.structureFileType = structureFileType; + } + + /** + * filetype of last file processed + * + * @return + */ + public String getStructureFileType() + { + return structureFileType; + } + @SuppressWarnings({ "unchecked", "rawtypes" }) protected void processPdbFileWithAnnotate3d(List rna) throws Exception @@ -264,11 +310,8 @@ public abstract class StructureFile extends AlignFile Class cl = Class.forName("jalview.ext.jmol.JmolParser"); if (cl != null) { - final Constructor constructor = cl.getConstructor(new Class[] { - boolean.class, boolean.class, boolean.class, FileParse.class }); - final Object[] args = new Object[] { visibleChainAnnotation, - predictSecondaryStructure, externalSecondaryStructure, - new FileParse(getDataName(), dataSourceType) }; + final Constructor constructor = cl.getConstructor(new Class[] {FileParse.class }); + final Object[] args = new Object[] { new FileParse(getDataName(), dataSourceType) }; StructureImportSettings.setShowSeqFeatures(false); StructureImportSettings.setVisibleChainAnnotation(false); @@ -408,7 +451,7 @@ public abstract class StructureFile extends AlignFile public void setDbRefType(String dbRefType) { - this.dbRefType = Type.valueOf(dbRefType); + this.dbRefType = Type.getType(dbRefType); } public void setDbRefType(Type dbRefType) @@ -430,4 +473,35 @@ public abstract class StructureFile extends AlignFile { return new PDBFeatureSettings(); } + + /** + * Answers true if the structure file has a PDBId + * + * @return + */ + public boolean isPPDBIdAvailable() + { + return pdbIdAvailable; + } + + public void setPDBIdAvailable(boolean pdbIdAvailable) + { + this.pdbIdAvailable = pdbIdAvailable; + } + + public static boolean isStructureFile(String fileType) + { + if (fileType == null) + { + return false; + } + for (StructureFileType sfType : StructureFileType.values()) + { + if (sfType.name().equalsIgnoreCase(fileType)) + { + return true; + } + } + return false; + } }