X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureSelectionManager.java;h=58bba481587a6da743b068b0d49afa238ef56f03;hb=3325395b33ef3b52b4a62327621c5bddf12ee4e0;hp=5a9e382369288c89e3bb84a89a615deb9a139162;hpb=865a855a4ca87eadb3e5ff284ed32ed307d9c34b;p=jalview.git diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 5a9e382..58bba48 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -1,31 +1,42 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1) + * 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 . + * 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.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.SearchResults; +import jalview.datamodel.SequenceI; +import jalview.util.MessageManager; + +import java.io.PrintStream; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.IdentityHashMap; +import java.util.Vector; + +import MCview.Atom; +import MCview.PDBChain; public class StructureSelectionManager { @@ -55,12 +66,26 @@ public class StructureSelectionManager Hashtable mappingData = new Hashtable(); + private static StructureSelectionManager nullProvider = null; + public static StructureSelectionManager getStructureSelectionManager( StructureSelectionManagerProvider context) { - if (context==null) + if (context == null) { - throw new Error("Implementation error. Structure selection manager's context is 'null'", new NullPointerException("SSM context is 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) { @@ -69,7 +94,15 @@ public class 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; } @@ -156,9 +189,26 @@ public class StructureSelectionManager * 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(); @@ -192,7 +242,9 @@ public class StructureSelectionManager } } else + { targetChain = ""; + } int max = -10; AlignSeq maxAlignseq = null; @@ -201,7 +253,7 @@ public class StructureSelectionManager 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) { @@ -210,8 +262,8 @@ public class StructureSelectionManager // 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(); @@ -292,7 +344,9 @@ public class StructureSelectionManager } if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE)) + { pdbFile = "INLINE" + pdb.id; + } mappings[mappings.length - 1] = new StructureMapping(sequence[s], pdbFile, pdb.id, maxChainId, mapping, @@ -327,7 +381,9 @@ public class StructureSelectionManager 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++) { @@ -419,7 +475,9 @@ public class StructureSelectionManager { Object li = listeners.elementAt(i); if (li instanceof SequenceListener) + { ((SequenceListener) li).highlightSequence(results); + } } } } @@ -443,7 +501,9 @@ public class StructureSelectionManager 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++) @@ -661,9 +721,13 @@ public class StructureSelectionManager 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++) @@ -701,8 +765,10 @@ public class StructureSelectionManager 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; }