[Biojava-dev] Editable sequences

Schreiber, Mark mark.schreiber at agresearch.co.nz
Tue Jul 29 23:48:15 EDT 2003


Here is some examples of the use of the biojava Edit object.
 
import org.biojava.bio.seq.*;
import org.biojava.bio.symbol.*;
 
public class EditExamples {

  public static void main(String[] args) throws Exception{

    //you can't actually edit a sequence
    Sequence seq = DNATools.createDNASequence("atggct", "seq");
 
    //so you need to get a copy of the Symbols in it
    //using a "copy constructor"
    SimpleSymbolList syms = new SimpleSymbolList(seq);
 
    //add to the end, while overwriting 0 symbols, "cc"
    Edit e = new Edit(seq.length()+1, 0, DNATools.createDNA("cc"));
    //apply the edit
    syms.edit(e);
    //should now be atggctcc
    System.out.println(syms.seqString());
 
    //insert at the start, while overwriting 0 Symbols "tt"
    e = new Edit(1, 0, DNATools.createDNA("tt"));
    syms.edit(e);
    //should now be ttatggctcc
    System.out.println(syms.seqString());
 
    //insert at position 4, overwriting 0 symbols "aca"
    e = new Edit(4, 0, DNATools.createDNA("aca"));
    syms.edit(e);
    //should now be ttaacatggctcc
    System.out.println(syms.seqString());
 
    //overwrite at position 2, 3 bases with "ggg"
    e = new Edit(2, 3, DNATools.createDNA("ggg"));
    syms.edit(e);
    //should now be tgggcatggctcc
    System.out.println(syms.seqString());
 
    //delete from the start 5 bases (overwrite 5 bases with nothing)
    e = new Edit(1, 5, SymbolList.EMPTY_LIST);
    syms.edit(e);
    //should now be atggctcc
    System.out.println(syms.seqString());
 
    //now a more complex example
    //overwrite positions two and three with aa and then insert tt
    e = new Edit(2, 2, DNATools.createDNA("aatt"));
    syms.edit(e);

    //should now be aaattgctcc
    System.out.println(syms.seqString());
  }
}

	-----Original Message----- 
	From: daviddebeule at pandora.be [mailto:daviddebeule at pandora.be] 
	Sent: Tue 29/07/2003 7:11 p.m. 
	To: biojava-dev at biojava.org 
	Cc: 
	Subject: [Biojava-dev] Editable sequences
	
	

	Hi,
	
	Is there an easy way to make a SimpleSequence 'Editable' ? I want to add/ remove/insert symbols.  I probably need to make something like a SimpleEditableSequence but I am not sure which methods I can to override to accomplish this.
	
	Thanks in advance,
	
	David
	
	_______________________________________________
	biojava-dev mailing list
	biojava-dev at biojava.org
	http://biojava.org/mailman/listinfo/biojava-dev
	


=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================



More information about the biojava-dev mailing list