+ for (int pi = 0; pi < getPdbCount(); pi++)
+ {
+ String file = getPdbEntry(pi).getFile();
+ if (file == null)
+ {
+ // todo: extract block as method and pull up (also ChimeraViewFrame)
+ // retrieve the pdb and store it locally
+ AlignmentI pdbseq = null;
+ PDBEntry strucEntry = getPdbEntry(pi);
+ pdbid = strucEntry.getId();
+ long hdl = pdbid.hashCode() - System.currentTimeMillis();
+ structureViewer.setProgressMessage(MessageManager
+ .formatMessage("status.fetching_pdb", new String[]
+ { pdbid }), hdl);
+ try
+ {
+ if (afclient.isValidReference(pdbid))
+ {
+ pdbseq = afclient.getSequenceRecords(pdbid);
+ } else {
+ if (strucEntry.hasRetrievalUrl())
+ {
+ File tmpFile = File.createTempFile(pdbid, ".cif");
+ String fromUrl = strucEntry.getRetrievalUrl();
+ UrlDownloadClient.download(fromUrl, tmpFile);
+
+ // may not need this check ?
+ file = tmpFile.getAbsolutePath();
+ if (file != null)
+ {
+ pdbseq = EBIAlfaFold.importDownloadedStructureFromUrl(fromUrl,tmpFile,pdbid,null,null,null);
+ }
+ } else {
+ pdbseq = pdbclient.getSequenceRecords(pdbid);
+ }
+ }
+ } catch (OutOfMemoryError oomerror)
+ {
+ new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ errormsgs.append("'").append(pdbid).append("'");
+ } finally
+ {
+ structureViewer.setProgressMessage(
+ MessageManager.getString("label.state_completed"), hdl);
+ }
+ if (pdbseq != null)
+ {
+ // just transfer the file name from the first sequence's first
+ // PDBEntry
+ file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
+ .elementAt(0).getFile()).getAbsolutePath();
+ getPdbEntry(pi).setFile(file);
+ files.add(file);
+ }
+ else
+ {
+ errormsgs.append("'").append(pdbid).append("' ");
+ }
+ }
+ else
+ {
+ if (filesInViewer != null && filesInViewer.length > 0)
+ {
+ structureViewer.setAddingStructures(true); // already files loaded.
+ for (int c = 0; c < filesInViewer.length; c++)
+ {
+ if (Platform.pathEquals(filesInViewer[c], file))
+ {
+ file = null;
+ break;
+ }
+ }
+ }
+ if (file != null)
+ {
+ files.add(file);
+ }
+ }
+ }
+ } catch (OutOfMemoryError oomerror)
+ {
+ new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ errormsgs.append("When retrieving pdbfiles : current was: '")
+ .append(pdbid).append("'");
+ }
+ if (errormsgs.length() > 0)
+ {
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.formatMessage(
+ "label.pdb_entries_couldnt_be_retrieved", new String[]
+ { errormsgs.toString() }),
+ MessageManager.getString("label.couldnt_load_file"),
+ JvOptionPane.ERROR_MESSAGE);
+ }
+ return files;