- * Builds codon mappings from this (protein) alignment to any compatible
- * nucleotide alignments. Mappings are built between sequences with the same
- * name and compatible lengths. Also makes the cDNA alignment a
- * CommandListener for the protein alignment so that edits are mirrored.
- */
- @Override
- protected void linkCdna_actionPerformed()
- {
- int linkedCount = 0;
- int alreadyLinkedCount = 0;
- final AlignmentI thisAlignment = this.alignPanel.getAlignment();
-
- for (AlignFrame af : Desktop.getAlignFrames())
- {
- if (af.alignPanel != null)
- {
- final AlignmentI thatAlignment = af.alignPanel.getAlignment();
- if (thatAlignment.isNucleotide())
- {
- MappingResult mapped = AlignmentUtils.mapProteinToCdna(
- thisAlignment, thatAlignment);
- if (mapped == MappingResult.AlreadyMapped)
- {
- alreadyLinkedCount++;
- }
- else if (mapped == MappingResult.Mapped)
- {
- final StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Desktop.instance);
- ssm.addMappings(thisAlignment.getCodonFrames());
- // enable the next line to enable linked editing
- // ssm.addCommandListener(af.getViewport());
- linkedCount++;
- }
- }
- }
- }
- String msg = "";
- if (linkedCount == 0 && alreadyLinkedCount == 0)
- {
- msg = MessageManager.getString("label.no_cdna");
- }
- else if (linkedCount > 0)
- {
- msg = MessageManager.formatMessage("label.linked_cdna", linkedCount);
- }
- else
- {
- msg = MessageManager.formatMessage("label.cdna_all_linked",
- alreadyLinkedCount);
- }
- setStatus(msg);
- }
-
- /**
- * Align any linked cDNA to match the alignment of this (protein) alignment.
- * Any mapped sequence regions will be realigned, unmapped sequences are not
- * affected.
- */
- @Override
- protected void alignCdna_actionPerformed()
- {
- int seqCount = 0;
- int alignCount = 0;
- final AlignmentI thisAlignment = this.alignPanel.getAlignment();
- for (AlignFrame af : Desktop.getAlignFrames())
- {
- if (af.alignPanel != null)
- {
- final AlignmentI thatAlignment = af.alignPanel.getAlignment();
- if (thatAlignment.isNucleotide())
- {
- int seqsAligned = thatAlignment.alignAs(thisAlignment);
- seqCount += seqsAligned;
- if (seqsAligned > 0)
- {
- af.alignPanel.alignmentChanged();
- alignCount++;
- }
- }
- }
- }
- setStatus(MessageManager.formatMessage("label.cdna_aligned", seqCount,
- alignCount));
- }
- /**