File: ViewSequenceTest.java

package info (click to toggle)
biojava-live 1%3A1.7.1-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 55,160 kB
  • sloc: java: 180,820; xml: 6,908; sql: 510; makefile: 50
file content (81 lines) | stat: -rw-r--r-- 3,017 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package org.biojava.bio.seq.impl;

import junit.framework.TestCase;

import org.biojava.bio.Annotation;
import org.biojava.bio.SmallAnnotation;
import org.biojava.bio.seq.DNATools;
import org.biojava.bio.seq.Feature;
import org.biojava.bio.seq.Sequence;
import org.biojava.bio.seq.SequenceTools;
import org.biojava.bio.symbol.DummySymbolList;
import org.biojava.bio.symbol.LocationTools;
import org.biojava.ontology.OntoTools;

/**
 *
 *
 * @author Matthew Pocock
 */
public class ViewSequenceTest
        extends TestCase
{
  public void testEquivalentOriginals()
          throws Throwable
  {
    Sequence original = SequenceTools.createSequence(new DummySymbolList(DNATools.getDNA(), 1000),
                                                     "dummy",
                                                     "dummy",
                                                     Annotation.EMPTY_ANNOTATION);
    Feature.Template tplt = new Feature.Template();
    tplt.annotation = new SmallAnnotation();
    tplt.annotation.setProperty("geneID", "braca1");
    tplt.location = LocationTools.makeLocation(1,2);
    tplt.type = "synth";
    tplt.typeTerm = OntoTools.ANY;
    tplt.source = "my head";
    tplt.sourceTerm = OntoTools.ANY;

    Feature made = original.createFeature(tplt);
    ViewSequence view = new ViewSequence(original);
    Feature viewed = (Feature) view.features().next();
    Feature.Template copy = viewed.makeTemplate();

    System.out.println("template: " + tplt);
    System.out.println("orignal:  " + made.makeTemplate());
    System.out.println("copy:     " + copy);
    assertEquals("templates are equal", tplt, copy);
    assertEquals("made are equal", tplt, made.makeTemplate());
    assertEquals("both are equal", made.makeTemplate(), copy);
  }

  public void testEquivalentViews()
          throws Throwable
  {
    Sequence original = SequenceTools.createSequence(new DummySymbolList(DNATools.getDNA(), 1000),
                                                     "dummy",
                                                     "dummy",
                                                     Annotation.EMPTY_ANNOTATION);
    Feature.Template tplt = new Feature.Template();
    tplt.annotation = new SmallAnnotation();
    tplt.annotation.setProperty("geneID", "braca1");
    tplt.location = LocationTools.makeLocation(1, 2);
    tplt.type = "synth";
    tplt.typeTerm = OntoTools.ANY;
    tplt.source = "my head";
    tplt.sourceTerm = OntoTools.ANY;

    ViewSequence view = new ViewSequence(original);
    Feature made = view.createFeature(tplt);

    Feature viewed = (Feature) view.features().next();
    Feature.Template copy = viewed.makeTemplate();

    System.out.println("template: " + tplt);
    System.out.println("orignal:  " + made.makeTemplate());
    System.out.println("copy:     " + copy);
    assertEquals("templates are equal", tplt, copy);
    assertEquals("made are equal", tplt, made.makeTemplate());
    assertEquals("both are equal", made.makeTemplate(), copy);
  }
}