import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
+import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.jmol.modelsetbio.Monomer;
import org.jmol.viewer.Viewer;
+import MCview.PDBChain;
+
/**
- * Import and process PDB files with Jmol
+ * Import and process files with Jmol for file like PDB, mmCIF
*
* @author jprocter
*
*/
-public class PDBFileWithJmol extends AlignFile implements
+public class JmolParser extends AlignFile implements
JmolStatusListener
{
Viewer viewer = null;
- public PDBFileWithJmol(String inFile, String type) throws IOException
+ private Collection<PDBChain> chains;
+
+ /*
+ * Set true to predict secondary structure (using JMol for protein, Annotate3D
+ * for RNA)
+ */
+ private boolean predictSecondaryStructure = true;
+
+ public JmolParser(String inFile, String type) throws IOException
{
super(inFile, type);
}
- public PDBFileWithJmol(FileParse fp) throws IOException
+ public JmolParser(FileParse fp) throws IOException
{
super(fp);
}
- public PDBFileWithJmol()
+ public JmolParser()
{
}
@Override
public void parse() throws IOException
{
+
+ chains = new ArrayList<PDBChain>();
Viewer jmolModel = getJmolData();
jmolModel.openReader(getDataName(), getDataName(), getReader());
waitForScript(jmolModel);
/*
* construct and add the Jalview sequence
*/
- String seqName = "" + getDataName() + "|" + modelTitle + "|"
+ String seqName = "" + modelTitle + "|"
+ chainId;
- SequenceI sq = new Sequence(seqName, seq, firstResNum, firstResNum + length - 1);
+ int start = firstResNum;
+ int end = firstResNum + length - 1;
+
+ SequenceI sq = new Sequence(seqName, seq, start, end);
+
+ addPdbid(sq, modelTitle, chainId);
+
+ addSourceDBref(sq, modelTitle, start, end);
+
seqs.add(sq);
+ addChainMetaData(sq, monomers, chainId);
+
/*
* add secondary structure predictions (if any)
*/
- addSecondaryStructureAnnotation(modelTitle, sq, secstr, secstrcode,
+ if (isPredictSecondaryStructure())
+ {
+ addSecondaryStructureAnnotation(modelTitle, sq, secstr, secstrcode,
chainId, firstResNum);
+ }
- /*
- * record the PDB id for the sequence
- */
- addPdbid(sq, chainId);
+ }
+
+ public void addChainMetaData(SequenceI sq, List<Monomer> monomers,
+ String chainId)
+ {
+ for (char res : sq.getSequence())
+ {
+
+ }
+ }
+
+ /**
+ * Add a source db ref entry for the given sequence.
+ *
+ * @param sq
+ * @param accessionId
+ * @param start
+ * @param end
+ */
+ protected void addSourceDBref(SequenceI sq, String accessionId,
+ int start, int end)
+ {
+ DBRefEntry sourceDBRef = new DBRefEntry();
+ sourceDBRef.setAccessionId(accessionId);
+ sourceDBRef.setSource(DBRefSource.MMCIF);
+ sourceDBRef.setStartRes(start);
+ sourceDBRef.setEndRes(end);
+ sq.setSourceDBRef(sourceDBRef);
+ sq.addDBRef(sourceDBRef);
+ }
+
+
+ /**
+ * Add a PDBEntry giving the source of PDB data to the sequence
+ *
+ * @param sq
+ * @param id
+ * @param chainId
+ */
+ protected void addPdbid(SequenceI sq, String id, String chainId)
+ {
+ PDBEntry entry = new PDBEntry();
+ entry.setId(id);
+ entry.setType(PDBEntry.Type.MMCIF);
+ entry.setProperty(new Hashtable());
+ if (chainId != null)
+ {
+ // entry.getProperty().put("CHAIN", chains.elementAt(i).id);
+ entry.setChainCode(String.valueOf(chainId));
+ }
+ if (inFile != null)
+ {
+ entry.setFile(inFile.getAbsolutePath());
+ }
+ else
+ {
+ // TODO: decide if we should dump the datasource to disk
+ entry.setFile(getDataName());
+ }
+
+ sq.addPDBId(entry);
}
/**
}
}
- /**
- * Add a PDBEntry giving the source of PDB data to the sequence
- *
- * @param sq
- * @param chainId
- */
- protected void addPdbid(SequenceI sq, String chainId)
- {
- PDBEntry pdbe = new PDBEntry();
- pdbe.setFile(getDataName());
- pdbe.setId(getDataName());
- pdbe.setProperty(new Hashtable());
- pdbe.setChainCode(chainId);
- sq.addPDBId(pdbe);
- }
/**
* Scans the list of Monomers (residue models), inspecting the chain id for
return result;
}
+ public boolean isPredictSecondaryStructure()
+ {
+ return predictSecondaryStructure;
+ }
+
+ public void setPredictSecondaryStructure(boolean predictSecondaryStructure)
+ {
+ this.predictSecondaryStructure = predictSecondaryStructure;
+ }
+
+ public Collection<PDBChain> getChains()
+ {
+ return chains;
+ }
+
+ public void setChains(Collection<PDBChain> chains)
+ {
+ this.chains = chains;
+ }
+
}