From: tcofoegbu Date: Mon, 20 Feb 2017 12:25:32 +0000 (+0000) Subject: JAL-2136 merged and resolved conflicts with 80edaa84d6d9beac9f0d2c71b50b7b56fd393427 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d980f203d66517042c7d2707ec300c653cae1892;p=jalview.git JAL-2136 merged and resolved conflicts with 80edaa84d6d9beac9f0d2c71b50b7b56fd393427 --- d980f203d66517042c7d2707ec300c653cae1892 diff --cc src/MCview/AppletPDBCanvas.java index aac796c,244421e..edcd754 --- a/src/MCview/AppletPDBCanvas.java +++ b/src/MCview/AppletPDBCanvas.java @@@ -158,9 -157,9 +158,9 @@@ public class AppletPDBCanvas extends Pa try { - pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol); + pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol, null); - if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE)) + if (protocol == DataSourceType.PASTE) { pdbentry.setFile("INLINE" + pdb.getId()); } diff --cc src/MCview/PDBCanvas.java index 292de91,c582293..baecac0 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@@ -152,9 -151,10 +152,10 @@@ public class PDBCanvas extends JPanel i try { - pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol); + pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol, + ap.alignFrame); - if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE)) + if (protocol.equals(jalview.io.DataSourceType.PASTE)) { pdbentry.setFile("INLINE" + pdb.getId()); } diff --cc src/jalview/appletgui/AppletJmolBinding.java index f938cad,0234a1e..d18d193 --- a/src/jalview/appletgui/AppletJmolBinding.java +++ b/src/jalview/appletgui/AppletJmolBinding.java @@@ -24,7 -24,7 +24,8 @@@ import jalview.api.AlignmentViewPanel import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; import jalview.ext.jmol.JalviewJmolBinding; + import jalview.gui.IProgressIndicator; +import jalview.io.DataSourceType; import jalview.structure.StructureSelectionManager; import java.awt.Container; diff --cc src/jalview/appletgui/ExtJmol.java index 189fe88,04096a3..0c58049 --- a/src/jalview/appletgui/ExtJmol.java +++ b/src/jalview/appletgui/ExtJmol.java @@@ -26,7 -26,7 +26,8 @@@ import jalview.api.SequenceRenderer import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; import jalview.ext.jmol.JalviewJmolBinding; + import jalview.gui.IProgressIndicator; +import jalview.io.DataSourceType; import java.awt.Container; import java.util.ArrayList; diff --cc src/jalview/ext/jmol/JalviewJmolBinding.java index 2d2d10e,d7da38c..f55e844 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@@ -27,7 -27,8 +27,8 @@@ import jalview.datamodel.AlignmentI import jalview.datamodel.ColumnSelection; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; + import jalview.gui.IProgressIndicator; -import jalview.io.AppletFormatAdapter; +import jalview.io.DataSourceType; import jalview.io.StructureFile; import jalview.schemes.ColourSchemeI; import jalview.schemes.ResidueProperties; @@@ -1148,7 -1145,8 +1149,7 @@@ public abstract class JalviewJmolBindin // see JAL-623 - need method of matching pasted data up { pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe], - pdbfile, DataSourceType.PASTE); - pdbfile, AppletFormatAdapter.PASTE, - getIProgressIndicator()); ++ pdbfile, DataSourceType.PASTE, getIProgressIndicator()); getPdbEntry(modelnum).setFile("INLINE" + pdb.getId()); matches = true; foundEntry = true; @@@ -1241,12 -1239,8 +1242,14 @@@ setLoadingFromArchive(false); } + @Override + public List getChainNames() + { + return chainNames; + } + + protected abstract IProgressIndicator getIProgressIndicator(); + public void notifyNewPickingModeMeasurement(int iatom, String strMeasure) { notifyAtomPicked(iatom, strMeasure, null); diff --cc src/jalview/gui/ChimeraViewFrame.java index b82eef3,b261ca6..d9ba9c5 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@@ -66,7 -68,8 +66,6 @@@ import javax.swing.JCheckBoxMenuItem import javax.swing.JColorChooser; import javax.swing.JInternalFrame; import javax.swing.JMenu; - import javax.swing.JOptionPane; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; import javax.swing.event.MenuEvent; @@@ -589,9 -674,9 +588,10 @@@ public class ChimeraViewFrame extends S stopProgressBar("", startTime); } // Explicitly map to the filename used by Chimera ; - jmb.getSsm().setMapping(jmb.getSequence()[pos], + pdb = jmb.getSsm().setMapping(jmb.getSequence()[pos], - jmb.getChains()[pos], pe.getFile(), protocol); + jmb.getChains()[pos], pe.getFile(), protocol, + progressBar); + stashFoundChains(pdb, pe.getFile()); } catch (OutOfMemoryError oomerror) { new OOMWarning( diff --cc src/jalview/gui/Jalview2XML.java index 35db33f,79cffdc..8a69ec2 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@@ -129,7 -124,7 +129,6 @@@ import java.util.jar.JarInputStream import java.util.jar.JarOutputStream; import javax.swing.JInternalFrame; --import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import org.exolab.castor.xml.Marshaller; @@@ -4232,7 -3968,8 +4231,8 @@@ public class Jalview2XM StructureData filedat = oldFiles.get(id); String pdbFile = filedat.getFilePath(); SequenceI[] seq = filedat.getSeqList().toArray(new SequenceI[0]); - binding.getSsm().setMapping(seq, null, pdbFile, DataSourceType.FILE); - binding.getSsm().setMapping(seq, null, pdbFile, - jalview.io.AppletFormatAdapter.FILE, null); ++ binding.getSsm().setMapping(seq, null, pdbFile, DataSourceType.FILE, ++ null); binding.addSequenceForStructFile(pdbFile, seq); } // and add the AlignmentPanel's reference to the view panel diff --cc src/jalview/gui/StructureChooser.java index 4d59d45,8dbe0c2..bff6d6f --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@@ -771,12 -717,7 +771,9 @@@ public class StructureChooser extends G @Override public void ok_ActionPerformed() { - final long progressSessionId = System.currentTimeMillis(); final StructureSelectionManager ssm = ap.getStructureSelectionManager(); + final int preferredHeight = pnl_filter.getHeight(); - ssm.setProgressIndicator(this); - ssm.setProgressSessionId(progressSessionId); + ssm.setMappingForPhyre2Model(false); new Thread(new Runnable() { @Override @@@ -808,70 -751,68 +805,71 @@@ pdbEntry = getFindEntry(pdbIdStr, selectedSeq.getAllPDBEntries()); } - if (pdbEntry == null) - { - pdbEntry = new PDBEntry(); - pdbEntry.setId(pdbIdStr); - pdbEntry.setType(PDBEntry.Type.PDB); - selectedSeq.getDatasetSequence().addPDBId(pdbEntry); + if (pdbEntry == null) + { + pdbEntry = new PDBEntry(); + pdbEntry.setId(pdbIdStr); + pdbEntry.setType(PDBEntry.Type.PDB); + selectedSeq.getDatasetSequence().addPDBId(pdbEntry); + } + pdbEntriesToView[count++] = pdbEntry; + } + SequenceI[] selectedSeqs = selectedSeqsToView + .toArray(new SequenceI[selectedSeqsToView.size()]); + launchStructureViewer(ssm, pdbEntriesToView, ap, selectedSeqs); } - pdbEntriesToView[count++] = pdbEntry; - } - SequenceI[] selectedSeqs = selectedSeqsToView - .toArray(new SequenceI[selectedSeqsToView.size()]); - launchStructureViewer(ssm, pdbEntriesToView, ap, - selectedSeqs); - } - else if (currentView == VIEWS_LOCAL_PDB) - { - int[] selectedRows = tbl_local_pdb.getSelectedRows(); - PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length]; - int count = 0; + else if (currentView == VIEWS_LOCAL_PDB) + { + int[] selectedRows = tbl_local_pdb.getSelectedRows(); + PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length]; + int count = 0; int pdbIdColIndex = tbl_local_pdb.getColumn("PDB Id") .getModelIndex(); - int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence") - .getModelIndex(); - ArrayList selectedSeqsToView = new ArrayList(); - for (int row : selectedRows) - { - PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row, - pdbIdColIndex); - pdbEntriesToView[count++] = pdbEntry; - SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(row, - refSeqColIndex); - selectedSeqsToView.add(selectedSeq); - } - SequenceI[] selectedSeqs = selectedSeqsToView - .toArray(new SequenceI[selectedSeqsToView.size()]); - launchStructureViewer(ssm, pdbEntriesToView, ap, - selectedSeqs); - } - else if (currentView == VIEWS_ENTER_ID) - { - SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel - .getCmb_assSeq().getSelectedItem()).getSequence(); - if (userSelectedSeq != null) - { - selectedSequence = userSelectedSeq; - } + int refSeqColIndex = tbl_local_pdb.getColumn("Ref Sequence") + .getModelIndex(); + List selectedSeqsToView = new ArrayList(); + for (int row : selectedRows) + { + PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row, + pdbIdColIndex); + pdbEntriesToView[count++] = pdbEntry; + SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt( + row, refSeqColIndex); + selectedSeqsToView.add(selectedSeq); + } + SequenceI[] selectedSeqs = selectedSeqsToView + .toArray(new SequenceI[selectedSeqsToView.size()]); + launchStructureViewer(ssm, pdbEntriesToView, ap, selectedSeqs); + } + else if (currentView == VIEWS_ENTER_ID) + { + SequenceI userSelectedSeq = ((AssociateSeqOptions) idInputAssSeqPanel + .getCmb_assSeq().getSelectedItem()).getSequence(); + if (userSelectedSeq != null) + { + selectedSequence = userSelectedSeq; + } - String pdbIdStr = txt_search.getText(); - PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr); - if (pdbEntry == null) - { - pdbEntry = new PDBEntry(); ++ + String pdbIdStr = txt_search.getText(); + PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr); + if (pdbEntry == null) + { + pdbEntry = new PDBEntry(); if (pdbIdStr.split(":").length > 1) { - pdbEntry.setChainCode(pdbIdStr.split(":")[1]); + pdbEntry.setId(pdbIdStr.split(":")[0]); + pdbEntry.setChainCode(pdbIdStr.split(":")[1].toUpperCase()); } - pdbEntry.setId(pdbIdStr); - pdbEntry.setType(PDBEntry.Type.PDB); - selectedSequence.getDatasetSequence().addPDBId(pdbEntry); - } + else + { + pdbEntry.setId(pdbIdStr); + } + pdbEntry.setType(PDBEntry.Type.PDB); + selectedSequence.getDatasetSequence().addPDBId(pdbEntry); + } - PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry }; + PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry }; launchStructureViewer(ssm, pdbEntriesToView, ap, new SequenceI[] { selectedSequence }); } @@@ -883,75 -824,16 +881,76 @@@ { selectedSequence = userSelectedSeq; } - PDBEntry fileEntry = new AssociatePdbFileWithSeq() - .associatePdbWithSeq(selectedPdbFileName, - jalview.io.AppletFormatAdapter.FILE, + PDBEntry fileEntry = new AssociateStructureFileWithSeq() + .associateStructureWithSeq(selectedStructureFileName, + DataSourceType.FILE, selectedSequence, true, Desktop.instance); - launchStructureViewer(ssm, new PDBEntry[] { fileEntry }, ap, + launchStructureViewer(ssm, + new PDBEntry[] { fileEntry }, ap, new SequenceI[] { selectedSequence }); - } - mainFrame.dispose(); + } + else if (currentView == VIEWS_PHYRE2_PREDICTION) + { + SequenceI userSelectedSeq = ((AssociateSeqOptions) phyre2InputAssSeqPanel + .getCmb_assSeq().getSelectedItem()).getSequence(); + if (userSelectedSeq != null) + { + selectedSequence = userSelectedSeq; + } + int templateColIndex = getPhyreResultTable() + .getColumn("Template") + .getModelIndex(); + int[] selectedRows = getPhyreResultTable().getSelectedRows(); + PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length]; + int count = 0; + for (int row : selectedRows) + { + String templateId = getPhyreResultTable().getValueAt(row, + templateColIndex).toString(); + String structureFile = phyre2ResultDirectory + templateId + + ".pdb"; + pdbEntriesToView[count++] = new AssociateStructureFileWithSeq() + .associateStructureWithSeq(structureFile, + DataSourceType.FILE, selectedSequence, true, + Desktop.instance); + } + + final StructureSelectionManager ssm = ap + .getStructureSelectionManager(); + ssm.setMappingForPhyre2Model(true); + final long progressSessionId = System.currentTimeMillis(); + ssm.setProgressSessionId(progressSessionId); + + SequenceI[] sequences = new SequenceI[] { selectedSequence }; + + ssm.setProgressBar(MessageManager + .getString("status.launching_3d_structure_viewer")); + final StructureViewer sViewer = new StructureViewer(ssm); + if (pdbEntriesToView.length > 1) + { + ArrayList seqsMap = new ArrayList(); + for (SequenceI seq : sequences) + { + seqsMap.add(new SequenceI[] { seq }); + } + SequenceI[][] collatedSeqs = seqsMap + .toArray(new SequenceI[0][0]); + ssm.setProgressBar(null); + ssm.setProgressBar(MessageManager + .getString("status.fetching_3d_structures_for_selected_entries")); + sViewer.viewStructures(pdbEntriesToView, collatedSeqs, ap); + } + else + { + ssm.setProgressBar(null); + ssm.setProgressBar(MessageManager.formatMessage( + "status.fetching_3d_structures_for", + pdbEntriesToView[0].getId())); + sViewer.viewStructures(pdbEntriesToView[0], sequences, ap); + } + } + closeAction(preferredHeight); } }).start(); } @@@ -1000,33 -865,17 +1001,34 @@@ if (SiftsSettings.isMapWithSifts()) { - // TODO: prompt user if there are lots of sequences without dbrefs. - // It can take a long time if we need to fetch all dbrefs for all - // sequences! - ArrayList seqsWithoutSourceDBRef = new ArrayList(); + List seqsWithoutSourceDBRef = new ArrayList(); + int p = 0; + // TODO: skip PDBEntry:Sequence pairs where PDBEntry doesn't look like a + // real PDB ID. For moment, we can also safely do this if there is already + // a known mapping between the PDBEntry and the sequence. ++ for (SequenceI seq : sequences) { - if (seq.getSourceDBRef() == null && seq.getDBRefs() == null) + PDBEntry pdbe = pdbEntriesToView[p++]; + if (pdbe != null && pdbe.getFile() != null) { - seqsWithoutSourceDBRef.add(seq); - continue; + StructureMapping[] smm = ssm.getMapping(pdbe.getFile()); + if (smm != null && smm.length > 0) + { + for (StructureMapping sm : smm) + { + if (sm.getSequence() == seq) + { + continue; + } + } } + } + if (seq.getPrimaryDBRefs().size() == 0) + { + seqsWithoutSourceDBRef.add(seq); + continue; + } } if (!seqsWithoutSourceDBRef.isEmpty()) { diff --cc src/jalview/gui/StructureViewerBase.java index 91d7130,41390b1..f42a417 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@@ -38,9 -34,8 +38,8 @@@ import java.util.ArrayList import java.util.List; import java.util.Vector; +import javax.swing.JCheckBoxMenuItem; import javax.swing.JMenuItem; --import javax.swing.JOptionPane; /** * Base class with common functionality for JMol, Chimera or other structure @@@ -420,7 -415,7 +421,7 @@@ public abstract class StructureViewerBa * create the mappings */ apanel.getStructureSelectionManager().setMapping(seq, chains, - pdbFilename, DataSourceType.FILE); - pdbFilename, AppletFormatAdapter.FILE, getIProgressIndicator()); ++ pdbFilename, DataSourceType.FILE, getIProgressIndicator()); /* * alert the FeatureRenderer to show new (PDB RESNUM) features diff --cc src/jalview/structure/StructureSelectionManager.java index bda269c,f813411..b0c185b --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@@ -326,11 -317,14 +326,14 @@@ public class StructureSelectionManage * @return null or the structure data parsed as a pdb file */ synchronized public StructureFile setMapping(SequenceI[] sequence, - String[] targetChains, String pdbFile, DataSourceType protocol) - String[] targetChains, String pdbFile, String protocol, ++ String[] targetChains, String pdbFile, DataSourceType protocol, + IProgressIndicator progress) { - return setMapping(true, sequence, targetChains, pdbFile, protocol); + return computeMapping(true, sequence, targetChains, pdbFile, protocol, + progress); } + /** * create sequence structure mappings between each sequence and the given * pdbFile (retrieved via the given protocol). @@@ -351,8 -345,19 +354,18 @@@ */ synchronized public StructureFile setMapping(boolean forStructureView, SequenceI[] sequenceArray, String[] targetChainIds, - String pdbFile, DataSourceType sourceType) - String pdbFile, - String protocol) ++ String pdbFile, DataSourceType protocol) { + return computeMapping(forStructureView, sequenceArray, targetChainIds, + pdbFile, protocol, null); + } + + synchronized public StructureFile computeMapping( + boolean forStructureView, SequenceI[] sequenceArray, - String[] targetChainIds, String pdbFile, String protocol, ++ String[] targetChainIds, String pdbFile, DataSourceType protocol, + IProgressIndicator progress) + { + long progressSessionId = System.currentTimeMillis() * 3; /* * There will be better ways of doing this in the future, for now we'll use * the tried and tested MCview pdb mapping @@@ -387,10 -392,20 +400,10 @@@ boolean isMapUsingSIFTs = SiftsSettings.isMapWithSifts(); try { - pdb = new JmolParser(pdbFile, sourceType); - - if (pdbFile != null && isCIFFile(pdbFile)) - { - pdb = new jalview.ext.jmol.JmolParser(addTempFacAnnot, parseSecStr, - secStructServices, pdbFile, protocol); - } - else - { - pdb = new PDBfile(addTempFacAnnot, parseSecStr, secStructServices, - pdbFile, protocol); - } ++ pdb = new JmolParser(pdbFile, protocol); if (pdb.getId() != null && pdb.getId().trim().length() > 0 - && DataSourceType.FILE == sourceType) - && AppletFormatAdapter.FILE.equals(protocol)) ++ && DataSourceType.FILE == protocol) { registerPDBFile(pdb.getId().trim(), pdbFile); } @@@ -494,17 -500,18 +507,19 @@@ continue; } - if (sourceType == DataSourceType.PASTE) - if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE)) ++ if (protocol.equals(DataSourceType.PASTE)) { pdbFile = "INLINE" + pdb.getId(); } - ArrayList seqToStrucMapping = new ArrayList(); - if (isMapUsingSIFTs) + + List seqToStrucMapping = new ArrayList(); + if (!isMappingForPhyre2Model() && isMapUsingSIFTs && seq.isProtein()) { - setProgressBar(null); - setProgressBar(MessageManager - .getString("status.obtaining_mapping_with_sifts")); + if (progress!=null) { + progress.setProgressBar(MessageManager + .getString("status.obtaining_mapping_with_sifts"), + progressSessionId); + } jalview.datamodel.Mapping sqmpping = maxAlignseq .getMappingFromS1(false); if (targetChainId != null && !targetChainId.trim().isEmpty()) @@@ -578,29 -566,17 +593,32 @@@ } } } + else if (isMappingForPhyre2Model()) + { + setProgressBar(null); + setProgressBar(MessageManager + .getString("status.obtaining_mapping_with_phyre2_template_alignment")); + StructureMapping phyre2ModelMapping = new Phyre2Client(pdb) + .getStructureMapping(seq, pdbFile, " "); + + seqToStrucMapping.add(phyre2ModelMapping); + ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); + } else { - setProgressBar(null); - setProgressBar(MessageManager - .getString("status.obtaining_mapping_with_nw_alignment")); + if (progress != null) + { + progress.setProgressBar(MessageManager - .getString("status.obtaining_mapping_with_nw_alignment"), ++ .getString("status.obtaining_mapping_with_nw_alignment"), + progressSessionId); + } - seqToStrucMapping.add(getNWMappings(seq, pdbFile, maxChainId, - maxChain, pdb, maxAlignseq)); + StructureMapping nwMapping = getNWMappings(seq, pdbFile, + maxChainId, maxChain, pdb, maxAlignseq); + seqToStrucMapping.add(nwMapping); + ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); + } + if (forStructureView) { mappings.addAll(seqToStrucMapping); diff --cc test/jalview/structures/models/AAStructureBindingModelTest.java index b74a089,e82bfea..1325513 --- a/test/jalview/structures/models/AAStructureBindingModelTest.java +++ b/test/jalview/structures/models/AAStructureBindingModelTest.java @@@ -120,14 -97,14 +120,15 @@@ public class AAStructureBindingModelTes seqs[2] = new SequenceI[] { seq3 }; StructureSelectionManager ssm = new StructureSelectionManager(); - ssm.setMapping(new SequenceI[] { seq1 }, null, PDB_1, - AppletFormatAdapter.PASTE, null); + ssm.setMapping(new SequenceI[] { seq1a, seq1b }, null, PDB_1, - DataSourceType.PASTE); ++ DataSourceType.PASTE, null); ssm.setMapping(new SequenceI[] { seq2 }, null, PDB_2, - DataSourceType.PASTE); - AppletFormatAdapter.PASTE, null); ++ DataSourceType.PASTE, null); ssm.setMapping(new SequenceI[] { seq3 }, null, PDB_3, - DataSourceType.PASTE); - AppletFormatAdapter.PASTE, null); ++ DataSourceType.PASTE, null); ++ - testee = new AAStructureBindingModel(ssm, pdbFiles, seqs, chains, null) + testee = new AAStructureBindingModel(ssm, pdbFiles, seqs, null) { @Override public String[] getPdbFile()