package jalview.datamodel;\r
\r
-\r
+import jalview.analysis.*;\r
import java.awt.*;\r
+import java.util.*;\r
+import MCview.*;\r
+\r
\r
-public class Sequence implements SequenceI {\r
+public class Sequence implements SequenceI\r
+{\r
protected String name;\r
protected String sequence;\r
+ protected String description;\r
protected int start;\r
protected int end;\r
- protected String description;\r
- protected int charHeight;\r
protected String displayId;\r
- protected Color color = Color.black;\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
return this.sequence;\r
}\r
public String getSequence(int start,int end) {\r
+ if(end>sequence.length())\r
+ end = sequence.length();\r
return this.sequence.substring(start,end);\r
}\r
\r
\r
while (i< sequence.length() && j <= end && j <= pos) {\r
\r
- String s = sequence.substring(i,i+1);\r
+ char c = sequence.charAt(i);\r
\r
- if (!(s.equals(".") || s.equals("-") || s.equals(" "))) {\r
+ if (!jalview.util.Comparison.isGap((c)))\r
j++;\r
- }\r
+\r
i++;\r
}\r
- if (j == end && j < pos) {\r
+ if (j == end && j < pos)\r
return end+1;\r
- } else {\r
-\r
+ else\r
return i;\r
- }\r
+\r
}\r
\r
public int findPosition(int i) {\r
int j = 0;\r
int pos = start;\r
\r
- while (j < i) {\r
- String s = sequence.substring(j,j+1);\r
-\r
- if (!(s.equals(".") || s.equals("-") || s.equals(" "))) {\r
+ while (j < i && j<sequence.length())\r
+ {\r
+ char c = sequence.charAt(j);\r
+ if (!jalview.util.Comparison.isGap((c)))\r
pos++;\r
- }\r
+\r
j++;\r
}\r
return pos;\r
}\r
+\r
+ public int[] gapMap() {\r
+ // Returns an int array giving the position of each residue in the sequence in the alignment\r
+ String seq = jalview.analysis.AlignSeq.extractGaps("-. ",sequence);\r
+ int[] map = new int[seq.length()];\r
+ int j=0;\r
+ int p=0;\r
+ while (j<sequence.length()) {\r
+ if (!jalview.util.Comparison.isGap(sequence.charAt(j))) {\r
+ map[p++]=j;\r
+ }\r
+ j++;\r
+ }\r
+ return map;\r
+ }\r
+\r
public void deleteCharAt(int i)\r
{\r
StringBuffer sbuffer = new StringBuffer(sequence);\r
sequence = sbuffer.toString();\r
}\r
\r
+ public void deleteChars(int i, int j)\r
+ {\r
+ StringBuffer sbuffer = new StringBuffer(sequence);\r
+ sbuffer.delete(i,j);\r
+ sequence = sbuffer.toString();\r
+ }\r
+\r
public void insertCharAt(int i, char c)\r
{\r
insertCharAt(i,c,true);\r