X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAnnotationFile.java;h=c1ddeedac740c366b86886f059b6a89c9cc06bf3;hb=849ce08f4fdfc619cf1e2f45d6e97884ecac595f;hp=d40ee1bedfcf0768f87cb5a5f556ce58223b8371;hpb=e95ce7b42f95c193fc6ef5b6efb803d13dbac8b9;p=jalview.git 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)