package jalview.io;
import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Mapping;
+import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
String proteinSeq = ">prot1/10-16\nYCWRSGA";
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
proteinSeq, FormatAdapter.PASTE);
+
/*
- * exonerate map of residues 11-15 (CWRSG) to bases 10-24 in sequence 'dna1'
- * starting at position 10 (forward strand)
+ * exonerate GFF output mapping residues 11-15 (CWRSG)
+ * to bases 24-10 in sequence 'dna1' (reverse strand)
*/
String exonerateGff = "##gff-version 2\n"
- + "prot1\tprotein2genome\tsimilarity\t11\t15\t99\t+\t.\talignment_id 0 ; Target dna1 ; Align 11 10 5";
+ + "prot1\tprotein2genome\tsimilarity\t11\t15\t99\t-\t.\talignment_id 0 ; Target dna1 ; Align 11 24 5";
af.loadJalviewDataFile(exonerateGff, FormatAdapter.PASTE, null, null);
/*
assertEquals("dna1", mappedDna.getName());
Mapping[] mapList = mapping.getProtMappings();
assertEquals(1, mapList.length);
- // 11 in protein should map to codon [10, 11, 12] in dna
+ // 11 in protein should map to codon [24, 23, 22] in dna
int[] mappedRegion = mapList[0].getMap().locateInFrom(11, 11);
- assertArrayEquals(new int[] { 10, 12 }, mappedRegion);
- // 15 in protein should map to codon [22, 23, 24] in dna
+ assertArrayEquals(new int[] { 24, 22 }, mappedRegion);
+ // 15 in protein should map to codon [12, 11, 10] in dna
mappedRegion = mapList[0].getMap().locateInFrom(15, 15);
- assertArrayEquals(new int[] { 22, 24 }, mappedRegion);
+ assertArrayEquals(new int[] { 12, 10 }, mappedRegion);
// so far so good; TODO: programmatically add mapped sequences
// and verify the mappings are 'realised'
+ SequenceI dna1 = new Sequence("dna1", "AAACCCGGGTTTAAACCCGGGTTT");
+ AlignmentI al = new Alignment(new SequenceI[] { dna1 });
+ al.setDataset(null);
+
+ /*
+ * Now 'realise' the virtual mapping to the real DNA sequence;
+ * interactively this could be by a drag or fetch of the sequence data
+ */
+ mapping.realiseWith(dna1);
+ // verify the mapping is now from the real, not the dummy sequence
+ assertSame(dna1.getDatasetSequence(),
+ mapping.getDnaForAaSeq(dataset.getSequenceAt(0)));
}
}