*
* @param seqs
* @param xrefs
- * @param dataset
- * alignment dataset shared by the new copy
* @return
*/
public static AlignmentI makeCopyAlignment(SequenceI[] seqs,
- SequenceI[] xrefs, AlignmentI dataset)
+ SequenceI[] xrefs)
{
AlignmentI copy = new Alignment(new Alignment(seqs));
- copy.setDataset(dataset);
+
+ /*
+ * add mappings between sequences to the new alignment
+ */
+ AlignedCodonFrame mappings = new AlignedCodonFrame();
+ copy.addCodonFrame(mappings);
+ for (int i = 0; i < copy.getHeight(); i++)
+ {
+ SequenceI from = seqs[i];
+ SequenceI to = copy.getSequenceAt(i);
+ if (to.getDatasetSequence() != null)
+ {
+ to = to.getDatasetSequence();
+ }
+ int start = from.getStart();
+ int end = from.getEnd();
+ MapList map = new MapList(new int[] { start, end }, new int[] {
+ start, end }, 1, 1);
+ mappings.addMap(to, from, map);
+ }
SequenceIdMatcher matcher = new SequenceIdMatcher(seqs);
if (xrefs != null)
}
else
{
- /*
- * copy peptide sequences, and add in any alternate products
- * of their located coding xrefs
- */
copyAlignment = AlignmentUtils.makeCopyAlignment(
- sequenceSelection, xrefs.getSequencesArray(), dataset);
+ sequenceSelection, xrefs.getSequencesArray());
}
copyAlignment.setGapCharacter(AlignFrame.this.viewport
.getGapCharacter());
.contains(cds.getSequenceAt(1).getDatasetSequence()));
/*
- * verify cds has dbref with mapping to protein and vice versa
- */
- DBRefEntry[] cdsDbrefs = cds.getSequenceAt(0).getDBRefs();
- // assertNotNull(cdsDbrefs);
- // assertEquals(1, cdsDbrefs.length);
- // assertNotNull(cdsDbrefs[0].getMap());
-
- /*
* Verify mappings from CDS to peptide, cDNA to CDS, and cDNA to peptide
* the mappings are on the shared alignment dataset
- * 6 mappings, 2*(DNA->CDS), 2*(DNA->Pep), 2*(CDS->Pep)
*/
List<AlignedCodonFrame> cdsMappings = cds.getDataset().getCodonFrames();
+ /*
+ * 6 mappings, 2*(DNA->CDS), 2*(DNA->Pep), 2*(CDS->Pep)
+ */
assertEquals(6, cdsMappings.size());
/*
// change sequence, should trigger an update of cached result
sq.setSequence("ASDFASDFADSF");
assertTrue(sq.isProtein());
-
- /*
- * in situ change of sequence doesn't change hashcode :-O
- * (sequence should not expose internal implementation)
- */
- for (int i = 0; i < sq.getSequence().length; i++)
- {
- sq.getSequence()[i] = "acgtu".charAt(i % 5);
- }
- assertTrue(sq.isProtein()); // but it isn't
}
-
@Test(groups = { "Functional" })
public void testGetAnnotation()
{