- protected String name;\r
- protected String sequence;\r
- protected String description;\r
- protected int start;\r
- protected int end;\r
- protected String displayId;\r
- protected Color color = Color.white;\r
- String pdbId;\r
- PDBfile pdb;\r
-\r
- public int maxchain = -1;\r
- public int pdbstart;\r
- public int pdbend;\r
- public int seqstart;\r
- public int seqend;\r
-\r
- public Vector sequenceFeatures = new Vector();\r
- public void setSequenceFeatures(Vector v)\r
- {\r
- sequenceFeatures = v;\r
- }\r
-\r
- public Vector getSequenceFeatures()\r
- {return sequenceFeatures; }\r
-\r
- public void setPDBId(String id)\r
- {\r
- pdbId = id;\r
- }\r
- public String getPDBId()\r
- {\r
- return pdbId;\r
- }\r
-\r
- public void setPDBfile(PDBfile pdb)\r
- {\r
- this.pdb = pdb;\r
- int max = -10;\r
- maxchain = -1;\r
-\r
- for (int i=0; i < pdb.chains.size(); i++) {\r
-\r
- System.out.println("PDB sequence = " + ((PDBChain)pdb.chains.elementAt(i)).sequence);\r
- // Now lets compare the sequences to get\r
- // the start and end points.\r
-\r
-\r
- StringTokenizer str = new StringTokenizer(sequence, ".");\r
- String newString = "";\r
-\r
- while (str.hasMoreTokens()) {\r
- newString += str.nextToken();\r
- }\r
- // Align the sequence to the pdb\r
- AlignSeq as = new AlignSeq(this,((PDBChain)pdb.chains.elementAt(i)).sequence,"pep");\r
- as.calcScoreMatrix();\r
- as.traceAlignment();\r
- as.printAlignment();\r
-\r
- System.out.println("Score = " + as.maxscore);\r
- if (as.maxscore > max) {\r
- System.out.println("New max score");\r
- max = as.maxscore;\r
- maxchain = i;\r
-\r
- pdbstart = as.seq2start;\r
- pdbend = as.seq2end;\r
- seqstart = as.seq1start - 1 ;\r
- seqend = as.seq1end -1;\r
- }\r
-\r
- System.out.println("PDB start/end " + pdbstart + " " + pdbend);\r
- System.out.println("SEQ start/end " + seqstart + " " + seqend);\r
- }\r
- }\r
-\r
- public Sequence(String name, String sequence, int start, int end)\r
- {\r
-\r
- this.name = name;\r
- this.sequence = sequence;\r
- this.start = start;\r
- this.end = end;\r
-\r
- setDisplayId();\r
-\r
- }\r
-\r
- public Sequence(String name,String sequence) {\r
- this(name,sequence,1,sequence.length());\r
- }\r
- public Sequence(SequenceI seq) {\r
- this(seq.getName(),seq.getSequence(),seq.getStart(),seq.getEnd());\r
- }\r
- public String getDisplayId() {\r
- return displayId;\r
- }\r
- public void setDisplayId() {\r
- displayId = name + "/" + start + "-" + end;\r
- }\r
- public void setName(String name) {\r
- this.name = name;\r
- setDisplayId();\r
- }\r
- public String getName() {\r
- return this.name;\r
- }\r
- public void setStart(int start) {\r
- this.start = start;\r
- setDisplayId();\r
- }\r
- public int getStart() {\r
- return this.start;\r
- }\r
- public void setEnd(int end) {\r
- this.end = end;\r
- setDisplayId();\r
- }\r
- public int getEnd() {\r
- return this.end;\r
- }\r
- public int getLength() {\r
- return this.sequence.length();\r
- }\r
- public void setSequence(String seq) {\r
- this.sequence = seq;\r
- }\r
- public String getSequence() {\r
- return this.sequence;\r
- }\r
- public String getSequence(int start,int end) {\r
- return this.sequence.substring(start,end);\r
- }\r
-\r
- public char getCharAt(int i) {\r
- if (i < sequence.length()) {\r
- return sequence.charAt(i);\r
- } else {\r
- return ' ';\r
- }\r
- }\r
- public void setDescription(String desc) {\r
- this.description = desc;\r
- }\r
- public String getDescription() {\r
- return this.description;\r
- }\r
-\r
- public int findIndex(int pos) {\r
- // returns the alignment position for a residue\r
- int j = start;\r
- int i = 0;\r
-\r
- while (i< sequence.length() && j <= end && j <= pos) {\r
-\r
- char c = sequence.charAt(i);\r
-\r
- if (!jalview.util.Comparison.isGap((c)))\r
- j++;\r
-\r
- i++;\r
- }\r
- if (j == end && j < pos)\r
- return end+1;\r
- else\r
- return i;\r
-\r
- }\r
-\r
- public int findPosition(int i) {\r
- // Returns the sequence position for an alignment position\r
- int j = 0;\r
- int pos = start;\r
-\r
- while (j < i)\r
- {\r
- char c = sequence.charAt(j);\r
-\r
- if (!jalview.util.Comparison.isGap((c)))\r
- pos++;\r
-\r
- j++;\r
- }\r
- return pos;\r
- }\r
- public void deleteCharAt(int i)\r
- {\r
- StringBuffer sbuffer = new StringBuffer(sequence);\r
- sbuffer.deleteCharAt(i);\r
- sequence = sbuffer.toString();\r
- }\r
-\r
- public void insertCharAt(int i, char c)\r
- {\r
- insertCharAt(i,c,true);\r
- }\r
-\r
- public void insertCharAt(int i,char c,boolean chop) {\r
-\r
- String tmp = new String(sequence);\r
-\r
- if (i < sequence.length()) {\r
- sequence = tmp.substring(0,i) + String.valueOf(c) + tmp.substring(i);\r
- } else {\r
- sequence = tmp + String.valueOf(c);\r
- }\r
-\r
- }\r
-\r
- public void setColor(Color c) {\r
- this.color = c;\r
- }\r
-\r
- public Color getColor() {\r
- return color;\r
- }\r
+ protected String name;\r
+ protected String sequence;\r
+ protected String description;\r
+ protected int start;\r
+ protected int end;\r
+ protected String displayId;\r
+ protected Color color = Color.white;\r
+ String pdbId;\r
+\r
+ /** DOCUMENT ME!! */\r
+ public Vector sequenceFeatures = new Vector();\r
+\r
+ /**\r
+ * Creates a new Sequence object.\r
+ *\r
+ * @param name DOCUMENT ME!\r
+ * @param sequence DOCUMENT ME!\r
+ * @param start DOCUMENT ME!\r
+ * @param end DOCUMENT ME!\r
+ */\r
+ public Sequence(String name, String sequence, int start, int end)\r
+ {\r
+ this.name = name;\r
+ this.sequence = sequence;\r
+ this.start = start;\r
+ this.end = end;\r
+\r
+ if (end < 1)\r
+ {\r
+ int endRes = 0;\r
+ char ch;\r
+ for (int j = 0; j < sequence.length(); j++)\r
+ {\r
+ ch = sequence.charAt(j);\r
+ if (!jalview.util.Comparison.isGap( (ch)))\r
+ {\r
+ endRes++;\r
+ }\r
+ }\r
+ if (endRes > 0)\r
+ {\r
+ endRes += start - 1;\r
+ }\r
+\r
+ this.end = endRes;\r
+ }\r
+\r
+ setDisplayId();\r
+ }\r
+\r
+ /**\r
+ * Creates a new Sequence object.\r
+ *\r
+ * @param name DOCUMENT ME!\r
+ * @param sequence DOCUMENT ME!\r
+ */\r
+ public Sequence(String name, String sequence)\r
+ {\r
+ this(name, sequence, 1, sequence.length());\r
+ }\r
+\r
+ /**\r
+ * Creates a new Sequence object.\r
+ *\r
+ * @param seq DOCUMENT ME!\r
+ */\r
+ public Sequence(SequenceI seq)\r
+ {\r
+ this(seq.getName(), seq.getSequence(), seq.getStart(), seq.getEnd());\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param v DOCUMENT ME!\r
+ */\r
+ public void setSequenceFeatures(Vector v)\r
+ {\r
+ sequenceFeatures = v;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public Vector getSequenceFeatures()\r
+ {\r
+ return sequenceFeatures;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param id DOCUMENT ME!\r
+ */\r
+ public void setPDBId(String id)\r
+ {\r
+ pdbId = id;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public String getPDBId()\r
+ {\r
+ return pdbId;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public String getDisplayId()\r
+ {\r
+ return displayId;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ */\r
+ public void setDisplayId()\r
+ {\r
+ displayId = name + "/" + start + "-" + end;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param name DOCUMENT ME!\r
+ */\r
+ public void setName(String name)\r
+ {\r
+ this.name = name;\r
+ setDisplayId();\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public String getName()\r
+ {\r
+ return this.name;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param start DOCUMENT ME!\r
+ */\r
+ public void setStart(int start)\r
+ {\r
+ this.start = start;\r
+ setDisplayId();\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public int getStart()\r
+ {\r
+ return this.start;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param end DOCUMENT ME!\r
+ */\r
+ public void setEnd(int end)\r
+ {\r
+ this.end = end;\r
+ setDisplayId();\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public int getEnd()\r
+ {\r
+ return this.end;\r
+ }\r
+\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @return DOCUMENT ME!\r
+ */\r
+ public int getLength()\r
+ {\r
+ return this.sequence.length();\r
+ }\r