+ * 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 Exception
+ */
+ public static void retrieve_AlphaFold_pAE(String id,
+ AlignmentI pdbAlignment, String retrievalUrl) throws Exception
+ {
+ // import PAE as contact matrix - assume this will work if there was a
+ // model
+ File pae = File.createTempFile(id, "pae_json");
+ 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");
+ }
+ Console.debug("Downloading pae from " + paeURL + " to " + pae.toString()
+ + "");
+
+ try
+ {
+ UrlDownloadClient.download(paeURL, pae);
+ FileInputStream pae_input = new FileInputStream(pae);
+
+ if (!importPaeJSONAsContactMatrix(pdbAlignment, pae_input))
+ {
+ Console.warn("Couln't import contact matrix from " + paeURL
+ + " (stored in " + pae.toString() + ")");
+ }
+ } catch (Exception pae_ex)
+ {
+ Console.error("Couldn't download PAE", pae_ex);
+ }
+
+ }
+
+ /**
+ * parses the given pAE matrix and adds it to sequence 0 in the given
+ * alignment
+ *
+ * @param pdbAlignment
+ * @param pae_input
+ * @return true if there was a pAE matrix added
+ * @throws Exception
+ */
+ public static boolean importPaeJSONAsContactMatrix(
+ AlignmentI pdbAlignment, InputStream pae_input) throws Exception
+ {
+
+ List<Object> pae_obj = (List<Object>) Platform.parseJSON(pae_input);
+ if (pae_obj == null)
+ {
+ return false;
+ }
+ ContactMatrixI matrix = new PAEContactMatrix(
+ pdbAlignment.getSequenceAt(0),
+ (Map<String, Object>) pae_obj.get(0));
+
+ AlignmentAnnotation cmannot = pdbAlignment.getSequenceAt(0)
+ .addContactList(matrix);
+ pdbAlignment.addAnnotation(cmannot);
+ return true;
+ }
+
+ /**
+ * general purpose structure importer - designed to yield alignment useful for
+ * transfer of annotation to associated sequences
+ *