- protected String name;\r
- protected String sequence;\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.white;\r
- PDBfile pdb;\r
- public int maxchain = -1;\r
-\r
- public int pdbstart;\r
- public int pdbend;\r
- public int seqstart;\r
- public int seqend;\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
- String s = sequence.substring(i,i+1);\r
-\r
- if (!(s.equals(".") || s.equals("-") || s.equals(" "))) {\r
- j++;\r
+ SequenceI datasetSequence;\r
+ String name;\r
+ String sequence;\r
+ String description;\r
+ int start;\r
+ int end;\r
+ Color color = Color.white;\r
+ Vector pdbIds;\r
+ String vamsasId;\r
+ Vector dbrefs;\r
+\r
+ /** This annotation is displayed below the alignment but the\r
+ * positions are tied to the residues of this sequence */\r
+ Vector annotation;\r
+\r
+ /** DOCUMENT ME!! */\r
+ public Vector sequenceFeatures;\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
+ parseId();\r
+\r
+ checkValidRange();\r
+ }\r
+\r
+ com.stevesoft.pat.Regex limitrx = new com.stevesoft.pat.Regex(\r
+ "[/][0-9]{1,}[-][0-9]{1,}$");\r
+ com.stevesoft.pat.Regex endrx = new com.stevesoft.pat.Regex(\r
+ "[0-9]{1,}$");\r
+\r
+ void parseId()\r
+ {\r
+ // Does sequence have the /start-end signiature?\r
+ if(limitrx.search(name))\r
+ {\r
+ name = limitrx.left();\r
+ endrx.search(limitrx.stringMatched());\r
+ setStart( Integer.parseInt( limitrx.stringMatched().substring(1,endrx.matchedFrom()-1 )));\r
+ setEnd( Integer.parseInt( endrx.stringMatched() ));\r
+ }\r
+ }\r
+\r
+ void checkValidRange()\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