*/
package jalview.structure;
-import java.io.*;
-import java.util.*;
-
-import MCview.*;
-import jalview.analysis.*;
-import jalview.api.AlignmentViewPanel;
+import jalview.analysis.AlignSeq;
import jalview.api.StructureSelectionManagerProvider;
-import jalview.datamodel.*;
+import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SequenceI;
+import jalview.io.FormatAdapter;
+import jalview.util.MessageManager;
+
+import java.io.PrintStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.Vector;
+
+import MCview.Atom;
+import MCview.PDBChain;
public class StructureSelectionManager
{
}
}
- Hashtable mappingData = new Hashtable();
+ /**
+ * map between the PDB IDs (or structure identifiers) used by Jalview and the
+ * absolute filenames for PDB data that corresponds to it
+ */
+ HashMap<String, String> pdbIdFileName = new HashMap<String, String>(),
+ pdbFileNameId = new HashMap<String, String>();
+
+ public void registerPDBFile(String idForFile, String absoluteFile)
+ {
+ pdbIdFileName.put(idForFile, absoluteFile);
+ pdbFileNameId.put(absoluteFile, idForFile);
+ }
+
+ public String findIdForPDBFile(String idOrFile)
+ {
+ String id = pdbFileNameId.get(idOrFile);
+ return id;
+ }
+
+ public String findFileForPDBId(String idOrFile)
+ {
+ String id = pdbIdFileName.get(idOrFile);
+ return id;
+ }
+
+ public boolean isPDBFileRegistered(String idOrFile)
+ {
+ return pdbFileNameId.containsKey(idOrFile)
+ || pdbIdFileName.containsKey(idOrFile);
+ }
private static StructureSelectionManager nullProvider = null;
{
if (instances != null)
{
- throw new Error(
- "Implementation error. Structure selection manager's context is 'null'",
- new NullPointerException("SSM context is null"));
+ throw new Error(MessageManager.getString("error.implementation_error_structure_selection_manager_null"),
+ new NullPointerException(MessageManager.getString("exception.ssm_context_is_null")));
}
else
{
* the tried and tested MCview pdb mapping
*/
MCview.PDBfile pdb = null;
+ boolean parseSecStr=true;
+ for (SequenceI sq:sequence)
+ {
+ SequenceI ds = sq;while (ds.getDatasetSequence()!=null) { ds = ds.getDatasetSequence();};
+ if (ds.getAnnotation()!=null)
+ {
+ for (AlignmentAnnotation ala:ds.getAnnotation())
+ {
+ // false if any annotation present from this structure
+ if (MCview.PDBfile.isCalcIdForFile(ala.getCalcId(), pdbFile))
+ {
+ parseSecStr = false;
+ }
+ }
+ }
+ }
try
{
- pdb = new MCview.PDBfile(pdbFile, protocol);
+ pdb = new MCview.PDBfile(true, parseSecStr, pdbFile, protocol);
+
} catch (Exception ex)
{
ex.printStackTrace();
}
}
else
+ {
targetChain = "";
+ }
int max = -10;
AlignSeq maxAlignseq = null;
boolean first = true;
for (int i = 0; i < pdb.chains.size(); i++)
{
- PDBChain chain = ((PDBChain) pdb.chains.elementAt(i));
+ PDBChain chain = (pdb.chains.elementAt(i));
if (targetChain.length() > 0 && !targetChain.equals(chain.id)
&& !infChain)
{
// TODO: correctly determine sequence type for mixed na/peptide
// structures
AlignSeq as = new AlignSeq(sequence[s],
- ((PDBChain) pdb.chains.elementAt(i)).sequence,
- ((PDBChain) pdb.chains.elementAt(i)).isNa ? AlignSeq.DNA
+ pdb.chains.elementAt(i).sequence,
+ pdb.chains.elementAt(i).isNa ? AlignSeq.DNA
: AlignSeq.PEP);
as.calcScoreMatrix();
as.traceAlignment();
}
if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE))
+ {
pdbFile = "INLINE" + pdb.id;
+ }
mappings[mappings.length - 1] = new StructureMapping(sequence[s],
pdbFile, pdb.id, maxChainId, mapping,
String[] handlepdbs;
Vector pdbs = new Vector();
for (int i = 0; i < pdbfiles.length; pdbs.addElement(pdbfiles[i++]))
+ {
;
+ }
StructureListener sl;
for (int i = 0; i < listeners.size(); i++)
{
{
Object li = listeners.elementAt(i);
if (li instanceof SequenceListener)
+ {
((SequenceListener) li).highlightSequence(results);
+ }
}
}
}
boolean hasSequenceListeners = handlingVamsasMo || seqmappings != null;
SearchResults results = null;
if (index == -1)
+ {
index = seq.findPosition(indexpos);
+ }
StructureListener sl;
int atomNo = 0;
for (int i = 0; i < listeners.size(); i++)
AlignedCodonFrame[] codonFrames)
{
if (!add && (seqmappings == null || seqmappings.size() == 0))
+ {
return;
+ }
if (seqmappings == null)
+ {
seqmappings = new Vector();
+ }
if (codonFrames != null && codonFrames.length > 0)
{
for (int cf = 0; cf < codonFrames.length; cf++)
int[] nsr = new int[(seqmappingrefs == null) ? 1
: seqmappingrefs.length + 1];
if (seqmappingrefs != null && seqmappingrefs.length > 0)
+ {
System.arraycopy(seqmappingrefs, 0, nsr, 0,
seqmappingrefs.length);
+ }
nsr[(seqmappingrefs == null) ? 0 : seqmappingrefs.length] = 1;
seqmappingrefs = nsr;
}
listeners.clear();
listeners = null;
}
- if (mappingData != null)
+ if (pdbIdFileName != null)
{
- mappingData.clear();
- mappingData = null;
+ pdbIdFileName.clear();
+ pdbIdFileName = null;
}
if (sel_listeners != null)
{
}
}
+ public void registerPDBEntry(PDBEntry pdbentry)
+ {
+ if (pdbentry.getFile() != null
+ && pdbentry.getFile().trim().length() > 0)
+ {
+ registerPDBFile(pdbentry.getId(), pdbentry.getFile());
+ }
+ }
+
}