{\r
SequenceI datasetSequence;\r
String name;\r
+ String shortName;\r
String sequence;\r
String description;\r
int start;\r
int end;\r
- String displayId;\r
Color color = Color.white;\r
String pdbId;\r
String vamsasId;\r
public Sequence(String name, String sequence, int start, int end)\r
{\r
this.name = name;\r
+ parseId();\r
+\r
this.sequence = sequence;\r
this.start = start;\r
this.end = end;\r
checkValidRange();\r
}\r
\r
+ void parseId()\r
+ {\r
+ // Read in any DB refs first\r
+ StringTokenizer st = new StringTokenizer(name, "|");\r
+ if(st.countTokens()<1)\r
+ {\r
+ shortName = name;\r
+ return;\r
+ }\r
+\r
+ while (st.countTokens() > 1)\r
+ {\r
+ String a = st.nextToken();\r
+ String b = st.nextToken();\r
+ addDBRef(new DBRefEntry(a, "0", b));\r
+ }\r
+\r
+ if (st.hasMoreTokens())\r
+ shortName = st.nextToken();\r
+\r
+ // Remove /start-end from sequence\r
+ if (shortName.indexOf("/") > 0)\r
+ {\r
+ st = new StringTokenizer(shortName, "/");\r
+ String limits = null;\r
+ try\r
+ {\r
+ if (st.countTokens() == 2)\r
+ {\r
+ shortName = st.nextToken();\r
+\r
+ limits = st.nextToken();\r
+\r
+ st = new StringTokenizer(limits, "-");\r
+\r
+ if (st.countTokens() == 2)\r
+ {\r
+ setStart(Integer.valueOf(st.nextToken()).intValue());\r
+ setEnd(Integer.valueOf(st.nextToken()).intValue());\r
+ }\r
+ }\r
+ }\r
+ catch (NumberFormatException ex)\r
+ {\r
+ // Problem parsing sequence limits. Just add it back to the\r
+ // Id so we dont lose this info\r
+ shortName += "/" + limits;\r
+ }\r
+ }\r
+ }\r
+\r
void checkValidRange()\r
{\r
if (end < 1)\r
*/\r
public Sequence(String name, String sequence)\r
{\r
- this(name, sequence, 1, sequence.length());\r
+ this(name, sequence, 1, -1);\r
}\r
\r
/**\r
}\r
}\r
\r
- result.append(name);\r
+ result.append(shortName);\r
\r
if (jvsuffix)\r
{\r
*/\r
public void setName(String name)\r
{\r
- this.name = name;\r
+ this.name = name;\r
+ this.parseId();\r
}\r
\r
/**\r
*/\r
public String getName()\r
{\r
- return this.name;\r
+ return this.name;\r
}\r
\r
/**\r
*/\r
void sequenceName_actionPerformed(ActionEvent e)\r
{\r
- String id = sequence.getName();\r
+ String id = sequence.getDisplayId(false, false);\r
String s = (String) JOptionPane.showInternalInputDialog(ap,\r
"Edit sequence name",\r
"Edit sequence name (" + sequence.getName() + ")",\r
*/\r
Sequence parseId(String id)\r
{\r
+ Sequence seq = null;\r
id = id.trim();\r
- Sequence seq = new Sequence("","");\r
int space = id.indexOf(" ");\r
if(space>-1)\r
{\r
+ seq = new Sequence(id.substring(0, space),"");\r
seq.setDescription(id.substring(space+1));\r
- id = id.substring(0, space);\r
}\r
-\r
- // Read in any DB refs first\r
- StringTokenizer st;\r
- st = new StringTokenizer(id, "|");\r
-\r
- while (st.countTokens()>1)\r
+ else\r
{\r
- String a = st.nextToken();\r
- String b = st.nextToken();\r
- seq.addDBRef( new DBRefEntry( a, "0", b));\r
+ seq = new Sequence(id, "");\r
}\r
\r
- if(st.hasMoreTokens())\r
- id = st.nextToken();\r
-\r
-\r
- // Remove /start-end from sequence\r
- if (id.indexOf("/") > 0)\r
- {\r
- st = new StringTokenizer(id, "/");\r
- String limits=null;\r
- try{\r
- if (st.countTokens() == 2)\r
- {\r
- id = st.nextToken();\r
-\r
- limits = st.nextToken();\r
\r
- st = new StringTokenizer(limits, "-");\r
-\r
- if (st.countTokens() == 2)\r
- {\r
- seq.setStart(Integer.valueOf(st.nextToken()).intValue());\r
- seq.setEnd(Integer.valueOf(st.nextToken()).intValue());\r
- }\r
- }\r
- }catch(NumberFormatException ex)\r
- {\r
- // Problem parsing sequence limits. Just add it back to the\r
- // Id so we dont lose this info\r
- id += "/" + limits;\r
- }\r
- }\r
- seq.setName(id);\r
return seq;\r
}\r
\r
*/\r
String printId(SequenceI seq)\r
{\r
- StringBuffer result = new StringBuffer();\r
- if(dbPrefix && seq.getDBRef()!=null)\r
- {\r
- Vector dbrefs = seq.getDBRef();\r
- for(int i=0; i<dbrefs.size(); i++)\r
- {\r
- DBRefEntry entry = (DBRefEntry)dbrefs.elementAt(i);\r
- result.append(entry.getSource()+"|"+entry.getAccessionId()+"|");\r
- }\r
- }\r
-\r
- result.append(seq.getName());\r
-\r
- if(jvSuffix)\r
- {\r
- result.append("/"+seq.getStart()+"-"+seq.getEnd());\r
- }\r
-\r
- return result.toString();\r
+ return seq.getDisplayId(dbPrefix, jvSuffix);\r
}\r
\r
}\r