import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.GraphLine;
-import jalview.datamodel.HiddenMarkovModel;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.RnaViewerModel;
import jalview.datamodel.SequenceFeature;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.DataSourceType;
import jalview.io.FileFormat;
-import jalview.io.HMMFile;
import jalview.renderer.ResidueShaderI;
import jalview.schemabinding.version2.AlcodMap;
import jalview.schemabinding.version2.AlcodonFrame;
import jalview.schemabinding.version2.AnnotationColours;
import jalview.schemabinding.version2.AnnotationElement;
import jalview.schemabinding.version2.CalcIdParam;
+import jalview.schemabinding.version2.Colour;
import jalview.schemabinding.version2.CompoundMatcher;
import jalview.schemabinding.version2.DBRef;
import jalview.schemabinding.version2.Features;
private static final String RNA_PREFIX = "rna_";
- private static final String HMMER_PREFIX = "hmmer_";
-
private static final String UTF_8 = "UTF-8";
// use this with nextCounter() to make unique names for entities
}
}
- /*
- * save sequence features
- * TODO: omit sequence features from each alignment view's
- * XML dump if we are storing dataset
- */
- List<SequenceFeature> sfs = jds.getSequenceFeatures();
+ // TODO: omit sequence features from each alignment view's XML dump if we
+ // are storing dataset
+ List<jalview.datamodel.SequenceFeature> sfs = jds
+ .getSequenceFeatures();
for (SequenceFeature sf : sfs)
{
- Features features = saveFeature(sf);
+ Features features = new Features();
+
+ features.setBegin(sf.getBegin());
+ features.setEnd(sf.getEnd());
+ features.setDescription(sf.getDescription());
+ features.setType(sf.getType());
+ features.setFeatureGroup(sf.getFeatureGroup());
+ features.setScore(sf.getScore());
+ if (sf.links != null)
+ {
+ for (int l = 0; l < sf.links.size(); l++)
+ {
+ OtherData keyValue = new OtherData();
+ keyValue.setKey("LINK_" + l);
+ keyValue.setValue(sf.links.elementAt(l).toString());
+ features.addOtherData(keyValue);
+ }
+ }
+ if (sf.otherDetails != null)
+ {
+ /*
+ * save feature attributes, which may be simple strings or
+ * map valued (have sub-attributes)
+ */
+ for (Entry<String, Object> entry : sf.otherDetails.entrySet())
+ {
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ if (value instanceof Map<?, ?>)
+ {
+ for (Entry<String, Object> subAttribute : ((Map<String, Object>) value)
+ .entrySet())
+ {
+ OtherData otherData = new OtherData();
+ otherData.setKey(key);
+ otherData.setKey2(subAttribute.getKey());
+ otherData.setValue(subAttribute.getValue().toString());
+ features.addOtherData(otherData);
+ }
+ }
+ else
+ {
+ OtherData otherData = new OtherData();
+ otherData.setKey(key);
+ otherData.setValue(value.toString());
+ features.addOtherData(otherData);
+ }
+ }
+ }
+
jseq.addFeatures(features);
}
- /*
- * save PDB entries for sequence
- */
if (jdatasq.getAllPDBEntries() != null)
{
- Enumeration<PDBEntry> en = jdatasq.getAllPDBEntries().elements();
+ Enumeration en = jdatasq.getAllPDBEntries().elements();
while (en.hasMoreElements())
{
Pdbids pdb = new Pdbids();
- PDBEntry entry = en.nextElement();
+ jalview.datamodel.PDBEntry entry = (jalview.datamodel.PDBEntry) en
+ .nextElement();
String pdbId = entry.getId();
pdb.setId(pdbId);
saveRnaViewers(jout, jseq, jds, viewIds, ap, storeDS);
- if (jds.hasHMMProfile())
- {
- saveHmmerProfile(jout, jseq, jds);
- }
-
jms.addJSeq(jseq);
}
jGroup.setTextCol2(sg.textColour2.getRGB());
jGroup.setTextColThreshold(sg.thresholdTextColour);
jGroup.setShowUnconserved(sg.getShowNonconserved());
- jGroup.setIgnoreGapsinConsensus(sg.isIgnoreGapsConsensus());
+ jGroup.setIgnoreGapsinConsensus(sg.getIgnoreGapsConsensus());
jGroup.setShowConsensusHistogram(sg.isShowConsensusHistogram());
jGroup.setShowSequenceLogo(sg.isShowSequenceLogo());
jGroup.setNormaliseSequenceLogo(sg.isNormaliseSequenceLogo());
}
/**
- * 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());
- }
- }
-
- /**
- * Converts a Jalview SequenceFeature into the XML model of it to save
- *
- * @param sf
- * @return
- */
- protected Features saveFeature(SequenceFeature sf)
- {
- Features features = new Features();
-
- features.setBegin(sf.getBegin());
- features.setEnd(sf.getEnd());
- features.setDescription(sf.getDescription());
- features.setType(sf.getType());
- features.setFeatureGroup(sf.getFeatureGroup());
- features.setScore(sf.getScore());
- if (sf.links != null)
- {
- for (int l = 0; l < sf.links.size(); l++)
- {
- OtherData keyValue = new OtherData();
- keyValue.setKey("LINK_" + l);
- keyValue.setValue(sf.links.elementAt(l).toString());
- features.addOtherData(keyValue);
- }
- }
- if (sf.otherDetails != null)
- {
- /*
- * save feature attributes, which may be simple strings or
- * map valued (have sub-attributes)
- */
- for (Entry<String, Object> entry : sf.otherDetails.entrySet())
- {
- String key = entry.getKey();
- Object value = entry.getValue();
- if (value instanceof Map<?, ?>)
- {
- for (Entry<String, Object> subAttribute : ((Map<String, Object>) value)
- .entrySet())
- {
- OtherData otherData = new OtherData();
- otherData.setKey(key);
- otherData.setKey2(subAttribute.getKey());
- otherData.setValue(subAttribute.getValue().toString());
- features.addOtherData(otherData);
- }
- }
- else
- {
- OtherData otherData = new OtherData();
- otherData.setKey(key);
- otherData.setValue(value.toString());
- features.addOtherData(otherData);
- }
- }
- }
- return features;
- }
-
- /**
* Save any Varna viewers linked to this sequence. Writes an rnaViewer element
* for each viewer, with
* <ul>
}
else if (!matchedFile.equals(pdbentry.getFile()))
{
- 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
mpc.setDseqFor(jmpid);
if (!seqRefIds.containsKey(mpc.getDseqFor()))
{
- debug("creating new DseqFor ID");
+ jalview.bin.Cache.log.debug("creatign new DseqFor ID");
seqRefIds.put(mpc.getDseqFor(), ps);
}
else
{
- debug("reusing DseqFor ID");
+ jalview.bin.Cache.log.debug("reusing DseqFor ID");
}
mp.setMappingChoice(mpc);
//
for (int i = 0; i < vamsasSeq.length; i++)
{
- SequenceI alignmentSeq = al.getSequenceAt(i);
if (jseqs[i].getFeaturesCount() > 0)
{
Features[] features = jseqs[i].getFeatures();
for (int f = 0; f < features.length; f++)
{
- Features feature = features[f];
- SequenceFeature sf = new SequenceFeature(feature.getType(),
- feature.getDescription(), feature.getBegin(),
- feature.getEnd(), feature.getScore(),
- feature.getFeatureGroup());
- sf.setStatus(feature.getStatus());
+ SequenceFeature sf = new SequenceFeature(features[f].getType(),
+ features[f].getDescription(), features[f].getBegin(),
+ features[f].getEnd(), features[f].getScore(),
+ features[f].getFeatureGroup());
+ sf.setStatus(features[f].getStatus());
/*
* load any feature attributes - include map-valued attributes
*/
Map<String, Map<String, String>> mapAttributes = new HashMap<>();
- for (int od = 0; od < feature.getOtherDataCount(); od++)
+ for (int od = 0; od < features[f].getOtherDataCount(); od++)
{
- OtherData keyValue = feature.getOtherData(od);
+ OtherData keyValue = features[f].getOtherData(od);
String attributeName = keyValue.getKey();
String attributeValue = keyValue.getValue();
if (attributeName.startsWith("LINK"))
}
// adds feature to datasequence's feature set (since Jalview 2.10)
- alignmentSeq.addSequenceFeature(sf);
+ al.getSequenceAt(i).addSequenceFeature(sf);
}
}
if (vamsasSeq[i].getDBRefCount() > 0)
{
// adds dbrefs to datasequence's set (since Jalview 2.10)
addDBRefs(
- alignmentSeq.getDatasetSequence() == null ? alignmentSeq
- : alignmentSeq.getDatasetSequence(),
+ al.getSequenceAt(i).getDatasetSequence() == null
+ ? al.getSequenceAt(i)
+ : al.getSequenceAt(i).getDatasetSequence(),
vamsasSeq[i]);
}
if (jseqs[i].getPdbidsCount() > 0)
.getStructureSelectionManager(Desktop.instance)
.registerPDBEntry(entry);
// adds PDBEntry to datasequence's set (since Jalview 2.10)
- if (alignmentSeq.getDatasetSequence() != null)
+ if (al.getSequenceAt(i).getDatasetSequence() != null)
{
- alignmentSeq.getDatasetSequence().addPDBId(entry);
+ al.getSequenceAt(i).getDatasetSequence().addPDBId(entry);
}
else
{
- alignmentSeq.addPDBId(entry);
+ al.getSequenceAt(i).addPDBId(entry);
}
}
}
-
- /*
- * load any HMMER profile
- */
- String hmmJarFile = jseqs[i].getHmmerProfile();
- if (hmmJarFile != null)
- {
- loadHmmerProfile(jprovider, hmmJarFile, alignmentSeq);
- }
}
} // end !multipleview
}
/**
- * 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.
af.viewport.getResidueShading().setThreshold(view.getPidThreshold(),
view.getIgnoreGapsinConsensus());
af.viewport.getResidueShading()
- .setConsensus(af.viewport.getConsensusProfiles());
+ .setConsensus(af.viewport.getSequenceConsensusHash());
af.viewport.setColourAppliesToAllGroups(false);
if (view.getConservationSelected() && cs != null)
id = object.getJalviewModelSequence().getViewport()[0]
.getSequenceSetId()))
{
- debug("Skipping sequence set id " + id);
+ if (Cache.log != null && Cache.log.isDebugEnabled())
+ {
+ Cache.log.debug("Skipping seuqence set id " + id);
+ }
return true;
}
return false;
seqRefIds.put(sqid, djs);
}
- debug("about to recurse on addDBRefs.");
+ jalview.bin.Cache.log.debug("about to recurse on addDBRefs.");
addDBRefs(djs, ms);
}
}
else
{
- debug("Ignoring " + jvobj.getClass() + " (ID = " + id);
+ Cache.log.debug("Ignoring " + jvobj.getClass() + " (ID = " + id);
}
}
}
maxcol = new Color(Integer.parseInt(colourModel.getRGB(), 16));
} catch (Exception e)
{
- if (Cache.log != null)
- {
- 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();