From: Jim Procter Date: Tue, 21 Jun 2016 09:21:23 +0000 (+0100) Subject: JAL-1369 ensure *real* alignment’s metadata written in Jalview2XML when view contains... X-Git-Tag: Release_2_10_0~161^2~5^2~5 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f47cbc54ccc008c3e4eefd4b0e514036b7ace708;p=jalview.git JAL-1369 ensure *real* alignment’s metadata written in Jalview2XML when view contains hidden sequences --- diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index a3604d6..5fb8e62 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -634,11 +634,15 @@ public class Jalview2XML object.setVersion(jalview.bin.Cache.getDefault("VERSION", "Development Build")); - jalview.datamodel.AlignmentI jal = av.getAlignment(); + /** + * rjal is full height alignment, jal is actual alignment with full metadata + * but excludes hidden sequences. + */ + jalview.datamodel.AlignmentI rjal = av.getAlignment(), jal = rjal; if (av.hasHiddenRows()) { - jal = jal.getHiddenSequences().getFullAlignment(); + rjal = jal.getHiddenSequences().getFullAlignment(); } SequenceSet vamsasSet = new SequenceSet(); @@ -655,6 +659,7 @@ public class Jalview2XML { // switch jal and the dataset jal = jal.getDataset(); + rjal = jal; } } if (jal.getProperties() != null) @@ -674,9 +679,9 @@ public class Jalview2XML Set calcIdSet = new HashSet(); // SAVE SEQUENCES - for (int i = 0; i < jal.getHeight(); i++) + for (int i = 0; i < rjal.getHeight(); i++) { - final SequenceI jds = jal.getSequenceAt(i); + final SequenceI jds = rjal.getSequenceAt(i); final SequenceI jdatasq = jds.getDatasetSequence() == null ? jds : jds.getDatasetSequence(); String id = seqHash(jds); @@ -715,20 +720,21 @@ public class Jalview2XML // Store any sequences this sequence represents if (av.hasHiddenRows()) { + // use rjal, contains the full height alignment jseq.setHidden(av.getAlignment().getHiddenSequences() .isHidden(jds)); - if (av.isHiddenRepSequence(jal.getSequenceAt(i))) + if (av.isHiddenRepSequence(rjal.getSequenceAt(i))) { jalview.datamodel.SequenceI[] reps = av - .getRepresentedSequences(jal.getSequenceAt(i)) - .getSequencesInOrder(jal); + .getRepresentedSequences(rjal.getSequenceAt(i)) + .getSequencesInOrder(rjal); for (int h = 0; h < reps.length; h++) { - if (reps[h] != jal.getSequenceAt(i)) + if (reps[h] != rjal.getSequenceAt(i)) { - jseq.addHiddenSequences(jal.findIndex(reps[h])); + jseq.addHiddenSequences(rjal.findIndex(reps[h])); } } }