-\r
- void ReadUniprotFile(String[] result, RandomAccessFile out, AlignmentI align) {\r
- SequenceI sequence = null;\r
- Vector features = null;\r
- String type;\r
- String description;\r
- String status;\r
- String start;\r
- String end;\r
- String pdb = null;\r
-\r
- for (int r = 0; r < result.length; r++) {\r
- if ((sequence == null) && (result[r].indexOf("<name>") > -1)) {\r
- long filePointer = 0;\r
-\r
- if (out != null) {\r
- try {\r
- filePointer = out.getFilePointer();\r
- out.writeBytes("<entry>\n");\r
- } catch (Exception ex) {\r
- }\r
- }\r
-\r
- String seqName = parseElement(result[r], "<name>", out);\r
- sequence = align.findName(seqName);\r
-\r
- if (sequence == null) {\r
- sequence = align.findName(seqName.substring(0,\r
- seqName.indexOf('_')));\r
-\r
- if (sequence != null) {\r
- sbuffer.append("changing " + sequence.getName() +\r
- " to " + seqName + "\n");\r
- sequence.setName(seqName);\r
- }\r
- }\r
-\r
- if (sequence == null) {\r
- sbuffer.append("UNIPROT updated suggestion is " +\r
- result[r] + "\n");\r
- sequence = align.findName(result[r]);\r
-\r
- // this entry has been suggested by ebi.\r
- // doesn't match id in alignment file\r
- try {\r
- out.setLength(filePointer);\r
- } catch (Exception ex) {\r
- }\r
-\r
- // now skip to next entry\r
- while (result[r].indexOf("</entry>") == -1)\r
- r++;\r
- }\r
-\r
- features = new Vector();\r
- type = "";\r
- start = "0";\r
- end = "0";\r
- description = "";\r
- status = "";\r
- pdb = "";\r
- }\r
-\r
- if (sequence == null) {\r
- continue;\r
- }\r
-\r
- if (result[r].indexOf("<property type=\"pdb accession\"") > -1) {\r
- pdb = parseValue(result[r], "value=", out);\r
- sequence.setPDBId(pdb);\r
- }\r
-\r
- if (result[r].indexOf("feature type") > -1) {\r
- type = parseValue(result[r], "type=", out);\r
- description = parseValue(result[r], "description=", null);\r
- status = parseValue(result[r], "status=", null);\r
-\r
- while (result[r].indexOf("position") == -1) {\r
- r++; //<location>\r
- }\r
-\r
- // r++;\r
- if (result[r].indexOf("begin") > -1) {\r
- start = parseValue(result[r], "position=", out);\r
- end = parseValue(result[++r], "position=", out);\r
- } else {\r
- start = parseValue(result[r], "position=", out);\r
- end = parseValue(result[r], "position=", null);\r
- }\r
-\r
- int sstart = Integer.parseInt(start);\r
- int eend = Integer.parseInt(end);\r
-\r
- if (out != null) {\r
- try {\r
- out.writeBytes("</feature>\n");\r
- } catch (Exception ex) {\r
- }\r
- }\r
-\r
- SequenceFeature sf = new SequenceFeature(type, sstart, eend,\r
- description, status);\r
- features.add(sf);\r
- }\r
-\r
- if (result[r].indexOf("<sequence") > -1) {\r
- StringBuffer seqString = new StringBuffer();\r
-\r
- if (out != null) {\r
- try {\r
- out.writeBytes(result[r] + "\n");\r
- } catch (Exception ex) {\r
- }\r
- }\r
-\r
- while (result[++r].indexOf("</sequence>") == -1) {\r
- seqString.append(result[r]);\r
-\r
- if (out != null) {\r
- try {\r
- out.writeBytes(result[r] + "\n");\r
- } catch (Exception ex) {\r
- }\r
- }\r
- }\r
-\r
- if (out != null) {\r
- try {\r
- out.writeBytes(result[r] + "\n");\r
- } catch (Exception ex) {\r
- }\r
- }\r
-\r
- StringBuffer nonGapped = new StringBuffer();\r
-\r
- for (int i = 0; i < sequence.getSequence().length(); i++) {\r
- if (!jalview.util.Comparison.isGap(sequence.getCharAt(i))) {\r
- nonGapped.append(sequence.getCharAt(i));\r
- }\r
- }\r
-\r
- int absStart = seqString.toString().indexOf(nonGapped.toString());\r
-\r
- if (absStart == -1) {\r
- unknownSequences.add(sequence.getName());\r
- features = null;\r
- sbuffer.append(sequence.getName() +\r
- " SEQUENCE NOT %100 MATCH \n");\r
-\r
- continue;\r
- }\r
-\r
- int absEnd = absStart + nonGapped.toString().length();\r
- absStart += 1;\r
-\r
- if ((absStart != sequence.getStart()) ||\r
- (absEnd != sequence.getEnd())) {\r
- sbuffer.append("Updated: " + sequence.getName() + " " +\r
- sequence.getStart() + "/" + sequence.getEnd() +\r
- " to " + absStart + "/" + absEnd + "\n");\r
- }\r
-\r
- sequence.setStart(absStart);\r
- sequence.setEnd(absEnd);\r
- }\r
-\r
- if (result[r].indexOf("</entry>") > -1) {\r
- if (features != null) {\r
- sequence.setSequenceFeatures(features);\r
- }\r
-\r
- features = null;\r
- sequence = null;\r
-\r
- if (out != null) {\r
- try {\r
- out.writeBytes("</entry>\n");\r
- } catch (Exception ex) {\r
- }\r
- }\r
- }\r
- }\r