Team:Freiburg software/Code/Sequence.java

From 2009.igem.org

(Difference between revisions)
JonasOnlyJonas (Talk | contribs)
(New page: <nowiki> /* Copyright: synbiowave License: GPL Authors: Jörg Walossek Version: 0.1 DESCRIPTION: This class can be used to create di...)
Newer edit →

Revision as of 23:26, 21 October 2009

 /*
     Copyright: synbiowave
     
     License: GPL
     
     Authors: Jörg Walossek
     
     Version: 0.1 
    
     DESCRIPTION:
    	This class can be used to create different visualizations of a DNA-Sequence
 */

 package org.synbiowave.database;

 import java.util.ArrayList;

 import javax.jdo.annotations.IdGeneratorStrategy;
 import javax.jdo.annotations.IdentityType;
 import javax.jdo.annotations.PersistenceCapable;
 import javax.jdo.annotations.Persistent;
 import javax.jdo.annotations.PrimaryKey;

 import com.google.appengine.api.datastore.Text;
 import com.google.wave.api.Annotation;
 import com.google.wave.api.Range;

 // TODO: Auto-generated Javadoc
 /**
  * The Class Sequence.
  */
 @PersistenceCapable(identityType = IdentityType.APPLICATION)
 public class Sequence {
    
    /** The id. */
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    /** The author. */
    @Persistent
    private String author;

    /** The timestamp. */
    @Persistent
    private Long timestamp;
    
    /** The wave id. */
    @Persistent
    private ArrayList<String> waveID;
    
    /** The wavelet id. */
    @Persistent
    private ArrayList<String> waveletID;
    
    /** The blip id. */
    @Persistent
    private ArrayList<String> blipID;
    
    /** The name. */
    @Persistent
    private String name;
    
    /** The sequence. */
    @Persistent(defaultFetchGroup="true")
    private Text sequence;
    
    /** The type. */
    @Persistent
    private String type;
    
    /** The annotations. */
    @Persistent
    private ArrayList<String> annotations;

    /** The plain. */
    @Persistent(defaultFetchGroup="true")
    private Text plain;
	
	/**
	 * Instantiates a new sequence.
	 */
	public Sequence(){}

    /**
     * Instantiates a new sequence.
     * 
     * @param author the author
     * @param timestamp the timestamp
     * @param waveID the wave id
     * @param waveletID the wavelet id
     * @param blipID the blip id
     * @param sequence the sequence
     * @param type the type
     */
    public Sequence(String author,Long timestamp,String waveID,String waveletID,String blipID,String sequence,String type) {
        this.author=author;
        this.timestamp=timestamp;
        this.waveID=new ArrayList<String>();
        this.waveID.add(waveID);
        this.waveletID=new ArrayList<String>();
        this.waveletID.add(waveletID);
        this.blipID=new ArrayList<String>();
        this.blipID.add(blipID);
        this.name=null;
        this.sequence=new Text(sequence);
        this.type=type;
        this.annotations=new ArrayList<String>();
        this.plain=null;}

	/**
	 * Gets the id.
	 * 
	 * @return the id
	 */
	public Long getId(){return id;} 
    
    /**
     * Gets the author.
     * 
     * @return the author
     */
    public String getAuthor(){return author;}

	/**
	 * Gets the timestamp.
	 * 
	 * @return the timestamp
	 */
	public Long getTimestamp(){return timestamp;}

	/**
	 * Gets the wave id.
	 * 
	 * @return the wave id
	 */
	public ArrayList<String> getWaveID(){return waveID;}

	/**
	 * Gets the wavelet id.
	 * 
	 * @return the wavelet id
	 */
	public ArrayList<String> getWaveletID(){return waveletID;}
	
	/**
	 * Gets the blip id.
	 * 
	 * @return the blip id
	 */
	public ArrayList<String> getBlipID(){return blipID;}
	
	/**
	 * Gets the name.
	 * 
	 * @return the name
	 */
	public String getName(){return name;}

	/**
	 * Gets the sequence.
	 * 
	 * @return the sequence
	 */
	public String getSequence(){return sequence.getValue();}
	
	/**
	 * Gets the type.
	 * 
	 * @return the type
	 */
	public String getType(){return type;}
	
	/**
	 * Gets the annotations.
	 * 
	 * @return the annotations
	 */
	public ArrayList<Annotation> getAnnotations(){
		ArrayList<Annotation> annotations=new ArrayList<Annotation>();
		for(String stringAnnotation:this.annotations){
			String[] annotationParts=stringAnnotation.split("§");
			annotations.add(new Annotation(annotationParts[0],annotationParts[1],
                                new Range(Integer.parseInt(annotationParts[2]),Integer.parseInt(annotationParts[3]))));}
		return annotations;}
	
	/**
	 * Gets the plain.
	 * 
	 * @return the plain
	 */
	public String getPlain(){return plain.getValue();}
	
	/**
	 * Sets the name.
	 * 
	 * @param name the new name
	 */
	public void setName(String name){this.name=name;}
	
	/**
	 * Sets the sequence.
	 * 
	 * @param sequence the new sequence
	 */
	public void setSequence(String sequence){this.sequence=new Text(sequence);}

	/**
	 * Sets the type.
	 * 
	 * @param type the new type
	 */
	public void setType(String type){this.type=type;}

	/**
	 * Adds the annotation.
	 * 
	 * @param annotation the annotation
	 */
	public void addAnnotation(Annotation annotation){
		String stringAnnotation=
                        annotation.getName()+"§"+annotation.getValue()+"§"+annotation.getRange().getStart()
                        +"§"+annotation.getRange().getEnd();
		this.annotations.add(stringAnnotation);}
	
	/**
	 * Sets the annotations.
	 * 
	 * @param annotations the new annotations
	 */
	public void setAnnotations(ArrayList<Annotation> annotations){
		String stringAnnotation;
		for(Annotation annotation:annotations){		
                        stringAnnotation=
                        annotation.getName()+"§"+annotation.getValue()+"§"+annotation.getRange().getStart()
                        +"§"+annotation.getRange().getEnd();
			this.annotations.add(stringAnnotation);}}

	/**
	 * Sets the plain.
	 * 
	 * @param plain the new plain
	 */
	public void setPlain(String plain){this.plain=new Text(plain);}
 }