*
* @return DOCUMENT ME!
*/
+ @Override
public char getGapCharacter()
{
return getAlignment().getGapCharacter();
*
* @return DOCUMENT ME!
*/
+ @Override
public ColumnSelection getColumnSelection()
{
return colSel;
/**
* Send the current selection to be broadcast to any selection listeners.
*/
+ @Override
public void sendSelection()
{
jalview.structure.StructureSelectionManager
return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
}
+ @Override
public boolean isNormaliseSequenceLogo()
{
return normaliseSequenceLogo;
*
* @return true if alignment characters should be displayed
*/
+ @Override
public boolean isValidCharWidth()
{
return validCharWidth;
* may give the user the option to open a new frame, or split panel, with cDNA
* and protein linked.
*
- * @param al
+ * @param toAdd
* @param title
*/
- public void addAlignment(AlignmentI al, String title)
+ public void addAlignment(AlignmentI toAdd, String title)
{
// TODO: promote to AlignViewportI? applet CutAndPasteTransfer is different
// TODO: create undo object for this JAL-1101
/*
- * If any cDNA/protein mappings can be made between the alignments, offer to
- * open a linked alignment with split frame option.
+ * Ensure datasets are created for the new alignment as
+ * mappings operate on dataset sequences
+ */
+ toAdd.setDataset(null);
+
+ /*
+ * Check if any added sequence could be the object of a mapping or
+ * cross-reference; if so, make the mapping explicit
+ */
+ realiseMappings(getAlignment(), toAdd);
+
+ /*
+ * If any cDNA/protein mappings exist or can be made between the alignments,
+ * offer to open a split frame with linked alignments
*/
if (Cache.getDefault(Preferences.ENABLE_SPLIT_FRAME, true))
{
- if (al.getDataset() == null)
- {
- // need to create ds seqs
- for (SequenceI sq : al.getSequences())
- {
- if (sq.getDatasetSequence() == null)
- {
- sq.createDatasetSequence();
- }
- }
- }
- if (AlignmentUtils.isMappable(al, getAlignment()))
+ // if (toAdd.getDataset() == null)
+ // {
+ // // need to create ds seqs
+ // for (SequenceI sq : toAdd.getSequences())
+ // {
+ // if (sq.getDatasetSequence() == null)
+ // {
+ // sq.createDatasetSequence();
+ // }
+ // }
+ // }
+ if (AlignmentUtils.isMappable(toAdd, getAlignment()))
{
- if (openLinkedAlignment(al, title))
+ if (openLinkedAlignment(toAdd, title))
{
return;
}
// TODO: JAL-407 regardless of above - identical sequences (based on ID and
// provenance) should share the same dataset sequence
- for (int i = 0; i < al.getHeight(); i++)
+ for (int i = 0; i < toAdd.getHeight(); i++)
{
- getAlignment().addSequence(al.getSequenceAt(i));
+ getAlignment().addSequence(toAdd.getSequenceAt(i));
}
setEndSeq(getAlignment().getHeight());
}
/**
+ * Check if any added sequence could be the object of a mapping or
+ * cross-reference; if so, make the mapping explicit. Returns the count of
+ * mappings updated.
+ *
+ * @param al
+ * @param toAdd
+ */
+ protected int realiseMappings(AlignmentI al, AlignmentI toAdd)
+ {
+ // TODO this is proof of concept
+ // we might want to give the user some choice here
+ int count = 0;
+ for (SequenceI seq : toAdd.getSequences())
+ {
+ count += realiseMappingsTo(al, seq);
+ }
+ return count;
+ }
+
+ /**
+ * If the alignment holds any mappings to a dummy (placeholder) sequence that
+ * matches the given sequence, then update the mapping to point to the
+ * sequence. Returns the number of mappings updated.
+ *
+ * @param al
+ * @param seq
+ * @return
+ */
+ protected int realiseMappingsTo(AlignmentI al, SequenceI seq)
+ {
+ int count = 0;
+ Set<AlignedCodonFrame> mappings = al.getDataset().getCodonFrames();
+ // TODO are mappings on alignment or alignment dataset?!?
+ for (AlignedCodonFrame mapping : mappings)
+ {
+ /*
+ * TODO could just go straight to realiseWith() here unless we want
+ * to give the user some choice before going ahead
+ */
+ if (mapping.isRealisableWith(seq))
+ {
+ count += mapping.realiseWith(seq);
+ }
+ }
+ return count;
+ }
+
+ /**
* Show a dialog with the option to open and link (cDNA <-> protein) as a new
* alignment, either as a standalone alignment or in a split frame. Returns
* true if the new alignment was opened, false if not, because the user