vamsasSet.setGapChar(jal.getGapCharacter() + "");\r
\r
JSeq jseq;\r
+ Vector pdbfiles = null;\r
\r
//SAVE SEQUENCES\r
int id = 0;\r
pdb.setId(entry.getId());\r
pdb.setType(entry.getType());\r
\r
+ if(entry.getFile()!=null)\r
+ {\r
+ if(pdbfiles==null)\r
+ pdbfiles = new Vector();\r
+\r
+\r
+ if(!pdbfiles.contains(entry.getId()))\r
+ {\r
+ pdbfiles.addElement(entry.getId());\r
+ try\r
+ {\r
+ File file = new File(entry.getFile());\r
+ if(file.exists())\r
+ {\r
+ byte[] data = new byte[ (int) file.length()];\r
+ jout.putNextEntry(new JarEntry(entry.getId()));\r
+ DataInputStream dis = new DataInputStream(new\r
+ FileInputStream(file));\r
+ dis.readFully(data);\r
+\r
+ DataOutputStream dout = new DataOutputStream(jout);\r
+ dout.write(data, 0, data.length);\r
+ jout.closeEntry();\r
+ }\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+\r
+\r
if(entry.getProperty()!=null)\r
{\r
PdbentryItem item = new PdbentryItem();\r
}\r
}\r
\r
- if(av.hasHiddenRows)\r
- {\r
- // av.alignment.getHiddenSequences().get\r
- // HiddenSequences hs = new HiddenSequences();\r
- // hs.ad\r
- // view.addHiddenSequences();\r
- // av.showAllHiddenSeqs();.alignment.getHiddenSequences().\r
- }\r
-\r
jms.addViewport(view);\r
\r
\r
*/\r
public AlignFrame LoadJalviewAlign(String file)\r
{\r
-\r
jalview.gui.AlignFrame af = null;\r
-\r
try\r
{\r
//UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING\r
for (int i = 0; i < entryCount; i++)\r
{\r
jarentry = jin.getNextJarEntry();\r
+ }\r
\r
- }\r
-\r
-\r
- class NoDescIDResolver implements IDResolver\r
- {\r
- public Object resolve(String idref)\r
- {\r
- System.out.println(idref+" used");\r
- return null;\r
- }\r
- }\r
-\r
-\r
- if (jarentry != null)\r
+ if (jarentry != null && jarentry.getName().endsWith(".xml"))\r
{\r
InputStreamReader in = new InputStreamReader(jin, "UTF-8");\r
JalviewModel object = new JalviewModel();\r
unmar.setValidation(false);\r
object = (JalviewModel) unmar.unmarshal( in );\r
\r
- af = LoadFromObject(object);\r
+ af = LoadFromObject(object, file);\r
entryCount++;\r
}\r
+ else if (jarentry != null)\r
+ {\r
+ //Some other file here.\r
+ entryCount++;\r
+ }\r
}\r
while (jarentry != null);\r
}\r
return af;\r
}\r
\r
- AlignFrame LoadFromObject(JalviewModel object)\r
+ String loadPDBFile(String file, String pdbId)\r
+ {\r
+ System.out.println("load file "+file);\r
+ try\r
+ {\r
+ JarInputStream jin = null;\r
+\r
+ if (file.startsWith("http://"))\r
+ {\r
+ jin = new JarInputStream(new URL(file).openStream());\r
+ }\r
+ else\r
+ {\r
+ jin = new JarInputStream(new FileInputStream(file));\r
+ }\r
+\r
+ JarEntry entry = null;\r
+ do\r
+ {\r
+ entry = jin.getNextJarEntry();\r
+ }\r
+ while (!entry.getName().equals(pdbId));\r
+\r
+ BufferedReader in = new BufferedReader(new InputStreamReader(jin));\r
+ File outFile = File.createTempFile("jalview_pdb", ".txt");\r
+ outFile.deleteOnExit();\r
+ PrintWriter out = new PrintWriter(new FileOutputStream(outFile));\r
+ String data;\r
+\r
+ while ( (data = in.readLine()) != null)\r
+ {\r
+ out.println(data);\r
+ }\r
+ out.close();\r
+ return outFile.getAbsolutePath();\r
+\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ ex.printStackTrace();\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
+\r
+ AlignFrame LoadFromObject(JalviewModel object, String file)\r
{\r
Vector seqids = new Vector();\r
SequenceSet vamsasSet = object.getVamsasModel().getSequenceSet(0);\r
/////////////////////////////////\r
\r
\r
+ Hashtable pdbloaded = new Hashtable();\r
for (int i = 0; i < vamsasSeq.length; i++)\r
{\r
if (JSEQ[i].getFeaturesCount() > 0)\r
jalview.datamodel.PDBEntry entry = new jalview.datamodel.PDBEntry();\r
entry.setId(ids[p].getId());\r
entry.setType(ids[p].getType());\r
+ if (ids[p].getFile() != null)\r
+ {\r
+ if (!pdbloaded.containsKey(ids[p].getFile()))\r
+ {\r
+ String tmppdb = loadPDBFile(file, ids[p].getId());\r
+ entry.setFile(tmppdb);\r
+ pdbloaded.put(ids[p].getId(), tmppdb);\r
+ }\r
+ else\r
+ entry.setFile(pdbloaded.get(ids[p].getId()).toString());\r
+ }\r
+\r
al.getSequenceAt(i).getDatasetSequence().addPDBId(entry);\r
}\r
-\r
}\r
if(vamsasSeq[i].getDBRefCount()>0)\r
{\r