X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fproject%2FJalview2XML.java;h=70ef5385ebc0f9b6fc5339e5c46ced3d1406502c;hb=c794c5033adeee182b03a5ea92c0a7495a29661f;hp=6340e64eb3a88a2c140e1147a81bcefc6dc72fa1;hpb=e1dbbc5edc07f65706eeb1dda9f4c9bcdee9d3a5;p=jalview.git diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index 6340e64..70ef538 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -41,6 +41,7 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.GeneLocus; import jalview.datamodel.GraphLine; +import jalview.datamodel.HiddenMarkovModel; import jalview.datamodel.PDBEntry; import jalview.datamodel.Point; import jalview.datamodel.RnaViewerModel; @@ -72,6 +73,7 @@ import jalview.gui.TreePanel; import jalview.io.BackupFiles; import jalview.io.DataSourceType; import jalview.io.FileFormat; +import jalview.io.HMMFile; import jalview.io.NewickFile; import jalview.math.Matrix; import jalview.math.MatrixI; @@ -96,9 +98,9 @@ import jalview.viewmodel.ViewportRanges; import jalview.viewmodel.seqfeatures.FeatureRendererModel; import jalview.viewmodel.seqfeatures.FeatureRendererSettings; import jalview.viewmodel.seqfeatures.FeaturesDisplayed; -import jalview.ws.jws2.Jws2Discoverer; +import jalview.ws.api.ServiceWithParameters; +import jalview.ws.jws2.PreferredServiceRegistry; import jalview.ws.jws2.dm.AAConSettings; -import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.params.ArgumentI; import jalview.ws.params.AutoCalcSetting; import jalview.ws.params.WsParamSetI; @@ -224,6 +226,8 @@ public class Jalview2XML private static final String RNA_PREFIX = "rna_"; + private static final String HMMER_PREFIX = "hmmer_"; + private static final String UTF_8 = "UTF-8"; /** @@ -1064,6 +1068,9 @@ public class Jalview2XML jseq.getFeatures().add(features); } + /* + * save PDB entries for sequence + */ if (jdatasq.getAllPDBEntries() != null) { Enumeration en = jdatasq.getAllPDBEntries().elements(); @@ -1156,6 +1163,11 @@ public class Jalview2XML saveRnaViewers(jout, jseq, jds, viewIds, ap, storeDS); + if (jds.hasHMMProfile()) + { + saveHmmerProfile(jout, jseq, jds); + } + // jms.addJSeq(jseq); object.getJSeq().add(jseq); } @@ -1704,7 +1716,39 @@ public class Jalview2XML } return object; } + /** + * Saves the HMMER profile associated with the sequence as a file in the jar, + * in HMMER format, and saves the name of the file as a child element of the + * XML sequence element + * + * @param jout + * @param xmlSeq + * @param seq + */ + protected void saveHmmerProfile(JarOutputStream jout, JSeq xmlSeq, + SequenceI seq) + { + HiddenMarkovModel profile = seq.getHMM(); + if (profile == null) + { + warn("Want to save HMM profile for " + seq.getName() + + " but none found"); + return; + } + HMMFile hmmFile = new HMMFile(profile); + String hmmAsString = hmmFile.print(); + String jarEntryName = HMMER_PREFIX + nextCounter(); + try + { + writeJarEntry(jout, jarEntryName, hmmAsString.getBytes()); + xmlSeq.setHmmerProfile(jarEntryName); + } catch (IOException e) + { + warn("Error saving HMM profile: " + e.getMessage()); + } + } + /** * Writes PCA viewer attributes and computed values to an XML model object and * adds it to the JalviewModel. Any exceptions are reported by logging. @@ -2099,9 +2143,9 @@ public class Jalview2XML } else if (!matchedFile.equals(pdbentry.getFile())) { - Cache.log.warn( - "Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): " - + pdbentry.getFile()); + Cache.log.warn( + "Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): " + + pdbentry.getFile()); } // record the // file so we @@ -2383,7 +2427,7 @@ public class Jalview2XML if (calcIdParam.getVersion().equals("1.0")) { final String[] calcIds = calcIdParam.getServiceURL().toArray(new String[0]); - Jws2Instance service = Jws2Discoverer.getDiscoverer() + ServiceWithParameters service = PreferredServiceRegistry.getRegistry() .getPreferredServiceFor(calcIds); if (service != null) { @@ -2416,7 +2460,7 @@ public class Jalview2XML argList = parmSet.getArguments(); parmSet = null; } - AAConSettings settings = new AAConSettings( + AutoCalcSetting settings = new AAConSettings( calcIdParam.isAutoUpdate(), service, parmSet, argList); av.setCalcIdSettingsFor(calcIdParam.getCalcId(), settings, calcIdParam.isNeedsUpdate()); @@ -2424,7 +2468,7 @@ public class Jalview2XML } else { - warn("Cannot resolve a service for the parameters used in this project. Try configuring a JABAWS server."); + warn("Cannot resolve a service for the parameters used in this project. Try configuring a server in the Web Services preferences tab."); return false; } } @@ -3602,6 +3646,18 @@ public class Jalview2XML } } } + + /* + * load any HMMER profile + */ + // TODO fix this + + String hmmJarFile = jseqs.get(i).getHmmerProfile(); + if (hmmJarFile != null && jprovider != null) + { + loadHmmerProfile(jprovider, hmmJarFile, al.getSequenceAt(i)); + } + } } // end !multipleview @@ -4076,6 +4132,31 @@ public class Jalview2XML } /** + * Loads a HMMER profile from a file stored in the project, and associates it + * with the specified sequence + * + * @param jprovider + * @param hmmJarFile + * @param seq + */ + protected void loadHmmerProfile(jarInputStreamProvider jprovider, + String hmmJarFile, SequenceI seq) + { + try + { + String hmmFile = copyJarEntry(jprovider, hmmJarFile, "hmm", null); + HMMFile parser = new HMMFile(hmmFile, DataSourceType.FILE); + HiddenMarkovModel hmmModel = parser.getHMM(); + hmmModel = new HiddenMarkovModel(hmmModel, seq); + seq.setHMM(hmmModel); + } catch (IOException e) + { + warn("Error loading HMM profile for " + seq.getName() + ": " + + e.getMessage()); + } + } + + /** * Instantiate and link any saved RNA (Varna) viewers. The state of the Varna * panel is restored from separate jar entries, two (gapped and trimmed) per * sequence and secondary structure. @@ -5474,10 +5555,10 @@ public class Jalview2XML String id = object.getViewport().get(0).getSequenceSetId(); if (skipList.containsKey(id)) { - if (Cache.log != null && Cache.log.isDebugEnabled()) - { - Cache.log.debug("Skipping seuqence set id " + id); - } + if (Cache.log != null && Cache.log.isDebugEnabled()) + { + Cache.log.debug("Skipping seuqence set id " + id); + } return true; } return false; @@ -5951,7 +6032,6 @@ public class Jalview2XML jmap.setTo(djs); incompleteSeqs.put(sqid, djs); seqRefIds.put(sqid, djs); - } jalview.bin.Cache.log.debug("about to recurse on addDBRefs."); addDBRefs(djs, ms); @@ -6135,7 +6215,7 @@ public class Jalview2XML } else { - Cache.log.debug("Ignoring " + jvobj.getClass() + " (ID = " + id); + Cache.log.debug("Ignoring " + jvobj.getClass() + " (ID = " + id); } } } @@ -6609,7 +6689,7 @@ public class Jalview2XML maxcol = new Color(Integer.parseInt(colourModel.getRGB(), 16)); } catch (Exception e) { - Cache.log.warn("Couldn't parse out graduated feature color.", e); + Cache.log.warn("Couldn't parse out graduated feature color.", e); } NoValueColour noCol = colourModel.getNoValueColour();