+ // done during structure retrieval
+ // retrieve_AlphaFold_pAE(id, pdbAlignment, retrievalUrl);
+
+ } catch (Exception ex) // Problem parsing PDB file
+ {
+ stopQuery();
+ throw (ex);
+ }
+ return pdbAlignment;
+ }
+
+ /**
+ * get an alphafold pAE for the given id, and add it to sequence 0 in
+ * pdbAlignment (assuming it came from structurefile parser).
+ *
+ * @param id
+ * @param pdbAlignment
+ * @param retrievalUrl
+ * - URL of .mmcif from EBI-AlphaFold - will be used to generate the
+ * pAE URL automatically
+ * @throws IOException
+ * @throws Exception
+ */
+ public static void retrieve_AlphaFold_pAE(String id,
+ AlignmentI pdbAlignment, String retrievalUrl) throws IOException
+ {
+ // import PAE as contact matrix - assume this will work if there was a
+ // model
+ String paeURL = getAlphaFoldPaeDownloadUrl(id, AF_VERSION);
+
+ if (retrievalUrl != null)
+ {
+ // manufacture the PAE url from a url like ...-model-vN.cif
+ paeURL = retrievalUrl.replace("model", "predicted_aligned_error")
+ .replace(".cif", ".json");
+ }
+
+ File pae = null;
+ try
+ {
+ pae = File.createTempFile(id == null ? "af_pae" : id, "pae_json");
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ Console.debug("Downloading pae from " + paeURL + " to " + pae.toString()
+ + "");
+ UrlDownloadClient.download(paeURL, pae);
+ addAlphaFoldPAEToSequence(pdbAlignment, pae, 0, null);
+ }
+
+ public static void addAlphaFoldPAEToSequence(AlignmentI pdbAlignment,
+ File pae, int index, String seqId)
+ {
+ addAlphaFoldPAE(pdbAlignment, pae, index, seqId, false, false);
+ }
+
+ public static void addAlphaFoldPAEToStructure(AlignmentI pdbAlignment,
+ File pae, int index, String structIdOrFile, boolean isStructId)
+ {
+ addAlphaFoldPAE(pdbAlignment, pae, index, structIdOrFile, true,
+ isStructId);
+ }
+
+ public static void addAlphaFoldPAE(AlignmentI pdbAlignment, File pae,
+ int index, String id, boolean isStruct, boolean isStructId)
+ {
+ FileInputStream paeInput = null;
+ try
+ {
+ paeInput = new FileInputStream(pae);
+ } catch (FileNotFoundException e)
+ {
+ Console.error(
+ "Could not find pAE file '" + pae.getAbsolutePath() + "'", e);
+ return;
+ }
+
+ if (isStruct)
+ {
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance);
+ if (ssm != null)
+ {
+ String structFile = isStructId ? ssm.findFileForPDBId(id) : id;