import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import jalview.bin.Cache;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
import jalview.datamodel.Alignment;
import jalview.util.MapList;
import jalview.ws.SequenceFetcher;
import jalview.ws.SequenceFetcherFactory;
-import jalview.ws.params.InvalidArgumentException;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
public class CrossRefTest
{
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
}
+ @BeforeMethod(alwaysRun = true)
+ public void loadProperties()
+ {
+ Cache.loadProperties("test/jalview/util/comparisonTestProps.jvprops");
+ }
+
@Test(groups = { "Functional" })
public void testFindXDbRefs()
{
AlignmentI al = new Alignment(new SequenceI[] { emblSeq, uniprotSeq });
Alignment xrefs = new CrossRef(new SequenceI[] { emblSeq }, al)
.findXrefSequences("UNIPROT", true);
+ System.err.println("xrefs=" + xrefs);
assertEquals(1, xrefs.getHeight());
assertSame(uniprotSeq, xrefs.getSequenceAt(0));
}
*/
package jalview.datamodel;
-import java.util.Locale;
-
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
-import jalview.analysis.AlignmentGenerator;
-import jalview.commands.EditCommand;
-import jalview.commands.EditCommand.Action;
-import jalview.datamodel.PDBEntry.Type;
-import jalview.gui.JvOptionPane;
-import jalview.util.MapList;
-import jalview.ws.params.InvalidArgumentException;
-
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Vector;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import jalview.analysis.AlignmentGenerator;
+import jalview.bin.Cache;
+import jalview.commands.EditCommand;
+import jalview.commands.EditCommand.Action;
+import jalview.datamodel.PDBEntry.Type;
+import jalview.gui.JvOptionPane;
+import jalview.util.MapList;
import junit.extensions.PA;
public class SequenceTest
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
}
+ @BeforeMethod(alwaysRun = true)
+ public void loadProperties()
+ {
+ Cache.loadProperties("test/jalview/util/comparisonTestProps.jvprops");
+ }
+
Sequence seq;
@BeforeMethod(alwaysRun = true)
assertTrue(new Sequence("prot", "ASDFASDFASDFXXXXXXXXX").isProtein());
// test DNA with X
assertFalse(new Sequence("prot", "ACGTACGTACGTXXXXXXXX").isProtein());
+ // short sequence is nucleotide only if 50% is nucleotide and remaining N/X
+ // is either N or X only
+ assertTrue(new Sequence("prot", "ACGTACGTACGTXN").isProtein());
// test DNA with N
assertFalse(new Sequence("prot", "ACGTACGTACGTNNNNNNNN").isProtein());
// test RNA with X
- assertFalse(new Sequence("prot", "ACGUACGUACGUXXXXXXXXX").isProtein());
+ assertFalse(new Sequence("prot", "ACGUACGUACGUACTGACAXX").isProtein());
assertFalse(new Sequence("prot", "ACGUACGUACGUNNNNNNNNN").isProtein());
}
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import jalview.bin.Cache;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.gui.JvOptionPane;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
public class ComparisonTest
{
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
}
+ @BeforeMethod(alwaysRun = true)
+ public void loadProperties()
+ {
+ Cache.loadProperties("test/jalview/util/comparisonTestProps.jvprops");
+ }
+
@Test(groups = { "Functional" })
public void testIsGap()
{
@Test(groups = { "Functional" })
public void testIsNucleotide_sequences()
{
- SequenceI seq = new Sequence("eightypercent", "agctuAGCPV");
+ SequenceI seq = new Sequence("eightypercent+fivepercent", "agctuagcPV");
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq }));
assertFalse(
Comparison.isNucleotide(new SequenceI[][]
{ new SequenceI[] { seq } }));
- seq = new Sequence("eightyfivepercent", "agctuAGCPVagctuAGCUV");
+ seq = new Sequence("eightyfivepercent+tenpercent",
+ "agctuagcgVagctuagcuVE");
+ assertFalse(Comparison.isNucleotide(new SequenceI[] { seq }));
+
+ seq = new Sequence(">nineyfivepercent+0percent",
+ "aagctuagcgEagctuagcua");
+ assertFalse(Comparison.isNucleotide(new SequenceI[] { seq }));
+
+ seq = new Sequence("nineyfivepercent+0percent", "agctuagcgEagctuagcua");
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq }));
- seq = new Sequence("nineypercent", "agctuAGCgVagctuAGCUV");
+ seq = new Sequence("nineyfivepercent+fivepercent",
+ "agctuagcgWagctuagcua");
assertTrue(Comparison.isNucleotide(new SequenceI[] { seq }));
+ seq = new Sequence("nineyfivepercent+tenpercent",
+ "agctuagcgEWWctuagcua");
+ assertFalse(Comparison.isNucleotide(new SequenceI[] { seq }));
+
+ seq = new Sequence("eightyfivepercent+fifteenpercent",
+ "agctuagcgWWWctuagcua");
+ assertFalse(Comparison.isNucleotide(new SequenceI[] { seq }));
+
seq = new Sequence("eightyfivepercentgapped",
"--agc--tuA--GCPV-a---gct-uA-GC---UV");
assertFalse(Comparison.isNucleotide(new SequenceI[] { seq }));
- seq = new Sequence("nineypercentgapped",
- "ag--ct-u-A---GC---g----Vag--c---tuAGCUV");
+ seq = new Sequence("ninetyfivepercentgapped",
+ "ag--ct-u-a---gc---g----aag--c---tuagcuV");
assertTrue(Comparison.isNucleotide(new SequenceI[] { seq }));
seq = new Sequence("allgap", "---------");
new SequenceI[]
{ seq, seq, seq, seq, seq2, seq2, null } }));
- seq = new Sequence("ProteinThatLooksLikeDNA", "WYATGCCTGAgtcgt");
- // 12/14 = 85.7%
+ String seqString = "aaatatatatgEcctgagtcgt";
+ seq = new Sequence("ShortProteinThatLooksLikeDNA", seqString);
+ assertFalse(Comparison.isNucleotide(new SequenceI[] { seq }));
+ seq = new Sequence("LongProteinThatLooksLikeDNA", seqString.repeat(10));
assertTrue(Comparison.isNucleotide(new SequenceI[] { seq }));
assertFalse(Comparison.isNucleotide((SequenceI[]) null));
assertFalse(Comparison.isNucleotide('P'));
}
+ @Test(groups = { "Functional" })
+ public void testIsNucleotideAmbiguity()
+ {
+ assertTrue(Comparison.isNucleotide('b', true));
+ assertTrue(Comparison.isNucleotide('B', true));
+ assertTrue(Comparison.isNucleotide('d', true));
+ assertTrue(Comparison.isNucleotide('V', true));
+ assertTrue(Comparison.isNucleotide('M', true));
+ assertTrue(Comparison.isNucleotide('s', true));
+ assertTrue(Comparison.isNucleotide('W', true));
+ assertTrue(Comparison.isNucleotide('x', true));
+ assertTrue(Comparison.isNucleotide('Y', true));
+ assertTrue(Comparison.isNucleotide('r', true));
+ assertTrue(Comparison.isNucleotide('i', true));
+ assertFalse(Comparison.isNucleotide('-', true));
+ assertFalse(Comparison.isNucleotide('n', true));
+ assertFalse(Comparison.isNucleotide('P', true));
+ }
+
/**
* Test the percentage identity calculation for two sequences
*/
assertFalse(Comparison.isNucleotideSequence("aAgGcCtTuUx", false));
assertTrue(Comparison.isNucleotideSequence("a A-g.GcCtTuU", true));
assertFalse(Comparison.isNucleotideSequence("a A-g.GcCtTuU", false));
+ assertFalse(Comparison.isNucleotideSequence("gatactawgataca", false));
+ // including nucleotide ambiguity
+ assertTrue(
+ Comparison.isNucleotideSequence("gatacaWgataca", true, true));
+ assertFalse(
+ Comparison.isNucleotideSequence("gatacaEgataca", true, true));
+
+ // not quite all nucleotides and ambiguity codes
+ Sequence seq = new Sequence("Ambiguity DNA codes", "gatacagatacabve");
+ assertFalse(Comparison.isNucleotide(seq));
+ // all nucleotide and nucleotide ambiguity codes
+ seq = new Sequence("Ambiguity DNA codes", "gatacagatacabvt");
+ assertFalse(Comparison.isNucleotide(seq));
+ seq = new Sequence("Ambiguity DNA codes", "agatacabb");
+ assertFalse(Comparison.isNucleotide(seq));
+ // 55% nucleotide with only Xs or Ns
+ assertTrue(Comparison
+ .isNucleotide(new Sequence("dnaWithXs", "gatacaXXXX")));
+ assertTrue(Comparison
+ .isNucleotide(new Sequence("dnaWithXs", "gatacaNNNN")));
+ assertFalse(Comparison
+ .isNucleotide(new Sequence("dnaWithXs", "gatacXXXXX")));
+ assertFalse(Comparison
+ .isNucleotide(new Sequence("dnaWithXs", "gatacNNNNN")));
}
@Test(groups = { "Functional" })
assertFalse(Comparison.isSameResidue('a', 'A', true));
assertFalse(Comparison.isSameResidue('A', 'a', true));
}
+
+ @Test(groups = { "Functional" })
+ public void testNucleotideProportion()
+ {
+ assertFalse(Comparison.myShortSequenceNucleotideProportionCount(2, 3));
+ assertTrue(Comparison.myShortSequenceNucleotideProportionCount(3, 3));
+ assertFalse(Comparison.myShortSequenceNucleotideProportionCount(2, 4));
+ assertTrue(Comparison.myShortSequenceNucleotideProportionCount(3, 4));
+ assertFalse(
+ Comparison.myShortSequenceNucleotideProportionCount(17, 20));
+ assertTrue(Comparison.myShortSequenceNucleotideProportionCount(18, 20));
+ assertFalse(
+ Comparison.myShortSequenceNucleotideProportionCount(38, 50));
+ assertTrue(Comparison.myShortSequenceNucleotideProportionCount(39, 50));
+ assertFalse(
+ Comparison.myShortSequenceNucleotideProportionCount(54, 100));
+ assertTrue(
+ Comparison.myShortSequenceNucleotideProportionCount(55, 100));
+ }
}