/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
- * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Copyright (C) 2014 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.
+ * 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 <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
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;
public static StructureSelectionManager getStructureSelectionManager(
StructureSelectionManagerProvider context)
{
+ if (context == null)
+ {
+ if (nullProvider == null)
+ {
+ if (instances != null)
+ {
+ throw new Error(MessageManager.getString("error.implementation_error_structure_selection_manager_null"),
+ new NullPointerException(MessageManager.getString("exception.ssm_context_is_null")));
+ }
+ else
+ {
+ nullProvider = new StructureSelectionManager();
+ }
+ return nullProvider;
+ }
+ }
if (instances == null)
{
instances = new java.util.IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager>();
StructureSelectionManager instance = instances.get(context);
if (instance == null)
{
- instances.put(context, instance = new StructureSelectionManager());
+ if (nullProvider != null)
+ {
+ instance = nullProvider;
+ }
+ else
+ {
+ instance = new StructureSelectionManager();
+ }
+ instances.put(context, instance);
}
return instance;
}
* 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());
+ }
+ }
+
}