Vector headers;\r
long start;\r
long end;\r
- boolean dbPrefix = true;\r
boolean jvSuffix = true;\r
\r
/**\r
*/\r
public abstract String print();\r
\r
- public void addDBPrefix(boolean b)\r
- {\r
- dbPrefix = b;\r
- }\r
-\r
public void addJVSuffix(boolean b)\r
{\r
jvSuffix = b;\r
}\r
\r
/**\r
- * A general parser for ids. Will look for dbrefs in\r
- * Uniprot format source|id\r
- * And also Jalview /start-end\r
+ * A general parser for ids.\r
*\r
* @String id Id to be parsed\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(jvSuffix);\r
}\r
\r
}\r