/**
* Constructs an alignment consisting of the mapped exon regions in the given
- * nucleotide sequences, and updates mappings to match.
+ * nucleotide sequences, and updates mappings to match. The new alignment's
+ * sequences are added to the parent alignment's dataset, and both alignments
+ * share the same dataset.
*
* @param dna
* aligned dna sequences
* sequences (or null if no exons are found)
*/
public static AlignmentI makeExonAlignment(SequenceI[] dna,
- Set<AlignedCodonFrame> mappings)
+ Set<AlignedCodonFrame> mappings, AlignmentI al)
{
Set<AlignedCodonFrame> newMappings = new LinkedHashSet<AlignedCodonFrame>();
List<SequenceI> exonSequences = new ArrayList<SequenceI>();
}
}
}
- AlignmentI al = new Alignment(
+ AlignmentI cds = new Alignment(
exonSequences.toArray(new SequenceI[exonSequences.size()]));
- al.setDataset(null);
+
+ /*
+ * add new sequences to the shared dataset, set it on the new alignment
+ */
+ List<SequenceI> dsseqs = al.getDataset().getSequences();
+ for (SequenceI seq : cds.getSequences())
+ {
+ if (!dsseqs.contains(seq.getDatasetSequence()))
+ {
+ dsseqs.add(seq.getDatasetSequence());
+ }
+ }
+ cds.setDataset(al.getDataset());
/*
* Replace the old mappings with the new ones
mappings.clear();
mappings.addAll(newMappings);
- return al;
+ return cds;
}
/**
* operation that affects the data in the current view (selection changed,
* etc) to update the menus to reflect the new state.
*/
+ @Override
public void setMenusForViewport()
{
setMenusFromViewport(viewport);
alignPanel.makeEPS(f);
}
+ @Override
public void createSVG(File f)
{
alignPanel.makeSVG(f);
}
}
+ @Override
public void addHistoryItem(CommandI command)
{
if (command.getSize() > 0)
* @param cs
* DOCUMENT ME!
*/
+ @Override
public void changeColour(ColourSchemeI cs)
{
// TODO: pull up to controller method
try
{
// update our local dataset reference
- Alignment ds = AlignFrame.this.getViewport().getAlignment()
- .getDataset();
+ AlignmentI alignment = AlignFrame.this.getViewport()
+ .getAlignment();
+ Alignment ds = alignment.getDataset();
Alignment prods = CrossRef
.findXrefSequences(sel, dna, source, ds);
if (prods != null)
if (dna)
{
copyAlignment = AlignmentUtils.makeExonAlignment(
- sequenceSelection, cf);
+ sequenceSelection, cf, alignment);
al.getCodonFrames().clear();
al.getCodonFrames().addAll(cf);
final StructureSelectionManager ssm = StructureSelectionManager
viewport.firePropertyChange("alignment", null, al);
}
+ @Override
public void setShowSeqFeatures(boolean b)
{
showSeqFeatures.setSelected(b);
*/
Map<String, SequenceI> seqRefIds = null;
- Vector frefedSequence = null;
+ Vector<Object[]> frefedSequence = null;
boolean raiseGUI = true; // whether errors are raised in dialog boxes or not
int r = 0, rSize = frefedSequence.size();
while (r < rSize)
{
- Object[] ref = (Object[]) frefedSequence.elementAt(r);
+ Object[] ref = frefedSequence.elementAt(r);
if (ref != null)
{
String sref = (String) ref[0];
{
SwingUtilities.invokeAndWait(new Runnable()
{
+ @Override
public void run()
{
setLoadingFinishedForNewStructureViewers();
}
if (frefedSequence == null)
{
- frefedSequence = new Vector();
+ frefedSequence = new Vector<Object[]>();
}
AlignFrame af = null, _af = null;
{
mapping = addMapping(maps[m].getMapping());
}
- if (dnaseq != null)
+ if (dnaseq != null && mapping.getTo() != null)
{
cf.addMap(dnaseq, mapping.getTo(), mapping.getMap());
}
}
if (this.frefedSequence == null)
{
- frefedSequence = new Vector();
+ frefedSequence = new Vector<Object[]>();
}
viewportsAdded.clear();
acf.addMap(dna2.getDatasetSequence(), pep2.getDatasetSequence(), map);
mappings.add(acf);
+ AlignmentI dna = new Alignment(new SequenceI[] { dna1, dna2 });
+ dna.setDataset(null);
AlignmentI exons = AlignmentUtils.makeExonAlignment(new SequenceI[] {
- dna1, dna2 }, mappings);
- assertEquals(2, exons.getSequences().size());
- assertEquals("GGGTTT", exons.getSequenceAt(0).getSequenceAsString());
- assertEquals("GGGTTTCCC", exons.getSequenceAt(1).getSequenceAsString());
+ dna1, dna2 }, mappings, dna);
+ List<SequenceI> exonSeqs = exons.getSequences();
+ assertEquals(2, exonSeqs.size());
+ assertEquals("GGGTTT", exonSeqs.get(0).getSequenceAsString());
+ assertEquals("GGGTTTCCC", exonSeqs.get(1).getSequenceAsString());
+
+ /*
+ * verify shared, extended alignment dataset
+ */
+ assertSame(dna.getDataset(), exons.getDataset());
+ assertTrue(dna.getDataset().getSequences()
+ .contains(exonSeqs.get(0).getDatasetSequence()));
+ assertTrue(dna.getDataset().getSequences()
+ .contains(exonSeqs.get(1).getDatasetSequence()));
/*
* Verify updated mappings
* Create the Exon alignment; also replaces the dna-to-protein mappings with
* exon-to-protein and exon-to-dna mappings
*/
+ AlignmentI dna = new Alignment(new SequenceI[] { dna1 });
+ dna.setDataset(null);
AlignmentI exal = AlignmentUtils.makeExonAlignment(
- new SequenceI[] { dna1 }, mappings);
+ new SequenceI[] { dna1 }, mappings, dna);
/*
* Verify we have 3 exon sequences, mapped to pep1/2/3 respectively
List<SequenceI> exons = exal.getSequences();
assertEquals(3, exons.size());
+ /*
+ * verify shared, extended alignment dataset
+ */
+ assertSame(dna.getDataset(), exal.getDataset());
+ assertTrue(dna.getDataset().getSequences()
+ .contains(exons.get(0).getDatasetSequence()));
+ assertTrue(dna.getDataset().getSequences()
+ .contains(exons.get(1).getDatasetSequence()));
+ assertTrue(dna.getDataset().getSequences()
+ .contains(exons.get(2).getDatasetSequence()));
+
SequenceI exon = exons.get(0);
assertEquals("GGGTTT", exon.getSequenceAsString());
assertEquals("dna1|A12345", exon.getName());