View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2008 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-core Project
18  //
19  // Gene.java
20  // Since: Jul 8, 2008
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.bio;
26  
27  import java.io.Serializable;
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  /**
32   * Gene with Exon and CDS regions
33   * 
34   * @author leo
35   * 
36   */
37  public class Gene extends Read implements Serializable {
38  
39  	private static final long serialVersionUID = 1L;
40  	ArrayList<Exon> exonList = new ArrayList<Exon>();
41  	ArrayList<CDS> cdsList = new ArrayList<CDS>();
42  
43  	public Gene() {
44  	}
45  
46  	public Gene(Gene other) {
47  		super(other);
48  		this.exonList = other.exonList;
49  		this.cdsList = other.cdsList;
50  	}
51  
52  	public Gene(int start, int end) {
53  		this(null, start, end);
54  	}
55  
56  	public Gene(String name, int start, int end) {
57  		super(start, end);
58  		setName(name);
59  	}
60  
61  	public void addExon(Exon exon) {
62  		this.exonList.add(exon);
63  	}
64  
65  	public List<Exon> getExon() {
66  		return exonList;
67  	}
68  
69  	public Exon getExon(int index) {
70  		return exonList.get(index);
71  	}
72  
73  	public void addCDS(CDS cds) {
74  		cdsList.add(cds);
75  	}
76  
77  	public List<CDS> getCDS() {
78  		return cdsList;
79  	}
80  
81  	@Override
82  	public void adjustToOneOrigin() {
83  		super.adjustToOneOrigin();
84  		for (Exon each : exonList)
85  			each.adjustToOneOrigin();
86  
87  		for (CDS each : cdsList)
88  			each.adjustToOneOrigin();
89  	}
90  
91  	@Override
92  	public void accept(OnGenomeDataVisitor visitor) {
93  		visitor.visitGene(this);
94  	}
95  }