PDBEntry pdbentry;
boolean colourBySequence = true;
Vector atomsPicked = new Vector();
-
+ /**
+ * datasource protocol for access to PDBEntry
+ */
+ String protocol=null;
public AppletJmol(PDBEntry pdbentry,
SequenceI[] seq,
String[] chains,
this.sequence = seq;
this.chains = chains;
this.pdbentry = pdbentry;
-
- String alreadyMapped = StructureSelectionManager
+ this.protocol = protocol;
+ if (pdbentry.getId()==null || pdbentry.getId().length()<1)
+ {
+ if (jalview.bin.JalviewLite.debug)
+ {
+ System.err.println("Setting PDB id for file "+pdbentry.getFile());
+ if (protocol.equals(AppletFormatAdapter.PASTE))
+ {
+ pdbentry.setId("PASTED PDB"+(chains==null ? "_" : chains.toString()));
+ } else {
+ pdbentry.setId(pdbentry.getFile());
+ }
+ }
+ }
+ if (jalview.bin.JalviewLite.debug)
+ {
+ System.err.println("AppletJmol: PDB ID is '"+pdbentry.getId()+"'");
+ }
+
+ String alreadyMapped = StructureSelectionManager
.getStructureSelectionManager()
.alreadyMappedToFile(pdbentry.getId());
-
+ MCview.PDBfile reader = null;
if (alreadyMapped != null)
{
- StructureSelectionManager.getStructureSelectionManager()
+ reader = StructureSelectionManager.getStructureSelectionManager()
.setMapping(seq, chains, pdbentry.getFile(), protocol);
//PROMPT USER HERE TO ADD TO NEW OR EXISTING VIEW?
//FOR NOW, LETS JUST OPEN A NEW WINDOW
// probably CLASSLOADER based datasource..
// Try and get a reader on the datasource, and pass that to Jmol
try {
- FileParse fparser = new jalview.io.FileParse(protocol, pdbentry.getFile());
- if (!fparser.isValid())
- {
- throw new Exception("Invalid datasource. "+fparser.getWarningMessage());
+ java.io.Reader freader = null;
+ if (reader!=null) {
+ if (jalview.bin.JalviewLite.debug)
+ {
+ System.err.println("AppletJmol:Trying to reuse existing PDBfile IO parser.");
+ }
+ // re-use the one we opened earlier
+ freader = reader.getReader();
+ }
+ if (freader==null) {
+ if (jalview.bin.JalviewLite.debug)
+ {
+ System.err.println("AppletJmol:Creating new PDBfile IO parser.");
+ }
+ FileParse fp = new FileParse(pdbentry.getFile(), protocol);
+ fp.mark();
+ // reader = new MCview.PDBfile(fp);
+ // could set ID, etc.
+ //if (!reader.isValid())
+ //{
+ // throw new Exception("Invalid datasource. "+reader.getWarningMessage());
+ //}
+ //fp.reset();
+ freader = fp.getReader();
+ }
+ if (freader==null) {
+ throw new Exception("Invalid datasource. Could not obtain Reader.");
}
- viewer.openReader(pdbentry.getFile(), pdbentry.getId(), fparser.getReader());
+ viewer.openReader(pdbentry.getFile(), pdbentry.getId(), freader);
} catch (Exception e)
{
// give up!
{
pdb = ssm.setMapping(sequence,chains,
pdbentry.getFile(),
- AppletFormatAdapter.URL);
+ protocol);
}
pdbentry.setId(pdb.id);