import jalview.analysis.AlignSeq;
import jalview.api.DBRefEntryI;
+import jalview.util.Comparison;
import jalview.util.DBRefUtils;
import jalview.util.MapList;
import jalview.util.StringUtils;
{
if (seq == this)
{
- throw new Error(
+ throw new IllegalArgumentException(
"Implementation Error: self reference passed to SequenceI.setDatasetSequence");
}
if (seq != null && seq.getDatasetSequence() != null)
{
- throw new Error(
+ throw new IllegalArgumentException(
"Implementation error: cascading dataset sequences are not allowed.");
}
datasetSequence = seq;
private long _seqhash = 0;
+ /**
+ * Answers false if the sequence is more than 85% nucleotide (ACGTU), else
+ * true
+ */
@Override
public boolean isProtein()
{
if (_seqhash != sequence.hashCode())
{
_seqhash = sequence.hashCode();
- _isNa=jalview.util.Comparison.isNucleotide(new SequenceI[] { this });
+ _isNa = Comparison.isNucleotide(this);
}
return !_isNa;
};
public int[] findPositionMap();
/**
+ * Answers true if the sequence is composed of amino acid characters. Note
+ * that implementations may use heuristic methods which are not guaranteed to
+ * give the biologically 'right' answer.
*
- * @return true if sequence is composed of amino acid characters
+ * @return
*/
public boolean isProtein();
{
sq.getDatasetSequence().setDatasetSequence(sq); // loop!
Assert.fail("Expected Error to be raised when calling setDatasetSequence with self reference");
- } catch (Error e)
+ } catch (IllegalArgumentException e)
{
// TODO Jalview error/exception class for raising implementation errors
assertTrue(e.getMessage().toLowerCase()
assertEquals(4, seq.getAllPDBEntries().size());
assertSame(pdbe5, seq.getAllPDBEntries().get(3));
}
+
+ @Test(
+ groups = { "Functional" },
+ expectedExceptions = { IllegalArgumentException.class })
+ public void testSetDatasetSequence_toSelf()
+ {
+ seq.setDatasetSequence(seq);
+ }
+
+ @Test(
+ groups = { "Functional" },
+ expectedExceptions = { IllegalArgumentException.class })
+ public void testSetDatasetSequence_cascading()
+ {
+ SequenceI seq2 = new Sequence("Seq2", "xyz");
+ seq2.createDatasetSequence();
+ seq.setDatasetSequence(seq2);
+ }
}