1 package jalview.datamodel;
\r
6 public class Sequence implements SequenceI
\r
8 protected String name;
\r
9 protected String sequence;
\r
10 protected int start;
\r
12 protected String description;
\r
13 protected int charHeight;
\r
14 protected String displayId;
\r
15 protected Color color = Color.white;
\r
17 public Sequence(String name, String sequence, int start, int end)
\r
21 this.sequence = sequence;
\r
29 public Sequence(String name,String sequence) {
\r
30 this(name,sequence,1,sequence.length());
\r
32 public Sequence(SequenceI seq) {
\r
33 this(seq.getName(),seq.getSequence(),seq.getStart(),seq.getEnd());
\r
35 public String getDisplayId() {
\r
38 public void setDisplayId() {
\r
39 displayId = name + "/" + start + "-" + end;
\r
41 public void setName(String name) {
\r
45 public String getName() {
\r
48 public void setStart(int start) {
\r
52 public int getStart() {
\r
55 public void setEnd(int end) {
\r
59 public int getEnd() {
\r
62 public int getLength() {
\r
63 return this.sequence.length();
\r
65 public void setSequence(String seq) {
\r
66 this.sequence = seq;
\r
68 public String getSequence() {
\r
69 return this.sequence;
\r
71 public String getSequence(int start,int end) {
\r
72 return this.sequence.substring(start,end);
\r
75 public char getCharAt(int i) {
\r
76 if (i < sequence.length()) {
\r
77 return sequence.charAt(i);
\r
82 public void setDescription(String desc) {
\r
83 this.description = desc;
\r
85 public String getDescription() {
\r
86 return this.description;
\r
89 public int findIndex(int pos) {
\r
90 // returns the alignment position for a residue
\r
94 while (i< sequence.length() && j <= end && j <= pos) {
\r
96 String s = sequence.substring(i,i+1);
\r
98 if (!(s.equals(".") || s.equals("-") || s.equals(" "))) {
\r
103 if (j == end && j < pos) {
\r
111 public int findPosition(int i) {
\r
112 // Returns the sequence position for an alignment position
\r
117 String s = sequence.substring(j,j+1);
\r
119 if (!(s.equals(".") || s.equals("-") || s.equals(" "))) {
\r
126 public void deleteCharAt(int i)
\r
128 StringBuffer sbuffer = new StringBuffer(sequence);
\r
129 sbuffer.deleteCharAt(i);
\r
130 sequence = sbuffer.toString();
\r
133 public void insertCharAt(int i, char c)
\r
135 insertCharAt(i,c,true);
\r
138 public void insertCharAt(int i,char c,boolean chop) {
\r
140 String tmp = new String(sequence);
\r
142 if (i < sequence.length()) {
\r
143 sequence = tmp.substring(0,i) + String.valueOf(c) + tmp.substring(i);
\r
145 sequence = tmp + String.valueOf(c);
\r
150 public void setColor(Color c) {
\r
154 public Color getColor() {
\r