import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.GeneLociI;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.IncompleteCodonException;
import jalview.datamodel.Mapping;
import jalview.datamodel.Sequence;
}
return true;
}
+
+ /**
+ * Creates a deep copy of an alignment along with a dataset alignment,
+ * alignment annotations, representative sequence and hidden columns.
+ */
+ public static AlignmentI deepCopyAlignment(AlignmentI alignment)
+ {
+ var alnCpy = new Alignment(alignment);
+ alnCpy.setGapCharacter(alignment.getGapCharacter());
+ alnCpy.setDataset(alignment.getDataset());
+ for (AlignmentAnnotation annotation : alignment.getAlignmentAnnotation())
+ alnCpy.addAnnotation(new AlignmentAnnotation(annotation));
+ if (alignment.hasSeqrep())
+ {
+ int idx = alignment.findIndex(alignment.getSeqrep());
+ if (idx >= 0)
+ alnCpy.setSeqrep(alnCpy.getSequenceAt(idx));
+ }
+ if (alignment.getHiddenColumns() != null)
+ alnCpy.setHiddenColumns(new HiddenColumns(alignment.getHiddenColumns()));
+ return alnCpy;
+ }
}
import javax.swing.SwingUtilities;
+import jalview.analysis.AlignmentUtils;
import jalview.bin.Console;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
}
infoPanel.showResultsNewFrame.addActionListener(evt -> {
// copy alignment for each frame to have its own instance
- var alnCpy = new Alignment(result);
- alnCpy.setGapCharacter(result.getGapCharacter());
- alnCpy.setDataset(result.getDataset());
- for (AlignmentAnnotation annotation : result.getAlignmentAnnotation())
- alnCpy.addAnnotation(new AlignmentAnnotation(annotation));
- if (result.hasSeqrep())
- {
- int idx = result.findIndex(result.getSeqrep());
- if (idx >= 0)
- alnCpy.setSeqrep(alnCpy.getSequenceAt(idx));
- }
- if (result.getHiddenColumns() != null)
- alnCpy.setHiddenColumns(new HiddenColumns(result.getHiddenColumns()));
+ var alnCpy = AlignmentUtils.deepCopyAlignment(result);
displayResultsNewFrame(alnCpy);
});
SwingUtilities.invokeLater(infoPanel::setResultsReady);