[Biojava-l] test of CircularView

Mark Schreiber mark_s@sanger.otago.ac.nz
Thu, 1 Feb 2001 13:03:24 +1300 (NZDT)


Hi all,

Below is a program that is a test of CircularView. It can (and has) be
refactored for testing the CircularSequence class.

Mark

/**
 * A test of the CircularView class. Should produce the following output
 *
 * atgcgtgaccgtcgaatgca
 * gcaatgcg
 * cgtcgaatgcaat
 * g
 * gtcgaatgcaatgcg
 */

package SCHREIBER.biojava_additions.seq;
  import org.biojava.bio.*;
  import org.biojava.bio.seq.*;
  import org.biojava.bio.symbol.*;
  import org.biojava.bio.seq.impl.*;
  import org.biojava.bio.seq.io.*;
  import org.biojava.utils.*;

  import java.util.*;

public class CircularViewTest {

  public CircularViewTest() {
    String s = "ATGCGTGACCGTCGAATGCA";
    Alphabet dna = DNATools.getDNA();

    try{
      SymbolParser dnaParser = dna.getParser("token");
      SymbolList sl = dnaParser.parse(s);
      Sequence seq = new SimpleSequence(
                            sl,"","test",Annotation.EMPTY_ANNOTATION);
      CircularView cseq = new CircularView(seq);

      Iterator i = cseq.iterator();
      while(i.hasNext()){
        Symbol sy = (Symbol)i.next();
        System.out.print(sy.getToken());
      }
      System.out.print('\n');
      System.out.println(cseq.subStr(18,5).toCharArray());
      i = cseq.subList(10,22).iterator();
      while(i.hasNext()){
        Symbol sy = (Symbol)i.next();
        System.out.print(sy.getToken());
      }
      System.out.print('\n');
      System.out.println(cseq.symbolAt(-3).getToken());
      i = cseq.subList(-10,5).iterator();
      while(i.hasNext()){
        Symbol sy = (Symbol)i.next();
        System.out.print(sy.getToken());
      }
      System.out.print('\n');
    }catch(BioException be){
      be.printStackTrace();
    }

  }

  public static void main(String[] args) {
    CircularViewTest circularViewTest1 = new CircularViewTest();
  }
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Schreiber			Ph: 64 3 4797875
Rm 218				email mark_s@sanger.otago.ac.nz
Department of Biochemistry	email m.schreiber@clear.net.nz
University of Otago		
PO Box 56
Dunedin
New Zealand
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~