*/
package jalview.analysis;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertSame;
+import static org.testng.AssertJUnit.assertTrue;
+
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import java.util.Map;
import java.util.Set;
-import org.junit.Test;
+import org.testng.annotations.Test;
-public class AlignmentUtilsTests
+public class AlignmentUtilsTests
{
// @formatter:off
private static final String TEST_DATA =
public static Sequence ts = new Sequence("short",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm");
- @Test
+ @Test(groups ={ "Functional" })
public void testExpandContext()
{
AlignmentI al = new Alignment(new Sequence[] {});
/**
* Test that annotations are correctly adjusted by expandContext
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testExpandContext_annotation()
{
AlignmentI al = new Alignment(new Sequence[]
*
* @throws IOException
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testGetSequencesByName() throws IOException
{
final String data = ">Seq1Name\nKQYL\n" + ">Seq2Name\nRFPW\n"
*/
protected AlignmentI loadAlignment(final String data, String format) throws IOException
{
- Alignment a = new FormatAdapter().readFile(data,
+ AlignmentI a = new FormatAdapter().readFile(data,
AppletFormatAdapter.PASTE, format);
a.setDataset(null);
return a;
*
* @throws IOException
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testMapProteinToCdna_noXrefs() throws IOException
{
List<SequenceI> protseqs = new ArrayList<SequenceI>();
/**
* Test for the alignSequenceAs method that takes two sequences and a mapping.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testAlignSequenceAs_withMapping_noIntrons()
{
MapList map = new MapList(new int[]
/**
* Test for the alignSequenceAs method that takes two sequences and a mapping.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testAlignSequenceAs_withMapping_withIntrons()
{
/*
/**
* Test for the case where not all of the protein sequence is mapped to cDNA.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testAlignSequenceAs_withMapping_withUnmappedProtein()
{
/**
* Test for the alignSequenceAs method where we preserve gaps in introns only.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testAlignSequenceAs_keepIntronGapsOnly()
{
* Test for the method that generates an aligned translated sequence from one
* mapping.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testGetAlignedTranslation_dnaLikeProtein()
{
// dna alignment will be replaced
/**
* Test the method that realigns protein to match mapped codon alignment.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testAlignProteinAsDna()
{
// seq1 codons are [1,2,3] [4,5,6] [7,8,9] [10,11,12]
* Test the method that tests whether a CDNA sequence translates to a protein
* sequence
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testTranslatesAs()
{
assertTrue(AlignmentUtils.translatesAs("tttcccaaaggg".toCharArray(), 0,
"FPKG".toCharArray()));
- // with start codon
+ // with start codon (not in protein)
assertTrue(AlignmentUtils.translatesAs("atgtttcccaaaggg".toCharArray(),
3, "FPKG".toCharArray()));
- // with stop codon1
+ // with stop codon1 (not in protein)
assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtaa".toCharArray(),
0, "FPKG".toCharArray()));
- // with stop codon2
+ // with stop codon1 (in protein as *)
+ assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtaa".toCharArray(),
+ 0, "FPKG*".toCharArray()));
+ // with stop codon2 (not in protein)
assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtag".toCharArray(),
0, "FPKG".toCharArray()));
- // with stop codon3
+ // with stop codon3 (not in protein)
assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtga".toCharArray(),
0, "FPKG".toCharArray()));
// with start and stop codon1
assertTrue(AlignmentUtils.translatesAs(
- "atgtttcccaaaggtaa".toCharArray(), 3, "FPKG".toCharArray()));
+ "atgtttcccaaagggtaa".toCharArray(), 3, "FPKG".toCharArray()));
+ // with start and stop codon1 (in protein as *)
+ assertTrue(AlignmentUtils.translatesAs(
+ "atgtttcccaaagggtaa".toCharArray(), 3, "FPKG*".toCharArray()));
// with start and stop codon2
assertTrue(AlignmentUtils.translatesAs(
- "atgtttcccaaaggtag".toCharArray(), 3, "FPKG".toCharArray()));
+ "atgtttcccaaagggtag".toCharArray(), 3, "FPKG".toCharArray()));
// with start and stop codon3
assertTrue(AlignmentUtils.translatesAs(
- "atgtttcccaaaggtga".toCharArray(), 3, "FPKG".toCharArray()));
+ "atgtttcccaaagggtga".toCharArray(), 3, "FPKG".toCharArray()));
+
+ // with embedded stop codon
+ assertTrue(AlignmentUtils.translatesAs(
+ "atgtttTAGcccaaaTAAgggtga".toCharArray(), 3,
+ "F*PK*G".toCharArray()));
// wrong protein
assertFalse(AlignmentUtils.translatesAs("tttcccaaaggg".toCharArray(),
*
* @throws IOException
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testMapProteinToCdna_withStartAndStopCodons()
throws IOException
{
*
* @throws IOException
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testMapProteinToCdna_withXrefs() throws IOException
{
List<SequenceI> protseqs = new ArrayList<SequenceI>();
*
* @throws IOException
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testMapProteinToCdna_prioritiseXrefs() throws IOException
{
List<SequenceI> protseqs = new ArrayList<SequenceI>();
* Test the method that shows or hides sequence annotations by type(s) and
* selection group.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testShowOrHideSequenceAnnotations()
{
SequenceI seq1 = new Sequence("Seq1", "AAA");
/**
* Tests for the method that checks if one sequence cross-references another
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testHasCrossRef()
{
assertFalse(AlignmentUtils.hasCrossRef(null, null));
* Tests for the method that checks if either sequence cross-references the
* other
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testHaveCrossRef()
{
assertFalse(AlignmentUtils.hasCrossRef(null, null));
/**
* Test the method that extracts the exon-only part of a dna alignment.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testMakeExonAlignment()
{
SequenceI dna1 = new Sequence("dna1", "aaaGGGcccTTTaaa");
* already has a protein product (Uniprot translation) which in turn has an
* x-ref to the EMBLCDS record.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testMakeExonSequences()
{
SequenceI dna1 = new Sequence("dna1", "aaaGGGcccTTTaaa");
* its product mappings, for the case where there are multiple exon mappings
* to different protein products.
*/
- @Test
+ @Test(groups ={ "Functional" })
public void testMakeExonAlignment_multipleProteins()
{
SequenceI dna1 = new Sequence("dna1", "aaaGGGcccTTTaaa");
assertEquals(1, peptideMappings.size());
assertSame(pep3.getDatasetSequence(), peptideMappings.get(0).getTo());
}
+
+ @Test(groups = { "Functional" })
+ public void testIsMappable()
+ {
+ SequenceI dna1 = new Sequence("dna1", "cgCAGtgGT");
+ SequenceI aa1 = new Sequence("aa1", "RSG");
+ AlignmentI al1 = new Alignment(new SequenceI[] { dna1 });
+ AlignmentI al2 = new Alignment(new SequenceI[] { aa1 });
+
+ assertFalse(AlignmentUtils.isMappable(null, null));
+ assertFalse(AlignmentUtils.isMappable(al1, null));
+ assertFalse(AlignmentUtils.isMappable(null, al1));
+ assertFalse(AlignmentUtils.isMappable(al1, al1));
+ assertFalse(AlignmentUtils.isMappable(al2, al2));
+
+ assertTrue(AlignmentUtils.isMappable(al1, al2));
+ assertTrue(AlignmentUtils.isMappable(al2, al1));
+ }
}