more robust parsing for DBset/DBname|id1|id2 type ids
authorjprocter <Jim Procter>
Mon, 30 May 2005 14:58:53 +0000 (14:58 +0000)
committerjprocter <Jim Procter>
Mon, 30 May 2005 14:58:53 +0000 (14:58 +0000)
src/jalview/io/FastaFile.java

index 4c1ba9e..cd287ff 100755 (executable)
@@ -54,13 +54,21 @@ public class FastaFile extends AlignFile {
 \r
            id = str.nextToken();\r
            id = id.substring(1);\r
-           if(id.indexOf("UniProt/Swiss-Prot")>-1)\r
-            {\r
-              id = id.substring(id.indexOf("UniProt/Swiss-Prot|") + 19);\r
-              if(id.indexOf("|")>-1)\r
-                id = id.substring(id.indexOf("|") + 1);\r
-            }\r
-\r
+            com.stevesoft.pat.Regex dbId = new com.stevesoft.pat.Regex("[A-Za-z-]+/[A-Za-z-]+\\|(\\w+)\\|(.+)");\r
+            if (dbId.search(id))\r
+               {\r
+                 String dbid = dbId.stringMatched(1);\r
+                 String idname = dbId.stringMatched(2);\r
+                 if (idname.length()>0 && idname.indexOf("_") > -1)\r
+                 {\r
+                   id = idname; // just use friendly name // JBPNote: we may lose uniprot standardised ID here.\r
+                 }\r
+                 else\r
+                 {\r
+                   id = dbid; // use dbid to ensure sensible queries\r
+                 }\r
+\r
+               }\r
            if (id.indexOf("/") > 0 ) {\r
 \r
              StringTokenizer st = new StringTokenizer(id,"/");\r