From 849ce08f4fdfc619cf1e2f45d6e97884ecac595f Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Fri, 10 Mar 2017 14:29:21 +0000 Subject: [PATCH] JAL-2136 JAL-2137 Modified STRUCTMODEL annotation format and added implementation to register Phyre2 model file from AnnotationFile such that it could be properly processed Phyre2 client on structure viewing. --- .../phyre2results/56da5616b4559c93/allhits.ann | 22 +++ src/jalview/gui/AssociateStructureFileWithSeq.java | 4 +- src/jalview/gui/StructureChooser.java | 59 ++++---- src/jalview/io/AnnotationFile.java | 146 +++++++++----------- .../structure/StructureSelectionManager.java | 28 ++-- 5 files changed, 135 insertions(+), 124 deletions(-) create mode 100644 examples/testdata/phyre2results/56da5616b4559c93/allhits.ann diff --git a/examples/testdata/phyre2results/56da5616b4559c93/allhits.ann b/examples/testdata/phyre2results/56da5616b4559c93/allhits.ann new file mode 100644 index 0000000..1692259 --- /dev/null +++ b/examples/testdata/phyre2results/56da5616b4559c93/allhits.ann @@ -0,0 +1,22 @@ +JALVIEW_ANNOTATION +HIDE_INSERTIONS +STRUCTMODEL c4n58A_ c4n58A_.1.pdb 1 54 48 143 PDB Header: Hyrolase
Chain: A
PDB Molecule: Pectocin m2
PDB Title: Crystal structure of pectocin m2 at 1.86 amgtroms +STRUCTMODEL d1a70a_ d1a70a_.2.pdb 1 71 48 144 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1offa_ d1offa_.3.pdb 1 73 48 142 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1frra_ d1frra_.4.pdb 0.999 62 49 142 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1pfda_ d1pfda_.5.pdb 0.999 70 48 143 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1frda_ d1frda_.6.pdb 0.999 50 48 143 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1fxia_ d1fxia_.7.pdb 0.999 62 48 142 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1gaqb_ d1gaqb_.8.pdb 0.999 71 48 144 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1iuea_ d1iuea_.9.pdb 0.999 48 48 142 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1awda_ d1awda_.10.pdb 0.999 68 50 142 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1wria_ d1wria_.11.pdb 0.999 59 49 142 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d1czpa_ d1czpa_.12.pdb 0.999 64 48 142 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d2cjoa_ d2cjoa_.13.pdb 0.999 63 48 142 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL d4fxca_ d4fxca_.14.pdb 0.999 64 48 142 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin-related +STRUCTMODEL c4itkA_ c4itkA_.15.pdb 0.999 57 50 142 PDB Header: Electron transport
Chain: A
PDB Molecule: Apoferredoxin
PDB Title: The structure of c.reinhardtii ferredoxin 2 +STRUCTMODEL c1krhA_ c1krhA_.16.pdb 0.999 25 48 142 PDB Header: Oxidoreductase
Chain: A
PDB Molecule: Benzoate 1,2-deoxygenase reductase
PDB Title: X-ray structure of benzoate deoxygenate reductase +STRUCTMODEL d1krha3 d1krha3.17.pdb 0.999 24 48 143 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin domains from multi domain proteins +STRUCTMODEL d1jq4a_ d1jq4a_.18.pdb 0.999 29 47 138 Fold: Beta-Grasp (ubiquitin-like)
Superfamily: 2Fe-2S ferredoxin-like
Family: 2Fe-2S ferredoxin domains from multi domain proteins +STRUCTMODEL c4wqmA_ c4wqmA_.19.pdb 0.999 28 49 144 PDB header: Oxidoreductase
Chain: A
PDB Molecule: Toluene-4-monooxygenase electron transfer component
PDB Title: Structure of the toluene 4-monooxygenase nah oxidoreductase t4mof,2 k270s k271s variant +STRUCTMODEL c2piaA_ c2piaA_.20.pdb 0.999 22 1 136 PDB header: Reductase
Chain: A
PDB Molecule: Phthalate deoxygenase reductase
PDB Title: Phthalate deoxygenate reductase: a modular structure for2 electron transfer from pyridine nucleotides to [2fe-2s] \ No newline at end of file diff --git a/src/jalview/gui/AssociateStructureFileWithSeq.java b/src/jalview/gui/AssociateStructureFileWithSeq.java index 1a169cb..63f9b25 100644 --- a/src/jalview/gui/AssociateStructureFileWithSeq.java +++ b/src/jalview/gui/AssociateStructureFileWithSeq.java @@ -28,8 +28,6 @@ import jalview.io.StructureFile; import jalview.structure.StructureSelectionManager; import jalview.util.MessageManager; -import javax.swing.JOptionPane; - /** * GUI related routines for associating PDB files with sequences * @@ -40,7 +38,7 @@ public class AssociateStructureFileWithSeq { /** - * assocate the given PDB file with + * associate the given PDB file with * * @param choice * @param sequence diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index cad168f..66fe431 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -522,7 +522,8 @@ public class StructureChooser extends GStructureChooser implements if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION) { selectedStructureFileName = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedStructureFileName); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + selectedStructureFileName); validateSelections(); } } @@ -706,7 +707,8 @@ public class StructureChooser extends GStructureChooser implements "-Select Associated Seq-"))) { btn_pdbFromFile.setEnabled(true); - if (selectedStructureFileName != null && selectedStructureFileName.length() > 0) + if (selectedStructureFileName != null + && selectedStructureFileName.length() > 0) { btn_view.setEnabled(true); lbl_fromFileStatus.setIcon(goodImage); @@ -773,7 +775,6 @@ public class StructureChooser extends GStructureChooser implements { final StructureSelectionManager ssm = ap.getStructureSelectionManager(); final int preferredHeight = pnl_filter.getHeight(); - ssm.setMappingForPhyre2Model(false); new Thread(new Runnable() { @Override @@ -850,7 +851,6 @@ public class StructureChooser extends GStructureChooser implements selectedSequence = userSelectedSeq; } - String pdbIdStr = txt_search.getText(); PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr); if (pdbEntry == null) @@ -872,22 +872,21 @@ public class StructureChooser extends GStructureChooser implements PDBEntry[] pdbEntriesToView = new PDBEntry[] { pdbEntry }; launchStructureViewer(ssm, pdbEntriesToView, ap, new SequenceI[] { selectedSequence }); - } - else if (currentView == VIEWS_FROM_FILE) - { - SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel - .getCmb_assSeq().getSelectedItem()).getSequence(); - if (userSelectedSeq != null) - { - selectedSequence = userSelectedSeq; - } - PDBEntry fileEntry = new AssociateStructureFileWithSeq() - .associateStructureWithSeq(selectedStructureFileName, - DataSourceType.FILE, - selectedSequence, true, Desktop.instance); + } + else if (currentView == VIEWS_FROM_FILE) + { + SequenceI userSelectedSeq = ((AssociateSeqOptions) fileChooserAssSeqPanel + .getCmb_assSeq().getSelectedItem()).getSequence(); + if (userSelectedSeq != null) + { + selectedSequence = userSelectedSeq; + } + 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 }); } else if (currentView == VIEWS_PHYRE2_PREDICTION) @@ -899,8 +898,7 @@ public class StructureChooser extends GStructureChooser implements selectedSequence = userSelectedSeq; } int templateColIndex = getPhyreResultTable() - .getColumn("Template") - .getModelIndex(); + .getColumn("Template").getModelIndex(); int[] selectedRows = getPhyreResultTable().getSelectedRows(); PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length]; int count = 0; @@ -913,11 +911,11 @@ public class StructureChooser extends GStructureChooser implements .associateStructureWithSeq(structureFile, DataSourceType.FILE, selectedSequence, true, Desktop.instance); + ssm.registerPhyre2Template(structureFile); } final StructureSelectionManager ssm = ap .getStructureSelectionManager(); - ssm.setMappingForPhyre2Model(true); final long progressSessionId = System.currentTimeMillis(); ssm.setProgressSessionId(progressSessionId); @@ -998,8 +996,10 @@ public class StructureChooser extends GStructureChooser implements final AlignmentPanel alignPanel, SequenceI[] sequences) { long progressId = sequences.hashCode(); - setProgressBar(MessageManager - .getString("status.launching_3d_structure_viewer"), progressId); + setProgressBar( + MessageManager + .getString("status.launching_3d_structure_viewer"), + progressId); final StructureViewer sViewer = new StructureViewer(ssm); setProgressBar(null, progressId); @@ -1028,7 +1028,8 @@ public class StructureChooser extends GStructureChooser implements } } } - if (seq.getPrimaryDBRefs().size() == 0) + if (seq.getPrimaryDBRefs().size() == 0 + && !ssm.isPhyre2Template(pdbe.getFile())) { seqsWithoutSourceDBRef.add(seq); continue; @@ -1058,15 +1059,17 @@ public class StructureChooser extends GStructureChooser implements seqsMap.add(new SequenceI[] { seq }); } SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]); - setProgressBar(MessageManager - .getString("status.fetching_3d_structures_for_selected_entries"), progressId); + setProgressBar( + MessageManager + .getString("status.fetching_3d_structures_for_selected_entries"), + progressId); sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel); } else { setProgressBar(MessageManager.formatMessage( "status.fetching_3d_structures_for", - pdbEntriesToView[0].getId()),progressId); + pdbEntriesToView[0].getId()), progressId); sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel); } setProgressBar(null, progressId); diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index d40ee1b..c1ddeed 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -32,6 +32,7 @@ import jalview.datamodel.PDBEntry; import jalview.datamodel.PDBEntry.Type; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.gui.Desktop; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; import jalview.schemes.UserColourScheme; @@ -40,7 +41,6 @@ import jalview.structure.StructureSelectionManager; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; -import java.io.IOException; import java.io.InputStreamReader; import java.io.StringReader; import java.net.URL; @@ -1017,8 +1017,8 @@ public class AnnotationFile { boolean failedtoadd = true; // expect - // STRUCTMODEL + // STRUCTMODEL <%.I.D> + // [] if (st.hasMoreTokens()) { refSeq = al.findName(refSeqId = st.nextToken()); if (refSeq == null) @@ -1030,11 +1030,13 @@ public class AnnotationFile else { String tempId = st.nextToken(); - String urlToModel = st.nextToken(); - String urlToPairwise = st.hasMoreTokens() ? st.nextToken() - : ""; - if (add_structmodel(al, refSeq, tempId, urlToModel, - urlToPairwise)) + String confidence = 100 * Double.valueOf(st.nextToken()) + ""; + String pid = st.nextToken(); + String alignRange = st.nextToken() + "-" + st.nextToken(); + String otherInfo = st.hasMoreTokens() ? st.nextToken() : ""; + String coverage = ""; + if (add_structmodel(al, refSeq, tempId, alignRange, coverage, + confidence, pid, otherInfo)) { failedtoadd = false; } @@ -1043,8 +1045,9 @@ public class AnnotationFile if (failedtoadd) { System.err - .println("Need [] as tab separated fields after " - + STRUCTMODEL); + .println("Need <%.I.D> [] as tab separated fields after" + + STRUCTMODEL + + ".\nNote: other information could be provided in html format "); } else { modified = true; } @@ -1259,77 +1262,26 @@ public class AnnotationFile * @param urlToPairwise * @return true if model and sequence was added */ - private boolean add_structmodel(AlignmentI al, SequenceI refSeq2, String tempId, - String urlToModel, String urlToPairwise) + private boolean add_structmodel(AlignmentI al, SequenceI refSeq, + String tempId, String aRange, String coverage, String confidence, + String pid, String otherInfo) { - String warningMessage = null, modelPath = null, aliPath = null; - DataSourceType modelProt = null, aliProt = null; + String warningMessage = null; boolean added = false; try { - // locate tempId. if it exists, will need to merge, otherwise: - SequenceI templateSeq = al.findName(tempId); - // 1. load urlToModel - modelPath = resolveAbsolute(urlToModel); - modelProt = AppletFormatAdapter.checkProtocol(modelPath); - // need to transfer to local temp file ? - PDBEntry modelpe = new PDBEntry(tempId, null, Type.FILE, modelPath); - PDBEntry templpe = new PDBEntry(tempId, null, Type.FILE, modelPath); - refSeq2.addPDBId(modelpe); - aliPath = resolveAbsolute(urlToPairwise); - aliProt = AppletFormatAdapter.checkProtocol(aliPath); - // 2. load urlToPairwise - AlignmentI pwa = new AppletFormatAdapter().readFile(aliPath, aliProt, - FileFormat.Fasta); - SequenceI qPw = null, tPw = null; - if (pwa != null) - { - // resolve query/template sequences in provided alignment - qPw = pwa.findName(refSeqId); - tPw = pwa.findName(tempId); - } - if (false) - // (qPw != null && tPw != null) - { - // not yet complete - // refalQ vvva--addrvvvtttddd - // refalT ---aaaa---sss---ddd - // profalQ ---v-v-v-a.-.-a---dd--r--vvvtt--td--dd - // profalT ---.-.-.-aa-a-a---..--.--sss..--.d--dd - // Pragmatic solution here: - // Map templpe onto refalT only where refalT and refalQ are both - // non-gaps - - // columns for start..end in refSeq2 - int[] gapMap = refSeq2.gapMap(); - // insert gaps in tPw - int curi = 0, width = refSeq2.getLength(); - // TBC - } - else - { - // assume 1:1 - so synthesise sequences to use to construct mapping - StructureFile pdbf = StructureSelectionManager - .getStructureSelectionManager().setMapping(false, - new SequenceI[] { refSeq2.getDatasetSequence() }, - null, modelPath, modelProt); - refSeq2.getDatasetSequence().addPDBId(modelpe); - if (templateSeq == null && tPw != null) - { - tPw.createDatasetSequence(); - tPw.getDatasetSequence().addPDBId(templpe); // needs to set mapping based on model yet... - al.addSequence(tPw); - added = true; - } - } - // 3. pad/insert gaps in urlToPairwise according to gaps already present in - // refSeq2 - // 4. add padded tempId sequence to alignment - // 4. associate urlToModel with refSeq2 based on position map provided by - // urlToPairwise - // 5. associate urlToModel with tempId based on position map provided by - // urlToPairwise - // start a thread to load urlToModel and process/annotate sequences. - } catch (IOException x) + String pdbFile = baseUri + tempId; + PDBEntry phyre2PDBEntry = new PDBEntry(tempId, null, Type.FILE, + pdbFile); + refSeq.getDatasetSequence().addPDBId(phyre2PDBEntry); + String phyre2ModelDesc = generatePhyre2InfoHTMLTable(aRange, + coverage, confidence, pid, otherInfo); + refSeq.setDescription(phyre2ModelDesc); + StructureSelectionManager ssm = StructureSelectionManager + .getStructureSelectionManager(Desktop.instance); + ssm.registerPhyre2Template(pdbFile); + added = true; + + } catch (Exception x) { warningMessage = x.toString(); } finally { @@ -1337,8 +1289,44 @@ public class AnnotationFile { System.err.println("Warnings whilst processing STRUCTMODEL: "+warningMessage); } - return added; } + return added; + } + + private String generatePhyre2InfoHTMLTable(String aRange, + String coverage, String confidence, String pid, String otherInfo) + { + StringBuilder phyre2InfoBuilder = new StringBuilder(); + phyre2InfoBuilder.append(""); + phyre2InfoBuilder + .append(""); + if (aRange != null && !aRange.isEmpty()) + { + phyre2InfoBuilder.append(""); + } + if (coverage != null && !coverage.isEmpty()) + { + phyre2InfoBuilder.append(""); + } + if (confidence != null && !confidence.isEmpty()) + { + phyre2InfoBuilder.append(""); + } + if (pid != null && !pid.isEmpty()) + { + phyre2InfoBuilder.append(""); + } + if (otherInfo != null && !otherInfo.isEmpty()) + { + phyre2InfoBuilder.append(""); + } + phyre2InfoBuilder.append("
Phyre2 Template Info
").append("Aligned range") + .append("").append(aRange).append("
").append("Coverage") + .append("").append(coverage).append("
").append("Confidence") + .append("").append(confidence).append("
").append("%.i.d") + .append("").append(pid).append("
").append("Other information") + .append("").append(otherInfo).append("
"); + return phyre2InfoBuilder.toString(); } private String resolveAbsolute(String relURI) diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index b0c185b..addf310 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -79,7 +79,6 @@ public class StructureSelectionManager private long progressSessionId; - private boolean mappingForPhyre2Model; /* * Set of any registered mappings between (dataset) sequences. @@ -90,6 +89,8 @@ public class StructureSelectionManager private List sel_listeners = new ArrayList(); + private List phyre2ModelTemplates = new ArrayList(); + /** * @return true if will try to use external services for processing secondary * structure @@ -511,9 +512,9 @@ public class StructureSelectionManager { pdbFile = "INLINE" + pdb.getId(); } - + boolean phyre2Template = isPhyre2Template(pdbFile); List seqToStrucMapping = new ArrayList(); - if (!isMappingForPhyre2Model() && isMapUsingSIFTs && seq.isProtein()) + if (!phyre2Template && isMapUsingSIFTs && seq.isProtein()) { if (progress!=null) { progress.setProgressBar(MessageManager @@ -593,7 +594,7 @@ public class StructureSelectionManager } } } - else if (isMappingForPhyre2Model()) + else if (phyre2Template) { setProgressBar(null); setProgressBar(MessageManager @@ -627,11 +628,9 @@ public class StructureSelectionManager return pdb; } - private boolean isCIFFile(String filename) + public void registerPhyre2Template(String phyre2Template) { - String fileExt = filename.substring(filename.lastIndexOf(".") + 1, - filename.length()); - return "cif".equalsIgnoreCase(fileExt); + phyre2ModelTemplates.add(phyre2Template); } /** @@ -1394,15 +1393,16 @@ public class StructureSelectionManager return seqmappings; } - public boolean isMappingForPhyre2Model() + public boolean isPhyre2Template(String structureFile) { - return mappingForPhyre2Model; + if (structureFile == null || phyre2ModelTemplates == null + || phyre2ModelTemplates.isEmpty()) + { + return false; + } + return (phyre2ModelTemplates.contains(structureFile)); } - public void setMappingForPhyre2Model(boolean mappingForPhyre2Model) - { - this.mappingForPhyre2Model = mappingForPhyre2Model; - } public static StructureSelectionManager getStructureSelectionManager() { -- 1.7.10.2