X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fproject%2FJalview2XML.java;fp=src%2Fjalview%2Fproject%2FJalview2XML.java;h=983b5121d23243e530d136fafe5add9aab156bc4;hb=eb3e681d6e82ccdd5d312d1981dfb306e7f479f0;hp=d5b3808f8dbfaa10b7a5ae3efdaa79a6652c978a;hpb=cb31e23d9138e481479623374aed7767bf8934d2;p=jalview.git diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index d5b3808..983b512 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -287,13 +287,15 @@ public class Jalview2XML * entry names */ private Map rnaSessions = new HashMap<>(); - + /** * map from contact matrices to their XML ids */ - private Map contactMatrices = new HashMap<>(); + private Map contactMatrices = new HashMap<>(); + private Map contactMatrixRefs = new HashMap<>(); - private List xmlMatrices= new ArrayList<>(); + + private List xmlMatrices = new ArrayList<>(); /** * A helper method for safely using the value of an optional attribute that @@ -391,12 +393,14 @@ public class Jalview2XML } /** - * base class for resolving forward references to an as-yet unmarshalled object referenced by already unmarshalled objects + * base class for resolving forward references to an as-yet unmarshalled + * object referenced by already unmarshalled objects * * @author jprocter * */ - abstract class forwardRef { + abstract class forwardRef + { String sref; String type; @@ -413,6 +417,7 @@ public class Jalview2XML } public abstract boolean isResolvable(); + /** * @return true if the forward reference was fully resolved */ @@ -424,8 +429,10 @@ public class Jalview2XML return type + " reference to " + sref; } } + /** * resolve forward references to sequences by their ID + * * @author jprocter */ abstract class SeqFref extends forwardRef @@ -434,6 +441,7 @@ public class Jalview2XML { super(_sref, type); } + public SequenceI getSrefSeq() { return seqRefIds.get(sref); @@ -518,7 +526,7 @@ public class Jalview2XML }; return fref; } - + public forwardRef newMatrixFref(final String matRef, final jalview.util.MapList mapping, final AlignmentAnnotation jaa) { @@ -1647,8 +1655,9 @@ public class Jalview2XML view.setShowFullId(av.getShowJVSuffix()); view.setRightAlignIds(av.isRightAlignIds()); view.setIdWidth(av.getIdWidth()); - view.setIdWidthManuallyAdjusted(ap.getIdPanel().getIdCanvas().isManuallyAdjusted()); - + view.setIdWidthManuallyAdjusted( + ap.getIdPanel().getIdCanvas().isManuallyAdjusted()); + view.setShowSequenceFeatures(av.isShowSequenceFeatures()); view.setShowText(av.getShowText()); view.setShowUnconserved(av.getShowUnconserved()); @@ -1820,20 +1829,19 @@ public class Jalview2XML // jms.addViewport(view); object.getViewport().add(view); } - - + if (storeDS) { // store matrices referenced by any views or annotation in this dataset - if (xmlMatrices!=null && xmlMatrices.size()>0) + if (xmlMatrices != null && xmlMatrices.size() > 0) { - Console.debug("Adding "+xmlMatrices.size()+" matrices to dataset."); + Console.debug( + "Adding " + xmlMatrices.size() + " matrices to dataset."); vamsasSet.getMatrix().addAll(xmlMatrices); xmlMatrices.clear(); } } - // object.setJalviewModelSequence(jms); // object.getVamsasModel().addSequenceSet(vamsasSet); object.getVamsasModel().getSequenceSet().add(vamsasSet); @@ -2398,7 +2406,7 @@ public class Jalview2XML .getContactMatrixFor(annotation); if (cm != null) { - storeMatrixFor(vamsasSet, an,annotation, cm); + storeMatrixFor(vamsasSet, an, annotation, cm); } } } @@ -2505,11 +2513,12 @@ public class Jalview2XML } - private void storeMatrixFor(SequenceSet root, Annotation an, AlignmentAnnotation annotation, ContactMatrixI cm) + private void storeMatrixFor(SequenceSet root, Annotation an, + AlignmentAnnotation annotation, ContactMatrixI cm) { String cmId = contactMatrices.get(cm); - MatrixType xmlmat=null; - + MatrixType xmlmat = null; + // first create an xml ref for the matrix data, if none exist if (cmId == null) { @@ -2537,20 +2546,23 @@ public class Jalview2XML { xmlmat.setCutHeight(cm.getCutHeight()); } - xmlmat.setId(cmId = "m"+contactMatrices.size()+System.currentTimeMillis()); - Console.trace("Matrix data stored :"+cmId); + xmlmat.setId(cmId = "m" + contactMatrices.size() + + System.currentTimeMillis()); + Console.trace("Matrix data stored :" + cmId); contactMatrices.put(cm, cmId); contactMatrixRefs.put(cmId, cm); xmlMatrices.add(xmlmat); - } else { - Console.trace("Existing Matrix stored :"+cmId); + } + else + { + Console.trace("Existing Matrix stored :" + cmId); } // now store mapping MapOnAMatrixType xmlmatmapping = new MapOnAMatrixType(); xmlmatmapping.setMatrix(cmId); - + // Pretty much all matrices currently managed in this way are // mappableContactMatrixI implementations - but check anyway if (cm instanceof MappableContactMatrixI) @@ -3163,7 +3175,7 @@ public class Jalview2XML initSeqRefs(); } AlignFrame af = null, _af = null; - List toRepaint=new ArrayList(); + List toRepaint = new ArrayList(); IdentityHashMap importedDatasets = new IdentityHashMap<>(); Map gatherToThisFrame = new HashMap<>(); final String file = jprovider.getFilename(); @@ -3228,7 +3240,7 @@ public class Jalview2XML } while (jarentry != null); jin.close(); resolveFrefedSequences(); - for (AlignFrame alignFrame:toRepaint) + for (AlignFrame alignFrame : toRepaint) { alignFrame.repaint(); } @@ -3623,12 +3635,12 @@ public class Jalview2XML // //////////////////////////////// // LOAD MATRICES (IF ANY) - - if (vamsasSet.getMatrix()!=null && vamsasSet.getMatrix().size()>0) + + if (vamsasSet.getMatrix() != null && vamsasSet.getMatrix().size() > 0) { importMatrixData(vamsasSet.getMatrix()); } - + // //////////////////////////////// // LOAD SEQUENCES @@ -4164,7 +4176,7 @@ public class Jalview2XML for (MapOnAMatrixType xmlmat : annotation.getContactmatrix()) { restoreMatrixFor(jaa.sequenceRef, jaa, xmlmat); - } + } } } @@ -4396,11 +4408,12 @@ public class Jalview2XML private void importMatrixData(List xmlmatrices) { - for (MatrixType xmlmat:xmlmatrices) + for (MatrixType xmlmat : xmlmatrices) { if (!PAEContactMatrix.PAEMATRIX.equals(xmlmat.getType())) { - Console.error("Ignoring matrix '"+xmlmat.getId()+"' of type '"+xmlmat.getType()); + Console.error("Ignoring matrix '" + xmlmat.getId() + "' of type '" + + xmlmat.getType()); continue; } @@ -4410,11 +4423,10 @@ public class Jalview2XML continue; } - float[][] elements = ContactMatrix - .fromFloatStringToContacts(xmlmat.getElements(), - xmlmat.getCols().intValue(), - xmlmat.getRows().intValue()); - + float[][] elements = ContactMatrix.fromFloatStringToContacts( + xmlmat.getElements(), xmlmat.getCols().intValue(), + xmlmat.getRows().intValue()); + List newgroups = new ArrayList(); if (xmlmat.getGroups().size() > 0) { @@ -4423,30 +4435,28 @@ public class Jalview2XML newgroups.add(deStringifyBitset(sgroup)); } } - String nwk = xmlmat.getNewick().size() > 0 - ? xmlmat.getNewick().get(0) + String nwk = xmlmat.getNewick().size() > 0 ? xmlmat.getNewick().get(0) : null; if (xmlmat.getNewick().size() > 1) { - Console.log.info( - "Ignoring additional clusterings for contact matrix"); + Console.log + .info("Ignoring additional clusterings for contact matrix"); } String treeMethod = xmlmat.getTreeMethod(); - double thresh = xmlmat.getCutHeight() != null - ? xmlmat.getCutHeight() + double thresh = xmlmat.getCutHeight() != null ? xmlmat.getCutHeight() : 0; GroupSet grpset = new GroupSet(); grpset.restoreGroups(newgroups, treeMethod, nwk, thresh); - + FloatContactMatrix newcm = new FloatContactMatrix(elements, grpset); contactMatrixRefs.put(xmlmat.getId(), newcm); - Console.trace("Restored base contact matrix "+xmlmat.getId()); + Console.trace("Restored base contact matrix " + xmlmat.getId()); } } private void restoreMatrixFor(SequenceI sequenceRef, AlignmentAnnotation jaa, MapOnAMatrixType xmlmatmapping) - { + { // restore mapping data to matrix data jalview.util.MapList mapping = null; if (xmlmatmapping.getMapping() != null) @@ -4473,7 +4483,7 @@ public class Jalview2XML mapping = new jalview.util.MapList(fr, fto, m.getMapFromUnit().intValue(), m.getMapToUnit().intValue()); } - + // locate matrix data in project XML and import ContactMatrixI cm = contactMatrixRefs.get(xmlmatmapping.getMatrix()); if (cm == null) @@ -5244,21 +5254,26 @@ public class Jalview2XML } af.setBounds(safeInt(view.getXpos()), safeInt(view.getYpos()), safeInt(view.getWidth()), safeInt(view.getHeight())); - - af.alignPanel.fontChanged(); // make sure font is updated *before* we set ID width - if (view.getIdWidth()==null) + + af.alignPanel.fontChanged(); // make sure font is updated *before* we set ID + // width + if (view.getIdWidth() == null) { - if (!isVersionStringLaterThan("2.11.3", jm.getVersion())) { + if (!isVersionStringLaterThan("2.11.3", jm.getVersion())) + { // Pre 2.11.3 jalview projects do not store the id width // idWidth was also calculated in a different way. viewport.setIdWidth(af.alignPanel.getLegacyIdWidth()); af.alignPanel.getIdPanel().getIdCanvas().setManuallyAdjusted(true); } - } else { + } + else + { viewport.setIdWidth(view.getIdWidth()); - af.alignPanel.getIdPanel().getIdCanvas().setManuallyAdjusted(view.isIdWidthManuallyAdjusted()); + af.alignPanel.getIdPanel().getIdCanvas() + .setManuallyAdjusted(view.isIdWidthManuallyAdjusted()); } - + // startSeq set in af.alignPanel.updateLayout below af.alignPanel.updateLayout(); ColourSchemeI cs = null;