1 package jalview.datamodel;
\r
3 import jalview.util.*;
\r
4 import jalview.jbgui.*;
\r
5 import jalview.schemes.*;
\r
8 public class SequenceFeature {
\r
21 public SequenceFeature() {
\r
24 public SequenceFeature(Sequence sequence,String type, int start, int end, String description) {
\r
25 this.sequence = sequence;
\r
29 this.description = description;
\r
35 public String toGFFString() {
\r
36 String gff = id + "\t" + type + "\tfeature\t" + start + "\t" + end + "\t" + score + "\t" + strand + "\t.";
\r
39 public double getScore() {
\r
43 public void setScore(double score) {
\r
47 public String getId() {
\r
50 public void setId(String id) {
\r
53 public void setSequence(Sequence seq) {
\r
54 this.sequence = seq;
\r
56 public void setStart(int start) {
\r
59 public void setEnd(int end) {
\r
62 public int getStrand() {
\r
65 public void setStrand(int strand) {
\r
66 this.strand = strand;
\r
68 public int getStart() {
\r
72 public int getEnd() {
\r
76 public String getType() {
\r
80 public String getDescription() {
\r
84 public double getPValue() {
\r
87 public void setPValue(double value) {
\r
88 this.pvalue = value;
\r
90 public double getPercentId() {
\r
93 public void setPercentId(double pid) {
\r
96 public Color getColor() {
\r
100 public void setColor() {
\r
101 if (type.equals("CHAIN")) {
\r
102 color = Color.white;
\r
103 } else if (type.equals("DOMAIN")) {
\r
104 color = Color.white;
\r
105 } else if (type.equals("TRANSMEM")) {
\r
106 color = Color.red.darker();
\r
107 } else if (type.equals("SIGNAL")) {
\r
108 color = Color.cyan;
\r
109 } else if (type.equals("HELIX")) {
\r
110 color = Color.magenta;
\r
111 } else if (type.equals("TURN")) {
\r
112 color = Color.cyan;
\r
113 } else if (type.equals("SHEET")) {
\r
114 color = Color.yellow;
\r
115 } else if (type.equals("STRAND")) {
\r
116 color = Color.yellow;
\r
117 } else if (type.equals("CARBOHYD")) {
\r
118 color = Color.pink;
\r
119 } else if (type.equals("ACT_SITE")) {
\r
121 } else if (type.equals("TRANSIT")) {
\r
122 color = Color.orange;
\r
123 } else if (type.equals("VARIANT")) {
\r
124 color = Color.orange.darker();
\r
125 } else if (type.equals("BINDING")) {
\r
126 color = Color.blue;
\r
127 } else if (type.equals("DISULFID")) {
\r
128 color = Color.yellow.darker();
\r
129 } else if (type.equals("NP_BIND")) {
\r
131 } else if (type.indexOf("BIND") > 0) {
\r
134 color = Color.lightGray;
\r
137 public String print() {
\r
138 String tmp = new Format("%15s").form(type);
\r
139 tmp = tmp + new Format("%6d").form(start);
\r
140 tmp = tmp + new Format("%6d").form(end);
\r
141 tmp = tmp + " " + description;
\r
144 public void draw(Graphics g, int fstart, int fend, int x1, int y1, int width, int height) {
\r
145 g.setColor(new Color((float)(Math.random()),(float)(Math.random()),(float)(Math.random())));
\r
147 // int xstart = sequence.findIndex(start);
\r
148 //int xend = sequence.findIndex(end);
\r
149 int xstart = start;
\r
151 long tstart = System.currentTimeMillis();
\r
152 if (!(xend < fstart && xstart > fend)) {
\r
154 if (xstart > fstart) {
\r
155 x1 = x1 + (xstart-fstart)*width;
\r
163 for (int i = fstart; i <= fend; i++) {
\r
164 String s = sequence.sequence.substring(i,i+1);
\r
165 if (!(s.equals(".") || s.equals("-") || s.equals(" "))) {
\r
166 g.fillRect(x1+(i-fstart)*width,y1,width,height);
\r
168 g.drawString("-",x1+(i-fstart)*width,y1+height);
\r
173 long tend = System.currentTimeMillis();
\r
174 System.out.println("Time = " + (tend-tstart) + "ms");
\r
178 public static void main(String[] args) {
\r
179 SequenceFeature sf = new SequenceFeature();
\r
181 System.out.println("Feature " + sf);
\r
183 public static int CHAIN = 0;
\r
184 public static int DOMAIN = 1;
\r
185 public static int TRANSMEM = 2;
\r
186 public static int SIGNAL = 3;
\r
187 public static int HELIX = 4;
\r
188 public static int TURN = 5;
\r
189 public static int SHEET = 6;
\r
190 public static int CARBOHYD = 7;
\r
191 public static int ACT_SITE = 8;
\r
192 public static int TRANSIT = 9;
\r
193 public static int VARIANT = 10;
\r
194 public static int BINDING = 11;
\r