Map<SequenceI, SequenceI> alignedDatasets = new HashMap<SequenceI, SequenceI>();
for (SequenceI seq : aligned.getSequences())
{
+ // JAL-2110: fail if two or more alignment sequences have a common dataset
+ // sequence.
alignedDatasets.put(seq.getDatasetSequence(), seq);
}
{
SequenceI alignedSequence = alignedDatasets.get(seq
.getDatasetSequence());
+ // JAL-2110: fail if two or more alignment sequences have common dataset
+ // sequence.
// TODO: getSequenceAsString() will be deprecated in the future
// TODO: need to leave to SequenceI implementor to update gaps
seq.setSequence(alignedSequence.getSequenceAsString());
al1.addSequence(dna6);
assertFalse(AlignmentUtils.alignAsSameSequences(al1, al2));
}
+
+ @Test(groups = "Functional")
+ public void testAlignAsSameSequencesMultipleSubSeq()
+ {
+ SequenceI dna1 = new Sequence("dna1", "cccGGGTTTaaa");
+ SequenceI dna2 = new Sequence("dna2", "CCCgggtttAAA");
+ SequenceI as1 = dna1.deriveSequence(), as2 = dna1.deriveSequence()
+ .getSubSequence(3, 7), as3 = dna2.deriveSequence();
+ as1.insertCharAt(6, 5, '-');
+ String s_as1 = as1.getSequenceAsString();
+ as2.insertCharAt(6, 5, '-');
+ String s_as2 = as2.getSequenceAsString();
+ as3.insertCharAt(6, 5, '-');
+ String s_as3 = as3.getSequenceAsString();
+ AlignmentI aligned = new Alignment(new SequenceI[] { as1, as2, as3 });
+
+ // why do we need to cast this still ?
+ ((Alignment) aligned).createDatasetAlignment();
+ SequenceI uas1 = dna1.deriveSequence(), uas2 = dna1.deriveSequence()
+ .getSubSequence(3, 7), uas3 = dna2.deriveSequence();
+ AlignmentI tobealigned = new Alignment(new SequenceI[] { uas1, uas2,
+ uas3 });
+ ((Alignment) tobealigned).createDatasetAlignment();
+
+ assertTrue(AlignmentUtils.alignAsSameSequences(tobealigned, aligned));
+ assertEquals(s_as1, uas1.getSequenceAsString());
+ assertEquals(s_as2, uas2.getSequenceAsString());
+ assertEquals(s_as3, uas3.getSequenceAsString());
+ }
}