package jalview.analysis;\r
\r
import jalview.datamodel.*;\r
-import jalview.io.*;\r
import jalview.util.*;\r
-\r
import java.util.*;\r
\r
public class AlignmentUtil {\r
return pos;\r
}\r
\r
- class FeatureThread extends Thread\r
- {\r
-\r
- }\r
-\r
- public static void addUniprotFeatures(AlignmentI align)\r
+ public static void fetchSequenceFeatures(AlignmentI al, jalview.gui.AlignmentPanel ap)\r
{\r
- EBIFetchClient ebi = new EBIFetchClient();\r
- int seqIndex = 0;\r
- Vector sequences = align.getSequences();\r
- SequenceI sequence;\r
-\r
- while (seqIndex < sequences.size())\r
- {\r
- StringBuffer ids = new StringBuffer("uniprot:");\r
- for (int i=0; seqIndex<sequences.size() && i<50; seqIndex++, i++)\r
- {\r
- sequence = (SequenceI) sequences.get(seqIndex);\r
- ids.append(sequence.getName() + ";");\r
- }\r
-\r
- String[] result = ebi.fetchData(ids.toString(), "xml", null);\r
- sequence = null;\r
- Vector features = null;\r
- String type, description, status, start, end, pdb = null;\r
-\r
- for (int r = 0; r < result.length; r++)\r
- {\r
- if(sequence==null && result[r].indexOf("<name>")>-1)\r
- {\r
- sequence = align.findName( parseElement( result[r], "<name>" )) ;\r
- features = new Vector();\r
- type=""; start="0"; end="0"; description=""; status=""; pdb="";\r
- }\r
-\r
- if(sequence==null)\r
- continue;\r
-\r
- if( result[r].indexOf("<property type=\"pdb accession\"")>-1)\r
- {\r
- pdb = parseValue( result[r], "value=" );\r
- sequence.setPDBId(pdb);\r
- }\r
-\r
- if(result[r].indexOf("feature type")>-1)\r
- {\r
- type = parseValue( result[r], "type=" );\r
- description = parseValue( result[r], "description=" );\r
- status = parseValue ( result[r], "status=");\r
-\r
- while( result[r].indexOf("<location>")==-1)\r
- {\r
- r++; //<location>\r
- }\r
- r++;\r
- if(result[r].indexOf("begin")>-1)\r
- {\r
- start = parseValue( result[r], "position=" );\r
- end = parseValue( result[++r], "position=" );\r
- }\r
- else\r
- {\r
- start = parseValue( result[r], "position=" );\r
- end = parseValue( result[r], "position=" );\r
- }\r
- int sstart = Integer.parseInt(start);\r
- int eend = Integer.parseInt(end);\r
-\r
- if(sstart>=sequence.getStart() && eend<=sequence.getEnd())\r
- {\r
- SequenceFeature sf = new SequenceFeature(type,\r
- sstart,\r
- eend,\r
- description,\r
- status);\r
- features.add(sf);\r
- }\r
- }\r
-\r
- if(result[r].indexOf("</entry>")>-1)\r
- {\r
- sequence.setSequenceFeatures( features );\r
- features = null;\r
- sequence = null;\r
- }\r
- }\r
- }\r
+ SequenceFeatureFetcher sft = new SequenceFeatureFetcher(al, ap);\r
}\r
\r
- static String parseValue(String line, String tag)\r
- {\r
-\r
- int index = line.indexOf(tag)+tag.length()+1;\r
- if(index==tag.length())\r
- return "";\r
-\r
- return line.substring( index, line.indexOf("\"", index+1) );\r
- }\r
-\r
-\r
- static String parseElement(String line, String tag)\r
- {\r
- int index = line.indexOf(tag)+tag.length();\r
- return line.substring( index, line.indexOf("</") ) ;\r
- }\r
-\r
-\r
-\r
-\r
-\r
}\r